Author: jgardou
Date: Fri Jul 30 02:15:46 2010
New Revision: 48369
URL:
http://svn.reactos.org/svn/reactos?rev=48369&view=rev
Log:
[WIN32K]
- Cast Colors to RGBQUAD in EngCreateBitmap, since that's what they are.
- Copy selected palette of the DC when creating a DIBSection with DIB_PAL_COLORS.
- Do not try to get Colors in NtGdiGetDIBitsInternal when bpp == 0, this doesn't
make any sense.
- Get rid of SURFACE::dsBitfields and SURFACE::biClrUsed.
- Use RGB as default palette mod when creating the DIB Palette.
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h
branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/include/surface.h [iso-8859-1] Fri
Jul 30 02:15:46 2010
@@ -39,8 +39,6 @@
//UINT unk_078;
/* reactos specific */
- DWORD dsBitfields[3]; // hack, should probably use palette instead
- DWORD biClrUsed;
DWORD biClrImportant;
} SURFACE, *PSURFACE;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Fri
Jul 30 02:15:46 2010
@@ -1032,11 +1032,11 @@
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
pds->dsBmih.biXPelsPerMeter = 0;
pds->dsBmih.biYPelsPerMeter = 0;
- pds->dsBmih.biClrUsed = psurf->biClrUsed;
+ pds->dsBmih.biClrUsed = psurf->ppal->NumColors;
pds->dsBmih.biClrImportant = psurf->biClrImportant;
- pds->dsBitfields[0] = psurf->dsBitfields[0];
- pds->dsBitfields[1] = psurf->dsBitfields[1];
- pds->dsBitfields[2] = psurf->dsBitfields[2];
+ pds->dsBitfields[0] = psurf->ppal->RedMask;
+ pds->dsBitfields[1] = psurf->ppal->GreenMask;
+ pds->dsBitfields[2] = psurf->ppal->BlueMask;
pds->dshSection = psurf->hDIBSection;
pds->dsOffset = psurf->dwOffset;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Fri
Jul 30 02:15:46 2010
@@ -705,7 +705,6 @@
goto done;
}
-get_info:
/* Fill in the structure */
switch(bpp)
{
@@ -755,8 +754,7 @@
Info->bmiHeader.biClrImportant = 0;
ScanLines = psurf->SurfObj.sizlBitmap.cy;
/* Get Complete info now */
- bpp = Info->bmiHeader.biBitCount ;
- goto get_info;
+ goto done;
case 1:
case 4:
@@ -916,7 +914,12 @@
case 16:
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
{
- if (psurf->hSecure) RtlCopyMemory( Info->bmiColors,
psurf->dsBitfields, 3 * sizeof(DWORD) );
+ if (psurf->hSecure)
+ {
+ ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
+ ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
+ ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
+ }
else
{
((PDWORD)Info->bmiColors)[0] = 0xf800;
@@ -930,7 +933,12 @@
case 32:
if (Info->bmiHeader.biCompression == BI_BITFIELDS)
{
- if (psurf->hSecure) RtlCopyMemory( Info->bmiColors,
psurf->dsBitfields, 3 * sizeof(DWORD) );
+ if (psurf->hSecure)
+ {
+ ((PDWORD)Info->bmiColors)[0] = psurf->ppal->RedMask;
+ ((PDWORD)Info->bmiColors)[1] = psurf->ppal->GreenMask;
+ ((PDWORD)Info->bmiColors)[2] = psurf->ppal->BlueMask;
+ }
else
{
((PDWORD)Info->bmiColors)[0] = 0xff0000;
@@ -1427,7 +1435,7 @@
SURFACE *bmp = NULL;
void *mapBits = NULL;
HPALETTE hpal ;
- ULONG palMode = PAL_INDEXED;
+ INT palMode = PAL_INDEXED;
// Fill BITMAP32 structure with DIB data
CONST BITMAPINFOHEADER *bi = &bmi->bmiHeader;
@@ -1435,10 +1443,7 @@
ULONG totalSize;
BITMAP bm;
SIZEL Size;
- CONST RGBQUAD *lpRGB = NULL;
HANDLE hSecure;
- DWORD dsBitfields[3] = {0};
- ULONG ColorCount;
DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n",
bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount,
@@ -1520,54 +1525,27 @@
if (usage == DIB_PAL_COLORS)
{
- lpRGB = DIB_MapPaletteColors(dc, bmi);
- ColorCount = bi->biClrUsed;
- if (ColorCount == 0)
- {
- ColorCount = max(1 << bi->biBitCount, 256);
- }
- }
- else if(bi->biBitCount <= 8)
- {
- lpRGB = bmi->bmiColors;
- ColorCount = 1 << bi->biBitCount;
- }
- else
+ PPALETTE pdcPal ;
+ pdcPal = PALETTE_LockPalette(dc->dclevel.hpal);
+ if(!pdcPal)
+ {
+ DPRINT1("Unable to lock DC palette?!\n");
+ goto cleanup;
+ }
+ if(pdcPal->Mode != PAL_INDEXED)
+ {
+ DPRINT1("Not indexed palette selected in the DC?!\n");
+ PALETTE_UnlockPalette(pdcPal);
+ }
+ hpal = PALETTE_AllocPalette(PAL_INDEXED,
+ pdcPal->NumColors,
+ (ULONG*)pdcPal->IndexedColors, 0, 0, 0);
+ PALETTE_UnlockPalette(pdcPal);
+ }
+ else
{
- lpRGB = NULL;
- ColorCount = 0;
+ hpal = BuildDIBPalette(bmi, &palMode);
}
-
- /* Set dsBitfields values */
- if (usage == DIB_PAL_COLORS || bi->biBitCount <= 8)
- {
- dsBitfields[0] = dsBitfields[1] = dsBitfields[2] = 0;
- palMode = PAL_INDEXED;
- }
- else if (bi->biCompression == BI_RGB)
- {
- dsBitfields[0] = dsBitfields[1] = dsBitfields[2] = 0;
- switch (bi->biBitCount)
- {
- case 15:
- palMode = PAL_RGB16_555;
- break;
-
- case 16:
- palMode = PAL_RGB16_565;
- break;
-
- case 24:
- case 32:
- palMode = PAL_RGB;
- break;
- }
- }
- else
- {
- RtlCopyMemory(dsBitfields, bmi->bmiColors, sizeof(dsBitfields));
- palMode = PAL_BITFIELDS;
- }
// Create Device Dependent Bitmap and add DIB pointer
Size.cx = bm.bmWidth;
@@ -1600,18 +1578,9 @@
bmp->hSecure = hSecure;
bmp->dwOffset = offset;
bmp->flags = API_BITMAP;
- bmp->dsBitfields[0] = dsBitfields[0];
- bmp->dsBitfields[1] = dsBitfields[1];
- bmp->dsBitfields[2] = dsBitfields[2];
- bmp->biClrUsed = ColorCount;
bmp->biClrImportant = bi->biClrImportant;
- hpal = PALETTE_AllocPalette(palMode, ColorCount, (ULONG*)lpRGB,
- dsBitfields[0],
- dsBitfields[1],
- dsBitfields[2]);
-
- bmp->ppal = PALETTE_ShareLockPalette(hpal);
+ bmp->ppal = PALETTE_ShareLockPalette(hpal);
/* Lazy delete hpal, it will be freed at surface release */
GreDeleteObject(hpal);
@@ -1641,11 +1610,6 @@
SURFACE_FreeSurfaceByHandle(res);
res = 0;
}
- }
-
- if (lpRGB != bmi->bmiColors && lpRGB)
- {
- ExFreePoolWithTag((PVOID)lpRGB, TAG_COLORMAP);
}
if (bmp)
@@ -1853,7 +1817,7 @@
}
else
{
- *paletteType = PAL_BGR;
+ *paletteType = PAL_RGB;
RedMask = 0xff0000;
GreenMask = 0x00ff00;
BlueMask = 0x0000ff;
@@ -1874,7 +1838,7 @@
}
else
{
- hPal = PALETTE_AllocPalette(*paletteType, ColorCount,
+ hPal = PALETTE_AllocPalette(*paletteType, 0,
NULL,
RedMask, GreenMask, BlueMask);
}
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c [iso-8859-1] Fri
Jul 30 02:15:46 2010
@@ -392,7 +392,15 @@
{
HPALETTE Palette;
- Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
+ /* Low order three bytes are RGB -> RGBQUAD */
+ if(Mode == PAL_INDEXED)
+ {
+ Palette = PALETTE_AllocPaletteIndexedRGB(NumColors, (RGBQUAD*)Colors);
+ }
+ else
+ {
+ Palette = PALETTE_AllocPalette(Mode, NumColors, Colors, Red, Green, Blue);
+ }
if (Palette != NULL)
{
GDIOBJ_SetOwnership(Palette, NULL);