ReactOS 0.4.17-dev-470-gf9e3448
surface.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for surface.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

ULONG FASTCALL BitmapFormat (ULONG cBits, ULONG iCompression)
 
VOID NTAPI SURFACE_vCleanup (PVOID ObjectBody)
 
PSURFACE NTAPI SURFACE_AllocSurface (_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
 
HBITMAP APIENTRY EngCreateBitmap (_In_ SIZEL sizl, _In_ LONG lWidth, _In_ ULONG iFormat, _In_ ULONG fl, _In_opt_ PVOID pvBits)
 
HBITMAP APIENTRY EngCreateDeviceBitmap (_In_ DHSURF dhsurf, _In_ SIZEL sizl, _In_ ULONG iFormat)
 
HSURF APIENTRY EngCreateDeviceSurface (_In_ DHSURF dhsurf, _In_ SIZEL sizl, _In_ ULONG iFormat)
 
BOOL APIENTRY EngAssociateSurface (_In_ HSURF hsurf, _In_ HDEV hdev, _In_ FLONG flHooks)
 
BOOL APIENTRY EngModifySurface (_In_ HSURF hsurf, _In_ HDEV hdev, _In_ FLONG flHooks, _In_ FLONG flSurface, _In_ DHSURF dhsurf, _In_ PVOID pvScan0, _In_ LONG lDelta, _Reserved_ PVOID pvReserved)
 
BOOL APIENTRY EngDeleteSurface (_In_ _Post_ptr_invalid_ HSURF hsurf)
 
BOOL APIENTRY EngEraseSurface (_In_ SURFOBJ *pso, _In_ RECTL *prcl, _In_ ULONG iColor)
 
SURFOBJ *APIENTRY NtGdiEngLockSurface (IN HSURF hsurf)
 
SURFOBJ *APIENTRY EngLockSurface (_In_ HSURF hsurf)
 
__kernel_entry NTSTATUS APIENTRY NtGdiEngUnlockSurface (_In_ SURFOBJ *pso)
 
VOID APIENTRY EngUnlockSurface (_In_ _Post_ptr_invalid_ SURFOBJ *pso)
 

Variables

LONG giUniqueSurface = 0
 
UCHAR gajBitsPerFormat [11]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file surface.c.

Function Documentation

◆ BitmapFormat()

ULONG FASTCALL BitmapFormat ( ULONG  cBits,
ULONG  iCompression 
)

Definition at line 39 of file surface.c.

40{
41 switch (iCompression)
42 {
43 case BI_RGB:
44 /* Fall through */
45 case BI_BITFIELDS:
46 if (cBits <= 1) return BMF_1BPP;
47 if (cBits <= 4) return BMF_4BPP;
48 if (cBits <= 8) return BMF_8BPP;
49 if (cBits <= 16) return BMF_16BPP;
50 if (cBits <= 24) return BMF_24BPP;
51 if (cBits <= 32) return BMF_32BPP;
52 return 0;
53
54 case BI_RLE4:
55 return BMF_4RLE;
56
57 case BI_RLE8:
58 return BMF_8RLE;
59
60 default:
61 return 0;
62 }
63}
#define BI_RLE4
Definition: precomp.h:45
#define BI_BITFIELDS
Definition: mmreg.h:507
#define BI_RGB
Definition: uefivid.c:46
#define BMF_16BPP
Definition: winddi.h:358
#define BMF_8BPP
Definition: winddi.h:357
#define BMF_1BPP
Definition: winddi.h:355
#define BMF_24BPP
Definition: winddi.h:359
#define BMF_32BPP
Definition: winddi.h:360
#define BMF_8RLE
Definition: winddi.h:362
#define BMF_4RLE
Definition: winddi.h:361
#define BMF_4BPP
Definition: winddi.h:356
#define BI_RLE8
Definition: wingdi.h:35

Referenced by DIB_CreateDIBSection(), GreCreateBitmap(), IntCreateDIBitmap(), IntSetDIBits(), NtGdiCreateBitmap(), NtGdiDdDDICreateDCFromMemory(), NtGdiSetDIBitsToDeviceInternal(), and NtGdiStretchDIBitsInternal().

◆ EngAssociateSurface()

BOOL APIENTRY EngAssociateSurface ( _In_ HSURF  hsurf,
_In_ HDEV  hdev,
_In_ FLONG  flHooks 
)

Definition at line 438 of file surface.c.

442{
443 SURFOBJ *pso;
444 PSURFACE psurf;
445 PDEVOBJ* ppdev;
446 PPALETTE ppal;
447
448 ppdev = (PDEVOBJ*)hdev;
449
450 /* Lock the surface */
451 psurf = SURFACE_ShareLockSurface(hsurf);
452 if (!psurf)
453 {
454 return FALSE;
455 }
456 pso = &psurf->SurfObj;
457
458 /* Associate the hdev */
459 pso->hdev = hdev;
460 pso->dhpdev = ppdev->dhpdev;
461
462 /* Hook up specified functions */
463 psurf->flags &= ~HOOK_FLAGS;
464 psurf->flags |= (flHooks & HOOK_FLAGS);
465
466 /* Assign the PDEV's palette */
468 SURFACE_vSetPalette(psurf, ppal);
470
472
473 return TRUE;
474}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HPALETTE hpalDefault
Definition: winddi.h:398
DHPDEV dhpdev
Definition: pdevobj.h:120
DEVINFO devinfo
Definition: pdevobj.h:122
SURFOBJ SurfObj
Definition: surface.h:8
FLONG flags
Definition: surface.h:10
HDEV hdev
Definition: winddi.h:1208
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
FORCEINLINE VOID SURFACE_vSetPalette(_Inout_ PSURFACE psurf, _In_ PPALETTE ppal)
Definition: surface.h:136
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
#define PALETTE_ShareLockPalette(hpal)
Definition: palette.h:57
#define PALETTE_ShareUnlockPalette(ppal)
Definition: palette.h:59
_In_ HANDLE _In_ SURFOBJ * pso
Definition: winddi.h:3665
_In_ HDEV hdev
Definition: winddi.h:3449
#define HOOK_FLAGS
Definition: winddi.h:1438

Referenced by DrvEnableSurface(), and PanEnableSurface().

◆ EngCreateBitmap()

HBITMAP APIENTRY EngCreateBitmap ( _In_ SIZEL  sizl,
_In_ LONG  lWidth,
_In_ ULONG  iFormat,
_In_ ULONG  fl,
_In_opt_ PVOID  pvBits 
)

Definition at line 313 of file surface.c.

319{
320 PSURFACE psurf;
322
323 /* Allocate a surface */
325 sizl.cx,
326 sizl.cy,
327 iFormat,
328 fl,
329 lWidth,
330 0,
331 pvBits);
332 if (!psurf)
333 {
334 DPRINT1("SURFACE_AllocSurface failed. (STYPE_BITMAP, sizl.cx=%ld, sizl.cy=%ld, iFormat=%lu, fl=%lu, lWidth=%ld, pvBits=0x%p)\n",
335 sizl.cx, sizl.cy, iFormat, fl, lWidth, pvBits);
336 return NULL;
337 }
338
339 /* Get the handle for the bitmap */
340 hbmp = (HBITMAP)psurf->SurfObj.hsurf;
341
342 /* Mark as API bitmap */
343 psurf->flags = API_BITMAP;
344
345 /* Set public ownership */
347
348 /* Unlock the surface and return */
350 return hbmp;
351}
#define DPRINT1
Definition: precomp.h:8
HBITMAP hbmp
#define NULL
Definition: types.h:112
static HBITMAP
Definition: button.c:44
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
BASEOBJECT BaseObject
Definition: surface.h:6
HSURF hsurf
Definition: winddi.h:1206
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
@ API_BITMAP
Definition: surface.h:76
#define SURFACE_UnlockSurface(pBMObj)
Definition: surface.h:100
VOID NTAPI GDIOBJ_vSetObjectOwner(POBJ pobj, ULONG ulNewOwner)
Definition: gdiobj.c:972
#define STYPE_BITMAP
Definition: winddi.h:1175
_In_ FLONG fl
Definition: winddi.h:1279
_In_ SIZEL _In_ ULONG iFormat
Definition: winddi.h:3468
_In_ SIZEL sizl
Definition: winddi.h:3467

◆ EngCreateDeviceBitmap()

HBITMAP APIENTRY EngCreateDeviceBitmap ( _In_ DHSURF  dhsurf,
_In_ SIZEL  sizl,
_In_ ULONG  iFormat 
)

Definition at line 358 of file surface.c.

362{
363 PSURFACE psurf;
365
366 /* Allocate a surface */
368 sizl.cx,
369 sizl.cy,
370 iFormat,
371 0,
372 0,
373 0,
374 NULL);
375 if (!psurf)
376 {
377 DPRINT1("SURFACE_AllocSurface failed. (STYPE_DEVBITMAP, sizl.cx=%ld, sizl.cy=%ld, iFormat=%lu)\n",
378 sizl.cx, sizl.cy, iFormat);
379 return NULL;
380 }
381
382 /* Set the device handle */
383 psurf->SurfObj.dhsurf = dhsurf;
384
385 /* Set public ownership */
387
388 /* Get the handle for the bitmap */
389 hbmp = (HBITMAP)psurf->SurfObj.hsurf;
390
391 /* Unlock the surface and return */
393 return hbmp;
394}
DHSURF dhsurf
Definition: winddi.h:1205
#define STYPE_DEVBITMAP
Definition: winddi.h:1177

◆ EngCreateDeviceSurface()

