Commit 0a315ba0 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1: Fix rounding when setting scissor rectangle.

parent ff8af741
......@@ -166,10 +166,10 @@ static void d2d_rt_draw(struct d2d_d3d_render_target *render_target, enum d2d_sh
const D2D1_RECT_F *clip_rect;
clip_rect = &render_target->clip_stack.stack[render_target->clip_stack.count - 1];
scissor_rect.left = clip_rect->left + 0.5f;
scissor_rect.top = clip_rect->top + 0.5f;
scissor_rect.right = clip_rect->right + 0.5f;
scissor_rect.bottom = clip_rect->bottom + 0.5f;
scissor_rect.left = ceilf(clip_rect->left - 0.5f);
scissor_rect.top = ceilf(clip_rect->top - 0.5f);
scissor_rect.right = ceilf(clip_rect->right - 0.5f);
scissor_rect.bottom = ceilf(clip_rect->bottom - 0.5f);
}
else
{
......
......@@ -1059,6 +1059,72 @@ static void test_clip(void)
match = compare_surface(surface, "035a44d4198d6e422e9de6185b5b2c2bac5e33c9");
ok(match, "Surface does not match.\n");
/* Fractional clip rectangle coordinates, aliased mode. */
set_matrix_identity(&matrix);
ID2D1RenderTarget_SetTransform(rt, &matrix);
ID2D1RenderTarget_SetDpi(rt, 96.0f, 96.0f);
ID2D1RenderTarget_BeginDraw(rt);
set_color(&color, 0.0f, 0.0f, 0.0f, 1.0f);
ID2D1RenderTarget_Clear(rt, &color);
scale_matrix(&matrix, 2.0f, 2.0f);
ID2D1RenderTarget_SetTransform(rt, &matrix);
set_rect(&rect, 0.0f, 0.5f, 200.0f, 100.5f);
set_color(&color, 1.0f, 0.0f, 1.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
set_matrix_identity(&matrix);
ID2D1RenderTarget_SetTransform(rt, &matrix);
set_rect(&rect, 0.0f, 0.5f, 100.0f, 200.5f);
set_color(&color, 1.0f, 0.0f, 0.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
ID2D1RenderTarget_SetTransform(rt, &matrix);
set_rect(&rect, 0.5f, 250.0f, 100.5f, 300.0f);
set_color(&color, 1.0f, 1.0f, 0.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
translate_matrix(&matrix, 0.1f, 0.0f);
ID2D1RenderTarget_SetTransform(rt, &matrix);
set_rect(&rect, 110.0f, 250.25f, 150.0f, 300.25f);
set_color(&color, 0.0f, 0.5f, 1.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
set_rect(&rect, 160.0f, 250.75f, 200.0f, 300.75f);
set_color(&color, 0.0f, 0.0f, 1.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
ID2D1RenderTarget_SetDpi(rt, 48.0f, 192.0f);
set_rect(&rect, 160.25f, 0.0f, 200.25f, 100.0f);
set_color(&color, 1.0f, 0.0f, 1.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f);
set_rect(&rect, 160.75f, 100.0f, 200.75f, 120.0f);
set_color(&color, 0.0f, 1.0f, 1.0f, 1.0f);
ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED);
ID2D1RenderTarget_Clear(rt, &color);
ID2D1RenderTarget_PopAxisAlignedClip(rt);
hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr);
match = compare_surface(surface, "a958d1fe69ee880200d47b206948e4c1ef382748");
ok(match, "Surface does not match.\n");
ID2D1RenderTarget_Release(rt);
IDXGISurface_Release(surface);
IDXGISwapChain_Release(swapchain);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment