2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * PURPOSE: GDI TransparentBlt Function
24 * FILE: subsys/win32k/eng/transblt.c
25 * PROGRAMER: Jason Filby
30 #include <ddk/winddi.h>
31 #include <ddk/ntddk.h>
32 #include <ddk/ntddmou.h>
33 #include <ntos/minmax.h>
34 #include <include/dib.h>
35 #include <include/object.h>
36 #include <include/surface.h>
42 #include <include/mouse.h>
45 EngTransparentBlt(PSURFOBJ Dest,
48 PXLATEOBJ ColorTranslation,
51 ULONG TransparentColor,
54 PSURFGDI DestGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Dest),
55 SourceGDI = (PSURFGDI)AccessInternalObjectFromUserObject(Source);
58 POINTL TempPoint, SourcePoint;
64 dx = abs(DestRect->right - DestRect->left);
65 dy = abs(DestRect->bottom - DestRect->top);
67 sx = abs(SourceRect->right - SourceRect->left);
68 sy = abs(SourceRect->bottom - SourceRect->top);
73 MouseSafetyOnDrawStart(Source, SourceGDI, SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom);
74 MouseSafetyOnDrawStart(Dest, DestGDI, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
76 if(DestGDI->TransparentBlt != NULL)
78 // The destination is device managed, therefore get the source into a format compatible surface
85 TempSize.cx = TempRect.right;
86 TempSize.cy = TempRect.bottom;
88 hTemp = EngCreateBitmap(TempSize,
89 DIB_GetDIBWidthBytes(dx, BitsPerFormat(Dest->iBitmapFormat)),
90 Dest->iBitmapFormat, 0, NULL);
91 TempSurf = (PSURFOBJ)AccessUserObject((ULONG)hTemp);
93 SourcePoint.x = SourceRect->left;
94 SourcePoint.y = SourceRect->top;
96 // FIXME: Skip creating a TempSurf if we have the same BPP and palette
97 EngBitBlt(TempSurf, Source, NULL, NULL, ColorTranslation, &TempRect, &SourcePoint, NULL, NULL, NULL, 0);
99 ret = DestGDI->TransparentBlt(Dest, TempSurf, Clip, NULL, DestRect, SourceRect,
100 TransparentColor, Reserved);
102 MouseSafetyOnDrawEnd(Source, SourceGDI);
103 MouseSafetyOnDrawEnd(Dest, DestGDI);
105 if(EngDeleteSurface(hTemp) == FALSE)
107 DbgPrint("Win32k: Failed to delete surface: %d\n", hTemp);
114 // Simulate a transparent blt
116 MouseSafetyOnDrawEnd(Source, SourceGDI);
117 MouseSafetyOnDrawEnd(Dest, DestGDI);