Kovács András : wined3d: Fix CopyRects if pDestPointsArray is NULL.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 26 09:00:51 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: de051649c3148d307cb356f448a6f5bfeaf443a5
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=de051649c3148d307cb356f448a6f5bfeaf443a5

Author: Kovács András <andras at csevego.net>
Date:   Sun Jul 23 20:13:57 2006 +0100

wined3d: Fix CopyRects if pDestPointsArray is NULL.

---

 dlls/wined3d/device.c |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 323a2f5..83754c2 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -6781,8 +6781,38 @@ static HRESULT  WINAPI  IWineD3DDeviceIm
                 TRACE("Unlocked src and dst\n");
             }
         } else {
-            FIXME("Wanted to copy partial surfaces not implemented, returning WINED3DERR_INVALIDCALL\n");
-            hr = WINED3DERR_INVALIDCALL;
+		unsigned int i;
+		int bytesPerPixel = ((IWineD3DSurfaceImpl *) pSourceSurface)->bytesPerPixel;
+        	int copyperline;
+                int j;
+                WINED3DLOCKED_RECT lrSrc;
+                WINED3DLOCKED_RECT lrDst;
+                RECT dest_rect;
+										
+		for(i=0; i < cRects; i++) {
+		    CONST RECT*  r = &pSourceRectsArray[i];
+		    
+		    TRACE("Copying rect %d (%ld,%ld),(%ld,%ld) -> (0, 0)\n", i, r->left, r->top, r->right, r->bottom);
+            	    if (srcFormat == WINED3DFMT_DXT1) {
+		        copyperline = ((r->right - r->left) * bytesPerPixel) / 2; /* DXT1 is half byte per pixel */
+		    } else {
+			copyperline = ((r->right - r->left) * bytesPerPixel);
+		    }
+		    IWineD3DSurface_LockRect(pSourceSurface, &lrSrc, r, WINED3DLOCK_READONLY);
+		    dest_rect.left = 0;
+		    dest_rect.top = 0;
+		    dest_rect.right = r->right - r->left;
+		    dest_rect.bottom= r->bottom - r->top;
+		    IWineD3DSurface_LockRect(pDestinationSurface, &lrDst, &dest_rect, 0L);
+                    TRACE("Locked src and dst\n");
+                    /* Find where to start */
+                    for (j = 0; j < (r->bottom - r->top - 1); ++j) {
+                        memcpy((char*) lrDst.pBits + (j * lrDst.Pitch), (char*) lrSrc.pBits + (j * lrSrc.Pitch), copyperline);
+    	            }
+                    IWineD3DSurface_UnlockRect(pSourceSurface);
+	            IWineD3DSurface_UnlockRect(pDestinationSurface);
+		    TRACE("Unlocked src and dst\n");
+		}
         }
     }
 




More information about the wine-cvs mailing list