Author: greatlrd
Date: Thu May 4 09:23:54 2006
New Revision: 21794
URL:
http://svn.reactos.ru/svn/reactos?rev=21794&view=rev
Log:
Bug : 1452 : patch from w3seek, some xlate obj fixes for indexed palettes, should fix a
hack introduced in r21292
Modified:
trunk/reactos/subsystems/win32/win32k/eng/objects.h
trunk/reactos/subsystems/win32/win32k/eng/xlate.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/objects.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/objects.h (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/objects.h Thu May 4 09:23:54 2006
@@ -158,9 +158,6 @@
INT GreenShift;
INT BlueShift;
// };
-// struct { /* For Table Translations */
- ULONG *translationTable;
-// };
// struct { /* For Color -> Mono Translations */
ULONG BackgroundColor;
// };
Modified: trunk/reactos/subsystems/win32/win32k/eng/xlate.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/xlate.c (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/xlate.c Thu May 4 09:23:54 2006
@@ -181,6 +181,7 @@
XlateObj->iSrcType = SourcePalType;
XlateObj->iDstType = DestPalType;
XlateObj->flXlate = 0;
+ XlateObj->cEntries = 0;
/* Store handles of palettes in internal Xlate GDI object (or NULLs) */
XlateGDI->SourcePal = PaletteSource;
@@ -237,34 +238,34 @@
/* Indexed -> Indexed */
if (SourcePalType == PAL_INDEXED && DestPalType == PAL_INDEXED)
{
- XlateGDI->translationTable =
- EngAllocMem(0, sizeof(ULONG) * SourcePalGDI->NumColors, 0);
+ XlateObj->cEntries = SourcePalGDI->NumColors;
+ XlateObj->pulXlate =
+ EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
XlateObj->flXlate |= XO_TRIVIAL;
- for (i = 0; i < SourcePalGDI->NumColors; i++)
+ for (i = 0; i < XlateObj->cEntries; i++)
{
- XlateGDI->translationTable[i] = ClosestColorMatch(
+ XlateObj->pulXlate[i] = ClosestColorMatch(
XlateGDI, SourcePalGDI->IndexedColors + i,
- DestPalGDI->IndexedColors, DestPalGDI->NumColors);
- if (XlateGDI->translationTable[i] != i)
+ DestPalGDI->IndexedColors, XlateObj->cEntries);
+ if (XlateObj->pulXlate[i] != i)
XlateObj->flXlate &= ~XO_TRIVIAL;
}
XlateObj->flXlate |= XO_TABLE;
- XlateObj->pulXlate = XlateGDI->translationTable;
goto end;
}
/* Indexed -> Bitfields/RGB/BGR */
if (SourcePalType == PAL_INDEXED)
{
- XlateGDI->translationTable =
- EngAllocMem(0, sizeof(ULONG) * SourcePalGDI->NumColors, 0);
- for (i = 0; i < SourcePalGDI->NumColors; i++)
- XlateGDI->translationTable[i] =
+ XlateObj->cEntries = SourcePalGDI->NumColors;
+ XlateObj->pulXlate =
+ EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
+ for (i = 0; i < XlateObj->cEntries; i++)
+ XlateObj->pulXlate[i] =
ShiftAndMask(XlateGDI, *((ULONG *)&SourcePalGDI->IndexedColors[i]));
XlateObj->flXlate |= XO_TABLE;
- XlateObj->pulXlate = XlateGDI->translationTable;
goto end;
}
@@ -313,6 +314,7 @@
XlateGDI->SourcePal = PaletteSource;
XlateObj->flXlate = XO_TO_MONO;
+ XlateObj->cEntries = 1;
XlateObj->pulXlate = &XlateGDI->BackgroundColor;
switch (SourcePalType)
{
@@ -368,16 +370,15 @@
}
XlateObj = GDIToObj(XlateGDI, XLATE);
- XlateGDI->translationTable = EngAllocMem(0, sizeof(ULONG) * 2, 0);
- if (XlateGDI->translationTable == NULL)
+ XlateObj->cEntries = 2;
+ XlateObj->pulXlate = EngAllocMem(0, sizeof(ULONG) * XlateObj->cEntries, 0);
+ if (XlateObj->pulXlate == NULL)
{
PALETTE_UnlockPalette(DestPalGDI);
EngFreeMem(XlateGDI);
return NULL;
}
- XlateObj->pulXlate = XlateGDI->translationTable;
-
XlateObj->iSrcType = PAL_INDEXED;
XlateObj->iDstType = DestPalGDI->Mode;
@@ -394,19 +395,19 @@
XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) -
CalculateShift(XlateGDI->GreenMask);
XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) -
CalculateShift(XlateGDI->BlueMask);
- XlateGDI->translationTable[0] = ShiftAndMask(XlateGDI, BackgroundColor);
- XlateGDI->translationTable[1] = ShiftAndMask(XlateGDI, ForegroundColor);
+ XlateObj->pulXlate[0] = ShiftAndMask(XlateGDI, BackgroundColor);
+ XlateObj->pulXlate[1] = ShiftAndMask(XlateGDI, ForegroundColor);
if (XlateObj->iDstType == PAL_INDEXED)
{
- XlateGDI->translationTable[0] =
+ XlateObj->pulXlate[0] =
ClosestColorMatch(XlateGDI,
- (LPPALETTEENTRY)&XlateGDI->translationTable[0],
+ (LPPALETTEENTRY)&XlateObj->pulXlate[0],
DestPalGDI->IndexedColors,
DestPalGDI->NumColors);
- XlateGDI->translationTable[1] =
+ XlateObj->pulXlate[1] =
ClosestColorMatch(XlateGDI,
- (LPPALETTEENTRY)&XlateGDI->translationTable[1],
+ (LPPALETTEENTRY)&XlateObj->pulXlate[1],
DestPalGDI->IndexedColors,
DestPalGDI->NumColors);
}
@@ -453,9 +454,9 @@
XlateGDI = ObjToGDI(XlateObj, XLATE);
if ((XlateObj->flXlate & XO_TABLE) &&
- XlateGDI->translationTable != NULL)
- {
- EngFreeMem(XlateGDI->translationTable);
+ XlateObj->pulXlate != NULL)
+ {
+ EngFreeMem(XlateObj->pulXlate);
}
EngFreeMem(XlateGDI);
@@ -467,11 +468,9 @@
PULONG STDCALL
XLATEOBJ_piVector(XLATEOBJ *XlateObj)
{
- XLATEGDI *XlateGDI = ObjToGDI(XlateObj, XLATE);
-
if (XlateObj->iSrcType == PAL_INDEXED)
{
- return XlateGDI->translationTable;
+ return XlateObj->pulXlate;
}
return NULL;
@@ -494,8 +493,13 @@
if (XlateObj->flXlate & XO_TRIVIAL)
return Color;
- if ((XlateObj->flXlate & XO_TABLE))
- return XlateObj->pulXlate[Color & 0xff];
+ if (XlateObj->flXlate & XO_TABLE)
+ {
+ if (Color >= XlateObj->cEntries)
+ Color %= XlateObj->cEntries;
+
+ return XlateObj->pulXlate[Color];
+ }
if (XlateObj->flXlate & XO_TO_MONO)