Henri Verbeet : ddraw: Use wined3d_resource_map() in surface_lock().

Alexandre Julliard julliard at wine.codeweavers.com
Wed Feb 3 10:23:52 CST 2016


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Feb  2 19:23:29 2016 +0100

ddraw: Use wined3d_resource_map() in surface_lock().

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

---

 dlls/ddraw/surface.c           | 57 +++++++++++++++++++++---------------------
 dlls/wined3d/surface.c         |  4 +--
 dlls/wined3d/wined3d.spec      |  1 -
 dlls/wined3d/wined3d_private.h |  2 ++
 include/wine/wined3d.h         |  2 --
 5 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 6a07cd7..edb9485 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -941,17 +941,17 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac
  *  For more details, see IWineD3DSurface::LockRect
  *
  *****************************************************************************/
-static HRESULT surface_lock(struct ddraw_surface *This,
-        RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h)
+static HRESULT surface_lock(struct ddraw_surface *surface,
+        RECT *rect, DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
 {
     struct wined3d_box box;
     struct wined3d_map_desc map_desc;
     HRESULT hr = DD_OK;
 
-    TRACE("This %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
-            This, wine_dbgstr_rect(Rect), DDSD, Flags, h);
+    TRACE("surface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
+            surface, wine_dbgstr_rect(rect), surface_desc, flags, h);
 
-    /* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */
+    /* surface->surface_desc.dwWidth and dwHeight are changeable, thus lock */
     wined3d_mutex_lock();
 
     /* Should I check for the handle to be NULL?
@@ -961,33 +961,31 @@ static HRESULT surface_lock(struct ddraw_surface *This,
      */
 
     /* Windows zeroes this if the rect is invalid */
-    DDSD->lpSurface = 0;
+    surface_desc->lpSurface = NULL;
 
-    if (Rect)
+    if (rect)
     {
-        if ((Rect->left < 0)
-                || (Rect->top < 0)
-                || (Rect->left > Rect->right)
-                || (Rect->top > Rect->bottom)
-                || (Rect->right > This->surface_desc.dwWidth)
-                || (Rect->bottom > This->surface_desc.dwHeight))
+        if ((rect->left < 0) || (rect->top < 0)
+                || (rect->left > rect->right) || (rect->right > surface->surface_desc.dwWidth)
+                || (rect->top > rect->bottom) || (rect->bottom > surface->surface_desc.dwHeight))
         {
             WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
             wined3d_mutex_unlock();
             return DDERR_INVALIDPARAMS;
         }
-        box.left = Rect->left;
-        box.top = Rect->top;
-        box.right = Rect->right;
-        box.bottom = Rect->bottom;
+        box.left = rect->left;
+        box.top = rect->top;
+        box.right = rect->right;
+        box.bottom = rect->bottom;
         box.front = 0;
         box.back = 1;
     }
 
-    if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
-        hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE);
+    if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+        hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE);
     if (SUCCEEDED(hr))
-        hr = wined3d_surface_map(This->wined3d_surface, &map_desc, Rect ? &box : NULL, Flags);
+        hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
+                surface->sub_resource_idx, &map_desc, rect ? &box : NULL, flags);
     if (FAILED(hr))
     {
         wined3d_mutex_unlock();
@@ -1004,22 +1002,23 @@ static HRESULT surface_lock(struct ddraw_surface *This,
         }
     }
 
-    if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+    if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
     {
-        if (Flags & DDLOCK_READONLY)
-            memset(&This->ddraw->primary_lock, 0, sizeof(This->ddraw->primary_lock));
-        else if (Rect)
-            This->ddraw->primary_lock = *Rect;
+        if (flags & DDLOCK_READONLY)
+            memset(&surface->ddraw->primary_lock, 0, sizeof(surface->ddraw->primary_lock));
+        else if (rect)
+            surface->ddraw->primary_lock = *rect;
         else
-            SetRect(&This->ddraw->primary_lock, 0, 0, This->surface_desc.dwWidth, This->surface_desc.dwHeight);
+            SetRect(&surface->ddraw->primary_lock, 0, 0, surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
     }
 
     /* Windows does not set DDSD_LPSURFACE on locked surfaces. */
-    DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
-    DDSD->lpSurface = map_desc.data;
+    DD_STRUCT_COPY_BYSIZE(surface_desc, &surface->surface_desc);
+    surface_desc->lpSurface = map_desc.data;
 
     TRACE("locked surface returning description :\n");
-    if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
+    if (TRACE_ON(ddraw))
+        DDRAW_dump_surface_desc(surface_desc);
 
     wined3d_mutex_unlock();
 
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 2698d09..657ef12 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2434,8 +2434,8 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
     return WINED3D_OK;
 }
 
-HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
-        struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
+HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc,
+        const struct wined3d_box *box, DWORD flags)
 {
     const struct wined3d_format *format = surface->resource.format;
     unsigned int fmt_flags = surface->container->resource.format_flags;
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 2698d17..6ff3151 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -226,7 +226,6 @@
 @ cdecl wined3d_surface_get_parent(ptr)
 @ cdecl wined3d_surface_get_pitch(ptr)
 @ cdecl wined3d_surface_get_resource(ptr)
-@ cdecl wined3d_surface_map(ptr ptr ptr long)
 @ cdecl wined3d_surface_set_overlay_position(ptr long long)
 @ cdecl wined3d_surface_unmap(ptr)
 @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index dd2dacd..94c7005 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2550,6 +2550,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
         struct wined3d_context *context) DECLSPEC_HIDDEN;
 HRESULT surface_load_location(struct wined3d_surface *surface,
         struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
+HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc,
+        const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN;
 void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN;
 void wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context,
         DWORD location) DECLSPEC_HIDDEN;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 87f7532..04b022c 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2479,8 +2479,6 @@ HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surfac
 void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
 DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
 struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface);
-HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface,
-        struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
 HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
 HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface);
 HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,




More information about the wine-cvs mailing list