[ros-diffs] [greatlrd] 33887: Fixed almost all firefox 1.5 crash also sync with trunk thus files

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sat Jun 7 16:34:26 CEST 2008


Author: greatlrd
Date: Sat Jun  7 09:34:25 2008
New Revision: 33887

URL: http://svn.reactos.org/svn/reactos?rev=33887&view=rev
Log:
Fixed almost all firefox 1.5 crash 
also sync with trunk thus files

Modified:
    branches/win32k-gdi-dx/subsystems/win32/win32k/objects/bitblt.c
    branches/win32k-gdi-dx/subsystems/win32/win32k/objects/dibobj.c
    branches/win32k-gdi-dx/subsystems/win32/win32k/objects/fillshap.c
    branches/win32k-gdi-dx/subsystems/win32/win32k/objects/polyfill.c

Modified: branches/win32k-gdi-dx/subsystems/win32/win32k/objects/bitblt.c
URL: http://svn.reactos.org/svn/reactos/branches/win32k-gdi-dx/subsystems/win32/win32k/objects/bitblt.c?rev=33887&r1=33886&r2=33887&view=diff
==============================================================================
--- branches/win32k-gdi-dx/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] (original)
+++ branches/win32k-gdi-dx/subsystems/win32/win32k/objects/bitblt.c [iso-8859-1] Sat Jun  7 09:34:25 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);
@@ -88,14 +86,11 @@
 		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;
-	YOriginDest += DCDest->w.DCOrgY;
-	XOriginSrc += DCSrc->w.DCOrgX;
-	YOriginSrc += DCSrc->w.DCOrgY;
+	XOriginDest += DCDest->ptlDCOrig.x;
+	YOriginDest += DCDest->ptlDCOrig.y;
+	XOriginSrc += DCSrc->ptlDCOrig.x;
+	YOriginSrc += DCSrc->ptlDCOrig.y;
 
 	DestRect.left   = XOriginDest;
 	DestRect.top    = YOriginDest;
@@ -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,16 +224,16 @@
 		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;
-	YDest += DCDest->w.DCOrgY;
+        XDest += DCDest->ptlDCOrig.x;
+        YDest += DCDest->ptlDCOrig.y;
 	if (UsesSource)
 	{
-		XSrc += DCSrc->w.DCOrgX;
-		YSrc += DCSrc->w.DCOrgY;
+		XSrc += DCSrc->ptlDCOrig.x;
+		YSrc += DCSrc->ptlDCOrig.y;
 	}
 
 	DestRect.left   = XDest;
@@ -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,65 +289,25 @@
 	/* 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;
 		}
 	}
 
 	/* Perform the bitblt operation */
-	Status = IntEngBitBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, NULL,
+    Status = IntEngBitBlt( BitmapDest ? &BitmapDest->SurfObj : NULL, BitmapSrc ? &BitmapSrc->SurfObj : NULL, NULL,
                           DCDest->CombinedClip, XlateObj, &DestRect,
                           &SourcePoint, NULL,
                           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;
@@ -454,43 +392,51 @@
   }
 
   /* Offset positions */
-  xDst += DCDest->w.DCOrgX;
-  yDst += DCDest->w.DCOrgY;
-  xSrc += DCSrc->w.DCOrgX;
-  ySrc += DCSrc->w.DCOrgY;
-
-  if(DCDest->DcLevel.hpal)
-    DestPalette = DCDest->DcLevel.hpal;
-
-  if(DCSrc->DcLevel.hpal)
-    SourcePalette = DCSrc->DcLevel.hpal;
+  xDst += DCDest->ptlDCOrig.x;
+  yDst += DCDest->ptlDCOrig.y;
+  xSrc += DCSrc->ptlDCOrig.x;
+  ySrc += DCSrc->ptlDCOrig.y;
+
+  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 = pPrimarySurface->DevInfo.hpalDefault;
+
+  SourcePalette = BitmapSrc->hDIBPalette;
+  if (!SourcePalette) SourcePalette = pPrimarySurface->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;
-	BITMAPOBJ *BitmapDest, *BitmapSrc;
+	PDC_ATTR Dc_Attr;
+	BITMAPOBJ *BitmapDest, *BitmapSrc = NULL;
 	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,12 +796,13 @@
 	}
 
 	/* Offset the destination and source by the origin of their DCs. */
