wined3d: Use draw_textured_quad() in swapchain_blit().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4f027e627e
commit
012f9b03f8
|
@ -310,6 +310,7 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
|
||||||
UINT src_h = src_rect->bottom - src_rect->top;
|
UINT src_h = src_rect->bottom - src_rect->top;
|
||||||
GLenum gl_filter;
|
GLenum gl_filter;
|
||||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||||
|
enum wined3d_texture_filter_type filter;
|
||||||
RECT win_rect;
|
RECT win_rect;
|
||||||
UINT win_h;
|
UINT win_h;
|
||||||
|
|
||||||
|
@ -317,9 +318,15 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
|
||||||
swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
|
swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
|
||||||
|
|
||||||
if (src_w == dst_rect->right - dst_rect->left && src_h == dst_rect->bottom - dst_rect->top)
|
if (src_w == dst_rect->right - dst_rect->left && src_h == dst_rect->bottom - dst_rect->top)
|
||||||
|
{
|
||||||
|
filter = WINED3D_TEXF_NONE;
|
||||||
gl_filter = GL_NEAREST;
|
gl_filter = GL_NEAREST;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
filter = WINED3D_TEXF_LINEAR;
|
||||||
gl_filter = GL_LINEAR;
|
gl_filter = GL_LINEAR;
|
||||||
|
}
|
||||||
|
|
||||||
GetClientRect(swapchain->win_handle, &win_rect);
|
GetClientRect(swapchain->win_handle, &win_rect);
|
||||||
win_h = win_rect.bottom - win_rect.top;
|
win_h = win_rect.bottom - win_rect.top;
|
||||||
|
@ -361,75 +368,22 @@ static void swapchain_blit(const struct wined3d_swapchain *swapchain,
|
||||||
{
|
{
|
||||||
struct wined3d_device *device = swapchain->device;
|
struct wined3d_device *device = swapchain->device;
|
||||||
struct wined3d_context *context2;
|
struct wined3d_context *context2;
|
||||||
float tex_left = src_rect->left;
|
RECT r;
|
||||||
float tex_top = src_rect->top;
|
|
||||||
float tex_right = src_rect->right;
|
|
||||||
float tex_bottom = src_rect->bottom;
|
|
||||||
|
|
||||||
context2 = context_acquire(device, texture, 0);
|
context2 = context_acquire(device, texture, 0);
|
||||||
context_apply_blit_state(context2, device);
|
context_apply_blit_state(context2, device);
|
||||||
|
|
||||||
if (texture->flags & WINED3D_TEXTURE_NORMALIZED_COORDS)
|
r = *dst_rect;
|
||||||
{
|
surface_translate_drawable_coords(back_buffer, swapchain->win_handle, &r);
|
||||||
tex_left /= texture->pow2_width;
|
|
||||||
tex_right /= texture->pow2_width;
|
|
||||||
tex_top /= texture->pow2_height;
|
|
||||||
tex_bottom /= texture->pow2_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_complex_fixup(texture->resource.format->color_fixup))
|
if (is_complex_fixup(texture->resource.format->color_fixup))
|
||||||
gl_filter = GL_NEAREST;
|
filter = WINED3D_TEXF_NONE;
|
||||||
|
|
||||||
context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, front_buffer, NULL, WINED3D_LOCATION_DRAWABLE);
|
|
||||||
context_bind_texture(context2, back_buffer->texture_target, texture->texture_rgb.name);
|
|
||||||
|
|
||||||
/* Set up the texture. The surface is not in a wined3d_texture
|
|
||||||
* container, so there are no D3D texture settings to dirtify. */
|
|
||||||
device->blitter->set_shader(device->blit_priv, context2, back_buffer, NULL);
|
|
||||||
gl_info->gl_ops.gl.p_glTexParameteri(back_buffer->texture_target, GL_TEXTURE_MIN_FILTER, gl_filter);
|
|
||||||
gl_info->gl_ops.gl.p_glTexParameteri(back_buffer->texture_target, GL_TEXTURE_MAG_FILTER, gl_filter);
|
|
||||||
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
|
|
||||||
gl_info->gl_ops.gl.p_glTexParameteri(back_buffer->texture_target,
|
|
||||||
GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
|
|
||||||
|
|
||||||
|
context_apply_fbo_state_blit(context2, GL_FRAMEBUFFER, back_buffer, NULL, WINED3D_LOCATION_DRAWABLE);
|
||||||
context_set_draw_buffer(context, GL_BACK);
|
context_set_draw_buffer(context, GL_BACK);
|
||||||
|
|
||||||
/* Set the viewport to the destination rectandle, disable any projection
|
device->blitter->set_shader(device->blit_priv, context2, back_buffer, NULL);
|
||||||
* transformation set up by context_apply_blit_state(), and draw a
|
draw_textured_quad(back_buffer, context2, src_rect, &r, filter);
|
||||||
* (-1,-1)-(1,1) quad.
|
|
||||||
*
|
|
||||||
* Back up viewport and matrix to avoid breaking last_was_blit
|
|
||||||
*
|
|
||||||
* Note that context_apply_blit_state() set up viewport and ortho to
|
|
||||||
* match the surface size - we want the GL drawable(=window) size. */
|
|
||||||
gl_info->gl_ops.gl.p_glPushAttrib(GL_VIEWPORT_BIT);
|
|
||||||
gl_info->gl_ops.gl.p_glViewport(dst_rect->left, win_h - dst_rect->bottom,
|
|
||||||
dst_rect->right, win_h - dst_rect->top);
|
|
||||||
gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION);
|
|
||||||
gl_info->gl_ops.gl.p_glPushMatrix();
|
|
||||||
gl_info->gl_ops.gl.p_glLoadIdentity();
|
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glBegin(GL_QUADS);
|
|
||||||
/* bottom left */
|
|
||||||
gl_info->gl_ops.gl.p_glTexCoord2f(tex_left, tex_bottom);
|
|
||||||
gl_info->gl_ops.gl.p_glVertex2i(-1, -1);
|
|
||||||
|
|
||||||
/* top left */
|
|
||||||
gl_info->gl_ops.gl.p_glTexCoord2f(tex_left, tex_top);
|
|
||||||
gl_info->gl_ops.gl.p_glVertex2i(-1, 1);
|
|
||||||
|
|
||||||
/* top right */
|
|
||||||
gl_info->gl_ops.gl.p_glTexCoord2f(tex_right, tex_top);
|
|
||||||
gl_info->gl_ops.gl.p_glVertex2i(1, 1);
|
|
||||||
|
|
||||||
/* bottom right */
|
|
||||||
gl_info->gl_ops.gl.p_glTexCoord2f(tex_right, tex_bottom);
|
|
||||||
gl_info->gl_ops.gl.p_glVertex2i(1, -1);
|
|
||||||
gl_info->gl_ops.gl.p_glEnd();
|
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glPopMatrix();
|
|
||||||
gl_info->gl_ops.gl.p_glPopAttrib();
|
|
||||||
|
|
||||||
device->blitter->unset_shader(context->gl_info);
|
device->blitter->unset_shader(context->gl_info);
|
||||||
checkGLcall("Swapchain present blit(manual)\n");
|
checkGLcall("Swapchain present blit(manual)\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue