Author: jgardou
Date: Fri May 14 20:51:48 2010
New Revision: 47203
URL:
http://svn.reactos.org/svn/reactos?rev=47203&view=rev
Log:
[WIN32K]
- IntGdiCreateBitmap : assign a default palette to the bitmap created
- Use IntCreateBitmap where we already have a bitmap to assign
- delete all mono bitmaps related hacks in xlateobj implementation, as now all bitmaps
should have a palette
Fixes last immediately visible glitches when switching modes
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c
branches/reactos-yarotows/subsystems/win32/win32k/include/palette.h
branches/reactos-yarotows/subsystems/win32/win32k/objects/bitmaps.c
branches/reactos-yarotows/subsystems/win32/win32k/objects/palette.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] (original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/xlate.c [iso-8859-1] Fri May 14
20:51:48 2010
@@ -618,65 +618,31 @@
return;
}
- if (psurfSrc->ppal)
- {
- ppalSrc = psurfSrc->ppal;
- GDIOBJ_IncrementShareCount(&ppalSrc->BaseObject);
- }
- else
- ppalSrc = PALETTE_ShareLockPalette(pdcSrc->ppdev->devinfo.hpalDefault);
+ ppalSrc = psurfSrc->ppal;
if(!ppalSrc)
+ {
+ DPRINT1("No palette for src surface %p.\n", psurfSrc);
return;
-
- if (psurfDst->ppal)
- {
- ppalDst = psurfDst->ppal;
- GDIOBJ_IncrementShareCount(&ppalDst->BaseObject);
- }
- else
- ppalDst = PALETTE_ShareLockPalette(pdcDst->ppdev->devinfo.hpalDefault);
+ }
+
+ ppalDst = psurfDst->ppal;
if (!ppalDst)
{
- PALETTE_ShareUnlockPalette(ppalSrc);
+ DPRINT1("No palette for dst surface %p.\n", psurfDst);
return;
}
ppalDstDc = pdcDst->dclevel.ppal;
ASSERT(ppalDstDc);
- /* KB41464 details how to convert between mono and color */
- if (psurfDst->SurfObj.iBitmapFormat == BMF_1BPP)
- {
- if (psurfSrc->SurfObj.iBitmapFormat != BMF_1BPP)
- {
- // HACK!! FIXME: 1bpp DDBs should have gpalMono already!
- EXLATEOBJ_vInitialize(pexlo,
- ppalSrc,
- &gpalMono,
- pdcSrc->pdcattr->crBackgroundClr,
- pdcDst->pdcattr->crBackgroundClr,
- pdcDst->pdcattr->crForegroundClr);
- }
- }
- else if (psurfSrc->SurfObj.iBitmapFormat == BMF_1BPP &&
!psurfSrc->hSecure)
- {
- // HACK!! FIXME: 1bpp DDBs should have gpalMono already!
- EXLATEOBJ_vInitialize(pexlo,
- &gpalMono,
- ppalDst,
- 0,
- pdcDst->pdcattr->crBackgroundClr,
- pdcDst->pdcattr->crForegroundClr);
- }
- else
- {
- EXLATEOBJ_vInitialize(pexlo, ppalSrc, ppalDst, 0, 0, 0);
- }
-
- PALETTE_ShareUnlockPalette(ppalDst);
- PALETTE_ShareUnlockPalette(ppalSrc);
+ EXLATEOBJ_vInitialize(pexlo,
+ ppalSrc,
+ ppalDst,
+ pdcSrc->pdcattr->crBackgroundClr,
+ pdcDst->pdcattr->crBackgroundClr,
+ pdcDst->pdcattr->crForegroundClr);
}
@@ -699,68 +665,25 @@
EXLATEOBJ_vInitTrivial(pexlo);
- if (psurfDst->ppal)
- {
- ppalDst = psurfDst->ppal;
- GDIOBJ_IncrementShareCount(&ppalDst->BaseObject);
- }
- else
- ppalDst = PALETTE_ShareLockPalette(pPrimarySurface->devinfo.hpalDefault);
+ ppalDst = psurfDst->ppal;
if (!ppalDst)
{
- DPRINT1("No ppalDst!\n");
+ DPRINT1("No palette for dst surface %p.\n", psurfDst);
return;
}
psurfPattern = SURFACE_ShareLockSurface(pbrush->hbmPattern);
if (!psurfPattern)
{
- PALETTE_ShareUnlockPalette(ppalDst);
return;
}
-#if 0
- if (psurfDst->SurfObj.iBitmapFormat == BMF_1BPP)
- {
- if (psurfSrc->SurfObj.iBitmapFormat != BMF_1BPP)
- {
- // HACK!! FIXME: 1bpp DDBs should have gpalMono already!
- EXLATEOBJ_vInitialize(pexlo,
- ppalSrc,
- &gpalMono,
- 0,
- crBackgroundClr,
- crForegroundClr);
- }
- }
- else
-#endif
- if (psurfPattern->SurfObj.iBitmapFormat == BMF_1BPP &&
- !(pbrush->flAttrs & GDIBRUSH_IS_DIB))
- {
- /* Special case: 1 bpp pattern, not a DIB brush. */
- if (psurfDst->SurfObj.iBitmapFormat != BMF_1BPP)
- {
- // HACK!! FIXME: 1bpp DDBs should have gpalMono already!
- EXLATEOBJ_vInitialize(pexlo,
- &gpalMono,
- ppalDst,
- 0,
- crBackgroundClr,
- crForegroundClr);
- }
- }
- else
- {
- /* Default: use the patterns' palette */
- if (psurfPattern->ppal)
- {
- EXLATEOBJ_vInitialize(pexlo, psurfPattern->ppal, ppalDst, 0, 0, 0);
- }
- }
-
- PALETTE_ShareUnlockPalette(ppalDst);
+ if (psurfPattern->ppal)
+ {
+ EXLATEOBJ_vInitialize(pexlo, psurfPattern->ppal, ppalDst, 0, crBackgroundClr,
crForegroundClr);
+ }
+
SURFACE_ShareUnlockSurface(psurfPattern);
}
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] Fri
May 14 20:51:48 2010
@@ -54,7 +54,7 @@
HDEV hPDev;
} PALETTE, *PPALETTE;
-extern PALETTE gpalRGB, gpalBGR, gpalMono;
+extern PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565;
HPALETTE FASTCALL PALETTE_AllocPalette(ULONG Mode,
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
May 14 20:51:48 2010
@@ -87,6 +87,38 @@
IntSetBitmapBits(psurfBmp, psurfBmp->SurfObj.cjBits, pBits);
}
+ /* Find a suitable palette for this bitmap
+ * Increment internal objects share count
+ * so we can call PALETTE_ShareUnlockPalette
+ * or GDIOBJ_IncrementShareCount safely */
+ switch(BitsPixel)
+ {
+ case 1:
+ psurfBmp->ppal = &gpalMono;
+ gpalMono.BaseObject.ulShareCount++;
+ break;
+ case 4:
+ case 8:
+ psurfBmp->ppal = PALETTE_ShareLockPalette(StockObjects[DEFAULT_PALETTE]);
+ break;
+ case 15:
+ psurfBmp->ppal = &gpalRGB555;
+ gpalRGB555.BaseObject.ulShareCount++;
+ break;
+ case 16:
+ psurfBmp->ppal = &gpalRGB565;
+ gpalRGB565.BaseObject.ulShareCount++;
+ break;
+ case 24:
+ case 32:
+ psurfBmp->ppal = &gpalRGB;
+ gpalRGB.BaseObject.ulShareCount++;
+ break;
+ default:
+ DPRINT1("Could not determine palette for bit depth %u.\n",
BitsPixel);
+ break;
+ }
+
SURFACE_UnlockSurface(psurfBmp);
DPRINT("IntGdiCreateBitmap : %dx%d, %d BPP colors, topdown %d, returning
%08x\n",
@@ -144,15 +176,24 @@
if (Dc->dctype != DC_TYPE_MEMORY)
{
PSURFACE psurf;
- Bmp = IntGdiCreateBitmap(abs(Width),
- abs(Height),
- Dc->ppdev->gdiinfo.cPlanes,
- Dc->ppdev->gdiinfo.cBitsPixel,
- NULL);
- /* Set palette */
+ SIZEL size;
+
+ size.cx = abs(Width);
+ size.cy = abs(Height);
+
+ Bmp = IntCreateBitmap(size,
+ BITMAP_GetWidthBytes(Width,
Dc->ppdev->gdiinfo.cBitsPixel),
+ Dc->ppdev->pSurface->SurfObj.iBitmapFormat,
+ 0,
+ NULL);
+
psurf = SURFACE_LockSurface(Bmp);
ASSERT(psurf);
+ /* Set palette */
psurf->ppal =
PALETTE_ShareLockPalette(Dc->ppdev->devinfo.hpalDefault);
+ /* Set flags */
+ psurf->flFlags = BITMAPOBJ_IS_APIBITMAP;
+ psurf->hDC = NULL; // Fixme
SURFACE_UnlockSurface(psurf);
}
else
@@ -166,20 +207,24 @@
{
if (Count == sizeof(BITMAP))
{
- Bmp = IntGdiCreateBitmap(abs(Width),
- abs(Height),
- dibs.dsBm.bmPlanes,
- dibs.dsBm.bmBitsPixel,
- NULL);
+ SIZEL size;
+ PSURFACE psurfBmp;
+ size.cx = abs(Width);
+ size.cy = abs(Height);
+ Bmp = IntCreateBitmap(size,
+ BITMAP_GetWidthBytes(Width,
dibs.dsBm.bmBitsPixel),
+ psurf->SurfObj.iBitmapFormat,
+ 0,
+ NULL);
+ psurfBmp = SURFACE_LockSurface(Bmp);
+ ASSERT(psurfBmp);
/* Assign palette */
- if(Bmp && psurf->ppal)
- {
- PSURFACE psurfBmp = SURFACE_LockSurface(Bmp);
- ASSERT(psurfBmp);
- psurfBmp->ppal = psurf->ppal;
- GDIOBJ_IncrementShareCount((POBJ)psurf->ppal);
- SURFACE_UnlockSurface(psurfBmp);
- }
+ psurfBmp->ppal = psurf->ppal;
+ GDIOBJ_IncrementShareCount((POBJ)psurf->ppal);
+ /* Set flags */
+ psurfBmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
+ psurfBmp->hDC = NULL; // Fixme
+ SURFACE_UnlockSurface(psurfBmp);
}
else
{
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
May 14 20:51:48 2010
@@ -14,7 +14,7 @@
static UINT SystemPaletteUse = SYSPAL_NOSTATIC; /* the program need save the pallete and
restore it */
-PALETTE gpalRGB, gpalBGR, gpalMono;
+PALETTE gpalRGB, gpalBGR, gpalMono, gpalRGB555, gpalRGB565;
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS] =
{
@@ -104,14 +104,34 @@
gpalRGB.RedMask = RGB(0xFF, 0x00, 0x00);
gpalRGB.GreenMask = RGB(0x00, 0xFF, 0x00);
gpalRGB.BlueMask = RGB(0x00, 0x00, 0xFF);
+ gpalRGB.BaseObject.ulShareCount = 0;
+ gpalRGB.BaseObject.BaseFlags = 0 ;
gpalBGR.Mode = PAL_BGR;
gpalBGR.RedMask = RGB(0x00, 0x00, 0xFF);
gpalBGR.GreenMask = RGB(0x00, 0xFF, 0x00);
gpalBGR.BlueMask = RGB(0xFF, 0x00, 0x00);
+ gpalBGR.BaseObject.ulShareCount = 0;
+ gpalBGR.BaseObject.BaseFlags = 0 ;
+
+ gpalRGB555.Mode = PAL_RGB16_555 | PAL_BITFIELDS;
+ gpalRGB555.RedMask = 0x7C00;
+ gpalRGB555.GreenMask = 0x3E0;
+ gpalRGB555.BlueMask = 0x1F;
+ gpalRGB555.BaseObject.ulShareCount = 0;
+ gpalRGB555.BaseObject.BaseFlags = 0 ;
+
+ gpalRGB565.Mode = PAL_RGB16_565 | PAL_BITFIELDS;
+ gpalRGB565.RedMask = 0xF800;
+ gpalRGB565.GreenMask = 0x7E0;
+ gpalRGB565.BlueMask = 0x1F;
+ gpalRGB565.BaseObject.ulShareCount = 0;
+ gpalRGB565.BaseObject.BaseFlags = 0 ;
memset(&gpalMono, 0, sizeof(PALETTE));
gpalMono.Mode = PAL_MONOCHROME;
+ gpalMono.BaseObject.ulShareCount = 0;
+ gpalMono.BaseObject.BaseFlags = 0 ;
return hpalette;
}
@@ -169,7 +189,7 @@
PalGDI->RedMask = Red;
PalGDI->GreenMask = Green;
PalGDI->BlueMask = Blue;
-
+
if (Red == 0x7c00 && Green == 0x3E0 && Blue == 0x1F)
PalGDI->Mode |= PAL_RGB16_555;
else if (Red == 0xF800 && Green == 0x7E0 && Blue == 0x1F)