-	XOriginDest += DCDest->w.DCOrgX;
-	YOriginDest += DCDest->w.DCOrgY;
+	// FIXME: ptlDCOrig is in device coordinates!
+	XOriginDest += DCDest->ptlDCOrig.x;
+	YOriginDest += DCDest->ptlDCOrig.y;
 	if (UsesSource)
 	{
-		XOriginSrc += DCSrc->w.DCOrgX;
-		YOriginSrc += DCSrc->w.DCOrgY;
+		XOriginSrc += DCSrc->ptlDCOrig.x;
+		YOriginSrc += DCSrc->ptlDCOrig.y;
 	}
 
 	DestRect.left   = XOriginDest;
@@ -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,18 +912,26 @@
                                   &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)
+	if ( (BitmapSrc) && 
+		 (BitmapSrc != BitmapDest))
 	{
 		BITMAPOBJ_UnlockBitmap(BitmapSrc);
 	}
-	BITMAPOBJ_UnlockBitmap(BitmapDest);
+
+	if (BitmapDest)
+	{
+		BITMAPOBJ_UnlockBitmap(BitmapDest);
+	}
+
 	if (UsesSource && hDCSrc != hDCDest)
 	{
 		DC_UnlockDc(DCSrc);
@@ -1038,30 +970,30 @@
    {
       if (Width > 0)
       {
-         DestRect.left = XLeft + dc->w.DCOrgX;
-         DestRect.right = XLeft + Width + dc->w.DCOrgX;
+         DestRect.left = XLeft + dc->ptlDCOrig.x;
+         DestRect.right = XLeft + Width + dc->ptlDCOrig.x;
       }
       else
       {
-         DestRect.left = XLeft + Width + 1 + dc->w.DCOrgX;
-         DestRect.right = XLeft + dc->w.DCOrgX + 1;
+         DestRect.left = XLeft + Width + 1 + dc->ptlDCOrig.x;
+         DestRect.right = XLeft + dc->ptlDCOrig.x + 1;
       }
 
       if (Height > 0)
       {
-         DestRect.top = YLeft + dc->w.DCOrgY;
-         DestRect.bottom = YLeft + Height + dc->w.DCOrgY;
+         DestRect.top = YLeft + dc->ptlDCOrig.y;
+         DestRect.bottom = YLeft + Height + dc->ptlDCOrig.y;
       }
       else
       {
-         DestRect.top = YLeft + Height + dc->w.DCOrgY + 1;
-         DestRect.bottom = YLeft + dc->w.DCOrgY + 1;
+         DestRect.top = YLeft + Height + dc->ptlDCOrig.y + 1;
+         DestRect.bottom = YLeft + dc->ptlDCOrig.y + 1;
       }
 
       IntLPtoDP(dc, (LPPOINT)&DestRect, 2);
 
-      BrushOrigin.x = BrushObj->ptOrigin.x + dc->w.DCOrgX;
-      BrushOrigin.y = BrushObj->ptOrigin.y + dc->w.DCOrgY;
+      BrushOrigin.x = BrushObj->ptOrigin.x + dc->ptlDCOrig.x;
+      BrushOrigin.y = BrushObj->ptOrigin.y + dc->ptlDCOrig.y;
 
       IntGdiInitBrushInstance(&BrushInst, BrushObj, dc->XlateBrush);
 
@@ -1074,7 +1006,7 @@
          &DestRect,
          NULL,
          NULL,
-         &BrushInst.BrushObject,
+         &BrushInst.BrushObject, // use pDC->eboFill
          &BrushOrigin,
          ROP3_TO_ROP4(ROP));
    }
@@ -1144,10 +1076,18 @@
    DWORD ROP)
 {
    PGDIBRUSHOBJ BrushObj;
-   DC *dc = DC_LockDc(hDC);
+   DC *dc;
    PDC_ATTR Dc_Attr;
    BOOL ret;
 
+   BOOL UsesSource = ROP3_USES_SOURCE(ROP);
+   if (UsesSource)
+   {
+       /* in this case we call on GdiMaskBlt */
+       return NtGdiMaskBlt(hDC, XLeft, YLeft, Width, Height, 0,0,0,0,0,0,ROP,0);
+   }
+
+   dc = DC_LockDc(hDC);
    if (dc == NULL)
    {
       SetLastWin32Error(ERROR_INVALID_HANDLE);

Modified: branches/win32k-gdi-dx/subsystems/win32/win32k/objects/dibobj.c
URL: http://svn.reactos.org/svn/reactos/branches/win32k-gdi-dx/subsystems/win32/win32k/objects/dibobj.c?rev=33887&r1=33886&r2=33887&view=diff
==============================================================================
--- branches/win32k-gdi-dx/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] (original)
+++ branches/win32k-gdi-dx/subsystems/win32/win32k/objects/dibobj.c [iso-8859-1] Sat Jun  7 09:34:25 2008
@@ -372,8 +372,14 @@
 
     rcDest.left = XDest;
     rcDest.top = YDest;
-    rcDest.right = XDest + Width;
-    rcDest.bottom = YDest + Height;
+    if (bTransformCoordinates)
+    {
+        CoordLPtoDP(pDC, (LPPOINT)&rcDest);
+    }
+    rcDest.left += pDC->ptlDCOrig.x;
+    rcDest.top += pDC->ptlDCOrig.y;
+    rcDest.right = rcDest.left + Width;
+    rcDest.bottom = rcDest.top + Height;
     ptSource.x = XSrc;
     ptSource.y = YSrc;
 
@@ -758,7 +764,7 @@
 INT
 APIENTRY
 NtGdiStretchDIBitsInternal(
-    HDC  hDC,
+    HDC  hdc,
     INT  XDest,
     INT  YDest,
     INT  DestWidth,
@@ -779,6 +785,7 @@
    HDC hdcMem;
    HPALETTE hPal = NULL;
    PDC pDC;
+   HDC hDC = hdc;
 
    if (!Bits || !BitsInfo)
    {
@@ -786,15 +793,33 @@
       return 0;
    }
 
+   /* if hdc is null we get it, for NtGdiCreateCompatibleDC can not handle NULL hdc */
+   if (hDC == NULL)
+   {
+       DPRINT1("hdc is NULL we using GetDC(NULL) hdc\n");
+       hDC = NtUserGetDC(NULL);
+   }
+
    hdcMem = NtGdiCreateCompatibleDC(hDC);
+   if (hdcMem == NULL)
+   {
+       DPRINT1("Waring : NtGdiCreateCompatibleDC fails \n");
+   }
+
    hBitmap = NtGdiCreateCompatibleBitmap(hDC, BitsInfo->bmiHeader.biWidth,
                                          BitsInfo->bmiHeader.biHeight);
+
+   if (hBitmap == NULL)
+   {
+       DPRINT1("Waring : NtGdiCreateCompatibleBitmap fails \n");
+   }
+
    hOldBitmap = NtGdiSelectBitmap(hdcMem, hBitmap);
 
    if(Usage == DIB_PAL_COLORS)
    {
       hPal = NtGdiGetDCObject(hDC, GDI_OBJECT_TYPE_PALETTE);
-      hPal = NtUserSelectPalette(hdcMem, hPal, FALSE);
+      hPal = GdiSelectPalette(hdcMem, hPal, FALSE);
    }
 
    if (BitsInfo->bmiHeader.biCompression == BI_RLE4 ||
@@ -811,12 +836,18 @@
    }
 
    pDC = DC_LockDc(hdcMem);
-
-   IntSetDIBits(pDC, hBitmap, 0, BitsInfo->bmiHeader.biHeight, Bits,
+   if (pDC != NULL)
+   {
+        /* Note BitsInfo->bmiHeader.biHeight is the number of scanline, 
+         * if it negitve we getting to many scanline for scanline is UINT not
+         * a INT, so we need make the negtive value to positve and that make the
+         * count correct for negtive bitmap, TODO : we need testcase for this api */
+
+         IntSetDIBits(pDC, hBitmap, 0, abs(BitsInfo->bmiHeader.biHeight), Bits,
                   BitsInfo, Usage);
 
-   DC_UnlockDc(pDC);
-
+         DC_UnlockDc(pDC);
+   }
 
    /* Origin for DIBitmap may be bottom left (positive biHeight) or top
       left (negative biHeight) */
@@ -830,11 +861,18 @@
                       SrcWidth, SrcHeight, ROP, 0);
 
    if(hPal)
-      NtUserSelectPalette(hdcMem, hPal, FALSE);
+      GdiSelectPalette(hdcMem, hPal, FALSE);
 
    NtGdiSelectBitmap(hdcMem, hOldBitmap);
-   NtGdiDeleteObjectApp(hdcMem);
-   NtGdiDeleteObject(hBitmap);
+
+   if (hdcMem)
+        NtGdiDeleteObjectApp(hdcMem);
+
+   if (hBitmap)
+        NtGdiDeleteObject(hBitmap);
+
+   if (hdc == NULL)
+      UserReleaseDC(NULL, hDC, FALSE);
 
    return SrcHeight;
 }
@@ -993,6 +1031,8 @@
   HBITMAP hbitmap = 0;
   DC *dc;
   BOOL bDesktopDC = FALSE;
+
+  if (!bmi) return hbitmap; // Make sure.
 
   // If the reference hdc is null, take the desktop dc
   if (hDC == 0)

Modified: branches/win32k-gdi-dx/subsystems/win32/win32k/objects/fillshap.c
URL: http://svn.reactos.org/svn/reactos/branches/win32k-gdi-dx/subsystems/win32/win32k/objects/fillshap.c?rev=33887&r1=33886&r2=33887&view=diff
==============================================================================
--- branches/win32k-gdi-dx/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] (original)
+++ branches/win32k-gdi-dx/subsystems/win32/win32k/objects/fillshap.c [iso-8859-1] Sat Jun  7 09:34:25 2008
@@ -73,8 +73,8 @@
     IntLPtoDP(dc, UnsafePoints, Count);
     for (CurrentPoint = 0; CurrentPoint < Count; CurrentPoint++)
     {
-        UnsafePoints[CurrentPoint].x += dc->w.DCOrgX;
-        UnsafePoints[CurrentPoint].y += dc->w.DCOrgY;
+        UnsafePoints[CurrentPoint].x += dc->ptlDCOrig.x;
+        UnsafePoints[CurrentPoint].y += dc->ptlDCOrig.y;
     }
 
     if (PATH_IsPathOpen(dc->w.path))
@@ -157,7 +157,8 @@
                   LPINT   PolyCounts,
                   int     Count)
 {
-    while (--Count >=0)
+    /* crash in POLYGONFILL_MakeEdgeList if we process point 0 */
+    while (--Count >=1)
     {
         if (!IntGdiPolygon ( dc, Points, *PolyCounts ))
             return FALSE;
@@ -273,10 +274,10 @@
 
     IntLPtoDP(dc, (LPPOINT)&RectBounds, 2);
 
-    RectBounds.left += dc->w.DCOrgX;
-    RectBounds.right += dc->w.DCOrgX;
-    RectBounds.top += dc->w.DCOrgY;
-    RectBounds.bottom += dc->w.DCOrgY;
+    RectBounds.left += dc->ptlDCOrig.x;
+    RectBounds.right += dc->ptlDCOrig.x;
+    RectBounds.top += dc->ptlDCOrig.y;
+    RectBounds.bottom += dc->ptlDCOrig.y;
 
     RadiusX = max((RectBounds.right - RectBounds.left) >> 1, 1);
     RadiusY = max((RectBounds.bottom - RectBounds.top) >> 1, 1);
@@ -683,14 +684,14 @@
         return FALSE;
     }
 
-    Left += dc->w.DCOrgX;
-    Right += dc->w.DCOrgX;
-    Top += dc->w.DCOrgY;
-    Bottom += dc->w.DCOrgY;
-    XRadialStart += dc->w.DCOrgX;
-    YRadialStart += dc->w.DCOrgY;
-    XRadialEnd += dc->w.DCOrgX;
-    YRadialEnd += dc->w.DCOrgY;
+    Left += dc->ptlDCOrig.x;
+    Right += dc->ptlDCOrig.x;
+    Top += dc->ptlDCOrig.y;
+    Bottom += dc->ptlDCOrig.y;
+    XRadialStart += dc->ptlDCOrig.x;
+    YRadialStart += dc->ptlDCOrig.y;
+    XRadialEnd += dc->ptlDCOrig.x;
+    YRadialEnd += dc->ptlDCOrig.y;
 
     RectBounds.left = Left;
     RectBounds.right = Right;
@@ -1047,10 +1048,10 @@
     }
     else
     {
-        LeftRect   += dc->w.DCOrgX;
-        RightRect  += dc->w.DCOrgX - 1;
-        TopRect    += dc->w.DCOrgY;
-        BottomRect += dc->w.DCOrgY - 1;
+        LeftRect   += dc->ptlDCOrig.x;
+        RightRect  += dc->ptlDCOrig.x - 1;
+        TopRect    += dc->ptlDCOrig.y;
+        BottomRect += dc->ptlDCOrig.y - 1;
 
         DestRect.left = LeftRect;
         DestRect.right = RightRect;
@@ -1207,10 +1208,10 @@
     xradius = xCurveDiameter >> 1;
     yradius = yCurveDiameter >> 1;
 
-    left += dc->w.DCOrgX;
-    right += dc->w.DCOrgX;
-    top += dc->w.DCOrgY;
-    bottom += dc->w.DCOrgY;
+    left += dc->ptlDCOrig.x;
+    right += dc->ptlDCOrig.x;
+    top += dc->ptlDCOrig.y;
+    bottom += dc->ptlDCOrig.y;
 
     RectBounds.left = left;
     RectBounds.right = right;
@@ -1492,6 +1493,7 @@
     POINTL DitherOrg;
     ULONG Mode, i;
     BOOL Ret;
+    HPALETTE hDestPalette;
 
     ASSERT(dc);
     ASSERT(pVertex);
@@ -1539,8 +1541,8 @@
         Extent.bottom = max(Extent.bottom, (pVertex + i)->y);
     }
 
