[ros-diffs] [tkreuzer] 50998: [WIN32K] clip the destination rect against the bounds of the destination and source surface. Fixes a crash of gdi32_winetest bitmap that occurs as soon as IntCreateCompatibleBitma...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Mon Mar 7 22:00:19 UTC 2011


Author: tkreuzer
Date: Mon Mar  7 22:00:19 2011
New Revision: 50998

URL: http://svn.reactos.org/svn/reactos?rev=50998&view=rev
Log:
[WIN32K]
clip the destination rect against the bounds of the destination and source surface. Fixes a crash of gdi32_winetest bitmap that occurs as soon as IntCreateCompatibleBitmap is fixed. Other Eng* code needs to be checked as well.

Modified:
    trunk/reactos/subsystems/win32/win32k/eng/copybits.c

Modified: trunk/reactos/subsystems/win32/win32k/eng/copybits.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng/copybits.c?rev=50998&r1=50997&r2=50998&view=diff
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/eng/copybits.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/win32k/eng/copybits.c [iso-8859-1] Mon Mar  7 22:00:19 2011
@@ -49,12 +49,28 @@
     BLTINFO   BltInfo;
     SURFACE *psurfDest;
     SURFACE *psurfSource;
+    RECTL rclDest = *DestRect;
+    POINTL ptlSrc = *SourcePoint;
 
     ASSERT(psoDest != NULL && psoSource != NULL && DestRect != NULL && SourcePoint != NULL);
 
     psurfSource = CONTAINING_RECORD(psoSource, SURFACE, SurfObj);
     psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
 
+    /* Clip dest rect against source surface size / source point */
+    if (psoSource->sizlBitmap.cx - ptlSrc.x < rclDest.right - rclDest.left)
+        rclDest.right = rclDest.left + psoSource->sizlBitmap.cx - ptlSrc.x;
+    if (psoSource->sizlBitmap.cy - ptlSrc.y < rclDest.bottom - rclDest.top)
+        rclDest.bottom = rclDest.top + psoSource->sizlBitmap.cy - ptlSrc.y;
+
+    /* Clip dest rect against target surface size */
+    if (rclDest.right > psoDest->sizlBitmap.cx)
+        rclDest.right = psoDest->sizlBitmap.cx;
+    if (rclDest.bottom > psoDest->sizlBitmap.cy)
+        rclDest.bottom = psoDest->sizlBitmap.cy;
+    if (RECTL_bIsEmptyRect(&rclDest)) return TRUE;
+    DestRect = &rclDest;
+    
     // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
     //        mark the copy block function to be DrvCopyBits instead of the
     //        GDI's copy bit function so as to remove clipping from the




More information about the Ros-diffs mailing list