HSURF APIENTRY EngCreateDeviceSurface ( _In_ DHSURF  dhsurf,
_In_ SIZEL  sizl,
_In_ ULONG  iFormat 
)

Definition at line 398 of file surface.c.

402{
403 PSURFACE psurf;
404 HSURF hsurf;
405
406 /* Allocate a surface */
408 sizl.cx,
409 sizl.cy,
410 iFormat,
411 0,
412 0,
413 0,
414 NULL);
415 if (!psurf)
416 {
417 DPRINT1("SURFACE_AllocSurface failed. (STYPE_DEVICE, sizl.cx=%ld, sizl.cy=%ld, iFormat=%lu)\n",
418 sizl.cx, sizl.cy, iFormat);
419 return NULL;
420 }
421
422 /* Set the device handle */
423 psurf->SurfObj.dhsurf = dhsurf;
424
425 /* Set public ownership */
427
428 /* Get the handle for the surface */
429 hsurf = psurf->SurfObj.hsurf;
430
431 /* Unlock the surface and return */
433 return hsurf;
434}
#define STYPE_DEVICE
Definition: lmshare.h:24
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)

Referenced by DrvEnableSurface(), and PanEnableSurface().

◆ EngDeleteSurface()

BOOL APIENTRY EngDeleteSurface ( _In_ _Post_ptr_invalid_ HSURF  hsurf)

Definition at line 574 of file surface.c.

576{
577 PSURFACE psurf;
578
579 psurf = SURFACE_ShareLockSurface(hsurf);
580 if (!psurf)
581 {
582 DPRINT1("Could not reference surface %p to delete\n", hsurf);
583 return FALSE;
584 }
585
587 return TRUE;
588}
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1118

Referenced by DrvDisableSurface(), DrvEnableSurface(), DxEngDeleteSurface(), EBRUSHOBJ_pvGetEngBrush(), EngRealizeBrush(), EngSetPointerShape(), IntEngEnter(), IntEngLeave(), IntExtTextOutW(), NtGdiSetDIBitsToDeviceInternal(), and PanDisableSurface().

◆ EngEraseSurface()

BOOL APIENTRY EngEraseSurface ( _In_ SURFOBJ pso,
_In_ RECTL prcl,
_In_ ULONG  iColor 
)

Definition at line 592 of file surface.c.

596{
597 ASSERT(pso);
598 ASSERT(prcl);
599 return FillSolid(pso, prcl, iColor);
600}
#define ASSERT(a)
Definition: mode.c:44
BOOL APIENTRY FillSolid(SURFOBJ *pso, PRECTL pRect, ULONG iColor)
Definition: paint.c:35
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3531
_In_ ULONG iColor
Definition: xlateobj.h:17

