Henri Verbeet : wined3d: Change surface_translate_frontbuffer_coords() to handle all drawable coordinates.

Alexandre Julliard julliard at winehq.org
Mon Nov 1 11:54:36 CDT 2010


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Nov  1 11:57:57 2010 +0100

wined3d: Change surface_translate_frontbuffer_coords() to handle all drawable coordinates.

---

 dlls/wined3d/arb_program_shader.c |   17 ++----------
 dlls/wined3d/surface.c            |   50 +++++++++++++++++-------------------
 dlls/wined3d/wined3d_private.h    |    2 +-
 3 files changed, 28 insertions(+), 41 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 2886180..ca9d0e6 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -7153,21 +7153,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
     context = context_acquire(device, dst_surface);
     context_apply_blit_state(context, device);
 
-    /* The coordinates of the ddraw front buffer are always fullscreen ('screen coordinates',
-     * while OpenGL coordinates are window relative.
-     * Also beware of the origin difference(top left vs bottom left).
-     * Also beware that the front buffer's surface size is screen width x screen height,
-     * whereas the real gl drawable size is the size of the window. */
-    dst_swapchain = dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
-            ? dst_surface->container.u.swapchain : NULL;
     if (!surface_is_offscreen(dst_surface))
-    {
-        if (dst_swapchain && dst_surface == dst_swapchain->front_buffer)
-            surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
-
-        dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
-        dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
-    }
+        surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
 
     arbfp_blit_set((IWineD3DDevice *)device, src_surface);
 
@@ -7181,6 +7168,8 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
     /* Leave the opengl state valid for blitting */
     arbfp_blit_unset((IWineD3DDevice *)device);
 
+    dst_swapchain = dst_surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+            ? dst_surface->container.u.swapchain : NULL;
     if (wined3d_settings.strict_draw_ordering || (dst_swapchain
             && (dst_surface == dst_swapchain->front_buffer
             || dst_swapchain->num_contexts > 1)))
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 3a18f9e..20a656c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -3176,15 +3176,29 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
  * drawable is limited to the window's client area. The sysmem and texture
  * copies do have the full screen size. Note that GL has a bottom-left
  * origin, while D3D has a top-left origin. */
-void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect)
+void surface_translate_drawable_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect)
 {
-    POINT offset = {0, surface->currentDesc.Height};
-    RECT windowsize;
+    UINT drawable_height;
 
-    GetClientRect(window, &windowsize);
-    offset.y -= windowsize.bottom - windowsize.top;
-    ScreenToClient(window, &offset);
-    OffsetRect(rect, offset.x, offset.y);
+    if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN
+            && surface == surface->container.u.swapchain->front_buffer)
+    {
+        POINT offset = {0, 0};
+        RECT windowsize;
+
+        ScreenToClient(window, &offset);
+        OffsetRect(rect, offset.x, offset.y);
+
+        GetClientRect(window, &windowsize);
+        drawable_height = windowsize.bottom - windowsize.top;
+    }
+    else
+    {
+        drawable_height = surface->currentDesc.Height;
+    }
+
+    rect->top = drawable_height - rect->top;
+    rect->bottom = drawable_height - rect->bottom;
 }
 
 static BOOL surface_is_full_rect(IWineD3DSurfaceImpl *surface, const RECT *r)
@@ -3262,11 +3276,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
 
         TRACE("Source surface %p is onscreen.\n", src_surface);
 
-        if (buffer == GL_FRONT)
-            surface_translate_frontbuffer_coords(src_surface, context->win_handle, &src_rect);
-
-        src_rect.top = src_surface->currentDesc.Height - src_rect.top;
-        src_rect.bottom = src_surface->currentDesc.Height - src_rect.bottom;
+        surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect);
 
         ENTER_GL();
         context_bind_fbo(context, GL_READ_FRAMEBUFFER, NULL);
@@ -3289,11 +3299,7 @@ static void surface_blt_fbo(IWineD3DDeviceImpl *device, const WINED3DTEXTUREFILT
 
         TRACE("Destination surface %p is onscreen.\n", dst_surface);
 
-        if (buffer == GL_FRONT)
-            surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
-
-        dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
-        dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
+        surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
 
         ENTER_GL();
         context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL);
@@ -3353,15 +3359,7 @@ static void surface_blt_to_drawable(IWineD3DDeviceImpl *device,
     context_apply_blit_state(context, device);
 
     if (!surface_is_offscreen(dst_surface))
-    {
-        if (swapchain && dst_surface == swapchain->front_buffer)
-        {
-            surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
-        }
-
-        dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
-        dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
-    }
+        surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect);
 
     device->blitter->set_shader((IWineD3DDevice *)device, src_surface);
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3313963..18da56a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2178,7 +2178,7 @@ void surface_set_container(IWineD3DSurfaceImpl *surface,
         enum wined3d_container_type type, IWineD3DBase *container) DECLSPEC_HIDDEN;
 void surface_set_texture_name(IWineD3DSurfaceImpl *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
 void surface_set_texture_target(IWineD3DSurfaceImpl *surface, GLenum target) DECLSPEC_HIDDEN;
-void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
+void surface_translate_drawable_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
 
 /* Predeclare the shared Surface functions */
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,




More information about the wine-cvs mailing list