From 474ed3e0764e938b6e6b0231fce4cf5184f9913e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 7 Jan 2009 20:02:28 +0000 Subject: [PATCH] - Fix creation of XLATE in IntEngCreateSrcMonoXlate. It was doing it wrong (colors swapped) and it only worked, because the caller of the function also passed the wrong arguments. - Mono DIBs need a special handling when creating the XLATEOBJ. Handle this in IntCreateXlateForBlt. Fixes broken colors on google/Firefox page. svn path=/trunk/; revision=38633 --- reactos/subsystems/win32/win32k/eng/xlate.c | 33 +++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/reactos/subsystems/win32/win32k/eng/xlate.c b/reactos/subsystems/win32/win32k/eng/xlate.c index 8e4b1677cd9..9f826903861 100644 --- a/reactos/subsystems/win32/win32k/eng/xlate.c +++ b/reactos/subsystems/win32/win32k/eng/xlate.c @@ -403,8 +403,9 @@ IntEngCreateSrcMonoXlate(HPALETTE PaletteDest, XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) - CalculateShift(XlateGDI->GreenMask); XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) - CalculateShift(XlateGDI->BlueMask); - XlateObj->pulXlate[0] = ShiftAndMask(XlateGDI, BackgroundColor); - XlateObj->pulXlate[1] = ShiftAndMask(XlateGDI, ForegroundColor); + /* Yes, that's how Windows works, ... */ + XlateObj->pulXlate[1] = ShiftAndMask(XlateGDI, BackgroundColor); + XlateObj->pulXlate[0] = ShiftAndMask(XlateGDI, ForegroundColor); if (XlateObj->iDstType == PAL_INDEXED) { @@ -484,9 +485,24 @@ IntCreateXlateForBlt(PDC pDCDest, PDC pDCSrc, BITMAPOBJ* pDestSurf, BITMAPOBJ* p { if (pSrcSurf->SurfObj.iBitmapFormat == BMF_1BPP) { - pDc_Attr = pDCDest->pDc_Attr; - if (!pDc_Attr) pDc_Attr = &pDCDest->Dc_Attr; - XlateObj = IntEngCreateSrcMonoXlate(DestPalette, pDc_Attr->crBackgroundClr, pDc_Attr->crForegroundClr); + /* DIB sections need special handling */ + if (pSrcSurf->dib) + { + PPALGDI ppal = PALETTE_LockPalette(pSrcSurf->hDIBPalette); + if (ppal) + { + XlateObj = IntEngCreateSrcMonoXlate(DestPalette, ((ULONG*)ppal->IndexedColors)[0], ((ULONG*)ppal->IndexedColors)[1]); + PALETTE_UnlockPalette(ppal); + } + else + XlateObj = NULL; + } + else + { + pDc_Attr = pDCDest->pDc_Attr; + if (!pDc_Attr) pDc_Attr = &pDCDest->Dc_Attr; + XlateObj = IntEngCreateSrcMonoXlate(DestPalette, pDc_Attr->crForegroundClr, pDc_Attr->crBackgroundClr); + } } else { @@ -563,7 +579,12 @@ XLATEOBJ_iXlate(XLATEOBJ *XlateObj, ULONG Color) if (XlateObj->flXlate & XO_TABLE) { if (Color >= XlateObj->cEntries) - Color %= XlateObj->cEntries; + { + DPRINT1("+++ Color = 0x%x, XlateObj->flXlate = 0x%x, XlateObj->cEntries = %ld\n", + Color, XlateObj->flXlate, XlateObj->cEntries); + XlateGDI = ObjToGDI(XlateObj, XLATE); + Color %= XlateObj->cEntries; + } return XlateObj->pulXlate[Color]; }