[PATCH 3/5] wined3d: Introduce surface_color_fill().

Henri Verbeet hverbeet at codeweavers.com
Sun Aug 29 14:57:42 CDT 2010


This is also a first attempt at a more structured interface to blitter
operations.
---
 dlls/wined3d/surface.c         |   32 +++++++++++++++++---------------
 dlls/wined3d/utils.c           |   23 +++++++++++++++++++++++
 dlls/wined3d/wined3d_private.h |    5 +++++
 3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a669b98..6dcd590 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3354,6 +3354,22 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
     context_release(context);
 }
 
+static HRESULT surface_color_fill(IWineD3DSurfaceImpl *s, const RECT *rect, const WINED3DCOLORVALUE *color)
+{
+    IWineD3DDeviceImpl *device = s->resource.device;
+    const struct blit_shader *blitter;
+
+    blitter = wined3d_select_blitter(&device->adapter->gl_info, BLIT_OP_COLOR_FILL,
+            NULL, 0, 0, NULL, rect, s->resource.usage, s->resource.pool, s->resource.format_desc);
+    if (!blitter)
+    {
+        FIXME("No blitter is capable of performing the requested color fill operation.\n");
+        return WINED3DERR_INVALIDCALL;
+    }
+
+    return blitter->color_fill(device, s, rect, color);
+}
+
 /* Not called from the VTable */
 static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, const RECT *DestRect,
         IWineD3DSurfaceImpl *src_surface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
@@ -3737,21 +3753,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
             if (!surface_convert_color_to_float(dst_surface, DDBltFx->u5.dwFillColor, &color))
                 return WINED3DERR_INVALIDCALL;
 
-            if (ffp_blit.blit_supported(gl_info, BLIT_OP_COLOR_FILL,
-                    NULL, 0, 0, NULL,
-                    &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
-                    dst_surface->resource.format_desc))
-            {
-                return ffp_blit.color_fill(device, dst_surface, &dst_rect, &color);
-            }
-            else if (cpu_blit.blit_supported(gl_info, BLIT_OP_COLOR_FILL,
-                    NULL, 0, 0, NULL,
-                    &dst_rect, dst_surface->resource.usage, dst_surface->resource.pool,
-                    dst_surface->resource.format_desc))
-            {
-                return cpu_blit.color_fill(device, dst_surface, &dst_rect, &color);
-            }
-            return WINED3DERR_INVALIDCALL;
+            return surface_color_fill(dst_surface, &dst_rect, &color);
         }
     }
 
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index b386db4..1c414e9 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3136,3 +3136,26 @@ void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected,
     else if (gl_info->supported[ATI_FRAGMENT_SHADER]) *ps_selected = SHADER_ATI;
     else *ps_selected = SHADER_NONE;
 }
+
+const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+        const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format,
+        const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format)
+{
+    static const struct blit_shader * const blitters[] =
+    {
+        &arbfp_blit,
+        &ffp_blit,
+        &cpu_blit,
+    };
+    unsigned int i;
+
+    for (i = 0; i < sizeof(blitters) / sizeof(*blitters); ++i)
+    {
+        if (blitters[i]->blit_supported(gl_info, blit_op,
+                src_rect, src_usage, src_pool, src_format,
+                dst_rect, dst_usage, dst_pool, dst_format))
+            return blitters[i];
+    }
+
+    return NULL;
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b9a1f81..cb743ae 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1151,6 +1151,11 @@ extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
 extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
 extern const struct blit_shader cpu_blit DECLSPEC_HIDDEN;
 
+const struct blit_shader *wined3d_select_blitter(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+        const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool, const struct wined3d_format_desc *src_format,
+        const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const struct wined3d_format_desc *dst_format)
+        DECLSPEC_HIDDEN;
+
 /* Temporary blit_shader helper functions */
 HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect,
                            IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, enum blit_operation blit_op,
-- 
1.7.1




More information about the wine-patches mailing list