*/
/* $Id: bitmaps.c 28300 2007-08-12 15:20:09Z tkreuzer $ */
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
{
PDC DCDest;
PDC DCSrc;
+ HDC ahDC[2];
+ PGDIOBJ apObj[2];
SURFACE *BitmapDest, *BitmapSrc;
RECTL DestRect, SourceRect;
BOOL bResult;
return FALSE;
}
- DCDest = DC_LockDc(hDCDest);
- if (NULL == DCDest)
+ DPRINT("Locking DCs\n");
+ ahDC[0] = hDCDest;
+ ahDC[1] = hDCSrc ;
+ GDIOBJ_LockMultipleObjs(2, ahDC, apObj);
+ DCDest = apObj[0];
+ DCSrc = apObj[1];
+
+ if ((NULL == DCDest) || (NULL == DCSrc))
{
- DPRINT1("Invalid destination dc handle (0x%08x) passed to NtGdiAlphaBlend\n", hDCDest);
+ DPRINT1("Invalid dc handle (dest=0x%08x, src=0x%08x) passed to NtGdiAlphaBlend\n", hDCDest, hDCSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ if(DCDest) GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
return FALSE;
}
- if (DCDest->dctype == DC_TYPE_INFO)
+ if (DCDest->dctype == DC_TYPE_INFO || DCDest->dctype == DCTYPE_INFO)
{
- DC_UnlockDc(DCDest);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
- if (hDCSrc != hDCDest)
- {
- DCSrc = DC_LockDc(hDCSrc);
- if (NULL == DCSrc)
- {
- DC_UnlockDc(DCDest);
- DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiAlphaBlend\n", hDCSrc);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (DCSrc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
- /* Yes, Windows really returns TRUE in this case */
- return TRUE;
- }
- }
- else
- {
- DCSrc = DCDest;
- }
-
DestRect.left = XOriginDest;
DestRect.top = YOriginDest;
DestRect.right = XOriginDest + WidthDest;
!SourceRect.right ||
!SourceRect.bottom)
{
- if (hDCSrc != hDCDest)
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
return TRUE;
}
+ /* Prepare DCs for blit */
+ DPRINT("Preparing DCs for blit\n");
+ DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+
/* Determine surfaces to be used in the bitblt */
BitmapDest = DCDest->dclevel.pSurface;
if (!BitmapDest)
{
- if (hDCSrc != hDCDest)
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
- return FALSE;
+ bResult = FALSE ;
+ goto leave ;
}
BitmapSrc = DCSrc->dclevel.pSurface;
if (!BitmapSrc)
{
- if (hDCSrc != hDCDest)
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
- return FALSE;
+ bResult = FALSE;
+ goto leave;
}
/* Create the XLATEOBJ. */
EXLATEOBJ_vInitXlateFromDCs(&exlo, DCSrc, DCDest);
/* Perform the alpha blend operation */
+ DPRINT("Performing the alpha Blend\n");
bResult = IntEngAlphaBlend(&BitmapDest->SurfObj,
&BitmapSrc->SurfObj,
DCDest->rosdc.CombinedClip,
&BlendObj);
EXLATEOBJ_vCleanup(&exlo);
- DC_UnlockDc(DCDest);
- if (hDCSrc != hDCDest)
- DC_UnlockDc(DCSrc);
+leave :
+ DPRINT("Finishing blit\n");
+ DC_vFinishBlit(DCDest, DCSrc);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
return bResult;
}
{
PDC DCDest;
PDC DCSrc = NULL;
+ HDC ahDC[2];
+ PGDIOBJ apObj[2];
PDC_ATTR pdcattr = NULL;
SURFACE *BitmapDest, *BitmapSrc = NULL;
- RECTL DestRect;
+ RECTL DestRect, SourceRect;
POINTL SourcePoint;
BOOL Status = FALSE;
EXLATEOBJ exlo;
XLATEOBJ *XlateObj = NULL;
BOOL UsesSource = ROP3_USES_SOURCE(ROP);
- DCDest = DC_LockDc(hDCDest);
+ DPRINT("Locking DCs\n");
+ ahDC[0] = hDCDest;
+ ahDC[1] = hDCSrc ;
+ GDIOBJ_LockMultipleObjs(2, ahDC, apObj);
+ DCDest = apObj[0];
+ DCSrc = apObj[1];
+
if (NULL == DCDest)
{
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
DPRINT("Invalid destination dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCDest);
return FALSE;
}
if (DCDest->dctype == DC_TYPE_INFO)
{
- DC_UnlockDc(DCDest);
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
if (UsesSource)
{
- if (hDCSrc != hDCDest)
+ if (NULL == DCSrc)
{
- DCSrc = DC_LockDc(hDCSrc);
- if (NULL == DCSrc)
- {
- DC_UnlockDc(DCDest);
- DPRINT("Invalid source dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCSrc);
- return FALSE;
- }
- if (DCSrc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
- /* Yes, Windows really returns TRUE in this case */
- return TRUE;
- }
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
+ DPRINT("Invalid source dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCSrc);
+ return FALSE;
}
- else
+ if (DCSrc->dctype == DC_TYPE_INFO)
{
- DCSrc = DCDest;
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ /* Yes, Windows really returns TRUE in this case */
+ return TRUE;
}
}
+ else if(DCSrc)
+ {
+ DPRINT1("Getting a valid Source handle without using source!!!\n");
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ DCSrc = NULL ;
+ }
pdcattr = DCDest->pdcattr;
- if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
- DC_vUpdateFillBrush(DCDest);
-
DestRect.left = XDest;
DestRect.top = YDest;
DestRect.right = XDest+Width;
SourcePoint.x += DCSrc->ptlDCOrig.x;
SourcePoint.y += DCSrc->ptlDCOrig.y;
+ /* Calculate Source Rect */
+ SourceRect.left = SourcePoint.x;
+ SourceRect.top = SourcePoint.y;
+ SourceRect.right = SourcePoint.x + DestRect.right - DestRect.left;
+ SourceRect.bottom = SourcePoint.y + DestRect.bottom - DestRect.top ;
}
+ /* Prepare blit */
+ DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+
+ if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+ DC_vUpdateFillBrush(DCDest);
+
/* Determine surfaces to be used in the bitblt */
BitmapDest = DCDest->dclevel.pSurface;
if (!BitmapDest)
&DCDest->dclevel.pbrFill->ptOrigin,
ROP3_TO_ROP4(ROP));
-cleanup:
if (UsesSource)
EXLATEOBJ_vCleanup(&exlo);
- if (UsesSource && hDCSrc != hDCDest)
+cleanup:
+ DC_vFinishBlit(DCDest, DCSrc);
+ if (UsesSource)
{
- DC_UnlockDc(DCSrc);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
}
- DC_UnlockDc(DCDest);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
return Status;
}
COLORREF TransColor)
{
PDC DCDest, DCSrc;
+ HDC ahDC[2];
+ PGDIOBJ apObj[2];
RECTL rcDest, rcSrc;
SURFACE *BitmapDest, *BitmapSrc = NULL;
- HPALETTE SourcePalette = 0, DestPalette = 0;
- PPALETTE PalDestGDI, PalSourceGDI;
- USHORT PalDestMode, PalSrcMode;
+ PPALETTE PalSourceGDI;
ULONG TransparentColor = 0;
BOOL Ret = FALSE;
EXLATEOBJ exlo;
- if(!(DCDest = DC_LockDc(hdcDst)))
+ DPRINT("Locking DCs\n");
+ ahDC[0] = hdcDst;
+ ahDC[1] = hdcSrc ;
+ GDIOBJ_LockMultipleObjs(2, ahDC, apObj);
+ DCDest = apObj[0];
+ DCSrc = apObj[1];
+
+ if ((NULL == DCDest) || (NULL == DCSrc))
{
- DPRINT1("Invalid destination dc handle (0x%08x) passed to NtGdiTransparentBlt\n", hdcDst);
+ DPRINT1("Invalid dc handle (dest=0x%08x, src=0x%08x) passed to NtGdiAlphaBlend\n", hdcDst, hdcSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ if(DCDest) GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
return FALSE;
}
- if (DCDest->dctype == DC_TYPE_INFO)
+
+ if (DCDest->dctype == DC_TYPE_INFO || DCDest->dctype == DCTYPE_INFO)
{
- DC_UnlockDc(DCDest);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
- if((hdcDst != hdcSrc) && !(DCSrc = DC_LockDc(hdcSrc)))
- {
- DC_UnlockDc(DCDest);
- DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiTransparentBlt\n", hdcSrc);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
+ rcDest.left = xDst;
+ rcDest.top = yDst;
+ rcDest.right = rcDest.left + cxDst;
+ rcDest.bottom = rcDest.top + cyDst;
+ IntLPtoDP(DCDest, (LPPOINT)&rcDest, 2);
- if(hdcDst == hdcSrc)
- {
- DCSrc = DCDest;
- }
+ rcDest.left += DCDest->ptlDCOrig.x;
+ rcDest.top += DCDest->ptlDCOrig.y;
+ rcDest.right += DCDest->ptlDCOrig.x;
+ rcDest.bottom += DCDest->ptlDCOrig.y;
- if (DCSrc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(DCSrc);
- if(hdcDst != hdcSrc)
- {
- DC_UnlockDc(DCDest);
- }
- /* Yes, Windows really returns TRUE in this case */
- return TRUE;
- }
+ rcSrc.left = xSrc;
+ rcSrc.top = ySrc;
+ rcSrc.right = rcSrc.left + cxSrc;
+ rcSrc.bottom = rcSrc.top + cySrc;
+ IntLPtoDP(DCSrc, (LPPOINT)&rcSrc, 2);
+
+ rcSrc.left += DCSrc->ptlDCOrig.x;
+ rcSrc.top += DCSrc->ptlDCOrig.y;
+ rcSrc.right += DCSrc->ptlDCOrig.x;
+ rcSrc.bottom += DCSrc->ptlDCOrig.y;
+
+ /* Prepare for blit */
+ DC_vPrepareDCsForBlit(DCDest, rcDest, DCSrc, rcSrc);
BitmapDest = DCDest->dclevel.pSurface;
if (!BitmapDest)
goto done;
}
- DestPalette = BitmapDest->hDIBPalette;
- if (!DestPalette) DestPalette = pPrimarySurface->devinfo.hpalDefault;
-
- SourcePalette = BitmapSrc->hDIBPalette;
- if (!SourcePalette) SourcePalette = pPrimarySurface->devinfo.hpalDefault;
-
- if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- goto done;
- }
- PalSrcMode = PalSourceGDI->Mode;
- PALETTE_UnlockPalette(PalSourceGDI);
-
- if(DestPalette != SourcePalette)
+ if (BitmapSrc->ppal)
{
- if (!(PalDestGDI = PALETTE_LockPalette(DestPalette)))
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- goto done;
- }
- PalDestMode = PalDestGDI->Mode;
- PALETTE_UnlockPalette(PalDestGDI);
+ GDIOBJ_IncrementShareCount(&BitmapSrc->ppal->BaseObject);
+ PalSourceGDI = BitmapSrc->ppal ;
}
else
+ PalSourceGDI = PALETTE_ShareLockPalette(pPrimarySurface->devinfo.hpalDefault) ;
+
+ if(!PalSourceGDI)
{
- PalDestMode = PalSrcMode;
- PalDestGDI = PalSourceGDI;
+ SetLastWin32Error(ERROR_INVALID_HANDLE);
+ goto done;
}
/* Translate Transparent (RGB) Color to the source palette */
EXLATEOBJ_vInitialize(&exlo, &gpalRGB, PalSourceGDI, 0, 0, 0);
TransparentColor = XLATEOBJ_iXlate(&exlo.xlo, (ULONG)TransColor);
EXLATEOBJ_vCleanup(&exlo);
+ PALETTE_ShareUnlockPalette(PalSourceGDI);
- EXLATEOBJ_vInitialize(&exlo, PalSourceGDI, PalDestGDI, 0, 0, 0);
-
- rcDest.left = xDst;
- rcDest.top = yDst;
- rcDest.right = rcDest.left + cxDst;
- rcDest.bottom = rcDest.top + cyDst;
- IntLPtoDP(DCDest, (LPPOINT)&rcDest, 2);
-
- rcDest.left += DCDest->ptlDCOrig.x;
- rcDest.top += DCDest->ptlDCOrig.y;
- rcDest.right += DCDest->ptlDCOrig.x;
- rcDest.bottom += DCDest->ptlDCOrig.y;
-
- rcSrc.left = xSrc;
- rcSrc.top = ySrc;
- rcSrc.right = rcSrc.left + cxSrc;
- rcSrc.bottom = rcSrc.top + cySrc;
- IntLPtoDP(DCSrc, (LPPOINT)&rcSrc, 2);
-
- rcSrc.left += DCSrc->ptlDCOrig.x;
- rcSrc.top += DCSrc->ptlDCOrig.y;
- rcSrc.right += DCSrc->ptlDCOrig.x;
- rcSrc.bottom += DCSrc->ptlDCOrig.y;
+ EXLATEOBJ_vInitXlateFromDCs(&exlo, DCSrc, DCDest);
Ret = IntEngTransparentBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
DCDest->rosdc.CombinedClip, &exlo.xlo, &rcDest, &rcSrc,
TransparentColor, 0);
-done:
- DC_UnlockDc(DCSrc);
- if(hdcDst != hdcSrc)
- {
- DC_UnlockDc(DCDest);
- }
EXLATEOBJ_vCleanup(&exlo);
+
+done:
+ DC_vFinishBlit(DCDest, DCSrc);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+
return Ret;
}
* A. It should be in here!
*/
+static const DWORD ROP3Table[256] =
+{
+ 0x000042, 0x010289, 0x020C89, 0x0300AA, 0x040C88, 0x0500A9, 0x060865, 0x0702C5,
+ 0x080F08, 0x090245, 0x0A0329, 0x0B0B2A, 0x0C0324, 0x0D0B25, 0x0E08A5, 0x0F0001,
+ 0x100C85, 0x1100A6, 0x120868, 0x1302C8, 0x140869, 0x1502C9, 0x165CCA, 0x171D54,
+ 0x180D59, 0x191CC8, 0x1A06C5, 0x1B0768, 0x1C06CA, 0x1D0766, 0x1E01A5, 0x1F0385,
+ 0x200F09, 0x210248, 0x220326, 0x230B24, 0x240D55, 0x251CC5, 0x2606C8, 0x271868,
+ 0x280369, 0x2916CA, 0x2A0CC9, 0x2B1D58, 0x2C0784, 0x2D060A, 0x2E064A, 0x2F0E2A,
+ 0x30032A, 0x310B28, 0x320688, 0x330008, 0x3406C4, 0x351864, 0x3601A8, 0x370388,
+ 0x38078A, 0x390604, 0x3A0644, 0x3B0E24, 0x3C004A, 0x3D18A4, 0x3E1B24, 0x3F00EA,
+ 0x400F0A, 0x410249, 0x420D5D, 0x431CC4, 0x440328, 0x450B29, 0x4606C6, 0x47076A,
+ 0x480368, 0x4916C5, 0x4A0789, 0x4B0605, 0x4C0CC8, 0x4D1954, 0x4E0645, 0x4F0E25,
+ 0x500325, 0x510B26, 0x5206C9, 0x530764, 0x5408A9, 0x550009, 0x5601A9, 0x570389,
+ 0x580785, 0x590609, 0x5A0049, 0x5B18A9, 0x5C0649, 0x5D0E29, 0x5E1B29, 0x5F00E9,
+ 0x600365, 0x6116C6, 0x620786, 0x630608, 0x640788, 0x650606, 0x660046, 0x6718A8,
+ 0x6858A6, 0x690145, 0x6A01E9, 0x6B178A, 0x6C01E8, 0x6D1785, 0x6E1E28, 0x6F0C65,
+ 0x700CC5, 0x711D5C, 0x720648, 0x730E28, 0x740646, 0x750E26, 0x761B28, 0x7700E6,
+ 0x7801E5, 0x791786, 0x7A1E29, 0x7B0C68, 0x7C1E24, 0x7D0C69, 0x7E0955, 0x7F03C9,
+ 0x8003E9, 0x810975, 0x820C49, 0x831E04, 0x840C48, 0x851E05, 0x8617A6, 0x8701C5,
+ 0x8800C6, 0x891B08, 0x8A0E06, 0x8B0666, 0x8C0E08, 0x8D0668, 0x8E1D7C, 0x8F0CE5,
+ 0x900C45, 0x911E08, 0x9217A9, 0x9301C4, 0x9417AA, 0x9501C9, 0x960169, 0x97588A,
+ 0x981888, 0x990066, 0x9A0709, 0x9B07A8, 0x9C0704, 0x9D07A6, 0x9E16E6, 0x9F0345,
+ 0xA000C9, 0xA11B05, 0xA20E09, 0xA30669, 0xA41885, 0xA50065, 0xA60706, 0xA707A5,
+ 0xA803A9, 0xA90189, 0xAA0029, 0xAB0889, 0xAC0744, 0xAD06E9, 0xAE0B06, 0xAF0229,
+ 0xB00E05, 0xB10665, 0xB21974, 0xB30CE8, 0xB4070A, 0xB507A9, 0xB616E9, 0xB70348,
+ 0xB8074A, 0xB906E6, 0xBA0B09, 0xBB0226, 0xBC1CE4, 0xBD0D7D, 0xBE0269, 0xBF08C9,
+ 0xC000CA, 0xC11B04, 0xC21884, 0xC3006A, 0xC40E04, 0xC50664, 0xC60708, 0xC707AA,
+ 0xC803A8, 0xC90184, 0xCA0749, 0xCB06E4, 0xCC0020, 0xCD0888, 0xCE0B08, 0xCF0224,
+ 0xD00E0A, 0xD1066A, 0xD20705, 0xD307A4, 0xD41D78, 0xD50CE9, 0xD616EA, 0xD70349,
+ 0xD80745, 0xD906E8, 0xDA1CE9, 0xDB0D75, 0xDC0B04, 0xDD0228, 0xDE0268, 0xDF08C8,
+ 0xE003A5, 0xE10185, 0xE20746, 0xE306EA, 0xE40748, 0xE506E5, 0xE61CE8, 0xE70D79,
+ 0xE81D74, 0xE95CE6, 0xEA02E9, 0xEB0849, 0xEC02E8, 0xED0848, 0xEE0086, 0xEF0A08,
+ 0xF00021, 0xF10885, 0xF20B05, 0xF3022A, 0xF40B0A, 0xF50225, 0xF60265, 0xF708C5,
+ 0xF802E5, 0xF90845, 0xFA0089, 0xFB0A09, 0xFC008A, 0xFD0A0A, 0xFE02A9, 0xFF0062,
+};
+
static __inline BYTE
SwapROP3_SrcDst(BYTE bRop3)
{
#define DSTCOPY 0x00AA0029
#define DSTERASE 0x00220326 /* dest = dest & (~src) : DSna */
+/* NOTE: An alternative algorithm could use a pattern brush, created from
+ * the mask bitmap and then use raster operation 0xCA to combine the fore
+ * and background bitmaps. In this case erasing the bits beforehand would be
+ * unneccessary. On the other hand the Operation does not provide an optimized
+ * version in the DIB code, while SRCAND and SRCPAINT do.
+ * A fully correct implementation would call Eng/DrvBitBlt, but our
+ * EngBitBlt completely ignores the mask surface.
+ *
+ * Msk Fg Bk => x
+ * P S D DPSDxax
+ * ------------------------------------------
+ * 0 0 0 0 0000xax = 000ax = 00x = 0
+ * 0 0 1 1 1001xax = 101ax = 10x = 1
+ * 0 1 0 0 0010xax = 001ax = 00x = 0
+ * 0 1 1 1 1011xax = 100ax = 10x = 1
+ * 1 0 0 0 0100xax = 010ax = 00x = 0
+ * 1 0 1 0 1101xax = 111ax = 11x = 0
+ * 1 1 0 1 0110xax = 011ax = 01x = 1
+ * 1 1 1 1 1111xax = 110ax = 10x = 1
+ *
+ * Operation index = 11001010 = 0xCA = PSaDPnao = DPSDxax
+ * ^ no, this is not random letters, its reverse Polish notation
+ */
+
BOOL APIENTRY
NtGdiMaskBlt(
HDC hdcDest,
DWORD dwRop,
IN DWORD crBackColor)
{
- HBITMAP hOldMaskBitmap, hBitmap2, hOldBitmap2, hBitmap3, hOldBitmap3;
- HDC hDCMask, hDC1, hDC2;
- static const DWORD ROP3Table[256] =
- {
- 0x00000042, 0x00010289,
- 0x00020C89, 0x000300AA,
- 0x00040C88, 0x000500A9,
- 0x00060865, 0x000702C5,
- 0x00080F08, 0x00090245,
- 0x000A0329, 0x000B0B2A,
- 0x000C0324, 0x000D0B25,
- 0x000E08A5, 0x000F0001,
- 0x00100C85, 0x001100A6,
- 0x00120868, 0x001302C8,
- 0x00140869, 0x001502C9,
- 0x00165CCA, 0x00171D54,
- 0x00180D59, 0x00191CC8,
- 0x001A06C5, 0x001B0768,
- 0x001C06CA, 0x001D0766,
- 0x001E01A5, 0x001F0385,
- 0x00200F09, 0x00210248,
- 0x00220326, 0x00230B24,
- 0x00240D55, 0x00251CC5,
- 0x002606C8, 0x00271868,
- 0x00280369, 0x002916CA,
- 0x002A0CC9, 0x002B1D58,
- 0x002C0784, 0x002D060A,
- 0x002E064A, 0x002F0E2A,
- 0x0030032A, 0x00310B28,
- 0x00320688, 0x00330008,
- 0x003406C4, 0x00351864,
- 0x003601A8, 0x00370388,
- 0x0038078A, 0x00390604,
- 0x003A0644, 0x003B0E24,
- 0x003C004A, 0x003D18A4,
- 0x003E1B24, 0x003F00EA,
- 0x00400F0A, 0x00410249,
- 0x00420D5D, 0x00431CC4,
- 0x00440328, 0x00450B29,
- 0x004606C6, 0x0047076A,
- 0x00480368, 0x004916C5,
- 0x004A0789, 0x004B0605,
- 0x004C0CC8, 0x004D1954,
- 0x004E0645, 0x004F0E25,
- 0x00500325, 0x00510B26,
- 0x005206C9, 0x00530764,
- 0x005408A9, 0x00550009,
- 0x005601A9, 0x00570389,
- 0x00580785, 0x00590609,
- 0x005A0049, 0x005B18A9,
- 0x005C0649, 0x005D0E29,
- 0x005E1B29, 0x005F00E9,
- 0x00600365, 0x006116C6,
- 0x00620786, 0x00630608,
- 0x00640788, 0x00650606,
- 0x00660046, 0x006718A8,
- 0x006858A6, 0x00690145,
- 0x006A01E9, 0x006B178A,
- 0x006C01E8, 0x006D1785,
- 0x006E1E28, 0x006F0C65,
- 0x00700CC5, 0x00711D5C,
- 0x00720648, 0x00730E28,
- 0x00740646, 0x00750E26,
- 0x00761B28, 0x007700E6,
- 0x007801E5, 0x00791786,
- 0x007A1E29, 0x007B0C68,
- 0x007C1E24, 0x007D0C69,
- 0x007E0955, 0x007F03C9,
- 0x008003E9, 0x00810975,
- 0x00820C49, 0x00831E04,
- 0x00840C48, 0x00851E05,
- 0x008617A6, 0x008701C5,
- 0x008800C6, 0x00891B08,
- 0x008A0E06, 0x008B0666,
- 0x008C0E08, 0x008D0668,
- 0x008E1D7C, 0x008F0CE5,
- 0x00900C45, 0x00911E08,
- 0x009217A9, 0x009301C4,
- 0x009417AA, 0x009501C9,
- 0x00960169, 0x0097588A,
- 0x00981888, 0x00990066,
- 0x009A0709, 0x009B07A8,
- 0x009C0704, 0x009D07A6,
- 0x009E16E6, 0x009F0345,
- 0x00A000C9, 0x00A11B05,
- 0x00A20E09, 0x00A30669,
- 0x00A41885, 0x00A50065,
- 0x00A60706, 0x00A707A5,
- 0x00A803A9, 0x00A90189,
- 0x00AA0029, 0x00AB0889,
- 0x00AC0744, 0x00AD06E9,
- 0x00AE0B06, 0x00AF0229,
- 0x00B00E05, 0x00B10665,
- 0x00B21974, 0x00B30CE8,
- 0x00B4070A, 0x00B507A9,
- 0x00B616E9, 0x00B70348,
- 0x00B8074A, 0x00B906E6,
- 0x00BA0B09, 0x00BB0226,
- 0x00BC1CE4, 0x00BD0D7D,
- 0x00BE0269, 0x00BF08C9,
- 0x00C000CA, 0x00C11B04,
- 0x00C21884, 0x00C3006A,
- 0x00C40E04, 0x00C50664,
- 0x00C60708, 0x00C707AA,
- 0x00C803A8, 0x00C90184,
- 0x00CA0749, 0x00CB06E4,
- 0x00CC0020, 0x00CD0888,
- 0x00CE0B08, 0x00CF0224,
- 0x00D00E0A, 0x00D1066A,
- 0x00D20705, 0x00D307A4,
- 0x00D41D78, 0x00D50CE9,
- 0x00D616EA, 0x00D70349,
- 0x00D80745, 0x00D906E8,
- 0x00DA1CE9, 0x00DB0D75,
- 0x00DC0B04, 0x00DD0228,
- 0x00DE0268, 0x00DF08C8,
- 0x00E003A5, 0x00E10185,
- 0x00E20746, 0x00E306EA,
- 0x00E40748, 0x00E506E5,
- 0x00E61CE8, 0x00E70D79,
- 0x00E81D74, 0x00E95CE6,
- 0x00EA02E9, 0x00EB0849,
- 0x00EC02E8, 0x00ED0848,
- 0x00EE0086, 0x00EF0A08,
- 0x00F00021, 0x00F10885,
- 0x00F20B05, 0x00F3022A,
- 0x00F40B0A, 0x00F50225,
- 0x00F60265, 0x00F708C5,
- 0x00F802E5, 0x00F90845,
- 0x00FA0089, 0x00FB0A09,
- 0x00FC008A, 0x00FD0A0A,
- 0x00FE02A9, 0x00FF0062,
- };
+ HBITMAP hbmFore, hbmBack;
+ HDC hdcMask, hdcFore, hdcBack;
+ PDC pdc;
+ HBRUSH hbr;
+ COLORREF crFore, crBack;
if (!hbmMask)
- return NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0, 0);
+ return NtGdiBitBlt(hdcDest,
+ nXDest,
+ nYDest,
+ nWidth,
+ nHeight,
+ hdcSrc,
+ nXSrc,
+ nYSrc,
+ FRGND_ROP3(dwRop),
+ crBackColor,
+ 0);
+
+ /* Lock the dest DC */
+ pdc = DC_LockDc(hdcDest);
+ if (!pdc) return FALSE;
+
+ /* Get brush and colors from dest dc */
+ hbr = pdc->pdcattr->hbrush;
+ crFore = pdc->pdcattr->crForegroundClr;
+ crBack = pdc->pdcattr->crBackgroundClr;
+
+ /* Unlock the DC */
+ DC_UnlockDc(pdc);
+
+ /* 1. Create mask bitmap's dc */
+ hdcMask = NtGdiCreateCompatibleDC(hdcDest);
+ NtGdiSelectBitmap(hdcMask, hbmMask);
+
+ /* 2. Create masked Background bitmap */
- /* 1. make mask bitmap's dc */
- hDCMask = NtGdiCreateCompatibleDC(hdcDest);
- hOldMaskBitmap = (HBITMAP)NtGdiSelectBitmap(hDCMask, hbmMask);
+ /* 2.1 Create bitmap */
+ hdcBack = NtGdiCreateCompatibleDC(hdcDest);
+ hbmBack = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
+ NtGdiSelectBitmap(hdcBack, hbmBack);
- /* 2. make masked Background bitmap */
+ /* 2.2 Copy source bitmap */
+ NtGdiSelectBrush(hdcBack, hbr);
+ IntGdiSetBkColor(hdcBack, crBack);
+ IntGdiSetTextColor(hdcBack, crFore);
+ NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY, 0, 0);
- /* 2.1 make bitmap */
- hDC1 = NtGdiCreateCompatibleDC(hdcDest);
- hBitmap2 = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
- hOldBitmap2 = (HBITMAP)NtGdiSelectBitmap(hDC1, hBitmap2);
+ /* 2.3 Do the background rop */
+ NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, BKGND_ROP3(dwRop), 0, 0);
- /* 2.2 draw dest bitmap and mask */
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY, 0, 0);
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, BKGND_ROP3(dwRop), 0, 0);
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, DSTERASE, 0, 0);
+ /* 2.4 Erase the foreground pixels */
+ IntGdiSetBkColor(hdcBack, 0xffffffff);
+ IntGdiSetTextColor(hdcBack, 0);
+ NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 0, 0);
- /* 3. make masked Foreground bitmap */
+ /* 3. Create masked Foreground bitmap */
- /* 3.1 make bitmap */
- hDC2 = NtGdiCreateCompatibleDC(hdcDest);
- hBitmap3 = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
- hOldBitmap3 = (HBITMAP)NtGdiSelectBitmap(hDC2, hBitmap3);
+ /* 3.1 Create bitmap */
+ hdcFore = NtGdiCreateCompatibleDC(hdcDest);
+ hbmFore = NtGdiCreateCompatibleBitmap(hdcDest, nWidth, nHeight);
+ NtGdiSelectBitmap(hdcFore, hbmFore);
- /* 3.2 draw src bitmap and mask */
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY, 0, 0);
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0,0);
- NtGdiBitBlt(hDC2, 0, 0, nWidth, nHeight, hDCMask, xMask, yMask, SRCAND, 0, 0);
+ /* 3.2 Copy the dest bitmap */
+ NtGdiSelectBrush(hdcFore, hbr);
+ IntGdiSetBkColor(hdcFore, crBack);
+ IntGdiSetTextColor(hdcFore, crFore);
+ NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcDest, nXDest, nYDest, SRCCOPY, 0, 0);
- /* 4. combine both and copy the result to hdcDest */
- NtGdiBitBlt(hDC1, 0, 0, nWidth, nHeight, hDC2, 0, 0, SRCPAINT, 0, 0);
- NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hDC1, 0, 0, SRCCOPY, 0, 0);
+ /* 2.3 Do the foreground rop */
+ NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, FRGND_ROP3(dwRop), 0,0);
- /* 5. restore all objects */
- NtGdiSelectBitmap(hDCMask, hOldMaskBitmap);
- NtGdiSelectBitmap(hDC1, hOldBitmap2);
- NtGdiSelectBitmap(hDC2, hOldBitmap3);
+ /* 2.4 Erase the background pixels */
+ IntGdiSetBkColor(hdcFore, 0);
+ IntGdiSetTextColor(hdcFore, 0xffffffff);
+ NtGdiBitBlt(hdcFore, 0, 0, nWidth, nHeight, hdcMask, xMask, yMask, SRCAND, 0, 0);
- /* 6. delete all temp objects */
- GreDeleteObject(hBitmap2);
- GreDeleteObject(hBitmap3);
+ /* 3. Combine the fore and background into the background bitmap */
+ NtGdiBitBlt(hdcBack, 0, 0, nWidth, nHeight, hdcFore, 0, 0, SRCPAINT, 0, 0);
- NtGdiDeleteObjectApp(hDC1);
- NtGdiDeleteObjectApp(hDC2);
- NtGdiDeleteObjectApp(hDCMask);
+ /* 4. Copy the result to hdcDest */
+ NtGdiBitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcBack, 0, 0, SRCCOPY, 0, 0);
+
+ /* 5. delete all temp objects */
+ NtGdiDeleteObjectApp(hdcBack);
+ NtGdiDeleteObjectApp(hdcFore);
+ NtGdiDeleteObjectApp(hdcMask);
+ GreDeleteObject(hbmFore);
+ GreDeleteObject(hbmBack);
return TRUE;
}
PDC DCDest;
PDC DCSrc = NULL;
PDC DCMask = NULL;
+ HDC ahDC[3];
+ PGDIOBJ apObj[3];
PDC_ATTR pdcattr;
SURFACE *BitmapDest, *BitmapSrc = NULL;
SURFACE *BitmapMask = NULL;
return FALSE;
}
- DCDest = DC_LockDc(hDCDest);
+ DPRINT("Locking DCs\n");
+ ahDC[0] = hDCDest;
+ ahDC[1] = hDCSrc ;
+ ahDC[2] = hDCMask ;
+ GDIOBJ_LockMultipleObjs(3, ahDC, apObj);
+ DCDest = apObj[0];
+ DCSrc = apObj[1];
+ DCMask = apObj[2];
+
if (NULL == DCDest)
{
- DPRINT1("Invalid destination dc handle (0x%08x) passed to NtGdiStretchBlt\n", hDCDest);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ if(DCMask) GDIOBJ_UnlockObjByPtr(&DCMask->BaseObject);
+ DPRINT("Invalid destination dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCDest);
return FALSE;
}
if (DCDest->dctype == DC_TYPE_INFO)
{
- DC_UnlockDc(DCDest);
+ if(DCSrc) GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ if(DCMask) GDIOBJ_UnlockObjByPtr(&DCMask->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
/* Yes, Windows really returns TRUE in this case */
return TRUE;
}
if (UsesSource)
{
- if (hDCSrc != hDCDest)
+ if (NULL == DCSrc)
{
- DCSrc = DC_LockDc(hDCSrc);
- if (NULL == DCSrc)
- {
- DC_UnlockDc(DCDest);
- DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiStretchBlt\n", hDCSrc);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
- if (DCSrc->dctype == DC_TYPE_INFO)
- {
- DC_UnlockDc(DCSrc);
- DC_UnlockDc(DCDest);
- /* Yes, Windows really returns TRUE in this case */
- return TRUE;
- }
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
+ if(DCMask) GDIOBJ_UnlockObjByPtr(&DCMask->BaseObject);
+ DPRINT("Invalid source dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCSrc);
+ return FALSE;
}
- else
+ if (DCSrc->dctype == DC_TYPE_INFO)
{
- DCSrc = DCDest;
+ GDIOBJ_UnlockObjByPtr(&DCDest->BaseObject);
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ if(DCMask) GDIOBJ_UnlockObjByPtr(&DCMask->BaseObject);
+ /* Yes, Windows really returns TRUE in this case */
+ return TRUE;
}
}
+ else if(DCSrc)
+ {
+ DPRINT1("Getting a valid Source handle without using source!!!\n");
+ GDIOBJ_UnlockObjByPtr(&DCSrc->BaseObject);
+ DCSrc = NULL ;
+ }
pdcattr = DCDest->pdcattr;
- if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
- DC_vUpdateFillBrush(DCDest);
-
DestRect.left = XOriginDest;
DestRect.top = YOriginDest;
DestRect.right = XOriginDest+WidthDest;
BrushOrigin.x = 0;
BrushOrigin.y = 0;
+ /* Only prepare Source and Dest, hdcMask represents a DIB */
+ DC_vPrepareDCsForBlit(DCDest, DestRect, DCSrc, SourceRect);
+
+ if (pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+ DC_vUpdateFillBrush(DCDest);
+
/* Determine surfaces to be used in the bitblt */
BitmapDest = DCDest->dclevel.pSurface;
if (BitmapDest == NULL)
BrushOrigin.y += DCDest->ptlDCOrig.y;
/* Make mask surface for source surface */
- if (BitmapSrc && hDCMask)
+ if (BitmapSrc && DCMask)
{
- DCMask = DC_LockDc(hDCMask);
- if (DCMask)
+ BitmapMask = DCMask->dclevel.pSurface;
+ if (BitmapMask &&
+ (BitmapMask->SurfObj.sizlBitmap.cx < WidthSrc ||
+ BitmapMask->SurfObj.sizlBitmap.cy < HeightSrc))
{
- BitmapMask = DCMask->dclevel.pSurface;
- if (BitmapMask &&
- (BitmapMask->SurfObj.sizlBitmap.cx < WidthSrc ||
- BitmapMask->SurfObj.sizlBitmap.cy < HeightSrc))
- {
- DPRINT1("%dx%d mask is smaller than %dx%d bitmap\n",
- BitmapMask->SurfObj.sizlBitmap.cx, BitmapMask->SurfObj.sizlBitmap.cy,
- WidthSrc, HeightSrc);
- goto failed;
- }
- /* Create mask offset point */
- MaskPoint.x = XOriginMask;
- MaskPoint.y = YOriginMask;
- IntLPtoDP(DCMask, &MaskPoint, 1);
- MaskPoint.x += DCMask->ptlDCOrig.x;
- MaskPoint.y += DCMask->ptlDCOrig.x;
+ DPRINT1("%dx%d mask is smaller than %dx%d bitmap\n",
+ BitmapMask->SurfObj.sizlBitmap.cx, BitmapMask->SurfObj.sizlBitmap.cy,
+ WidthSrc, HeightSrc);
+ EXLATEOBJ_vCleanup(&exlo);
+ goto failed;
}
+ /* Create mask offset point */
+ MaskPoint.x = XOriginMask;
+ MaskPoint.y = YOriginMask;
+ IntLPtoDP(DCMask, &MaskPoint, 1);
+ MaskPoint.x += DCMask->ptlDCOrig.x;
+ MaskPoint.y += DCMask->ptlDCOrig.x;
}
/* Perform the bitblt operation */
&DCDest->eboFill.BrushObject,
&BrushOrigin,
ROP3_TO_ROP4(ROP));
-
-failed:
if (UsesSource)
{
EXLATEOBJ_vCleanup(&exlo);
}
- if (UsesSource && hDCSrc != hDCDest)
+
+failed:
+ DC_vFinishBlit(DCDest, DCSrc);
+ if (UsesSource)
{
DC_UnlockDc(DCSrc);
}
{
RECTL DestRect;
SURFACE *psurf;
- EBRUSHOBJ eboFill;
+ EBRUSHOBJ eboFill ;
POINTL BrushOrigin;
BOOL ret;
ASSERT(pbrush);
- psurf = pdc->dclevel.pSurface;
- if (psurf == NULL)
- {
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
if (pbrush->flAttrs & GDIBRUSH_IS_NULL)
{
return TRUE;
BrushOrigin.x = pbrush->ptOrigin.x + pdc->ptlDCOrig.x;
BrushOrigin.y = pbrush->ptOrigin.y + pdc->ptlDCOrig.y;
+ DC_vPrepareDCsForBlit(pdc, DestRect, NULL, DestRect);
+
+ psurf = pdc->dclevel.pSurface;
+
+ if (pdc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
+ DC_vUpdateFillBrush(pdc);
+
EBRUSHOBJ_vInit(&eboFill, pbrush, pdc);
ret = IntEngBitBlt(
&DestRect,
NULL,
NULL,
- &eboFill.BrushObject, // use pDC->eboFill
+ &eboFill.BrushObject,
&BrushOrigin,
ROP3_TO_ROP4(dwRop));
+ DC_vFinishBlit(pdc, NULL);
+
EBRUSHOBJ_vCleanup(&eboFill);
return ret;