Henri Verbeet : wined3d: Clamp NULL source boxes in wined3d_device_copy_sub_resource_region().

Alexandre Julliard julliard at winehq.org
Wed Nov 15 16:46:01 CST 2017


Module: wine
Branch: master
Commit: 7b09398a0b27fe0efcd41f103526768348f61723
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b09398a0b27fe0efcd41f103526768348f61723

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Nov 16 01:01:05 2017 +0330

wined3d: Clamp NULL source boxes in wined3d_device_copy_sub_resource_region().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d9/device.c    | 10 ++++++----
 dlls/wined3d/device.c | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 3b0b483..f6086bf 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1400,9 +1400,6 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
     TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
             iface, src_surface, src_rect, dst_surface, dst_point);
 
-    if (src_rect)
-        wined3d_box_set(&src_box, src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1);
-
     wined3d_mutex_lock();
 
     wined3d_texture_get_sub_resource_desc(src->wined3d_texture, src->sub_resource_idx, &src_desc);
@@ -1416,10 +1413,15 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
         return D3DERR_INVALIDCALL;
     }
 
+    if (src_rect)
+        wined3d_box_set(&src_box, src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1);
+    else
+        wined3d_box_set(&src_box, 0, 0, src_desc.width, src_desc.height, 0, 1);
+
     hr = wined3d_device_copy_sub_resource_region(device->wined3d_device,
             wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0,
             dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture),
-            src->sub_resource_idx, src_rect ? &src_box : NULL);
+            src->sub_resource_idx, &src_box);
     wined3d_mutex_unlock();
 
     if (FAILED(hr))
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 9fbf3b0..de6f1c5 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4125,7 +4125,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
 
         if (!src_box)
         {
-            wined3d_box_set(&b, 0, 0, src_resource->size, 1, 0, 1);
+            unsigned int dst_w;
+
+            dst_w = dst_resource->size - dst_x;
+            wined3d_box_set(&b, 0, 0, min(src_resource->size, dst_w), 1, 0, 1);
             src_box = &b;
         }
         else if ((src_box->left >= src_box->right
@@ -4178,8 +4181,16 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev
 
         if (!src_box)
         {
-            wined3d_box_set(&b, 0, 0, wined3d_texture_get_level_width(src_texture, src_level),
-                    wined3d_texture_get_level_height(src_texture, src_level), 0, 1);
+            unsigned int src_w, src_h, dst_w, dst_h, dst_level;
+
+            src_w = wined3d_texture_get_level_width(src_texture, src_level);
+            src_h = wined3d_texture_get_level_height(src_texture, src_level);
+
+            dst_level = dst_sub_resource_idx % dst_texture->level_count;
+            dst_w = wined3d_texture_get_level_width(dst_texture, dst_level) - dst_x;
+            dst_h = wined3d_texture_get_level_height(dst_texture, dst_level) - dst_y;
+
+            wined3d_box_set(&b, 0, 0, min(src_w, dst_w), min(src_h, dst_h), 0, 1);
             src_box = &b;
         }
         else if (FAILED(wined3d_texture_check_box_dimensions(src_texture, src_level, src_box)))




More information about the wine-cvs mailing list