◆ EngLockSurface()

SURFOBJ *APIENTRY EngLockSurface ( _In_ HSURF  hsurf)

◆ EngModifySurface()

BOOL APIENTRY EngModifySurface ( _In_ HSURF  hsurf,
_In_ HDEV  hdev,
_In_ FLONG  flHooks,
_In_ FLONG  flSurface,
_In_ DHSURF  dhsurf,
_In_ PVOID  pvScan0,
_In_ LONG  lDelta,
_Reserved_ PVOID  pvReserved 
)

Definition at line 478 of file surface.c.

487{
488 SURFOBJ *pso;
489 PSURFACE psurf;
490 PDEVOBJ* ppdev;
491 PPALETTE ppal;
492
493 /* Lock the surface */
494 psurf = SURFACE_ShareLockSurface(hsurf);
495 if (psurf == NULL)
496 {
497 DPRINT1("Failed to reference surface %p\n", hsurf);
498 return FALSE;
499 }
500
501 ppdev = (PDEVOBJ*)hdev;
502 pso = &psurf->SurfObj;
503 pso->dhsurf = dhsurf;
504
505 /* Associate the hdev */
506 pso->hdev = hdev;
507 pso->dhpdev = ppdev->dhpdev;
508
509 /* Hook up specified functions */
510 psurf->flags &= ~HOOK_FLAGS;
511 psurf->flags |= (flHooks & HOOK_FLAGS);
512
513 /* Assign the PDEV's palette */
515 SURFACE_vSetPalette(psurf, ppal);
517
518 /* Update surface flags */
519 if (flSurface & MS_NOTSYSTEMMEMORY)
520 pso->fjBitmap |= BMF_NOTSYSMEM;
521 else
522 pso->fjBitmap &= ~BMF_NOTSYSMEM;
523 if (flSurface & MS_SHAREDACCESS)
524 psurf->flags |= SHAREACCESS_SURFACE;
525 else
526 psurf->flags &= ~SHAREACCESS_SURFACE;
527
528 /* Check if the caller passed bitmap bits */
529 if ((pvScan0 != NULL) && (lDelta != 0))
530 {
531 /* Update the fields */
532 pso->pvScan0 = pvScan0;
533 pso->lDelta = lDelta;
534
535 /* This is a bitmap now! */
536 pso->iType = STYPE_BITMAP;
537
538 /* Check memory layout */
539 if (lDelta > 0)
540 {
541 /* Topdown is the normal way */
542 pso->cjBits = lDelta * pso->sizlBitmap.cy;
543 pso->pvBits = pso->pvScan0;
544 pso->fjBitmap |= BMF_TOPDOWN;
545 }
546 else
547 {
548 /* Inversed bitmap (bottom up) */
549 pso->cjBits = (-lDelta) * pso->sizlBitmap.cy;
550 pso->pvBits = (PCHAR)pso->pvScan0 - pso->cjBits - lDelta;
551 pso->fjBitmap &= ~BMF_TOPDOWN;
552 }
553 }
554 else
555 {
556 /* Set bits to NULL */
557 pso->pvBits = NULL;
558 pso->pvScan0 = NULL;
559 pso->lDelta = 0;
560
561 /* Set appropriate surface type */
562 if (pso->iType != STYPE_DEVICE)
563 pso->iType = STYPE_DEVBITMAP;
564 }
565
567
568 return TRUE;
569}
char * PCHAR
Definition: typedefs.h:51
@ SHAREACCESS_SURFACE
Definition: surface.h:52
#define MS_NOTSYSTEMMEMORY
Definition: winddi.h:2129
#define MS_SHAREDACCESS
Definition: winddi.h:2130
#define BMF_TOPDOWN
Definition: winddi.h:1180
#define BMF_NOTSYSMEM
Definition: winddi.h:1185

Referenced by DrvAssertMode(), and DrvEnableSurface().

◆ EngUnlockSurface()

VOID APIENTRY EngUnlockSurface ( _In_ _Post_ptr_invalid_ SURFOBJ pso)

