* Sync up to trunk HEAD (r62286).
[reactos.git] / win32ss / gdi / eng / surface.h
1 #pragma once
2
3 /* GDI surface object */
4 typedef struct _SURFACE
5 {
6 BASEOBJECT BaseObject;
7
8 SURFOBJ SurfObj;
9 //XDCOBJ * pdcoAA;
10 FLONG flags;
11 struct _PALETTE * const ppal; // Use SURFACE_vSetPalette to assign a palette
12 //UINT unk_050;
13
14 union
15 {
16 HANDLE hSecureUMPD; // if UMPD_SURFACE set
17 HANDLE hMirrorParent;// if MIRROR_SURFACE set
18 HANDLE hDDSurface; // if DIRECTDRAW_SURFACE set
19 };
20
21 SIZEL sizlDim; /* For SetBitmapDimension(), do NOT use
22 to get width/height of bitmap, use
23 bitmap.bmWidth/bitmap.bmHeight for
24 that */
25
26 HDC hdc; // Doc in "Undocumented Windows", page 546, seems to be supported with XP.
27 ULONG cRef;
28 HPALETTE hpalHint;
29
30 /* For device-independent bitmaps: */
31 HANDLE hDIBSection;
32 HANDLE hSecure;
33 DWORD dwOffset;
34 //UINT unk_078;
35
36 /* reactos specific */
37 DWORD biClrImportant;
38 } SURFACE, *PSURFACE;
39
40 /* flags field */
41 enum _SURFACEFLAGS
42 {
43 //#define HOOK_BITBLT 0x00000001
44 //#define HOOK_STRETCHBLT 0x00000002
45 //#define HOOK_PLGBLT 0x00000004
46 //#define HOOK_TEXTOUT 0x00000008
47 //#define HOOK_PAINT 0x00000010
48 //#define HOOK_STROKEPATH 0x00000020
49 //#define HOOK_FILLPATH 0x00000040
50 //#define HOOK_STROKEANDFILLPATH 0x00000080
51 //#define HOOK_LINETO 0x00000100
52 //#define SHAREACCESS_SURFACE 0x00000200
53 //#define HOOK_COPYBITS 0x00000400
54 //#define REDIRECTION_SURFACE 0x00000800 // ?
55 //#define HOOK_MOVEPANNING 0x00000800
56 //#define HOOK_SYNCHRONIZE 0x00001000
57 //#define HOOK_STRETCHBLTROP 0x00002000
58 //#define HOOK_SYNCHRONIZEACCESS 0x00004000
59 //#define USE_DEVLOCK_SURFACE 0x00004000
60 //#define HOOK_TRANSPARENTBLT 0x00008000
61 //#define HOOK_ALPHABLEND 0x00010000
62 //#define HOOK_GRADIENTFILL 0x00020000
63 //#if (NTDDI_VERSION < 0x06000000)
64 // #define HOOK_FLAGS 0x0003B5FF
65 //#else
66 // #define HOOK_FLAGS 0x0003B5EF
67 //#endif
68 UMPD_SURFACE = 0x00040000,
69 MIRROR_SURFACE = 0x00080000,
70 DIRECTDRAW_SURFACE = 0x00100000,
71 DRIVER_CREATED_SURFACE = 0x00200000,
72 ENG_CREATE_DEVICE_SURFACE = 0x00400000,
73 DDB_SURFACE = 0x00800000,
74 LAZY_DELETE_SURFACE = 0x01000000,
75 BANDING_SURFACE = 0x02000000,
76 API_BITMAP = 0x04000000,
77 PALETTE_SELECT_SET = 0x08000000,
78 UNREADABLE_SURFACE = 0x10000000,
79 DYNAMIC_MODE_PALETTE = 0x20000000,
80 ABORT_SURFACE = 0x40000000,
81 PDEV_SURFACE = 0x80000000
82 };
83
84 #define BMF_POOLALLOC 0x100
85 #define PDEV_SURFACE 0x80000000
86
87 /* Internal interface */
88
89 #define SURFACE_AllocSurfaceWithHandle() ((PSURFACE) GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_BITMAP, sizeof(SURFACE)))
90 #define SURFACE_FreeSurface(pBMObj) GDIOBJ_FreeObj((POBJ) pBMObj, GDIObjType_SURF_TYPE)
91 #define SURFACE_FreeSurfaceByHandle(hBMObj) GDIOBJ_FreeObjByHandle((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
92
93 /* NOTE: Use shared locks! */
94 #define SURFACE_ShareLockSurface(hBMObj) \
95 ((PSURFACE) GDIOBJ_ShareLockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP))
96 #define SURFACE_UnlockSurface(pBMObj) \
97 GDIOBJ_vUnlockObject ((POBJ)pBMObj)
98 #define SURFACE_ShareUnlockSurface(pBMObj) \
99 GDIOBJ_vDereferenceObject ((POBJ)pBMObj)
100
101 #define GDIDEV(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))
102 #define GDIDEVFUNCS(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))->DriverFunctions
103
104 extern UCHAR gajBitsPerFormat[];
105 #define BitsPerFormat(Format) gajBitsPerFormat[Format]
106
107 #define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3)
108 #define WIDTH_BYTES_ALIGN16(cx, bpp) ((((cx) * (bpp) + 15) & ~15) >> 3)
109
110 ULONG
111 FASTCALL
112 BitmapFormat(ULONG cBits, ULONG iCompression);
113
114 BOOL
115 NTAPI
116 SURFACE_Cleanup(PVOID ObjectBody);
117
118 PSURFACE
119 NTAPI
120 SURFACE_AllocSurface(
121 _In_ USHORT iType,
122 _In_ ULONG cx,
123 _In_ ULONG cy,
124 _In_ ULONG iFormat,
125 _In_ ULONG fjBitmap,
126 _In_opt_ ULONG cjWidth,
127 _In_opt_ PVOID pvBits);
128
129 VOID
130 FORCEINLINE
131 SURFACE_vSetPalette(
132 _Inout_ PSURFACE psurf,
133 _In_ PPALETTE ppal)
134 {
135 if (psurf->ppal)
136 GDIOBJ_vDereferenceObject((POBJ)psurf->ppal);
137 if (ppal)
138 GDIOBJ_vReferenceObjectByPointer((POBJ)ppal);
139 *(PVOID*)&psurf->ppal = ppal;
140 }
141