From 803e39eb0ca711ad7a2867bdac796cc4360c4c27 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Sat, 4 Jan 2014 00:53:47 +0100
Subject: wined3d: Remove surface_validate_location.

---
 dlls/wined3d/arb_program_shader.c |  2 +-
 dlls/wined3d/device.c             |  4 ++--
 dlls/wined3d/surface.c            | 31 ++++++++++++-------------------
 dlls/wined3d/swapchain.c          |  4 ++--
 dlls/wined3d/texture.c            |  4 +---
 dlls/wined3d/wined3d_private.h    |  1 -
 6 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index e8526d8..a87b09b 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7888,7 +7888,7 @@ static void arbfp_blit_surface(struct wined3d_device *device, DWORD filter,
 
     context_release(context);
 
-    surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding);
+    wined3d_resource_validate_location(&dst_surface->resource, dst_surface->container->resource.draw_binding);
     surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding);
 }
 
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 2312267..c10c1fc 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -398,7 +398,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
 
             if (rt)
             {
-                surface_validate_location(rt, rt->container->resource.draw_binding);
+                wined3d_resource_validate_location(&rt->resource, rt->container->resource.draw_binding);
                 surface_invalidate_location(rt, ~rt->container->resource.draw_binding);
             }
         }
@@ -4047,7 +4047,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str
 
     context_release(context);
 
-    surface_validate_location(surface, WINED3D_LOCATION_TEXTURE_RGB);
+    wined3d_resource_validate_location(&surface->resource, WINED3D_LOCATION_TEXTURE_RGB);
     surface_invalidate_location(surface, ~WINED3D_LOCATION_TEXTURE_RGB);
 }
 
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 50282c0..4fb2578 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1158,14 +1158,14 @@ static void surface_unload(struct wined3d_resource *resource)
          * and all flags get lost */
         if (resource->usage & WINED3DUSAGE_DEPTHSTENCIL)
         {
-            surface_validate_location(surface, WINED3D_LOCATION_DISCARDED);
+            wined3d_resource_validate_location(&surface->resource, WINED3D_LOCATION_DISCARDED);
             surface_invalidate_location(surface, ~WINED3D_LOCATION_DISCARDED);
         }
         else
         {
             surface_prepare_system_memory(surface);
             memset(surface->resource.heap_memory, 0, surface->resource.size);
-            surface_validate_location(surface, WINED3D_LOCATION_SYSMEM);
+            wined3d_resource_validate_location(&surface->resource, WINED3D_LOCATION_SYSMEM);
             surface_invalidate_location(surface, ~WINED3D_LOCATION_SYSMEM);
         }
     }
@@ -1695,7 +1695,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
 
     context_release(context);
 
-    surface_validate_location(dst_surface, WINED3D_LOCATION_TEXTURE_RGB);
+    wined3d_resource_validate_location(&dst_surface->resource, WINED3D_LOCATION_TEXTURE_RGB);
     surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB);
 
     return WINED3D_OK;
@@ -2133,7 +2133,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
         valid_location = WINED3D_LOCATION_SYSMEM;
     }
 
-    surface_validate_location(surface, valid_location);
+    wined3d_resource_validate_location(&surface->resource, valid_location);
 
     return WINED3D_OK;
 }
@@ -2679,7 +2679,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
     {
         TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n",
                 wined3d_debug_location(surface->resource.map_binding));
-        surface_validate_location(surface, surface->resource.map_binding);
+        wined3d_resource_validate_location(&surface->resource, surface->resource.map_binding);
     }
     else
     {
@@ -3167,7 +3167,7 @@ static void fb_copy_to_texture_direct(struct wined3d_surface *dst_surface, struc
 
     /* The texture is now most up to date - If the surface is a render target
      * and has a drawable, this path is never entered. */
-    surface_validate_location(dst_surface, WINED3D_LOCATION_TEXTURE_RGB);
+    wined3d_resource_validate_location(&dst_surface->resource, WINED3D_LOCATION_TEXTURE_RGB);
     surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB);
 }
 
@@ -3440,7 +3440,7 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st
 
     /* The texture is now most up to date - If the surface is a render target
      * and has a drawable, this path is never entered. */
-    surface_validate_location(dst_surface, WINED3D_LOCATION_TEXTURE_RGB);
+    wined3d_resource_validate_location(&dst_surface->resource, WINED3D_LOCATION_TEXTURE_RGB);
     surface_invalidate_location(dst_surface, ~WINED3D_LOCATION_TEXTURE_RGB);
 }
 
@@ -3918,13 +3918,6 @@ void surface_load_ds_location(struct wined3d_surface *surface, struct wined3d_co
     surface->ds_current_size.cy = surface->resource.height;
 }
 
-void surface_validate_location(struct wined3d_surface *surface, DWORD location)
-{
-    TRACE("surface %p, location %s.\n", surface, wined3d_debug_location(location));
-
-    surface->resource.locations |= location;
-}
-
 void surface_invalidate_location(struct wined3d_surface *surface, DWORD location)
 {
     TRACE("surface %p, location %s.\n", surface, wined3d_debug_location(location));
@@ -4319,7 +4312,7 @@ void surface_load_location(struct wined3d_surface *surface, struct wined3d_conte
             break;
     }
 
-    surface_validate_location(surface, location);
+    wined3d_resource_validate_location(&surface->resource, location);
 
     if (location != WINED3D_LOCATION_SYSMEM && (surface->resource.locations & WINED3D_LOCATION_SYSMEM))
         surface_evict_sysmem(surface);
@@ -4493,7 +4486,7 @@ static void ffp_blit_blit_surface(struct wined3d_device *device, DWORD filter,
     wined3d_texture_set_color_key(src_surface->container, WINED3D_CKEY_SRC_BLT,
             (old_color_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
 
-    surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding);
+    wined3d_resource_validate_location(&dst_surface->resource, dst_surface->container->resource.draw_binding);
     surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding);
 }
 
@@ -5474,7 +5467,7 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
                         dst_surface, dst_surface->container->resource.draw_binding, &dst_rect);
                 context_release(context);
 
-                surface_validate_location(dst_surface, dst_surface->container->resource.draw_binding);
+                wined3d_resource_validate_location(&dst_surface->resource, dst_surface->container->resource.draw_binding);
                 surface_invalidate_location(dst_surface, ~dst_surface->container->resource.draw_binding);
 
                 return WINED3D_OK;
@@ -5564,7 +5557,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
     }
 
     surface->container = container;
-    surface_validate_location(surface, WINED3D_LOCATION_SYSMEM);
+    wined3d_resource_validate_location(&surface->resource, WINED3D_LOCATION_SYSMEM);
     list_init(&surface->renderbuffers);
     list_init(&surface->overlays);
 
@@ -5596,7 +5589,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
     if (surface->resource.map_binding == WINED3D_LOCATION_DIB)
     {
         wined3d_resource_free_sysmem(&surface->resource);
-        surface_validate_location(surface, WINED3D_LOCATION_DIB);
+        wined3d_resource_validate_location(&surface->resource, WINED3D_LOCATION_DIB);
         surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM);
     }
 
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index e45fe17..9758be4 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -562,7 +562,7 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT
 
     front = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0));
 
-    surface_validate_location(front, WINED3D_LOCATION_DRAWABLE);
+    wined3d_resource_validate_location(&front->resource, WINED3D_LOCATION_DRAWABLE);
     surface_invalidate_location(front, ~WINED3D_LOCATION_DRAWABLE);
     /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
      * and INTEXTURE copies can keep their old content if they have any defined content.
@@ -835,7 +835,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
     front_buffer = surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0));
     if (!(device->wined3d->flags & WINED3D_NO3D))
     {
-        surface_validate_location(front_buffer, WINED3D_LOCATION_DRAWABLE);
+        wined3d_resource_validate_location(&front_buffer->resource, WINED3D_LOCATION_DRAWABLE);
         surface_invalidate_location(front_buffer, ~WINED3D_LOCATION_DRAWABLE);
     }
 
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0f40a3c..6b41db8 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -795,9 +795,7 @@ static void texture2d_sub_resource_invalidate_location(struct wined3d_resource *
 
 static void texture2d_sub_resource_validate_location(struct wined3d_resource *sub_resource, DWORD location)
 {
-    struct wined3d_surface *surface = surface_from_resource(sub_resource);
-
-    surface_validate_location(surface, location);
+    wined3d_resource_validate_location(sub_resource, location);
 }
 
 static void texture2d_sub_resource_upload_data(struct wined3d_resource *sub_resource,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 87cd0d0..3848e76 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2477,7 +2477,6 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
         const struct wined3d_gl_info *gl_info, void *mem, unsigned int pitch) DECLSPEC_HIDDEN;
 HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
         struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
-void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
 HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
         GLenum target, unsigned int level, unsigned int layer, DWORD flags,
         struct wined3d_surface **surface) DECLSPEC_HIDDEN;
-- 
2.6.2