Definition at line 635 of file surface.c.

637{
638 if (pso != NULL)
639 {
640 SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
642 }
643}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by IntEngEnter(), IntEngLeave(), IntExtTextOutW(), IntGdiCreateMaskFromRLE(), NtGdiSetDIBitsToDeviceInternal(), PanDisableSurface(), and SynchronizeDriver().

◆ NtGdiEngLockSurface()

SURFOBJ *APIENTRY NtGdiEngLockSurface ( IN HSURF  hsurf)

Definition at line 606 of file surface.c.

607{
608 return EngLockSurface(hsurf);
609}
SURFOBJ *APIENTRY EngLockSurface(_In_ HSURF hsurf)
Definition: surface.c:614

◆ NtGdiEngUnlockSurface()

__kernel_entry NTSTATUS APIENTRY NtGdiEngUnlockSurface ( _In_ SURFOBJ pso)

Definition at line 625 of file surface.c.

627{
629 ASSERT(FALSE);
631}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

◆ SURFACE_AllocSurface()

PSURFACE NTAPI SURFACE_AllocSurface ( _In_ USHORT  iType,
_In_ ULONG  cx,
_In_ ULONG  cy,
_In_ ULONG  iFormat,
_In_ ULONG  fjBitmap,
_In_opt_ ULONG  cjWidth,
_In_opt_ ULONG  cjBufSize,
_In_opt_ PVOID  pvBits 
)

Definition at line 116 of file surface.c.

