From 612ceee6a020f96e8353db9740f22c30de751425 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 5 Mar 2018 11:06:34 +0330 Subject: [PATCH] wined3d: Pass a texture to surface_translate_drawable_coords(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/surface.c | 33 +++------------------------------ dlls/wined3d/texture.c | 26 ++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 3 ++- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index f86c167b606..87a233f9561 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7847,7 +7847,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl if (dst_location == WINED3D_LOCATION_DRAWABLE) { d = *dst_rect; - surface_translate_drawable_coords(dst_surface, context->win_handle, &d); + wined3d_texture_translate_drawable_coords(dst_texture, context->win_handle, &d); dst_rect = &d; } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 421b01c99a2..38924a8b227 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -449,7 +449,7 @@ static void surface_blt_fbo(const struct wined3d_device *device, { TRACE("Source surface %p is onscreen.\n", src_surface); buffer = wined3d_texture_get_gl_buffer(src_texture); - surface_translate_drawable_coords(src_surface, context->win_handle, &src_rect); + wined3d_texture_translate_drawable_coords(src_texture, context->win_handle, &src_rect); } else { @@ -466,7 +466,7 @@ static void surface_blt_fbo(const struct wined3d_device *device, { TRACE("Destination surface %p is onscreen.\n", dst_surface); buffer = wined3d_texture_get_gl_buffer(dst_texture); - surface_translate_drawable_coords(dst_surface, context->win_handle, &dst_rect); + wined3d_texture_translate_drawable_coords(dst_texture, context->win_handle, &dst_rect); } else { @@ -2005,33 +2005,6 @@ static void fb_copy_to_texture_hwstretch(struct wined3d_surface *dst_surface, st wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); } -/* Front buffer coordinates are always full screen coordinates, but our GL - * 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_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) -{ - struct wined3d_texture *texture = surface->container; - POINT offset = {0, 0}; - UINT drawable_height; - RECT windowsize; - - if (!texture->swapchain) - return; - - if (texture == texture->swapchain->front_buffer) - { - ScreenToClient(window, &offset); - OffsetRect(rect, offset.x, offset.y); - } - - GetClientRect(window, &windowsize); - drawable_height = windowsize.bottom - windowsize.top; - - rect->top = drawable_height - rect->top; - rect->bottom = drawable_height - rect->bottom; -} - static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RECT *dst_rect, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) @@ -2925,7 +2898,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit if (dst_location == WINED3D_LOCATION_DRAWABLE) { r = *dst_rect; - surface_translate_drawable_coords(dst_surface, context->win_handle, &r); + wined3d_texture_translate_drawable_coords(dst_texture, context->win_handle, &r); dst_rect = &r; } diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index c498c154852..72ab9618410 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -48,6 +48,32 @@ static BOOL wined3d_texture_use_immutable_storage(const struct wined3d_texture * && !(texture->resource.format_flags & WINED3DFMT_FLAG_HEIGHT_SCALE); } +/* Front buffer coordinates are always full screen coordinates, but our GL + * 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 wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture, HWND window, RECT *rect) +{ + unsigned int drawable_height; + POINT offset = {0, 0}; + RECT windowsize; + + if (!texture->swapchain) + return; + + if (texture == texture->swapchain->front_buffer) + { + ScreenToClient(window, &offset); + OffsetRect(rect, offset.x, offset.y); + } + + GetClientRect(window, &windowsize); + drawable_height = windowsize.bottom - windowsize.top; + + rect->top = drawable_height - rect->top; + rect->bottom = drawable_height - rect->bottom; +} + GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) { const struct wined3d_swapchain *swapchain = texture->swapchain; diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 1c4c3ef2b49..4b334320f47 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3254,6 +3254,8 @@ void wined3d_texture_prepare_texture(struct wined3d_texture *texture, void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN; void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN; +void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture, + HWND window, RECT *rect) DECLSPEC_HIDDEN; void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, const struct wined3d_context *context, const struct wined3d_box *box, const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN; @@ -3338,7 +3340,6 @@ BOOL surface_load_location(struct wined3d_surface *surface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; void surface_set_compatible_renderbuffer(struct wined3d_surface *surface, const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN; -void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN; void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN; -- 2.11.4.GIT