Author: tkreuzer
Date: Wed Jun 9 04:57:52 2010
New Revision: 47703
URL:
http://svn.reactos.org/svn/reactos?rev=47703&view=rev
Log:
[WIN32K]
- Initialize the palettes before creating any bitmaps.
- Replace SURFACE_vSetDefaultPalette with an array of default palettes.
- Check iFormat in SURFACE_AllocSurface
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
branches/reactos-yarotows/subsystems/win32/win32k/include/palette.h
branches/reactos-yarotows/subsystems/win32/win32k/main/dllmain.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/stockobj.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/surface.c [iso-8859-1] Wed Jun
9 04:57:52 2010
@@ -140,45 +140,6 @@
return TRUE;
}
-static
-void
-SURFACE_vSetDefaultPalette(
- PSURFACE psurfBmp)
-{
- ULONG cBitsPixel = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat);
-
- /* Find a suitable palette for this bitmap
- * Increment internal objects share count
- * so we can call PALETTE_ShareUnlockPalette
- * or GDIOBJ_IncrementShareCount safely */
- switch(cBitsPixel)
- {
- case 1:
- psurfBmp->ppal = &gpalMono;
- GDIOBJ_IncrementShareCount(&gpalMono.BaseObject);
- break;
- case 4:
- case 8:
- psurfBmp->ppal = PALETTE_ShareLockPalette(StockObjects[DEFAULT_PALETTE]);
- break;
- case 15:
- psurfBmp->ppal = &gpalRGB555;
- GDIOBJ_IncrementShareCount(&gpalRGB555.BaseObject);
- break;
- case 16:
- psurfBmp->ppal = &gpalRGB565;
- GDIOBJ_IncrementShareCount(&gpalRGB565.BaseObject);
- break;
- case 24:
- case 32:
- psurfBmp->ppal = &gpalBGR;
- GDIOBJ_IncrementShareCount(&gpalBGR.BaseObject);
- break;
- default:
- DPRINT1("Could not determine palette for bit depth %u.\n",
cBitsPixel);
- break;
- }
-}
PSURFACE
NTAPI
@@ -190,7 +151,14 @@
{
PSURFACE psurf;
SURFOBJ *pso;
-
+
+ /* Verify format */
+ if (iFormat < BMF_1BPP || iFormat > BMF_PNG)
+ {
+ DPRINT1("Invalid bitmap format: %ld\n", iFormat);
+ return NULL;
+ }
+
/* Allocate a SURFACE object */
psurf = (PSURFACE)GDIOBJ_AllocObjWithHandle(GDI_OBJECT_TYPE_BITMAP);
@@ -205,7 +173,9 @@
pso->iType = iType;
pso->iUniq = InterlockedIncrement((PLONG)&giUniqueSurface);
- SURFACE_vSetDefaultPalette(psurf);
+ /* Assign a default palette amd increment its reference count */
+ psurf->ppal = appalSurfaceDefault[iFormat];
+ GDIOBJ_IncrementShareCount(&psurf->ppal->BaseObject);
}
return psurf;
Modified: branches/reactos-yarotows/subsystems/win32/win32k/include/palette.h
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/include/palette.h [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/include/palette.h [iso-8859-1] Wed
Jun 9 04:57:52 2010
@@ -54,8 +54,8 @@
HDEV hPDev;
} PALETTE, *PPALETTE;
-extern PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565;
-
+extern PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565, *gppalDefault;
+extern PPALETTE appalSurfaceDefault[];
HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
ULONG NumColors,
Modified: branches/reactos-yarotows/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/main/dllmain.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Wed Jun
9 04:57:52 2010
@@ -439,6 +439,9 @@
return STATUS_UNSUCCESSFUL;
}
+ /* Initialize default palettes */
+ PALETTE_Init();
+
/* Create stock objects, ie. precreated objects commonly
used by win32 applications */
CreateStockObjects();
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] Wed
Jun 9 04:57:52 2010
@@ -14,7 +14,8 @@
static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* the program need save the pallete and
restore it */
-PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565;
+PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565, *gppalDefault;
+PPALETTE appalSurfaceDefault[11];
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS] =
{
@@ -132,6 +133,19 @@
gpalMono.Mode = PAL_MONOCHROME;
gpalMono.BaseObject.ulShareCount = 0;
gpalMono.BaseObject.BaseFlags = 0 ;
+
+ /* Initialize default surface palettes */
+ gppalDefault = PALETTE_ShareLockPalette(hpalette);
+ appalSurfaceDefault[BMF_1BPP] = &gpalMono;
+ appalSurfaceDefault[BMF_4BPP] = gppalDefault;
+ appalSurfaceDefault[BMF_8BPP] = gppalDefault;
+ appalSurfaceDefault[BMF_16BPP] = &gpalRGB565;
+ appalSurfaceDefault[BMF_24BPP] = &gpalRGB;
+ appalSurfaceDefault[BMF_32BPP] = &gpalRGB;
+ appalSurfaceDefault[BMF_4RLE] = gppalDefault;
+ appalSurfaceDefault[BMF_8RLE] = gppalDefault;
+ appalSurfaceDefault[BMF_JPEG] = &gpalRGB;
+ appalSurfaceDefault[BMF_PNG] = &gpalRGB;
return hpalette;
}
Modified: branches/reactos-yarotows/subsystems/win32/win32k/objects/stockobj.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/objects/stockobj.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/objects/stockobj.c [iso-8859-1] Wed
Jun 9 04:57:52 2010
@@ -190,7 +190,7 @@
(void) TextIntCreateFontIndirect(&SystemFixedFont,
(HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
(void) TextIntCreateFontIndirect(&DefaultGuiFont,
(HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
- StockObjects[DEFAULT_PALETTE] = (HGDIOBJ)PALETTE_Init();
+ StockObjects[DEFAULT_PALETTE] = (HGDIOBJ)gppalDefault->BaseObject.hHmgr;
for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
{