[ros-diffs] [tkreuzer] 33752: fix palette implementation: use the surface's palette to crate the xlate objects, default to the device default palette. The dc palette defaults to stock object default palette. Implement IntCreateXlateForBlt, used in BitBlt etc functions to perform the needed operations to create the xlate object instead of duplicating the code. This allows for global thermonuclear solitaire again and hopefully doesn't break everything else ; -)

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Thu May 29 03:17:51 CEST 2008


Author: tkreuzer
Date: Wed May 28 20:17:50 2008
New Revision: 33752

URL: http://svn.reactos.org/svn/reactos?rev=33752&view=rev
Log:
fix palette implementation: use the surface's palette to crate the xlate objects, default to the device default palette. The dc palette defaults to stock object default palette. Implement IntCreateXlateForBlt, used in BitBlt etc functions to perform the needed operations to create the xlate object instead of duplicating the code. This allows for global thermonuclear solitaire again and hopefully doesn't break everything else ;-)

Modified:
    trunk/reactos/subsystems/win32/win32k/include/dc.h
    trunk/reactos/subsystems/win32/win32k/include/intgdi.h
    trunk/reactos/subsystems/win32/win32k/objects/bitblt.c
    trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
    trunk/reactos/subsystems/win32/win32k/objects/brush.c
    trunk/reactos/subsystems/win32/win32k/objects/dc.c
    trunk/reactos/subsystems/win32/win32k/objects/fillshap.c
    trunk/reactos/subsystems/win32/win32k/objects/text.c

Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/dc.h?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Wed May 28 20:17:50 2008
@@ -311,5 +311,6 @@
 HDC FASTCALL IntGdiCreateDisplayDC(HDEV hDev, ULONG DcType, BOOL EmptyDC);
 BOOL FASTCALL IntGdiCleanDC(HDC hDC);
 
+extern GDIDEVICE PrimarySurface;
 
 #endif /* not __WIN32K_DC_H */

Modified: trunk/reactos/subsystems/win32/win32k/include/intgdi.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/include/intgdi.h?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/include/intgdi.h [iso-8859-1] Wed May 28 20:17:50 2008
@@ -7,6 +7,10 @@
 
 XLATEOBJ* FASTCALL
 IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed);