-    DitherOrg.x = dc->w.DCOrgX;
-    DitherOrg.y = dc->w.DCOrgY;
+    DitherOrg.x = dc->ptlDCOrig.x;
+    DitherOrg.y = dc->ptlDCOrig.y;
     Extent.left += DitherOrg.x;
     Extent.right += DitherOrg.x;
     Extent.top += DitherOrg.y;
@@ -1550,13 +1552,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 = pPrimarySurface->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: branches/win32k-gdi-dx/subsystems/win32/win32k/objects/polyfill.c
URL: http://svn.reactos.org/svn/reactos/branches/win32k-gdi-dx/subsystems/win32/win32k/objects/polyfill.c?rev=33887&r1=33886&r2=33887&view=diff
==============================================================================
--- branches/win32k-gdi-dx/subsystems/win32/win32k/objects/polyfill.c [iso-8859-1] (original)
+++ branches/win32k-gdi-dx/subsystems/win32/win32k/objects/polyfill.c [iso-8859-1] Sat Jun  7 09:34:25 2008
@@ -281,6 +281,7 @@
     else
       list->Edges[list->Count++] = e;
   }
+  /* notes pionts does not come with paris from IntGdiPolyPolygon */
   e = POLYGONFILL_MakeEdge ( Points[CurPt-1], Points[0] );
   if ( !e )
     goto fail;



More information about the Ros-diffs mailing list