125{
126 ULONG cBitsPixel, cjBits, cjObject;
127 PSURFACE psurf;
128 SURFOBJ *pso;
129 PVOID pvSection;
130
131 NT_ASSERT(!pvBits || (iType == STYPE_BITMAP));
132 NT_ASSERT((iFormat <= BMF_32BPP) || (cjBufSize != 0));
133 NT_ASSERT((LONG)cy > 0);
134
135 /* Verify format */
136 if ((iFormat < BMF_1BPP) || (iFormat > BMF_PNG))
137 {
138 DPRINT1("Invalid bitmap format: %lu\n", iFormat);
139 return NULL;
140 }
141
142 /* Get bits per pixel from the format */
143 cBitsPixel = gajBitsPerFormat[iFormat];
144
145 /* Are bits and a width in bytes given? */
146 if (pvBits && cjWidth)
147 {
148 /* Align the width (Windows compatibility, drivers expect that) */
149 cjWidth = WIDTH_BYTES_ALIGN32((cjWidth << 3) / cBitsPixel, cBitsPixel);
150 }
151 else
152 {
153 /* Calculate width from the bitmap width in pixels */
154 cjWidth = WIDTH_BYTES_ALIGN32(cx, cBitsPixel);
155 }
156
157 /* Is this an uncompressed format? */
158 if (iFormat <= BMF_32BPP)
159 {
160 /* Did we get a buffer and size? */
161 if ((pvBits != NULL) && (cjBufSize != 0))
162 {
163 /* Calculate and validate the bitmap size in bytes */
164 if (!NT_SUCCESS(RtlULongMult(cjWidth, cy, &cjBits)))
165 {
166 DPRINT1("Overflow calculating size: cjWidth %lu, cy %lu\n",
167 cjWidth, cy);
168 return NULL;
169 }
170
171 /* Make sure the buffer is large enough */
172 if (cjBufSize < cjBits)
173 {
174 DPRINT1("Buffer is too small, required: %lu, got %lu\n",
175 cjBits, cjBufSize);
176 return NULL;
177 }
178 }
179 else
180 {
181 /* Do a dumb calculation. Windows doesn't validate this either and
182 some drivers (e.g. Radeon IGP 320M) explicitly pass bogus values.
183 See CORE-13036. */
184 cjBits = cjWidth * cy;
185 }
186 }
187 else
188 {
189 /* Compressed format, use the provided size */
190 NT_ASSERT(cjBufSize != 0);
191 cjBits = cjBufSize;
192 }
193
194 /* Check if we need an extra large object */
195 if ((iType == STYPE_BITMAP) && (pvBits == NULL) &&
196 !(fjBitmap & BMF_USERMEM) && !(fjBitmap & BMF_KMSECTION))
197 {
198 /* Allocate an object large enough to hold the bits */
199 cjObject = sizeof(SURFACE) + cjBits;
200 }
201 else
202 {
203 /* Otherwise just allocate the SURFACE structure */
204 cjObject = sizeof(SURFACE);
205 }
206
207 /* Check for arithmetic overflow */
208 if (cjObject < sizeof(SURFACE))
209 {
210 /* Fail! */
211 DPRINT1("Overflow calculating cjObject: cjBits %lu\n", cjBits);
212 return NULL;
213 }
214
215 /* Allocate a SURFACE object */
217 if (!psurf)
218 {
219 return NULL;
220 }
221
222 /* Initialize the basic fields */
223 pso = &psurf->SurfObj;
224 pso->hsurf = psurf->BaseObject.hHmgr;
225 pso->sizlBitmap.cx = cx;
226 pso->sizlBitmap.cy = cy;
227 pso->iBitmapFormat = iFormat;
228 pso->iType = iType;
229 pso->fjBitmap = (USHORT)fjBitmap;
231 pso->cjBits = cjBits;
232
233 /* Check if we need a bitmap buffer */
234 if (iType == STYPE_BITMAP)
235 {
236 /* Check if we got one or if we need to allocate one */
237 if (pvBits != NULL)
238 {
239 /* Use the caller provided buffer */
240 pso->pvBits = pvBits;
241 }
242 else if (fjBitmap & BMF_USERMEM)
243 {
244 /* User mode memory was requested */
245 pso->pvBits = EngAllocUserMem(cjBits, 0);
246
247 /* Check for failure */
248 if (!pso->pvBits)
249 {
251 return NULL;
252 }
253 }
254 else if (fjBitmap & BMF_KMSECTION)
255 {
256 /* Use a kernel mode section */
257 pso->pvBits = EngAllocSectionMem(&pvSection,
258 (fjBitmap & BMF_NOZEROINIT) ?
259 0 : FL_ZERO_MEMORY,
260 cjBits, TAG_DIB);
261
262 /* Check for failure */
263 if (!pso->pvBits)
264 {
266 return NULL;
267 }
268
269 /* Free the section already, but keep the mapping */
270 EngFreeSectionMem(pvSection, NULL);
271 }
272 else
273 {
274 /* Buffer is after the object */
275 pso->pvBits = psurf + 1;
276
277 /* Zero the buffer, except requested otherwise */
278 if (!(fjBitmap & BMF_NOZEROINIT))
279 {
280 RtlZeroMemory(pso->pvBits, cjBits);
281 }
282 }
283
284 /* Set pvScan0 and lDelta */
285 if (fjBitmap & BMF_TOPDOWN)
286 {
287 /* Topdown is the normal way */
288 pso->pvScan0 = pso->pvBits;
289 pso->lDelta = cjWidth;
290 }
291 else
292 {
293 /* Inversed bitmap (bottom up) */
294 pso->pvScan0 = ((PCHAR)pso->pvBits + pso->cjBits - cjWidth);
295 pso->lDelta = -(LONG)cjWidth;
296 }
297 }
298 else
299 {
300 /* There are no bitmap bits */
301 pso->pvScan0 = pso->pvBits = NULL;
302 pso->lDelta = 0;
303 }
304
305 /* Assign a default palette and increment its reference count */
307
308 return psurf;
309}
#define InterlockedIncrement
Definition: armddk.h:53
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define GDI_OBJECT_TYPE_BITMAP
Definition: gdi.h:48
#define PCHAR
Definition: match.c:90
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define FL_ZERO_MEMORY
Definition: polytest.cpp:58
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define WIDTH_BYTES_ALIGN32(cx, bpp)
Definition: swimpl.c:16
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
BOOL APIENTRY EngFreeSectionMem(_In_opt_ PVOID pvSection, _In_opt_ PVOID pvMappedBase)
Definition: mapping.c:246
UCHAR gajBitsPerFormat[11]
Definition: surface.c:21
LONG giUniqueSurface
Definition: surface.c:18
struct _SURFACE SURFACE
struct _SURFACE * PSURFACE
POBJ NTAPI GDIOBJ_AllocObjWithHandle(ULONG ObjectType, ULONG cjSize)
Definition: gdiobj.c:1535
PPALETTE appalSurfaceDefault[11]
Definition: palette.c:21
#define TAG_DIB
Definition: tags.h:17
#define BMF_PNG
Definition: winddi.h:364
#define BMF_USERMEM
Definition: winddi.h:1183
_In_ ULONG iType
Definition: winddi.h:3748
#define BMF_NOZEROINIT
Definition: winddi.h:1181
#define BMF_KMSECTION
Definition: winddi.h:1184
#define NT_ASSERT
Definition: rtlfuncs.h:3327