+
+XLATEOBJ*
+FASTCALL
+IntCreateXlateForBlt(PDC pDCDest, PDC pDCSrc, BITMAPOBJ* pDestSurf, BITMAPOBJ* pSrcSurf);
 
 VOID FASTCALL
 IntGdiInitBrushInstance(GDIBRUSHINST *BrushInst, PGDIBRUSHOBJ BrushObj, XLATEOBJ *XlateObj);

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitblt.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitblt.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -42,13 +42,11 @@
 {
 	PDC DCDest = NULL;
 	PDC DCSrc  = NULL;
-        PDC_ATTR Dc_Attr = NULL;
 	BITMAPOBJ *BitmapDest, *BitmapSrc;
 	RECTL DestRect, SourceRect;
 	BOOL Status;
 	XLATEOBJ *XlateObj;
 	BLENDOBJ BlendObj;
-	HPALETTE SourcePalette = 0, DestPalette = 0;
 	BlendObj.BlendFunction = BlendFunc;
 
 	DCDest = DC_LockDc(hDCDest);
@@ -87,9 +85,6 @@
 	{
 		DCSrc = DCDest;
 	}
-
-        Dc_Attr = DCSrc->pDc_Attr;
-        if (!Dc_Attr) Dc_Attr = &DCSrc->Dc_Attr;
 
 	/* Offset the destination and source by the origin of their DCs. */
 	XOriginDest += DCDest->w.DCOrgX;
@@ -109,53 +104,43 @@
 
 	/* Determine surfaces to be used in the bitblt */
 	BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+	if (!BitmapDest)
+	{
+		DC_UnlockDc(DCSrc);
+		DC_UnlockDc(DCDest);
+		return FALSE;
+	}
 	if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
 		BitmapSrc = BitmapDest;
 	else
+	{
 		BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+		if (!BitmapDest)
+		{
+			BITMAPOBJ_UnlockBitmap(BitmapDest);
+			DC_UnlockDc(DCSrc);
+			DC_UnlockDc(DCDest);
+			return FALSE;
+		}
+	}
 
 	/* Create the XLATEOBJ. */
-	if (DCDest->DcLevel.hpal != 0)
-		DestPalette = DCDest->DcLevel.hpal;
-	if (DCSrc->DcLevel.hpal != 0)
-		SourcePalette = DCSrc->DcLevel.hpal;
-
-	/* KB41464 details how to convert between mono and color */
-	if (DCDest->w.bitsPerPixel == 1 && DCSrc->w.bitsPerPixel == 1)
-	{
+	XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
+
+	if (XlateObj == (XLATEOBJ*)-1)
+	{
+		DPRINT1("error!!!\n");
+		SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
 		XlateObj = NULL;
+		Status = FALSE;
 	}
 	else
 	{
-		if (DCDest->w.bitsPerPixel == 1)
-		{
-			XlateObj = IntEngCreateMonoXlate(0, DestPalette, SourcePalette, Dc_Attr->crBackgroundClr);
-		}
-		else if (DCSrc->w.bitsPerPixel == 1)
-		{
-			XlateObj = IntEngCreateSrcMonoXlate(DestPalette, Dc_Attr->crBackgroundClr, Dc_Attr->crForegroundClr);
-		}
-		else
-		{
-			XlateObj = IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
-		}
-		if (NULL == XlateObj)
-		{
-			BITMAPOBJ_UnlockBitmap(BitmapDest);
-			if (BitmapSrc != BitmapDest)
-				BITMAPOBJ_UnlockBitmap(BitmapSrc);
-			DC_UnlockDc(DCDest);
-			if (hDCSrc != hDCDest)
-				DC_UnlockDc(DCSrc);
-			SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
-			return FALSE;
-		}
-	}
-
-	/* Perform the alpha blend operation */
-	Status = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
-	                          DCDest->CombinedClip, XlateObj,
-	                          &DestRect, &SourceRect, &BlendObj);
+		/* Perform the alpha blend operation */
+		Status = IntEngAlphaBlend(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
+		                          DCDest->CombinedClip, XlateObj,
+		                          &DestRect, &SourceRect, &BlendObj);
+	}
 
 	if (XlateObj != NULL)
 		EngDeleteXlate(XlateObj);
@@ -186,14 +171,13 @@
 {
 	PDC DCDest = NULL;
 	PDC DCSrc  = NULL;
-        PDC_ATTR Dc_Attr = NULL;
-	BITMAPOBJ *BitmapDest, *BitmapSrc;
+	PDC_ATTR Dc_Attr = NULL;
+	BITMAPOBJ *BitmapDest, *BitmapSrc = NULL;
 	RECTL DestRect;
 	POINTL SourcePoint, BrushOrigin;
-	BOOL Status;
+	BOOL Status = FALSE;
 	XLATEOBJ *XlateObj = NULL;
-	HPALETTE SourcePalette = 0, DestPalette = 0;
-	PGDIBRUSHOBJ BrushObj;
+	PGDIBRUSHOBJ BrushObj = NULL;
 	GDIBRUSHINST BrushInst;
 	BOOL UsesSource = ROP3_USES_SOURCE(ROP);
 	BOOL UsesPattern = ROP3_USES_PATTERN(ROP);
@@ -240,8 +224,8 @@
 		DCSrc = NULL;
 	}
 
-        Dc_Attr = DCDest->pDc_Attr;
-        if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
+	Dc_Attr = DCDest->pDc_Attr;
+	if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
 
 	/* Offset the destination and source by the origin of their DCs. */
 	XDest += DCDest->w.DCOrgX;
