[PATCH 5/5] wined3d: Simply pass implementation pointers to stretch_rect_fbo().

Henri Verbeet hverbeet at codeweavers.com
Tue Apr 20 15:38:43 CDT 2010


---
 dlls/wined3d/device.c          |   46 +++++++++++++++++++--------------------
 dlls/wined3d/surface.c         |   12 +++++-----
 dlls/wined3d/wined3d_private.h |    4 +-
 3 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 28ff11e..0e85a1c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5719,10 +5719,9 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
     }
 }
 
-void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const RECT *src_rect_in,
-        IWineD3DSurface *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter)
+void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect_in,
+        IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter)
 {
-    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
     const struct wined3d_gl_info *gl_info;
     struct wined3d_context *context;
@@ -5730,10 +5729,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
     POINT offset = {0, 0};
     RECT src_rect, dst_rect;
 
-    TRACE("(%p) : src_surface %p, src_rect_in %p, dst_surface %p, dst_rect_in %p, filter %s (0x%08x)\n",
-            This, src_surface, src_rect_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter);
-    TRACE("src_rect_in %s\n", wine_dbgstr_rect(src_rect_in));
-    TRACE("dst_rect_in %s\n", wine_dbgstr_rect(dst_rect_in));
+    TRACE("device %p, src_surface %p, src_rect_in %s, dst_surface %p, dst_rect_in %s, filter %s (0x%08x).\n",
+            device, src_surface, wine_dbgstr_rect(src_rect_in), dst_surface,
+            wine_dbgstr_rect(dst_rect_in), debug_d3dtexturefiltertype(filter), filter);
 
     src_rect = *src_rect_in;
     dst_rect = *dst_rect_in;
@@ -5754,12 +5752,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
     /* Make sure the drawables are up-to-date. Note that loading the
      * destination surface isn't strictly required if we overwrite the
      * entire surface. */
-    IWineD3DSurface_LoadLocation(src_surface, SFLAG_INDRAWABLE, NULL);
-    IWineD3DSurface_LoadLocation(dst_surface, SFLAG_INDRAWABLE, NULL);
+    IWineD3DSurface_LoadLocation((IWineD3DSurface *)src_surface, SFLAG_INDRAWABLE, NULL);
+    IWineD3DSurface_LoadLocation((IWineD3DSurface *)dst_surface, SFLAG_INDRAWABLE, NULL);
 
-    if (!surface_is_offscreen((IWineD3DSurfaceImpl *)src_surface)) context = context_acquire(This, src_surface, CTXUSAGE_RESOURCELOAD);
-    else if (!surface_is_offscreen((IWineD3DSurfaceImpl *)dst_surface)) context = context_acquire(This, dst_surface, CTXUSAGE_RESOURCELOAD);
-    else context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD);
+    if (!surface_is_offscreen(src_surface)) context = context_acquire(device, (IWineD3DSurface *)src_surface, CTXUSAGE_RESOURCELOAD);
+    else if (!surface_is_offscreen(dst_surface)) context = context_acquire(device, (IWineD3DSurface *)dst_surface, CTXUSAGE_RESOURCELOAD);
+    else context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
 
     if (!context->valid)
     {
@@ -5770,9 +5768,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
 
     gl_info = context->gl_info;
 
-    if (!surface_is_offscreen((IWineD3DSurfaceImpl *)src_surface))
+    if (!surface_is_offscreen(src_surface))
     {
-        GLenum buffer = surface_get_gl_buffer((IWineD3DSurfaceImpl *)src_surface);
+        GLenum buffer = surface_get_gl_buffer(src_surface);
 
         TRACE("Source surface %p is onscreen\n", src_surface);
 
@@ -5786,8 +5784,8 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
             src_rect.top =  offset.y + h - src_rect.top;
             src_rect.bottom =  offset.y + h - src_rect.bottom;
         } else {
-            src_rect.top = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.top;
-            src_rect.bottom = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.bottom;
+            src_rect.top = src_surface->currentDesc.Height - src_rect.top;
+            src_rect.bottom = src_surface->currentDesc.Height - src_rect.bottom;
         }
 
         ENTER_GL();
@@ -5798,7 +5796,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
         TRACE("Source surface %p is offscreen\n", src_surface);
         ENTER_GL();
         context_bind_fbo(context, GL_READ_FRAMEBUFFER, &context->src_fbo);
-        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)src_surface);
+        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, src_surface);
         glReadBuffer(GL_COLOR_ATTACHMENT0);
         checkGLcall("glReadBuffer()");
         context_attach_depth_stencil_fbo(context, GL_READ_FRAMEBUFFER, NULL, FALSE);