Referenced by EngCreateBitmap(), EngCreateDeviceBitmap(), EngCreateDeviceSurface(), GreCreateBitmapEx(), IntEngMaskBlt(), NtGdiCreateBitmap(), NtGdiDdDDICreateDCFromMemory(), NtGdiGetPixel(), and UserDrawIconEx().

◆ SURFACE_vCleanup()

VOID NTAPI SURFACE_vCleanup ( PVOID  ObjectBody)

Definition at line 67 of file surface.c.

68{
69 PSURFACE psurf = (PSURFACE)ObjectBody;
70 PVOID pvBits = psurf->SurfObj.pvBits;
71
72 /* Check if the surface has bits */
73 if (pvBits)
74 {
75 /* Only bitmaps can have bits */
77
78 /* Check if it is a DIB section */
79 if (psurf->hDIBSection)
80 {
81 /* Unmap the section view */
82 EngUnmapSectionView(pvBits, psurf->dwOffset, psurf->hSecure);
83 }
84 else if (psurf->SurfObj.fjBitmap & BMF_USERMEM)
85 {
86 /* Bitmap was allocated from usermode memory */
87 EngFreeUserMem(pvBits);
88 }
89 else if (psurf->SurfObj.fjBitmap & BMF_KMSECTION)
90 {
91 /* Bitmap was allocated from a kernel section */
92 if (!EngFreeSectionMem(NULL, pvBits))
93 {
94 DPRINT1("EngFreeSectionMem failed for %p!\n", pvBits);
95 // Should we BugCheck here?
97 }
98 }
99 else if (psurf->SurfObj.fjBitmap & BMF_POOLALLOC)
100 {
101 /* Free a pool allocation */
102 EngFreeMem(pvBits);
103 }
104 }
105
106 /* Free palette */
107 if(psurf->ppal)
108 {
110 }
111}
#define EngFreeMem
Definition: polytest.cpp:56
HANDLE hDIBSection
Definition: surface.h:31
HANDLE hSecure
Definition: surface.h:32
DWORD dwOffset
Definition: surface.h:33
struct _PALETTE *const ppal
Definition: surface.h:11
USHORT iType
Definition: winddi.h:1216
USHORT fjBitmap
Definition: winddi.h:1217
PVOID pvBits
Definition: winddi.h:1211
VOID NTAPI EngUnmapSectionView(_In_ PVOID pvBits, _In_ ULONG cjOffset, _In_ HANDLE hSecure)
Definition: mapping.c:71
#define BMF_POOLALLOC
Definition: surface.h:84
ENGAPI VOID APIENTRY EngFreeUserMem(_Pre_notnull_ __drv_freesMem(UserMem) PVOID pv)

Variable Documentation

◆ gajBitsPerFormat

UCHAR gajBitsPerFormat[11]
Initial value:
=
{
0,
1,
4,
8,
16,
24,
32,
4,
8,
0,
0,
}

Definition at line 21 of file surface.c.

Referenced by DC_bIsBitmapCompatible(), EngBitBlt(), GreCreateBitmapEx(), NtGdiCreateBitmap(), NtGdiMaskBlt(), and SURFACE_AllocSurface().

◆ giUniqueSurface

LONG giUniqueSurface = 0

Definition at line 18 of file surface.c.

Referenced by SURFACE_AllocSurface().