@@ -267,12 +251,19 @@
 
 	/* Determine surfaces to be used in the bitblt */
 	BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+	if (!BitmapDest)
+		goto cleanup;
+
 	if (UsesSource)
 	{
 		if (DCSrc->w.hBitmap == DCDest->w.hBitmap)
 			BitmapSrc = BitmapDest;
 		else
+		{
 			BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+			if (!BitmapSrc)
+				goto cleanup;
+		}
 	}
 	else
 	{
@@ -284,21 +275,8 @@
 		BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
 		if (NULL == BrushObj)
 		{
-			if (UsesSource && hDCSrc != hDCDest)
-			{
-				DC_UnlockDc(DCSrc);
-			}
-			if(BitmapDest != NULL)
-			{
-				BITMAPOBJ_UnlockBitmap(BitmapDest);
-			}
-			if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
-			{
-				BITMAPOBJ_UnlockBitmap(BitmapSrc);
-			}
-			DC_UnlockDc(DCDest);
 			SetLastWin32Error(ERROR_INVALID_HANDLE);
-			return FALSE;
+			goto cleanup;
 		}
 		BrushOrigin = *((PPOINTL)&BrushObj->ptOrigin);
 		IntGdiInitBrushInstance(&BrushInst, BrushObj, DCDest->XlateBrush);
@@ -311,55 +289,14 @@
 	/* Create the XLATEOBJ. */
 	if (UsesSource)
 	{
-		if (DCDest->DcLevel.hpal != 0)
-			DestPalette = DCDest->DcLevel.hpal;
-
-		if (DCSrc->DcLevel.hpal != 0)
-			SourcePalette = DCSrc->DcLevel.hpal;
-
-		/* KB41464 details how to convert between mono and color */
-		if (DCDest->w.bitsPerPixel == 1 && DCSrc->w.bitsPerPixel == 1)
-		{
+		XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
+
+		if (XlateObj == (XLATEOBJ*)-1)
+		{
+			DPRINT1("error!\n");
+			SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
 			XlateObj = NULL;
-		}
-		else
-		{
-                        Dc_Attr = DCSrc->pDc_Attr;
-                        if (!Dc_Attr) Dc_Attr = &DCSrc->Dc_Attr;
-			if (DCDest->w.bitsPerPixel == 1)
-			{
-				XlateObj = IntEngCreateMonoXlate(0, DestPalette, SourcePalette, Dc_Attr->crBackgroundClr);
-			}
-			else if (DCSrc->w.bitsPerPixel == 1)
-			{
-				XlateObj = IntEngCreateSrcMonoXlate(DestPalette, Dc_Attr->crBackgroundClr, Dc_Attr->crForegroundClr);
-			}
-			else
-			{
-				XlateObj = IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
-			}
-			if (NULL == XlateObj)
-			{
-				if (UsesSource && hDCSrc != hDCDest)
-				{
-					DC_UnlockDc(DCSrc);
-				}
-				DC_UnlockDc(DCDest);
-				if(BitmapDest != NULL)
-				{
-					BITMAPOBJ_UnlockBitmap(BitmapDest);
-				}
-				if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
-				{
-					BITMAPOBJ_UnlockBitmap(BitmapSrc);
-				}
-				if(BrushObj != NULL)
-				{
-					BRUSHOBJ_UnlockBrush(BrushObj);
-				}
-				SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
-				return FALSE;
-			}
+			goto cleanup;
 		}
 	}
 
@@ -370,6 +307,7 @@
                           BrushObj ? &BrushInst.BrushObject : NULL,
                           &BrushOrigin, ROP3_TO_ROP4(ROP));
 
+cleanup:
 	if (UsesSource && XlateObj != NULL)
 		EngDeleteXlate(XlateObj);
 
@@ -410,8 +348,8 @@
 {
   PDC DCDest, DCSrc;
   RECTL rcDest, rcSrc;
-  BITMAPOBJ *BitmapDest, *BitmapSrc;
-  XLATEOBJ *XlateObj;
+  BITMAPOBJ *BitmapDest, *BitmapSrc = NULL;
+  XLATEOBJ *XlateObj = NULL;
   HPALETTE SourcePalette = 0, DestPalette = 0;
   PPALGDI PalDestGDI, PalSourceGDI;
   USHORT PalDestMode, PalSrcMode;
@@ -459,38 +397,46 @@
   xSrc += DCSrc->w.DCOrgX;
   ySrc += DCSrc->w.DCOrgY;
 
-  if(DCDest->DcLevel.hpal)
-    DestPalette = DCDest->DcLevel.hpal;
-
-  if(DCSrc->DcLevel.hpal)
-    SourcePalette = DCSrc->DcLevel.hpal;
+  BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+  if (!BitmapDest)
+  {
+    goto done;
+  }
+
+  BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+  if (!BitmapSrc)
+  {
+    goto done;
+  }
+
+  DestPalette = BitmapDest->hDIBPalette;
+  if (!DestPalette) DestPalette = PrimarySurface.DevInfo.hpalDefault;
+
+  SourcePalette = BitmapSrc->hDIBPalette;
+  if (!SourcePalette) SourcePalette = PrimarySurface.DevInfo.hpalDefault;
 
   if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
   {
-    DC_UnlockDc(DCSrc);
-    DC_UnlockDc(DCDest);
     SetLastWin32Error(ERROR_INVALID_HANDLE);
-    return FALSE;
-  }
-  if((DestPalette != SourcePalette) && !(PalDestGDI = PALETTE_LockPalette(DestPalette)))
-  {
-    PALETTE_UnlockPalette(PalSourceGDI);
-    DC_UnlockDc(DCSrc);
-    DC_UnlockDc(DCDest);
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
-    return FALSE;
-  }
+    goto done;
+  }
+  PalSrcMode = PalSourceGDI->Mode;
+  PALETTE_UnlockPalette(PalSourceGDI);
+
   if(DestPalette != SourcePalette)
   {
+    if (!(PalDestGDI = PALETTE_LockPalette(DestPalette)))
+    {
+      SetLastWin32Error(ERROR_INVALID_HANDLE);
+      goto done;
+    }
     PalDestMode = PalDestGDI->Mode;
-    PalSrcMode = PalSourceGDI->Mode;
     PALETTE_UnlockPalette(PalDestGDI);
   }
   else
   {
-    PalDestMode = PalSrcMode = PalSourceGDI->Mode;
-  }
-  PALETTE_UnlockPalette(PalSourceGDI);
+    PalDestMode = PalSrcMode;
+  }
 
   /* Translate Transparent (RGB) Color to the source palette */
   if((XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
@@ -501,13 +447,6 @@
 
   /* Create the XLATE object to convert colors between source and destination */
   XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
-
-  BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
-  /* FIXME - BitmapDest can be NULL!!!! Don't assert here! */
-  ASSERT(BitmapDest);
-  BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
-  /* FIXME - BitmapSrc can be NULL!!!! Don't assert here! */
-  ASSERT(BitmapSrc);
 
   rcDest.left = xDst;
   rcDest.top = yDst;
@@ -529,9 +468,15 @@
                              TransparentColor, 0);
 
 done:
-  BITMAPOBJ_UnlockBitmap(BitmapDest);
-  BITMAPOBJ_UnlockBitmap(BitmapSrc);
   DC_UnlockDc(DCSrc);
+  if (BitmapDest)
+  {
+    BITMAPOBJ_UnlockBitmap(BitmapDest);
+  }
+  if (BitmapSrc)
+  {
+    BITMAPOBJ_UnlockBitmap(BitmapSrc);
+  }
   if(hdcDst != hdcSrc)
   {
     DC_UnlockDc(DCDest);
@@ -791,14 +736,13 @@
 {
 	PDC DCDest = NULL;
 	PDC DCSrc  = NULL;
-        PDC_ATTR Dc_Attr = NULL;
+	PDC_ATTR Dc_Attr;
 	BITMAPOBJ *BitmapDest, *BitmapSrc;
 	RECTL DestRect;
 	RECTL SourceRect;
 	BOOL Status;
 	XLATEOBJ *XlateObj = NULL;
-	HPALETTE SourcePalette = 0, DestPalette = 0;
-	PGDIBRUSHOBJ BrushObj;
+	PGDIBRUSHOBJ BrushObj = NULL;
 	BOOL UsesSource = ((ROP & 0xCC0000) >> 2) != (ROP & 0x330000);
 	BOOL UsesPattern = ((ROP & 0xF00000) >> 4) != (ROP & 0x0F0000);
 
@@ -852,6 +796,7 @@
 	}
 
 	/* Offset the destination and source by the origin of their DCs. */
+	// FIXME: DCOrg is in device coordinates!
 	XOriginDest += DCDest->w.DCOrgX;
 	YOriginDest += DCDest->w.DCOrgY;
 	if (UsesSource)
@@ -878,14 +823,7 @@
 			BitmapSrc = BitmapDest;
 		else
 			BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
-	}
-	else
-	{
-		BitmapSrc = NULL;
-	}
-
-	if ( UsesSource )
-	{
+
 		int sw = BitmapSrc->SurfObj.sizlBitmap.cx;
 		int sh = BitmapSrc->SurfObj.sizlBitmap.cy;
 		if ( SourceRect.left < 0 )
@@ -936,50 +874,36 @@
 			Status = FALSE;
 			goto failed;
 		}
+
+		/* Create the XLATEOBJ. */
+		XlateObj = IntCreateXlateForBlt(DCDest, DCSrc, BitmapDest, BitmapSrc);
+		if (XlateObj == (XLATEOBJ*)-1)
+		{
+			SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
+			Status = FALSE;
+			goto failed;
+		}
+	}
+	else
+	{
+		BitmapSrc = NULL;
 	}
 
 	if (UsesPattern)
 	{
-                Dc_Attr = DCDest->pDc_Attr;
-                if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
+		Dc_Attr = DCDest->pDc_Attr;
+		if (!Dc_Attr) Dc_Attr = &DCDest->Dc_Attr;
 		BrushObj = BRUSHOBJ_LockBrush(Dc_Attr->hbrush);
 		if (NULL == BrushObj)
 		{
-			if (UsesSource && hDCSrc != hDCDest)
-			{
-				DC_UnlockDc(DCSrc);
-			}
-			DC_UnlockDc(DCDest);
 			SetLastWin32Error(ERROR_INVALID_HANDLE);
-			return FALSE;
+			Status = FALSE;
+			goto failed;
 		}
 	}
 	else
 	{
 		BrushObj = NULL;
-	}
-
-	/* Create the XLATEOBJ. */
-	if (UsesSource)
-	{
-		if (DCDest->DcLevel.hpal != 0)
-			DestPalette = DCDest->DcLevel.hpal;
-
-		if (DCSrc->DcLevel.hpal != 0)
-			SourcePalette = DCSrc->DcLevel.hpal;
-
-		/* FIXME: Use the same logic for create XLATEOBJ as in NtGdiBitBlt. */
-		XlateObj = (XLATEOBJ*)IntEngCreateXlate(0, 0, DestPalette, SourcePalette);
-		if (NULL == XlateObj)
-		{
-			if (UsesSource && hDCSrc != hDCDest)
-			{
-				DC_UnlockDc(DCSrc);
-			}
-			DC_UnlockDc(DCDest);
-			SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
-			return FALSE;
-		}
 	}
 
 	/* Perform the bitblt operation */
