wined3d: Pass a texture to surface_translate_drawable_coords().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2018-03-05 11:06:34 +03:30 committed by Alexandre Julliard
parent 665c8c84c7
commit 612ceee6a0
4 changed files with 32 additions and 32 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;