2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI TransparentBlt Function
5 * FILE: subsys/win32k/eng/transblt.c
6 * PROGRAMER: Jason Filby
11 #include <ddk/winddi.h>
12 #include <ddk/ntddk.h>
13 #include <ntos/minmax.h>
14 #include <include/dib.h>
15 #include <include/object.h>
16 #include <include/surface.h>
22 #include <include/mouse.h>
25 EngTransparentBlt(PSURFOBJ Dest,
28 PXLATEOBJ ColorTranslation,
31 ULONG TransparentColor,
34 PSURFGDI DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest),
35 SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source);
38 POINTL TempPoint, SourcePoint;
44 dx = abs(DestRect->right - DestRect->left);
45 dy = abs(DestRect->bottom - DestRect->top);
47 sx = abs(SourceRect->right - SourceRect->left);
48 sy = abs(SourceRect->bottom - SourceRect->top);
53 MouseSafetyOnDrawStart(Source, SourceGDI, SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom);
54 MouseSafetyOnDrawStart(Dest, DestGDI, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
56 if(DestGDI->TransparentBlt != NULL)
58 // The destination is device managed, therefore get the source into a format compatible surface
65 TempSize.cx = TempRect.right;
66 TempSize.cy = TempRect.bottom;
68 hTemp = EngCreateBitmap(TempSize,
69 DIB_GetDIBWidthBytes(dx, BitsPerFormat(Dest->iBitmapFormat)),
70 Dest->iBitmapFormat, 0, NULL);
71 TempSurf = (PSURFOBJ)AccessUserObject((ULONG)hTemp);
73 SourcePoint.x = SourceRect->left;
74 SourcePoint.y = SourceRect->top;
76 // FIXME: Skip creating a TempSurf if we have the same BPP and palette
77 EngBitBlt(TempSurf, Source, NULL, NULL, ColorTranslation, &TempRect, &SourcePoint, NULL, NULL, NULL, 0);
79 ret = DestGDI->TransparentBlt(Dest, TempSurf, Clip, NULL, DestRect, SourceRect,
80 TransparentColor, Reserved);
82 MouseSafetyOnDrawEnd(Source, SourceGDI);
83 MouseSafetyOnDrawEnd(Dest, DestGDI);
85 if(EngDeleteSurface(hTemp) == FALSE)
87 DbgPrint("Win32k: Failed to delete surface: %d\n", hTemp);
94 // Simulate a transparent blt
96 MouseSafetyOnDrawEnd(Source, SourceGDI);
97 MouseSafetyOnDrawEnd(Dest, DestGDI);