@@ -988,13 +912,15 @@
                                   &DestRect, &SourceRect, NULL, NULL, NULL,
                                   COLORONCOLOR);
 
-	if (UsesSource)
+failed:
+	if (XlateObj)
+	{
 		EngDeleteXlate(XlateObj);
-	if (UsesPattern)
+	}
+	if (BrushObj)
 	{
 		BRUSHOBJ_UnlockBrush(BrushObj);
 	}
-failed:
 	if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
 	{
 		BITMAPOBJ_UnlockBitmap(BitmapSrc);
@@ -1074,7 +1000,7 @@
          &DestRect,
          NULL,
          NULL,
-         &BrushInst.BrushObject,
+         &BrushInst.BrushObject, // use pDC->eboFill
          &BrushOrigin,
          ROP3_TO_ROP4(ROP));
    }

Modified: trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/bitmaps.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -265,8 +265,9 @@
 		SurfaceObject = &BitmapObject->SurfObj;
 		if ( BitmapObject )
 		{
-			if ( dc->DcLevel.hpal != 0 )
-				Pal = dc->DcLevel.hpal;
+			Pal = BitmapObject->hDIBPalette;
+			if (!Pal) Pal = PrimarySurface.DevInfo.hpalDefault;
+
 			/* FIXME: Verify if it shouldn't be PAL_BGR! */
 			XlateObj = (XLATEOBJ*)IntEngCreateXlate ( PAL_RGB, 0, NULL, Pal );
 			if ( XlateObj )

Modified: trunk/reactos/subsystems/win32/win32k/objects/brush.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/brush.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/brush.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -119,6 +119,16 @@
 IntGdiCreateBrushXlate(PDC Dc, GDIBRUSHOBJ *BrushObj, BOOLEAN *Failed)
 {
    XLATEOBJ *Result = NULL;
+   BITMAPOBJ * pSurface;
+   HPALETTE hPalette = NULL;
+
+   pSurface = BITMAPOBJ_LockBitmap(Dc->w.hBitmap);
+   if (pSurface)
+   {
+      hPalette = pSurface->hDIBPalette;
+      BITMAPOBJ_UnlockBitmap(pSurface);
+   }
+   if (!hPalette) hPalette = PrimarySurface.DevInfo.hpalDefault;
 
    if (BrushObj->flAttrs & GDIBRUSH_IS_NULL)
    {
@@ -127,7 +137,7 @@
    }
    else if (BrushObj->flAttrs & GDIBRUSH_IS_SOLID)
    {
-      Result = IntEngCreateXlate(0, PAL_RGB, Dc->DcLevel.hpal, NULL);
+      Result = IntEngCreateXlate(0, PAL_RGB, hPalette, NULL);
       *Failed = FALSE;
    }
    else
@@ -143,11 +153,11 @@
          if (!Dc_Attr) Dc_Attr = &Dc->Dc_Attr;
 
          if (Dc->w.bitsPerPixel != 1)
-            Result = IntEngCreateSrcMonoXlate(Dc->DcLevel.hpal, Dc_Attr->crForegroundClr, Dc_Attr->crBackgroundClr);
+            Result = IntEngCreateSrcMonoXlate(hPalette, Dc_Attr->crForegroundClr, Dc_Attr->crBackgroundClr);
       }
       else if (BrushObj->flAttrs & GDIBRUSH_IS_DIB)
       {
-         Result = IntEngCreateXlate(0, 0, Dc->DcLevel.hpal, Pattern->hDIBPalette);
+         Result = IntEngCreateXlate(0, 0, hPalette, Pattern->hDIBPalette);
       }
 
       BITMAPOBJ_UnlockBitmap(Pattern);

Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/dc.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/dc.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -29,7 +29,7 @@
 
 //  ---------------------------------------------------------  File Statics
 
-static GDIDEVICE PrimarySurface;
+GDIDEVICE PrimarySurface;
 static PGDIDEVICE pPrimarySurface = NULL;
 static KEVENT VideoDriverNeedsPreparation;
 static KEVENT VideoDriverPrepared;
@@ -829,7 +829,8 @@
 
   if (!CreateAsIC)
   {
-    NewDC->DcLevel.hpal = PrimarySurface.DevInfo.hpalDefault;
+    NewDC->DcLevel.hpal = NtGdiGetStockObject(DEFAULT_PALETTE);
+
     nDc_Attr->jROP2 = R2_COPYPEN;
 
     NewDC->erclWindow.top = NewDC->erclWindow.left = 0;
@@ -1957,12 +1958,10 @@
     if(pBmp->dib)
     {
         pDC->w.bitsPerPixel = pBmp->dib->dsBmih.biBitCount;
-        pDC->DcLevel.hpal = pBmp->hDIBPalette;
     }
     else
     {
         pDC->w.bitsPerPixel = BitsPerFormat(pBmp->SurfObj.iBitmapFormat);
-        pDC->DcLevel.hpal = ((GDIDEVICE *)pDC->pPDev)->DevInfo.hpalDefault;
     }
 
     /* Regenerate the XLATEOBJs. */

Modified: trunk/reactos/subsystems/win32/win32k/objects/fillshap.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/fillshap.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -1492,6 +1492,7 @@
     POINTL DitherOrg;
     ULONG Mode, i;
     BOOL Ret;
+    HPALETTE hDestPalette;
 
     ASSERT(dc);
     ASSERT(pVertex);
@@ -1550,13 +1551,19 @@
     /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
     ASSERT(BitmapObj);
 
-    PalDestGDI = PALETTE_LockPalette(dc->DcLevel.hpal);
-    /* FIXME - PalDestGDI can be NULL!!! Don't assert but handle this case gracefully! */
-    ASSERT(PalDestGDI);
-    Mode = PalDestGDI->Mode;
-    PALETTE_UnlockPalette(PalDestGDI);
-
-    XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->DcLevel.hpal, NULL);
+    hDestPalette = BitmapObj->hDIBPalette;
+    if (!hDestPalette) hDestPalette = PrimarySurface.DevInfo.hpalDefault;
+
+    PalDestGDI = PALETTE_LockPalette(hDestPalette);
+    if (PalDestGDI)
+    {
+        Mode = PalDestGDI->Mode;
+        PALETTE_UnlockPalette(PalDestGDI);
+    }
+    else
+        Mode = PAL_RGB;
+
+    XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL);
     ASSERT(XlateObj);
 
     Ret = IntEngGradientFill(&BitmapObj->SurfObj,

Modified: trunk/reactos/subsystems/win32/win32k/objects/text.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/objects/text.c?rev=33752&r1=33751&r2=33752&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/objects/text.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/objects/text.c [iso-8859-1] Wed May 28 20:17:50 2008
@@ -1547,6 +1547,7 @@
    POINT Start;
    BOOL DoBreak = FALSE;
    LPCWSTR String, SafeString = NULL;
+   HPALETTE hDestPalette;
 
    // TODO: Write test-cases to exactly match real Windows in different
    // bad parameters (e.g. does Windows check the DC or the RECT first?).
@@ -1629,7 +1630,9 @@
    YStart = Start.y + dc->w.DCOrgY;
 
    /* Create the brushes */
-   PalDestGDI = PALETTE_LockPalette(dc->DcLevel.hpal);
+   hDestPalette = BitmapObj->hDIBPalette;
+   if (!hDestPalette) hDestPalette = PrimarySurface.DevInfo.hpalDefault;
+   PalDestGDI = PALETTE_LockPalette(hDestPalette);
    if ( !PalDestGDI )
       Mode = PAL_RGB;
    else
@@ -1637,7 +1640,7 @@
       Mode = PalDestGDI->Mode;
       PALETTE_UnlockPalette(PalDestGDI);
    }
-   XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->DcLevel.hpal, NULL);
+   XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, hDestPalette, NULL);
    if ( !XlateObj )
    {
       goto fail;
@@ -1667,7 +1670,7 @@
       }
       IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
    }
-   XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, dc->DcLevel.hpal);
+   XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, hDestPalette);
    if ( !XlateObj2 )
    {
       goto fail;



More information about the Ros-diffs mailing list