@@ -5806,9 +5804,9 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
     LEAVE_GL();
 
     /* Attach dst surface to dst fbo */
-    if (!surface_is_offscreen((IWineD3DSurfaceImpl *)dst_surface))
+    if (!surface_is_offscreen(dst_surface))
     {
-        GLenum buffer = surface_get_gl_buffer((IWineD3DSurfaceImpl *)dst_surface);
+        GLenum buffer = surface_get_gl_buffer(dst_surface);
 
         TRACE("Destination surface %p is onscreen\n", dst_surface);
 
@@ -5823,8 +5821,8 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
             dst_rect.bottom =  offset.y + h - dst_rect.bottom;
         } else {
             /* Screen coords = window coords, surface height = window height */
-            dst_rect.top = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.top;
-            dst_rect.bottom = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.bottom;
+            dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
+            dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
         }
 
         ENTER_GL();
@@ -5837,12 +5835,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
 
         ENTER_GL();
         context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, &context->dst_fbo);
-        context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER, 0, (IWineD3DSurfaceImpl *)dst_surface);
+        context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER, 0, dst_surface);
         context_set_draw_buffer(context, GL_COLOR_ATTACHMENT0);
         context_attach_depth_stencil_fbo(context, GL_DRAW_FRAMEBUFFER, NULL, FALSE);
     }
     glDisable(GL_SCISSOR_TEST);
-    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
+    IWineD3DDeviceImpl_MarkStateDirty(device, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
 
     gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
             dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, mask, gl_filter);
@@ -5854,7 +5852,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const
 
     context_release(context);
 
-    IWineD3DSurface_ModifyLocation(dst_surface, SFLAG_INDRAWABLE, TRUE);
+    IWineD3DSurface_ModifyLocation((IWineD3DSurface *)dst_surface, SFLAG_INDRAWABLE, TRUE);
 }
 
 static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 46261fc..899ca34 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3552,10 +3552,11 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
                 &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
                 &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
-            stretch_rect_fbo((IWineD3DDevice *)device, SrcSurface, &src_rect,
-                    (IWineD3DSurface *)This, &dst_rect, Filter);
-        } else if((!stretchx) || dst_rect.right - dst_rect.left > Src->currentDesc.Width ||
-                                    dst_rect.bottom - dst_rect.top > Src->currentDesc.Height) {
+            stretch_rect_fbo(device, Src, &src_rect, This, &dst_rect, Filter);
+        }
+        else if (!stretchx || dst_rect.right - dst_rect.left > Src->currentDesc.Width
+                || dst_rect.bottom - dst_rect.top > Src->currentDesc.Height)
+        {
             TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n");
             fb_copy_to_texture_direct(This, SrcSurface, &src_rect, &dst_rect, Filter);
         } else {
@@ -3588,8 +3589,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
             TRACE("Using stretch_rect_fbo\n");
             /* The source is always a texture, but never the currently active render target, and the texture
              * contents are never upside down. */
-            stretch_rect_fbo((IWineD3DDevice *)device, SrcSurface, &src_rect,
-                    (IWineD3DSurface *)This, &dst_rect, Filter);
+            stretch_rect_fbo(device, Src, &src_rect, This, &dst_rect, Filter);
             return WINED3D_OK;
         }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0dfe082..1972d21 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3045,8 +3045,8 @@ static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
     return (stateblock->pixelShader && stateblock->device->ps_selected_mode != SHADER_NONE);
 }
 
-void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
-        const RECT *src_rect, IWineD3DSurface *dst_surface, const RECT *dst_rect,
+void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface,
+        const RECT *src_rect, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect,
         const WINED3DTEXTUREFILTERTYPE filter) DECLSPEC_HIDDEN;
 
 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
-- 
1.6.4.4




More information about the wine-patches mailing list