mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 09:13:00 +00:00
fix palette implementation: use the surface's palette to crate the xlate objects, default to the device default palette. The dc palette defaults to stock object default palette. Implement IntCreateXlateForBlt, used in BitBlt etc functions to perform the needed operations to create the xlate object instead of duplicating the code. This allows for global thermonuclear solitaire again and hopefully doesn't break everything else ;-)
svn path=/trunk/; revision=33752
This commit is contained in:
parent
8d17551ae9
commit
d60ea94881
8 changed files with 151 additions and 200 deletions
|
@ -311,5 +311,6 @@ VOID FASTCALL IntGdiUnreferencePdev(PGDIDEVICE pPDev, DWORD CleanUpType);
|
||||||
HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
|
HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
|
||||||
BOOL FASTCALL IntGdiCleanDC(HDC hDC);
|
BOOL FASTCALL IntGdiCleanDC(HDC hDC);
|
||||||
|
|
||||||
|
extern GDIDEVICE PrimarySurface;
|
||||||
|
|
||||||
#endif /* not __WIN32K_DC_H */
|
#endif /* not __WIN32K_DC_H */
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
XLATEOBJ* FASTCALL
|
XLATEOBJ* FASTCALL
|
||||||
IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed);
|
IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed);
|
||||||
|
|
||||||
|
XLATEOBJ*
|
||||||
|
FASTCALL
|
||||||
|
IntCreateXlateForBlt(PDC pDCDest, PDC pDCSrc, BITMAPOBJ* pDestSurf, BITMAPOBJ* pSrcSurf);
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
IntGdiInitBrushInstance(GDIBRUSHINST *BrushInst, PGDIBRUSHOBJ BrushObj, XLATEOBJ *XlateObj);
|
IntGdiInitBrushInstance(GDIBRUSHINST *BrushInst, PGDIBRUSHOBJ BrushObj, XLATEOBJ *XlateObj);
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,11 @@ NtGdiAlphaBlend(
|
||||||
{
|
{
|
||||||
PDC DCDest = NULL;
|
PDC DCDest = NULL;
|
||||||
PDC DCSrc = NULL;
|
PDC DCSrc = NULL;
|
||||||
PDC_ATTR Dc_Attr = NULL;
|
|
||||||
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
||||||
RECTL DestRect, SourceRect;
|
RECTL DestRect, SourceRect;
|
||||||
BOOL Status;
|
BOOL Status;
|
||||||
XLATEOBJ *XlateObj;
|
XLATEOBJ *XlateObj;
|
||||||
BLENDOBJ BlendObj;
|
BLENDOBJ BlendObj;
|
||||||
HPALETTE SourcePalette = 0, DestPalette = 0;
|
|
||||||
BlendObj.BlendFunction = BlendFunc;
|
BlendObj.BlendFunction = BlendFunc;
|
||||||
|
|
||||||
DCDest = DC_LockDc(hDCDest);
|
DCDest = DC_LockDc(hDCDest);
|
||||||
|
@ -88,9 +86,6 @@ NtGdiAlphaBlend(
|
||||||
DCSrc = DCDest;
|
DCSrc = DCDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dc_Attr = DCSrc->pDc_Attr;
|
|
||||||
if (!Dc_Attr) Dc_Attr = &DCSrc->Dc_Attr;
|
|
||||||
|
|
||||||
/* Offset the destination and source by the origin of their DCs. */
|
/* Offset the destination and source by the origin of their DCs. */
|
||||||
XOriginDest += DCDest->w.DCOrgX;
|
XOriginDest += DCDest->w.DCOrgX;
|
||||||
YOriginDest += DCDest->w.DCOrgY;
|
YOriginDest += DCDest->w.DCOrgY;
|
||||||
|
@ -109,53 +104,43 @@ NtGdiAlphaBlend(
|
||||||
|
|
||||||
/* Determine surfaces to be used in the bitblt */
|
/* Determine surfaces to be used in the bitblt */
|
||||||
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
||||||
|
if (!BitmapDest)
|
||||||
|
{
|
||||||
|
DC_UnlockDc(DCSrc);
|
||||||
|
DC_UnlockDc(DCDest);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
|
if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
|
||||||
BitmapSrc = BitmapDest;
|
BitmapSrc = BitmapDest;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
||||||
|
if (!BitmapDest)
|
||||||
/* Create the XLATEOBJ. */
|
|
||||||
if (DCDest->DcLevel.hpal != 0)
|
|
||||||
DestPalette = DCDest->DcLevel.hpal;
|
|
||||||
if (DCSrc->DcLevel.hpal != 0)
|
|
||||||
SourcePalette = DCSrc->DcLevel.hpal;
|
|
||||||
|
|
||||||
/* KB41464 details how to convert between mono and color */
|
|
||||||
if (DCDest->w.bitsPerPixel == 1 && DCSrc->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (DCDest->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateMonoXlate(0, DestPalette, SourcePalette, Dc_Attr->crBackgroundClr);
|
|
||||||
}
|
|
||||||
else if (DCSrc->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateSrcMonoXlate(DestPalette, Dc_Attr->crBackgroundClr, Dc_Attr->crForegroundClr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
|
|
||||||
}
|
|
||||||
if (NULL == XlateObj)
|
|
||||||
{
|
{
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
||||||
if (BitmapSrc != BitmapDest)
|
DC_UnlockDc(DCSrc);
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
|
||||||
DC_UnlockDc(DCDest);
|
DC_UnlockDc(DCDest);
|
||||||
if (hDCSrc != hDCDest)
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the alpha blend operation */
|
/* Create the XLATEOBJ. */
|
||||||
Status = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
|
XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
|
||||||
DCDest->CombinedClip, XlateObj,
|
|
||||||
&DestRect, &SourceRect, &BlendObj);
|
if (XlateObj == (XLATEOBJ*)-1)
|
||||||
|
{
|
||||||
|
DPRINT1("error!!!\n");
|
||||||
|
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
|
XlateObj = NULL;
|
||||||
|
Status = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Perform the alpha blend operation */
|
||||||
|
Status = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
|
||||||
|
DCDest->CombinedClip, XlateObj,
|
||||||
|
&DestRect, &SourceRect, &BlendObj);
|
||||||
|
}
|
||||||
|
|
||||||
if (XlateObj != NULL)
|
if (XlateObj != NULL)
|
||||||
EngDeleteXlate(XlateObj);
|
EngDeleteXlate(XlateObj);
|
||||||
|
@ -186,14 +171,13 @@ NtGdiBitBlt(
|
||||||
{
|
{
|
||||||
PDC DCDest = NULL;
|
PDC DCDest = NULL;
|
||||||
PDC DCSrc = NULL;
|
PDC DCSrc = NULL;
|
||||||
PDC_ATTR Dc_Attr = NULL;
|
PDC_ATTR Dc_Attr = NULL;
|
||||||
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
BITMAPOBJ *BitmapDest, *BitmapSrc = NULL;
|
||||||
RECTL DestRect;
|
RECTL DestRect;
|
||||||
POINTL SourcePoint, BrushOrigin;
|
POINTL SourcePoint, BrushOrigin;
|
||||||
BOOL Status;
|
BOOL Status = FALSE;
|
||||||
XLATEOBJ *XlateObj = NULL;
|
XLATEOBJ *XlateObj = NULL;
|
||||||
HPALETTE SourcePalette = 0, DestPalette = 0;
|
PGDIBRUSHOBJ BrushObj = NULL;
|
||||||
PGDIBRUSHOBJ BrushObj;
|
|
||||||
GDIBRUSHINST BrushInst;
|
GDIBRUSHINST BrushInst;
|
||||||
BOOL UsesSource = ROP3_USES_SOURCE(ROP);
|
BOOL UsesSource = ROP3_USES_SOURCE(ROP);
|
||||||
BOOL UsesPattern = ROP3_USES_PATTERN(ROP);
|
BOOL UsesPattern = ROP3_USES_PATTERN(ROP);
|
||||||
|
@ -240,8 +224,8 @@ NtGdiBitBlt(
|
||||||
DCSrc = NULL;
|
DCSrc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dc_Attr = DCDest->pDc_Attr;
|
Dc_Attr = DCDest->pDc_Attr;
|
||||||
if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
|
if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
|
||||||
|
|
||||||
/* Offset the destination and source by the origin of their DCs. */
|
/* Offset the destination and source by the origin of their DCs. */
|
||||||
XDest += DCDest->w.DCOrgX;
|
XDest += DCDest->w.DCOrgX;
|
||||||
|
@ -267,12 +251,19 @@ NtGdiBitBlt(
|
||||||
|
|
||||||
/* Determine surfaces to be used in the bitblt */
|
/* Determine surfaces to be used in the bitblt */
|
||||||
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
||||||
|
if (!BitmapDest)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (UsesSource)
|
if (UsesSource)
|
||||||
{
|
{
|
||||||
if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
|
if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
|
||||||
BitmapSrc = BitmapDest;
|
BitmapSrc = BitmapDest;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
||||||
|
if (!BitmapSrc)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -284,21 +275,8 @@ NtGdiBitBlt(
|
||||||
BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
|
BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
|
||||||
if (NULL == BrushObj)
|
if (NULL == BrushObj)
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
|
||||||
{
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
}
|
|
||||||
if(BitmapDest != NULL)
|
|
||||||
{
|
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
|
||||||
}
|
|
||||||
if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
|
|
||||||
{
|
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
return FALSE;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
BrushOrigin = *((PPOINTL)&BrushObj->ptOrigin);
|
BrushOrigin = *((PPOINTL)&BrushObj->ptOrigin);
|
||||||
IntGdiInitBrushInstance(&BrushInst, BrushObj, DCDest->XlateBrush);
|
IntGdiInitBrushInstance(&BrushInst, BrushObj, DCDest->XlateBrush);
|
||||||
|
@ -311,55 +289,14 @@ NtGdiBitBlt(
|
||||||
/* Create the XLATEOBJ. */
|
/* Create the XLATEOBJ. */
|
||||||
if (UsesSource)
|
if (UsesSource)
|
||||||
{
|
{
|
||||||
if (DCDest->DcLevel.hpal != 0)
|
XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
|
||||||
DestPalette = DCDest->DcLevel.hpal;
|
|
||||||
|
|
||||||
if (DCSrc->DcLevel.hpal != 0)
|
if (XlateObj == (XLATEOBJ*)-1)
|
||||||
SourcePalette = DCSrc->DcLevel.hpal;
|
|
||||||
|
|
||||||
/* KB41464 details how to convert between mono and color */
|
|
||||||
if (DCDest->w.bitsPerPixel == 1 && DCSrc->w.bitsPerPixel == 1)
|
|
||||||
{
|
{
|
||||||
|
DPRINT1("error!\n");
|
||||||
|
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
XlateObj = NULL;
|
XlateObj = NULL;
|
||||||
}
|
goto cleanup;
|
||||||
else
|
|
||||||
{
|
|
||||||
Dc_Attr = DCSrc->pDc_Attr;
|
|
||||||
if (!Dc_Attr) Dc_Attr = &DCSrc->Dc_Attr;
|
|
||||||
if (DCDest->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateMonoXlate(0, DestPalette, SourcePalette, Dc_Attr->crBackgroundClr);
|
|
||||||
}
|
|
||||||
else if (DCSrc->w.bitsPerPixel == 1)
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateSrcMonoXlate(DestPalette, Dc_Attr->crBackgroundClr, Dc_Attr->crForegroundClr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XlateObj = IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
|
|
||||||
}
|
|
||||||
if (NULL == XlateObj)
|
|
||||||
{
|
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
|
||||||
{
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
if(BitmapDest != NULL)
|
|
||||||
{
|
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
|
||||||
}
|
|
||||||
if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
|
|
||||||
{
|
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
|
||||||
}
|
|
||||||
if(BrushObj != NULL)
|
|
||||||
{
|
|
||||||
BRUSHOBJ_UnlockBrush(BrushObj);
|
|
||||||
}
|
|
||||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +307,7 @@ NtGdiBitBlt(
|
||||||
BrushObj ? &BrushInst.BrushObject : NULL,
|
BrushObj ? &BrushInst.BrushObject : NULL,
|
||||||
&BrushOrigin, ROP3_TO_ROP4(ROP));
|
&BrushOrigin, ROP3_TO_ROP4(ROP));
|
||||||
|
|
||||||
|
cleanup:
|
||||||
if (UsesSource && XlateObj != NULL)
|
if (UsesSource && XlateObj != NULL)
|
||||||
EngDeleteXlate(XlateObj);
|
EngDeleteXlate(XlateObj);
|
||||||
|
|
||||||
|
@ -410,8 +348,8 @@ NtGdiTransparentBlt(
|
||||||
{
|
{
|
||||||
PDC DCDest, DCSrc;
|
PDC DCDest, DCSrc;
|
||||||
RECTL rcDest, rcSrc;
|
RECTL rcDest, rcSrc;
|
||||||
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
BITMAPOBJ *BitmapDest, *BitmapSrc = NULL;
|
||||||
XLATEOBJ *XlateObj;
|
XLATEOBJ *XlateObj = NULL;
|
||||||
HPALETTE SourcePalette = 0, DestPalette = 0;
|
HPALETTE SourcePalette = 0, DestPalette = 0;
|
||||||
PPALGDI PalDestGDI, PalSourceGDI;
|
PPALGDI PalDestGDI, PalSourceGDI;
|
||||||
USHORT PalDestMode, PalSrcMode;
|
USHORT PalDestMode, PalSrcMode;
|
||||||
|
@ -459,38 +397,46 @@ NtGdiTransparentBlt(
|
||||||
xSrc += DCSrc->w.DCOrgX;
|
xSrc += DCSrc->w.DCOrgX;
|
||||||
ySrc += DCSrc->w.DCOrgY;
|
ySrc += DCSrc->w.DCOrgY;
|
||||||
|
|
||||||
if(DCDest->DcLevel.hpal)
|
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
||||||
DestPalette = DCDest->DcLevel.hpal;
|
if (!BitmapDest)
|
||||||
|
{
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if(DCSrc->DcLevel.hpal)
|
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
||||||
SourcePalette = DCSrc->DcLevel.hpal;
|
if (!BitmapSrc)
|
||||||
|
{
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
DestPalette = BitmapDest->hDIBPalette;
|
||||||
|
if (!DestPalette) DestPalette = PrimarySurface.DevInfo.hpalDefault;
|
||||||
|
|
||||||
|
SourcePalette = BitmapSrc->hDIBPalette;
|
||||||
|
if (!SourcePalette) SourcePalette = PrimarySurface.DevInfo.hpalDefault;
|
||||||
|
|
||||||
if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
|
if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
|
||||||
{
|
{
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
return FALSE;
|
goto done;
|
||||||
}
|
|
||||||
if((DestPalette != SourcePalette) && !(PalDestGDI = PALETTE_LockPalette(DestPalette)))
|
|
||||||
{
|
|
||||||
PALETTE_UnlockPalette(PalSourceGDI);
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
PalSrcMode = PalSourceGDI->Mode;
|
||||||
|
PALETTE_UnlockPalette(PalSourceGDI);
|
||||||
|
|
||||||
if(DestPalette != SourcePalette)
|
if(DestPalette != SourcePalette)
|
||||||
{
|
{
|
||||||
|
if (!(PalDestGDI = PALETTE_LockPalette(DestPalette)))
|
||||||
|
{
|
||||||
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
PalDestMode = PalDestGDI->Mode;
|
PalDestMode = PalDestGDI->Mode;
|
||||||
PalSrcMode = PalSourceGDI->Mode;
|
|
||||||
PALETTE_UnlockPalette(PalDestGDI);
|
PALETTE_UnlockPalette(PalDestGDI);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PalDestMode = PalSrcMode = PalSourceGDI->Mode;
|
PalDestMode = PalSrcMode;
|
||||||
}
|
}
|
||||||
PALETTE_UnlockPalette(PalSourceGDI);
|
|
||||||
|
|
||||||
/* Translate Transparent (RGB) Color to the source palette */
|
/* Translate Transparent (RGB) Color to the source palette */
|
||||||
if((XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
|
if((XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
|
||||||
|
@ -502,13 +448,6 @@ NtGdiTransparentBlt(
|
||||||
/* Create the XLATE object to convert colors between source and destination */
|
/* Create the XLATE object to convert colors between source and destination */
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
|
||||||
|
|
||||||
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
|
|
||||||
/* FIXME - BitmapDest can be NULL!!!! Don't assert here! */
|
|
||||||
ASSERT(BitmapDest);
|
|
||||||
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
|
||||||
/* FIXME - BitmapSrc can be NULL!!!! Don't assert here! */
|
|
||||||
ASSERT(BitmapSrc);
|
|
||||||
|
|
||||||
rcDest.left = xDst;
|
rcDest.left = xDst;
|
||||||
rcDest.top = yDst;
|
rcDest.top = yDst;
|
||||||
rcDest.right = rcDest.left + cxDst;
|
rcDest.right = rcDest.left + cxDst;
|
||||||
|
@ -529,9 +468,15 @@ NtGdiTransparentBlt(
|
||||||
TransparentColor, 0);
|
TransparentColor, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
|
||||||
DC_UnlockDc(DCSrc);
|
DC_UnlockDc(DCSrc);
|
||||||
|
if (BitmapDest)
|
||||||
|
{
|
||||||
|
BITMAPOBJ_UnlockBitmap(BitmapDest);
|
||||||
|
}
|
||||||
|
if (BitmapSrc)
|
||||||
|
{
|
||||||
|
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
||||||
|
}
|
||||||
if(hdcDst != hdcSrc)
|
if(hdcDst != hdcSrc)
|
||||||
{
|
{
|
||||||
DC_UnlockDc(DCDest);
|
DC_UnlockDc(DCDest);
|
||||||
|
@ -791,14 +736,13 @@ NtGdiStretchBlt(
|
||||||
{
|
{
|
||||||
PDC DCDest = NULL;
|
PDC DCDest = NULL;
|
||||||
PDC DCSrc = NULL;
|
PDC DCSrc = NULL;
|
||||||
PDC_ATTR Dc_Attr = NULL;
|
PDC_ATTR Dc_Attr;
|
||||||
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
BITMAPOBJ *BitmapDest, *BitmapSrc;
|
||||||
RECTL DestRect;
|
RECTL DestRect;
|
||||||
RECTL SourceRect;
|
RECTL SourceRect;
|
||||||
BOOL Status;
|
BOOL Status;
|
||||||
XLATEOBJ *XlateObj = NULL;
|
XLATEOBJ *XlateObj = NULL;
|
||||||
HPALETTE SourcePalette = 0, DestPalette = 0;
|
PGDIBRUSHOBJ BrushObj = NULL;
|
||||||
PGDIBRUSHOBJ BrushObj;
|
|
||||||
BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
|
BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
|
||||||
BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
|
BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
|
||||||
|
|
||||||
|
@ -852,6 +796,7 @@ NtGdiStretchBlt(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offset the destination and source by the origin of their DCs. */
|
/* Offset the destination and source by the origin of their DCs. */
|
||||||
|
// FIXME: DCOrg is in device coordinates!
|
||||||
XOriginDest += DCDest->w.DCOrgX;
|
XOriginDest += DCDest->w.DCOrgX;
|
||||||
YOriginDest += DCDest->w.DCOrgY;
|
YOriginDest += DCDest->w.DCOrgY;
|
||||||
if (UsesSource)
|
if (UsesSource)
|
||||||
|
@ -878,14 +823,7 @@ NtGdiStretchBlt(
|
||||||
BitmapSrc = BitmapDest;
|
BitmapSrc = BitmapDest;
|
||||||
else
|
else
|
||||||
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitmapSrc = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( UsesSource )
|
|
||||||
{
|
|
||||||
int sw = BitmapSrc->SurfObj.sizlBitmap.cx;
|
int sw = BitmapSrc->SurfObj.sizlBitmap.cx;
|
||||||
int sh = BitmapSrc->SurfObj.sizlBitmap.cy;
|
int sh = BitmapSrc->SurfObj.sizlBitmap.cy;
|
||||||
if ( SourceRect.left < 0 )
|
if ( SourceRect.left < 0 )
|
||||||
|
@ -936,22 +874,31 @@ NtGdiStretchBlt(
|
||||||
Status = FALSE;
|
Status = FALSE;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create the XLATEOBJ. */
|
||||||
|
XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
|
||||||
|
if (XlateObj == (XLATEOBJ*)-1)
|
||||||
|
{
|
||||||
|
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
|
Status = FALSE;
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BitmapSrc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsesPattern)
|
if (UsesPattern)
|
||||||
{
|
{
|
||||||
Dc_Attr = DCDest->pDc_Attr;
|
Dc_Attr = DCDest->pDc_Attr;
|
||||||
if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
|
if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
|
||||||
BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
|
BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
|
||||||
if (NULL == BrushObj)
|
if (NULL == BrushObj)
|
||||||
{
|
{
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
|
||||||
{
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||||
return FALSE;
|
Status = FALSE;
|
||||||
|
goto failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -959,42 +906,21 @@ NtGdiStretchBlt(
|
||||||
BrushObj = NULL;
|
BrushObj = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the XLATEOBJ. */
|
|
||||||
if (UsesSource)
|
|
||||||
{
|
|
||||||
if (DCDest->DcLevel.hpal != 0)
|
|
||||||
DestPalette = DCDest->DcLevel.hpal;
|
|
||||||
|
|
||||||
if (DCSrc->DcLevel.hpal != 0)
|
|
||||||
SourcePalette = DCSrc->DcLevel.hpal;
|
|
||||||
|
|
||||||
/* FIXME: Use the same logic for create XLATEOBJ as in NtGdiBitBlt. */
|
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
|
|
||||||
if (NULL == XlateObj)
|
|
||||||
{
|
|
||||||
if (UsesSource && hDCSrc != hDCDest)
|
|
||||||
{
|
|
||||||
DC_UnlockDc(DCSrc);
|
|
||||||
}
|
|
||||||
DC_UnlockDc(DCDest);
|
|
||||||
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Perform the bitblt operation */
|
/* Perform the bitblt operation */
|
||||||
Status = IntEngStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
|
Status = IntEngStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
|
||||||
NULL, DCDest->CombinedClip, XlateObj,
|
NULL, DCDest->CombinedClip, XlateObj,
|
||||||
&DestRect, &SourceRect, NULL, NULL, NULL,
|
&DestRect, &SourceRect, NULL, NULL, NULL,
|
||||||
COLORONCOLOR);
|
COLORONCOLOR);
|
||||||
|
|
||||||
if (UsesSource)
|
failed:
|
||||||
|
if (XlateObj)
|
||||||
|
{
|
||||||
EngDeleteXlate(XlateObj);
|
EngDeleteXlate(XlateObj);
|
||||||
if (UsesPattern)
|
}
|
||||||
|
if (BrushObj)
|
||||||
{
|
{
|
||||||
BRUSHOBJ_UnlockBrush(BrushObj);
|
BRUSHOBJ_UnlockBrush(BrushObj);
|
||||||
}
|
}
|
||||||
failed:
|
|
||||||
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
|
||||||
{
|
{
|
||||||
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
BITMAPOBJ_UnlockBitmap(BitmapSrc);
|
||||||
|
@ -1074,7 +1000,7 @@ IntPatBlt(
|
||||||
&DestRect,
|
&DestRect,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&BrushInst.BrushObject,
|
&BrushInst.BrushObject, // use pDC->eboFill
|
||||||
&BrushOrigin,
|
&BrushOrigin,
|
||||||
ROP3_TO_ROP4(ROP));
|
ROP3_TO_ROP4(ROP));
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,8 +265,9 @@ NtGdiGetPixel(HDC hDC, INT XPos, INT YPos)
|
||||||
SurfaceObject = &BitmapObject->SurfObj;
|
SurfaceObject = &BitmapObject->SurfObj;
|
||||||
if ( BitmapObject )
|
if ( BitmapObject )
|
||||||
{
|
{
|
||||||
if ( dc->DcLevel.hpal != 0 )
|
Pal = BitmapObject->hDIBPalette;
|
||||||
Pal = dc->DcLevel.hpal;
|
if (!Pal) Pal = PrimarySurface.DevInfo.hpalDefault;
|
||||||
|
|
||||||
/* FIXME: Verify if it shouldn't be PAL_BGR! */
|
/* FIXME: Verify if it shouldn't be PAL_BGR! */
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate ( PAL_RGB, 0, NULL, Pal );
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate ( PAL_RGB, 0, NULL, Pal );
|
||||||
if ( XlateObj )
|
if ( XlateObj )
|
||||||
|
|
|
@ -119,6 +119,16 @@ XLATEOBJ* FASTCALL
|
||||||
IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed)
|
IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed)
|
||||||
{
|
{
|
||||||
XLATEOBJ *Result = NULL;
|
XLATEOBJ *Result = NULL;
|
||||||
|
BITMAPOBJ * pSurface;
|
||||||
|
HPALETTE hPalette = NULL;
|
||||||
|
|
||||||
|
pSurface = BITMAPOBJ_LockBitmap(Dc->w.hBitmap);
|
||||||
|
if (pSurface)
|
||||||
|
{
|
||||||
|
hPalette = pSurface->hDIBPalette;
|
||||||
|
BITMAPOBJ_UnlockBitmap(pSurface);
|
||||||
|
}
|
||||||
|
if (!hPalette) hPalette = PrimarySurface.DevInfo.hpalDefault;
|
||||||
|
|
||||||
if (BrushObj->flAttrs & GDIBRUSH_IS_NULL)
|
if (BrushObj->flAttrs & GDIBRUSH_IS_NULL)
|
||||||
{
|
{
|
||||||
|
@ -127,7 +137,7 @@ IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed)
|
||||||
}
|
}
|
||||||
else if (BrushObj->flAttrs & GDIBRUSH_IS_SOLID)
|
else if (BrushObj->flAttrs & GDIBRUSH_IS_SOLID)
|
||||||
{
|
{
|
||||||
Result = IntEngCreateXlate(0, PAL_RGB, Dc->DcLevel.hpal, NULL);
|
Result = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL);
|
||||||
*Failed = FALSE;
|
*Failed = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -143,11 +153,11 @@ IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed)
|
||||||
if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr;
|
if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr;
|
||||||
|
|
||||||
if (Dc->w.bitsPerPixel != 1)
|
if (Dc->w.bitsPerPixel != 1)
|
||||||
Result = IntEngCreateSrcMonoXlate(Dc->DcLevel.hpal, Dc_Attr->crForegroundClr, Dc_Attr->crBackgroundClr);
|
Result = IntEngCreateSrcMonoXlate(hPalette, Dc_Attr->crForegroundClr, Dc_Attr->crBackgroundClr);
|
||||||
}
|
}
|
||||||
else if (BrushObj->flAttrs & GDIBRUSH_IS_DIB)
|
else if (BrushObj->flAttrs & GDIBRUSH_IS_DIB)
|
||||||
{
|
{
|
||||||
Result = IntEngCreateXlate(0, 0, Dc->DcLevel.hpal, Pattern->hDIBPalette);
|
Result = IntEngCreateXlate(0, 0, hPalette, Pattern->hDIBPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
BITMAPOBJ_UnlockBitmap(Pattern);
|
BITMAPOBJ_UnlockBitmap(Pattern);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
// --------------------------------------------------------- File Statics
|
// --------------------------------------------------------- File Statics
|
||||||
|
|
||||||
static GDIDEVICE PrimarySurface;
|
GDIDEVICE PrimarySurface;
|
||||||
static PGDIDEVICE pPrimarySurface = NULL;
|
static PGDIDEVICE pPrimarySurface = NULL;
|
||||||
static KEVENT VideoDriverNeedsPreparation;
|
static KEVENT VideoDriverNeedsPreparation;
|
||||||
static KEVENT VideoDriverPrepared;
|
static KEVENT VideoDriverPrepared;
|
||||||
|
@ -829,7 +829,8 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
|
||||||
|
|
||||||
if (!CreateAsIC)
|
if (!CreateAsIC)
|
||||||
{
|
{
|
||||||
NewDC->DcLevel.hpal = PrimarySurface.DevInfo.hpalDefault;
|
NewDC->DcLevel.hpal = NtGdiGetStockObject(DEFAULT_PALETTE);
|
||||||
|
|
||||||
nDc_Attr->jROP2 = R2_COPYPEN;
|
nDc_Attr->jROP2 = R2_COPYPEN;
|
||||||
|
|
||||||
NewDC->erclWindow.top = NewDC->erclWindow.left = 0;
|
NewDC->erclWindow.top = NewDC->erclWindow.left = 0;
|
||||||
|
@ -1957,12 +1958,10 @@ NtGdiSelectBitmap(
|
||||||
if(pBmp->dib)
|
if(pBmp->dib)
|
||||||
{
|
{
|
||||||
pDC->w.bitsPerPixel = pBmp->dib->dsBmih.biBitCount;
|
pDC->w.bitsPerPixel = pBmp->dib->dsBmih.biBitCount;
|
||||||
pDC->DcLevel.hpal = pBmp->hDIBPalette;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pDC->w.bitsPerPixel = BitsPerFormat(pBmp->SurfObj.iBitmapFormat);
|
pDC->w.bitsPerPixel = BitsPerFormat(pBmp->SurfObj.iBitmapFormat);
|
||||||
pDC->DcLevel.hpal = ((GDIDEVICE *)pDC->pPDev)->DevInfo.hpalDefault;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Regenerate the XLATEOBJs. */
|
/* Regenerate the XLATEOBJs. */
|
||||||
|
|
|
@ -1492,6 +1492,7 @@ IntGdiGradientFill(
|
||||||
POINTL DitherOrg;
|
POINTL DitherOrg;
|
||||||
ULONG Mode, i;
|
ULONG Mode, i;
|
||||||
BOOL Ret;
|
BOOL Ret;
|
||||||
|
HPALETTE hDestPalette;
|
||||||
|
|
||||||
ASSERT(dc);
|
ASSERT(dc);
|
||||||
ASSERT(pVertex);
|
ASSERT(pVertex);
|
||||||
|
@ -1550,13 +1551,19 @@ IntGdiGradientFill(
|
||||||
/* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
|
/* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
|
||||||
ASSERT(BitmapObj);
|
ASSERT(BitmapObj);
|
||||||
|
|
||||||
PalDestGDI = PALETTE_LockPalette(dc->DcLevel.hpal);
|
hDestPalette = BitmapObj->hDIBPalette;
|
||||||
/* FIXME - PalDestGDI can be NULL!!! Don't assert but handle this case gracefully! */
|
if (!hDestPalette) hDestPalette = PrimarySurface.DevInfo.hpalDefault;
|
||||||
ASSERT(PalDestGDI);
|
|
||||||
Mode = PalDestGDI->Mode;
|
|
||||||
PALETTE_UnlockPalette(PalDestGDI);
|
|
||||||
|
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->DcLevel.hpal, NULL);
|
PalDestGDI = PALETTE_LockPalette(hDestPalette);
|
||||||
|
if (PalDestGDI)
|
||||||
|
{
|
||||||
|
Mode = PalDestGDI->Mode;
|
||||||
|
PALETTE_UnlockPalette(PalDestGDI);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Mode = PAL_RGB;
|
||||||
|
|
||||||
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL);
|
||||||
ASSERT(XlateObj);
|
ASSERT(XlateObj);
|
||||||
|
|
||||||
Ret = IntEngGradientFill(&BitmapObj->SurfObj,
|
Ret = IntEngGradientFill(&BitmapObj->SurfObj,
|
||||||
|
|
|
@ -1547,6 +1547,7 @@ NtGdiExtTextOutW(
|
||||||
POINT Start;
|
POINT Start;
|
||||||
BOOL DoBreak = FALSE;
|
BOOL DoBreak = FALSE;
|
||||||
LPCWSTR String, SafeString = NULL;
|
LPCWSTR String, SafeString = NULL;
|
||||||
|
HPALETTE hDestPalette;
|
||||||
|
|
||||||
// TODO: Write test-cases to exactly match real Windows in different
|
// TODO: Write test-cases to exactly match real Windows in different
|
||||||
// bad parameters (e.g. does Windows check the DC or the RECT first?).
|
// bad parameters (e.g. does Windows check the DC or the RECT first?).
|
||||||
|
@ -1629,7 +1630,9 @@ NtGdiExtTextOutW(
|
||||||
YStart = Start.y + dc->w.DCOrgY;
|
YStart = Start.y + dc->w.DCOrgY;
|
||||||
|
|
||||||
/* Create the brushes */
|
/* Create the brushes */
|
||||||
PalDestGDI = PALETTE_LockPalette(dc->DcLevel.hpal);
|
hDestPalette = BitmapObj->hDIBPalette;
|
||||||
|
if (!hDestPalette) hDestPalette = PrimarySurface.DevInfo.hpalDefault;
|
||||||
|
PalDestGDI = PALETTE_LockPalette(hDestPalette);
|
||||||
if ( !PalDestGDI )
|
if ( !PalDestGDI )
|
||||||
Mode = PAL_RGB;
|
Mode = PAL_RGB;
|
||||||
else
|
else
|
||||||
|
@ -1637,7 +1640,7 @@ NtGdiExtTextOutW(
|
||||||
Mode = PalDestGDI->Mode;
|
Mode = PalDestGDI->Mode;
|
||||||
PALETTE_UnlockPalette(PalDestGDI);
|
PALETTE_UnlockPalette(PalDestGDI);
|
||||||
}
|
}
|
||||||
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->DcLevel.hpal, NULL);
|
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL);
|
||||||
if ( !XlateObj )
|
if ( !XlateObj )
|
||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -1667,7 +1670,7 @@ NtGdiExtTextOutW(
|
||||||
}
|
}
|
||||||
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
|
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
|
||||||
}
|
}
|
||||||
XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, dc->DcLevel.hpal);
|
XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, hDestPalette);
|
||||||
if ( !XlateObj2 )
|
if ( !XlateObj2 )
|
||||||
{
|
{
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue