423972ce3fb3fd1565721c9e8c548607a71a78c0
[reactos.git] / reactos / subsystems / win32 / win32k / eng / surface.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI Driver Surace Functions
5 * FILE: subsys/win32k/eng/surface.c
6 * PROGRAMER: Jason Filby
7 * REVISION HISTORY:
8 * 3/7/1999: Created
9 * 9/11/2000: Updated to handle real pixel packed bitmaps (UPDATE TO DATE COMPLETED)
10 * TESTING TO BE DONE:
11 * - Create a GDI bitmap with all formats, perform all drawing operations on them, render to VGA surface
12 * refer to \test\microwin\src\engine\devdraw.c for info on correct pixel plotting for various formats
13 */
14
15 #include <w32k.h>
16
17 #define NDEBUG
18 #include <debug.h>
19
20 enum Rle_EscapeCodes
21 {
22 RLE_EOL = 0, /* End of line */
23 RLE_END = 1, /* End of bitmap */
24 RLE_DELTA = 2 /* Delta */
25 };
26
27 INT FASTCALL BitsPerFormat(ULONG Format)
28 {
29 switch (Format)
30 {
31 case BMF_1BPP:
32 return 1;
33
34 case BMF_4BPP:
35 /* Fall through */
36 case BMF_4RLE:
37 return 4;
38
39 case BMF_8BPP:
40 /* Fall through */
41 case BMF_8RLE:
42 return 8;
43
44 case BMF_16BPP:
45 return 16;
46
47 case BMF_24BPP:
48 return 24;
49
50 case BMF_32BPP:
51 return 32;
52
53 default:
54 return 0;
55 }
56 }
57
58 ULONG FASTCALL BitmapFormat(WORD Bits, DWORD Compression)
59 {
60 switch (Compression)
61 {
62 case BI_RGB:
63 /* Fall through */
64 case BI_BITFIELDS:
65 switch (Bits)
66 {
67 case 1:
68 return BMF_1BPP;
69 case 4:
70 return BMF_4BPP;
71 case 8:
72 return BMF_8BPP;
73 case 16:
74 return BMF_16BPP;
75 case 24:
76 return BMF_24BPP;
77 case 32:
78 return BMF_32BPP;
79 }
80 return 0;
81
82 case BI_RLE4:
83 return BMF_4RLE;
84
85 case BI_RLE8:
86 return BMF_8RLE;
87
88 default:
89 return 0;
90 }
91 }
92
93 BOOL INTERNAL_CALL
94 SURFACE_Cleanup(PVOID ObjectBody)
95 {
96 PSURFACE psurf = (PSURFACE)ObjectBody;
97 PVOID pvBits = psurf->SurfObj.pvBits;
98
99 /* If this is an API bitmap, free the bits */
100 if (pvBits != NULL &&
101 (psurf->flFlags & BITMAPOBJ_IS_APIBITMAP))
102 {
103 /* Check if we have a DIB section */
104 if (psurf->hSecure)
105 {
106 // FIXME: IMPLEMENT ME!
107 // MmUnsecureVirtualMemory(psurf->hSecure);
108 if (psurf->hDIBSection)
109 {
110 /* DIB was created from a section */
111 NTSTATUS Status;
112
113 pvBits = (PVOID)((ULONG_PTR)pvBits - psurf->dwOffset);
114 Status = ZwUnmapViewOfSection(NtCurrentProcess(), pvBits);
115 if (!NT_SUCCESS(Status))
116 {
117 DPRINT1("Could not unmap section view!\n");
118 // Should we BugCheck here?
119 }
120 }
121 else
122 {
123 /* DIB was allocated */
124 EngFreeUserMem(pvBits);
125 }
126 }
127 else
128 {
129 // FIXME: use TAG
130 ExFreePool(psurf->SurfObj.pvBits);
131 }
132
133 if (psurf->hDIBPalette != NULL)
134 {
135 GreDeleteObject(psurf->hDIBPalette);
136 }
137 }
138
139 if (NULL != psurf->BitsLock)
140 {
141 ExFreePoolWithTag(psurf->BitsLock, TAG_SURFACE);
142 psurf->BitsLock = NULL;
143 }
144
145 return TRUE;
146 }
147
148 BOOL INTERNAL_CALL
149 SURFACE_InitBitsLock(PSURFACE psurf)
150 {
151 psurf->BitsLock = ExAllocatePoolWithTag(NonPagedPool,
152 sizeof(FAST_MUTEX),
153 TAG_SURFACE);
154 if (NULL == psurf->BitsLock)
155 {
156 return FALSE;
157 }
158
159 ExInitializeFastMutex(psurf->BitsLock);
160
161 return TRUE;
162 }
163
164 void INTERNAL_CALL
165 SURFACE_CleanupBitsLock(PSURFACE psurf)
166 {
167 if (NULL != psurf->BitsLock)
168 {
169 ExFreePoolWithTag(psurf->BitsLock, TAG_SURFACE);
170 psurf->BitsLock = NULL;
171 }
172 }
173
174
175 /*
176 * @implemented
177 */
178 HBITMAP APIENTRY
179 EngCreateDeviceBitmap(IN DHSURF dhsurf,
180 IN SIZEL Size,
181 IN ULONG Format)
182 {
183 HBITMAP NewBitmap;
184 SURFOBJ *pso;
185
186 NewBitmap = EngCreateBitmap(Size, DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(Format)), Format, 0, NULL);
187 if (!NewBitmap)
188 {
189 DPRINT1("EngCreateBitmap failed\n");
190 return 0;
191 }
192
193 pso = EngLockSurface((HSURF)NewBitmap);
194 if (!pso)
195 {
196 DPRINT1("EngLockSurface failed on newly created bitmap!\n");
197 GreDeleteObject(NewBitmap);
198 return NULL;
199 }
200
201 pso->dhsurf = dhsurf;
202 EngUnlockSurface(pso);
203
204 return NewBitmap;
205 }
206
207 VOID Decompress4bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
208 {
209 int x = 0;
210 int y = Size.cy - 1;
211 int c;
212 int length;
213 int width = ((Size.cx+1)/2);
214 int height = Size.cy - 1;
215 BYTE *begin = CompressedBits;
216 BYTE *bits = CompressedBits;
217 BYTE *temp;
218 while (y >= 0)
219 {
220 length = *bits++ / 2;
221 if (length)
222 {
223 c = *bits++;
224 while (length--)
225 {
226 if (x >= width) break;
227 temp = UncompressedBits + (((height - y) * Delta) + x);
228 x++;
229 *temp = c;
230 }
231 }
232 else
233 {
234 length = *bits++;
235 switch (length)
236 {
237 case RLE_EOL:
238 x = 0;
239 y--;
240 break;
241 case RLE_END:
242 return;
243 case RLE_DELTA:
244 x += (*bits++)/2;
245 y -= (*bits++)/2;
246 break;
247 default:
248 length /= 2;
249 while (length--)
250 {
251 c = *bits++;
252 if (x < width)
253 {
254 temp = UncompressedBits + (((height - y) * Delta) + x);
255 x++;
256 *temp = c;
257 }
258 }
259 if ((bits - begin) & 1)
260 {
261 bits++;
262 }
263 }
264 }
265 }
266 }
267
268 VOID Decompress8bpp(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta)
269 {
270 int x = 0;
271 int y = Size.cy - 1;
272 int c;
273 int length;
274 int width = Size.cx;
275 int height = Size.cy - 1;
276 BYTE *begin = CompressedBits;
277 BYTE *bits = CompressedBits;
278 BYTE *temp;
279 while (y >= 0)
280 {
281 length = *bits++;
282 if (length)
283 {
284 c = *bits++;
285 while (length--)
286 {
287 if (x >= width) break;
288 temp = UncompressedBits + (((height - y) * Delta) + x);
289 x++;
290 *temp = c;
291 }
292 }
293 else
294 {
295 length = *bits++;
296 switch (length)
297 {
298 case RLE_EOL:
299 x = 0;
300 y--;
301 break;
302 case RLE_END:
303 return;
304 case RLE_DELTA:
305 x += *bits++;
306 y -= *bits++;
307 break;
308 default:
309 while (length--)
310 {
311 c = *bits++;
312 if (x < width)
313 {
314 temp = UncompressedBits + (((height - y) * Delta) + x);
315 x++;
316 *temp = c;
317 }
318 }
319 if ((bits - begin) & 1)
320 {
321 bits++;
322 }
323 }
324 }
325 }
326 }
327
328 HBITMAP FASTCALL
329 IntCreateBitmap(IN SIZEL Size,
330 IN LONG Width,
331 IN ULONG Format,
332 IN ULONG Flags,
333 IN PVOID Bits)
334 {
335 HBITMAP hbmp;
336 SURFOBJ *pso;
337 PSURFACE psurf;
338 PVOID UncompressedBits;
339 ULONG UncompressedFormat;
340
341 if (Format == 0)
342 return 0;
343
344 psurf = SURFACE_AllocSurfaceWithHandle();
345 if (psurf == NULL)
346 {
347 return 0;
348 }
349 hbmp = psurf->BaseObject.hHmgr;
350
351 if (! SURFACE_InitBitsLock(psurf))
352 {
353 SURFACE_UnlockSurface(psurf);
354 SURFACE_FreeSurfaceByHandle(hbmp);
355 return 0;
356 }
357 pso = &psurf->SurfObj;
358
359 if (Format == BMF_4RLE)
360 {
361 pso->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_4BPP));
362 pso->cjBits = pso->lDelta * Size.cy;
363 UncompressedFormat = BMF_4BPP;
364 UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
365 Decompress4bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, pso->lDelta);
366 }
367 else if (Format == BMF_8RLE)
368 {
369 pso->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(BMF_8BPP));
370 pso->cjBits = pso->lDelta * Size.cy;
371 UncompressedFormat = BMF_8BPP;
372 UncompressedBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
373 Decompress8bpp(Size, (BYTE *)Bits, (BYTE *)UncompressedBits, pso->lDelta);
374 }
375 else
376 {
377 pso->lDelta = abs(Width);
378 pso->cjBits = pso->lDelta * Size.cy;
379 UncompressedBits = Bits;
380 UncompressedFormat = Format;
381 }
382
383 if (UncompressedBits != NULL)
384 {
385 pso->pvBits = UncompressedBits;
386 }
387 else
388 {
389 if (pso->cjBits == 0)
390 {
391 pso->pvBits = NULL;
392 }
393 else
394 {
395 if (0 != (Flags & BMF_USERMEM))
396 {
397 pso->pvBits = EngAllocUserMem(pso->cjBits, 0);
398 }
399 else
400 {
401 pso->pvBits = EngAllocMem(0 != (Flags & BMF_NOZEROINIT) ?
402 0 : FL_ZERO_MEMORY,
403 pso->cjBits, TAG_DIB);
404 }
405 if (pso->pvBits == NULL)
406 {
407 SURFACE_UnlockSurface(psurf);
408 SURFACE_FreeSurfaceByHandle(hbmp);
409 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
410 return 0;
411 }
412 }
413 }
414
415 if (0 == (Flags & BMF_TOPDOWN))
416 {
417 pso->pvScan0 = (PVOID)((ULONG_PTR)pso->pvBits + pso->cjBits - pso->lDelta);
418 pso->lDelta = - pso->lDelta;
419 }
420 else
421 {
422 pso->pvScan0 = pso->pvBits;
423 }
424
425 pso->dhsurf = 0; /* device managed surface */
426 pso->hsurf = (HSURF)hbmp;
427 pso->dhpdev = NULL;
428 pso->hdev = NULL;
429 pso->sizlBitmap = Size;
430 pso->iBitmapFormat = UncompressedFormat;
431 pso->iType = STYPE_BITMAP;
432 pso->fjBitmap = Flags & (BMF_TOPDOWN | BMF_NOZEROINIT);
433 pso->iUniq = 0;
434
435 psurf->flHooks = 0;
436 psurf->flFlags = 0;
437 psurf->dimension.cx = 0;
438 psurf->dimension.cy = 0;
439
440 psurf->hSecure = NULL;
441 psurf->hDIBSection = NULL;
442
443 SURFACE_UnlockSurface(psurf);
444
445 return hbmp;
446 }
447
448 /* Name gleaned from C++ symbol information for SURFMEM::bInitDIB */
449 typedef struct _DEVBITMAPINFO
450 {
451 ULONG Format;
452 ULONG Width;
453 ULONG Height;
454 ULONG Flags;
455 ULONG Size;
456 } DEVBITMAPINFO, *PDEVBITMAPINFO;
457
458 SURFOBJ*
459 FASTCALL
460 SURFMEM_bCreateDib(IN PDEVBITMAPINFO BitmapInfo,
461 IN PVOID Bits)
462 {
463 BOOLEAN Compressed = FALSE;
464 ULONG ScanLine = 0; // Compiler is dumb
465 ULONG Size;
466 SURFOBJ *pso;
467 PSURFACE psurf;
468 SIZEL LocalSize;
469
470 /*
471 * First, check the format so we can get the aligned scanline width.
472 * RLE and the newer fancy-smanshy JPG/PNG support do NOT have scanlines
473 * since they are compressed surfaces!
474 */
475 switch (BitmapInfo->Format)
476 {
477 case BMF_1BPP:
478 //ScanLine = ((BitmapInfo->Width + 31) & ~31) / 8;
479 break;
480
481 case BMF_4BPP:
482 //ScanLine = ((BitmapInfo->Width + 7) & ~7) / 2;
483 break;
484
485 case BMF_8BPP:
486 //ScanLine = ((BitmapInfo->Width + 3) & ~3);
487 break;
488
489 case BMF_16BPP:
490 //ScanLine = ((BitmapInfo->Width + 1) & ~1) * 2;
491 break;
492
493 case BMF_24BPP:
494 //ScanLine = ((BitmapInfo->Width * 3) + 3) & ~3;
495 break;
496
497 case BMF_32BPP:
498 // ScanLine = BitmapInfo->Width * 4;
499 break;
500
501 case BMF_8RLE:
502 case BMF_4RLE:
503 case BMF_JPEG:
504 case BMF_PNG:
505 Compressed = TRUE;
506 break;
507
508 default:
509 DPRINT1("Invalid bitmap format\n");
510 return NULL;
511 }
512
513 ScanLine = BitmapInfo->Width;
514
515 /* Does the device manage its own surface? */
516 if (!Bits)
517 {
518 /* We need to allocate bits for the caller, figure out the size */
519 if (Compressed)
520 {
521 /* Note: we should not be seeing this scenario from ENGDDI */
522 ASSERT(FALSE);
523 Size = BitmapInfo->Size;
524 }
525 else
526 {
527 /* The height times the bytes for each scanline */
528 Size = BitmapInfo->Height * ScanLine;
529 }
530
531 if (Size)
532 {
533 /* Check for allocation flag */
534 if (BitmapInfo->Flags & BMF_USERMEM)
535 {
536 /* Get the bits from user-mode memory */
537 Bits = EngAllocUserMem(Size, 'mbuG');
538 }
539 else
540 {
541 /* Get kernel bits (zeroed out if requested) */
542 Bits = EngAllocMem((BitmapInfo->Flags & BMF_NOZEROINIT) ? 0 : FL_ZERO_MEMORY,
543 Size,
544 TAG_DIB);
545 }
546
547 /* Bail out if that failed */
548 if (!Bits) return NULL;
549 }
550 }
551 else
552 {
553 /* Should not have asked for user memory */
554 ASSERT((BitmapInfo->Flags & BMF_USERMEM) == 0);
555 }
556
557 /* Allocate the actual surface object structure */
558 psurf = SURFACE_AllocSurfaceWithHandle();
559 if (!psurf) return NULL;
560
561 /* Lock down the surface */
562 if (!SURFACE_InitBitsLock(psurf))
563 {
564 /* Bail out if that failed */
565 SURFACE_UnlockSurface(psurf);
566 SURFACE_FreeSurface(psurf);
567 return NULL;
568 }
569
570 /* We should now have our surface object */
571 pso = &psurf->SurfObj;
572
573 /* Save format and flags */
574 pso->iBitmapFormat = BitmapInfo->Format;
575 pso->fjBitmap = BitmapInfo->Flags & (BMF_TOPDOWN | BMF_UMPDMEM | BMF_USERMEM);
576
577 /* Save size and type */
578 LocalSize.cy = BitmapInfo->Height;
579 LocalSize.cx = BitmapInfo->Width;
580 pso->sizlBitmap = LocalSize;
581 pso->iType = STYPE_BITMAP;
582
583 /* Device-managed surface, no flags or dimension */
584 pso->dhsurf = 0;
585 pso->dhpdev = NULL;
586 pso->hdev = NULL;
587 psurf->flFlags = 0;
588 psurf->dimension.cx = 0;
589 psurf->dimension.cy = 0;
590 psurf->hSecure = NULL;
591 psurf->hDIBSection = NULL;
592 psurf->flHooks = 0;
593
594 /* Set bits */
595 pso->pvBits = Bits;
596
597 /* Check for bitmap type */
598 if (!Compressed)
599 {
600 /* Number of bits is based on the height times the scanline */
601 pso->cjBits = BitmapInfo->Height * ScanLine;
602 if (BitmapInfo->Flags & BMF_TOPDOWN)
603 {
604 /* For topdown, the base address starts with the bits */
605 pso->pvScan0 = pso->pvBits;
606 pso->lDelta = ScanLine;
607 }
608 else
609 {
610 /* Otherwise we start with the end and go up */
611 pso->pvScan0 = (PVOID)((ULONG_PTR)pso->pvBits + pso->cjBits - ScanLine);
612 pso->lDelta = -ScanLine;
613 }
614 }
615 else
616 {
617 /* Compressed surfaces don't have scanlines! */
618 ASSERT(FALSE); // Should not get here on ENGDDI
619 pso->lDelta = 0;
620 pso->cjBits = BitmapInfo->Size;
621
622 /* Check for JPG or PNG */
623 if ((BitmapInfo->Format != BMF_JPEG) && (BitmapInfo->Format != BMF_PNG))
624 {
625 /* Wherever the bit data is */
626 pso->pvScan0 = pso->pvBits;
627 }
628 else
629 {
630 /* Fancy formats don't use a base address */
631 pso->pvScan0 = NULL;
632 ASSERT(FALSE); // ENGDDI shouldn't be creating PNGs for drivers ;-)
633 }
634 }
635
636 /* Finally set the handle and uniq */
637 pso->hsurf = (HSURF)psurf->BaseObject.hHmgr;
638 pso->iUniq = 0;
639
640 /* Unlock and return the surface */
641 SURFACE_UnlockSurface(psurf);
642 return pso;
643 }
644
645 /*
646 * @implemented
647 */
648 HBITMAP
649 APIENTRY
650 EngCreateBitmap(IN SIZEL Size,
651 IN LONG Width,
652 IN ULONG Format,
653 IN ULONG Flags,
654 IN PVOID Bits)
655 {
656 SURFOBJ* Surface;
657 DEVBITMAPINFO BitmapInfo;
658
659 /* Capture the parameters */
660 BitmapInfo.Format = Format;
661 BitmapInfo.Width = Size.cx;
662 BitmapInfo.Height = Size.cy;
663 BitmapInfo.Flags = Flags;
664
665 /*
666 * If the display driver supports framebuffer access, use the scanline width
667 * to determine the actual width of the bitmap, and convert it to pels instead
668 * of bytes.
669 */
670 if ((Bits) && (Width))
671 {
672 #if 0
673 switch (BitmapInfo.Format)
674 {
675 /* Do the conversion for each bit depth we support */
676 case BMF_1BPP:
677 BitmapInfo.Width = Width * 8;
678 break;
679 case BMF_4BPP:
680 BitmapInfo.Width = Width * 2;
681 break;
682 case BMF_8BPP:
683 BitmapInfo.Width = Width;
684 break;
685 case BMF_16BPP:
686 BitmapInfo.Width = Width / 2;
687 break;
688 case BMF_24BPP:
689 BitmapInfo.Width = Width / 3;
690 break;
691 case BMF_32BPP:
692 BitmapInfo.Width = Width / 4;
693 break;
694 }
695 #endif
696 BitmapInfo.Width = Width;
697
698 }
699
700 /* Now create the surface */
701 Surface = SURFMEM_bCreateDib(&BitmapInfo, Bits);
702 if (!Surface) return 0;
703
704 /* Set public ownership and reutrn the handle */
705 GDIOBJ_SetOwnership(Surface->hsurf, NULL);
706 return Surface->hsurf;
707 }
708
709 /*
710 * @unimplemented
711 */
712 HSURF APIENTRY
713 EngCreateDeviceSurface(IN DHSURF dhsurf,
714 IN SIZEL Size,
715 IN ULONG Format)
716 {
717 HSURF hsurf;
718 SURFOBJ *pso;
719 PSURFACE psurf;
720
721 psurf = SURFACE_AllocSurfaceWithHandle();
722 if (!psurf)
723 {
724 return 0;
725 }
726
727 hsurf = psurf->BaseObject.hHmgr;
728 GDIOBJ_SetOwnership(hsurf, NULL);
729
730 if (!SURFACE_InitBitsLock(psurf))
731 {
732 SURFACE_UnlockSurface(psurf);
733 SURFACE_FreeSurfaceByHandle(hsurf);
734 return 0;
735 }
736 pso = &psurf->SurfObj;
737
738 pso->dhsurf = dhsurf;
739 pso->hsurf = hsurf;
740 pso->sizlBitmap = Size;
741 pso->iBitmapFormat = Format;
742 pso->lDelta = DIB_GetDIBWidthBytes(Size.cx, BitsPerFormat(Format));
743 pso->iType = STYPE_DEVICE;
744 pso->iUniq = 0;
745
746 psurf->flHooks = 0;
747
748 SURFACE_UnlockSurface(psurf);
749
750 return hsurf;
751 }
752
753 /*
754 * @implemented
755 */
756 BOOL
757 APIENTRY
758 EngAssociateSurface(
759 IN HSURF hsurf,
760 IN HDEV hdev,
761 IN FLONG flHooks)
762 {
763 SURFOBJ *pso;
764 PSURFACE psurf;
765 PDEVOBJ* ppdev;
766
767 ppdev = (PDEVOBJ*)hdev;
768
769 /* Lock the surface */
770 psurf = SURFACE_LockSurface(hsurf);
771 if (!psurf)
772 {
773 return FALSE;
774 }
775 pso = &psurf->SurfObj;
776
777 /* Associate the hdev */
778 pso->hdev = hdev;
779 pso->dhpdev = ppdev->dhpdev;
780
781 /* Hook up specified functions */
782 psurf->flHooks = flHooks;
783
784 SURFACE_UnlockSurface(psurf);
785
786 return TRUE;
787 }
788
789 /*
790 * @implemented
791 */
792 BOOL APIENTRY
793 EngModifySurface(
794 IN HSURF hsurf,
795 IN HDEV hdev,
796 IN FLONG flHooks,
797 IN FLONG flSurface,
798 IN DHSURF dhsurf,
799 OUT VOID *pvScan0,
800 IN LONG lDelta,
801 IN VOID *pvReserved)
802 {
803 SURFOBJ *pso;
804 PSURFACE psurf;
805 PDEVOBJ* ppdev;
806
807 psurf = SURFACE_LockSurface(hsurf);
808 if (psurf == NULL)
809 {
810 return FALSE;
811 }
812
813 ppdev = (PDEVOBJ*)hdev;
814 pso = &psurf->SurfObj;
815 pso->dhsurf = dhsurf;
816 pso->lDelta = lDelta;
817 pso->pvScan0 = pvScan0;
818
819 /* Associate the hdev */
820 pso->hdev = hdev;
821 pso->dhpdev = ppdev->dhpdev;
822
823 /* Hook up specified functions */
824 psurf->flHooks = flHooks;
825
826 SURFACE_UnlockSurface(psurf);
827
828 return TRUE;
829 }
830
831 /*
832 * @implemented
833 */
834 BOOL APIENTRY
835 EngDeleteSurface(IN HSURF hsurf)
836 {
837 GDIOBJ_SetOwnership(hsurf, PsGetCurrentProcess());
838 SURFACE_FreeSurfaceByHandle(hsurf);
839 return TRUE;
840 }
841
842 /*
843 * @implemented
844 */
845 BOOL APIENTRY
846 EngEraseSurface(SURFOBJ *pso,
847 RECTL *Rect,
848 ULONG iColor)
849 {
850 ASSERT(pso);
851 ASSERT(Rect);
852 return FillSolid(pso, Rect, iColor);
853 }
854
855 /*
856 * @implemented
857 */
858 SURFOBJ * APIENTRY
859 NtGdiEngLockSurface(IN HSURF hsurf)
860 {
861 return EngLockSurface(hsurf);
862 }
863
864
865 /*
866 * @implemented
867 */
868 SURFOBJ * APIENTRY
869 EngLockSurface(IN HSURF hsurf)
870 {
871 SURFACE *psurf = GDIOBJ_ShareLockObj(hsurf, GDI_OBJECT_TYPE_BITMAP);
872
873 if (psurf != NULL)
874 return &psurf->SurfObj;
875
876 return NULL;
877 }
878
879
880 /*
881 * @implemented
882 */
883 VOID APIENTRY
884 NtGdiEngUnlockSurface(IN SURFOBJ *pso)
885 {
886 EngUnlockSurface(pso);
887 }
888
889 /*
890 * @implemented
891 */
892 VOID APIENTRY
893 EngUnlockSurface(IN SURFOBJ *pso)
894 {
895 if (pso != NULL)
896 {
897 SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
898 GDIOBJ_ShareUnlockObjByPtr((POBJ)psurf);
899 }
900 }
901
902
903 /* EOF */