Commit a525b697 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d2d1: Properly invert join directions when needed.

parent 25188eb7
......@@ -1743,6 +1743,7 @@ static BOOL d2d_geometry_outline_add_join(struct d2d_geometry *geometry,
struct d2d_outline_vertex *v;
struct d2d_face *f;
size_t base_idx;
float ccw;
if (!d2d_array_reserve((void **)&geometry->outline.vertices, &geometry->outline.vertices_size,
geometry->outline.vertex_count + 4, sizeof(*geometry->outline.vertices)))
......@@ -1767,7 +1768,8 @@ static BOOL d2d_geometry_outline_add_join(struct d2d_geometry *geometry,
d2d_point_normalise(&q_prev);
d2d_point_normalise(&q_next);
if (d2d_point_dot(&q_prev, &q_next) == -1.0f)
ccw = d2d_point_ccw(p0, prev, next);
if (ccw == 0.0f)
{
d2d_outline_vertex_set(&v[0], p0->x, p0->y, q_prev.x, q_prev.y, q_prev.x, q_prev.y);
d2d_outline_vertex_set(&v[1], p0->x, p0->y, -q_prev.x, -q_prev.y, -q_prev.x, -q_prev.y);
......@@ -1776,6 +1778,13 @@ static BOOL d2d_geometry_outline_add_join(struct d2d_geometry *geometry,
d2d_outline_vertex_set(&v[3], p0->x + 25.0f * q_prev.x, p0->y + 25.0f * q_prev.y,
q_prev.x, q_prev.y, q_prev.x, q_prev.y);
}
else if (ccw < 0.0f)
{
d2d_outline_vertex_set(&v[0], p0->x, p0->y, 0.0f, 0.0f, 0.0f, 0.0f);
d2d_outline_vertex_set(&v[1], p0->x, p0->y, -q_next.x, -q_next.y, -q_next.x, -q_next.y);
d2d_outline_vertex_set(&v[2], p0->x, p0->y, -q_next.x, -q_next.y, -q_prev.x, -q_prev.y);
d2d_outline_vertex_set(&v[3], p0->x, p0->y, -q_prev.x, -q_prev.y, -q_prev.x, -q_prev.y);
}
else
{
d2d_outline_vertex_set(&v[0], p0->x, p0->y, 0.0f, 0.0f, 0.0f, 0.0f);
......
......@@ -1917,12 +1917,10 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
float2 q_prev, q_next, v_p, q_i;
float l;
q_prev.x = dot(prev, transform_geometry._11_21);
q_prev.y = dot(prev, transform_geometry._12_22);
q_prev = float2(dot(prev, transform_geometry._11_21), dot(prev, transform_geometry._12_22));
q_prev = normalize(q_prev);
q_next.x = dot(next, transform_geometry._11_21);
q_next.y = dot(next, transform_geometry._12_22);
q_next = float2(dot(next, transform_geometry._11_21), dot(next, transform_geometry._12_22));
q_next = normalize(q_next);
/* tan(½θ) = sin(θ) / (1 + cos(θ))
......@@ -1930,21 +1928,19 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
v_p = float2(-q_prev.y, q_prev.x);
l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));
q_i = l * q_prev + v_p;
if (l < 0.0f)
q_i *= -1.0f;
position = mul(float3(position, 1.0f), transform_geometry) + stroke_width * 0.5f * q_i;
return float4(mul(float2x3(transform_rtx.xyz * transform_rtx.w, transform_rty.xyz * transform_rty.w),
float3(position.xy, 1.0f)) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
}
#endif
0x43425844, 0xb58748c9, 0x99343e01, 0x92198e38, 0x667ab784, 0x00000001, 0x000004c0, 0x00000003,
0x43425844, 0xe88f7af5, 0x480b101b, 0xfd80f66b, 0xd878e0b8, 0x00000001, 0x0000047c, 0x00000003,
0x0000002c, 0x00000098, 0x000000cc, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000059, 0x00000000, 0x00000000,
0x00000003, 0x00000001, 0x00000303, 0x0000005e, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
0x00000303, 0x49534f50, 0x4e4f4954, 0x45525000, 0x454e0056, 0xab005458, 0x4e47534f, 0x0000002c,
0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000003ec, 0x00010040, 0x000000fb, 0x04000059,
0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x000003a8, 0x00010040, 0x000000ea, 0x04000059,
0x00208e46, 0x00000000, 0x00000004, 0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x00101032,
0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
0x02000068, 0x00000003, 0x0800000f, 0x00100012, 0x00000000, 0x00101046, 0x00000002, 0x00208046,
......@@ -1960,22 +1956,20 @@ HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_target,
0x00000000, 0x00100a26, 0x00000001, 0x00100046, 0x00000000, 0x0700000f, 0x00100012, 0x00000000,
0x00100046, 0x00000001, 0x00100046, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010000a,
0x00000000, 0x00004001, 0x3f800000, 0x0800000e, 0x00100012, 0x00000000, 0x8010002a, 0x00000041,
0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100062, 0x00000000, 0x00100006, 0x00000000,
0x00100106, 0x00000001, 0x00100cf6, 0x00000001, 0x07000031, 0x00100012, 0x00000000, 0x0010000a,
0x00000000, 0x00004001, 0x00000000, 0x0a000037, 0x00100032, 0x00000000, 0x00100006, 0x00000000,
0x80100596, 0x00000041, 0x00000000, 0x00100596, 0x00000000, 0x08000038, 0x00100042, 0x00000000,
0x0020803a, 0x00000000, 0x00000001, 0x00004001, 0x3f000000, 0x05000036, 0x00100032, 0x00000001,
0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010,
0x00100012, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x08000010,
0x00100022, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001, 0x09000032,
0x00100032, 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002,
0x09000038, 0x00100072, 0x00000001, 0x00208ff6, 0x00000000, 0x00000002, 0x00208246, 0x00000000,
0x00000002, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x07000010, 0x00100012,
0x00000001, 0x00100246, 0x00000001, 0x00100246, 0x00000000, 0x09000038, 0x00100072, 0x00000002,
0x00208ff6, 0x00000000, 0x00000003, 0x00208246, 0x00000000, 0x00000003, 0x07000010, 0x00100022,
0x00000001, 0x00100246, 0x00000002, 0x00100246, 0x00000000, 0x0a000000, 0x00102032, 0x00000000,
0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036,
0x001020c2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100032, 0x00000000, 0x00100006, 0x00000000,
0x00100046, 0x00000001, 0x00100f36, 0x00000001, 0x08000038, 0x00100042, 0x00000000, 0x0020803a,
0x00000000, 0x00000001, 0x00004001, 0x3f000000, 0x05000036, 0x00100032, 0x00000001, 0x00101046,
0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012,
0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00100022,
0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001, 0x09000032, 0x00100032,
0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x09000038,
0x00100072, 0x00000001, 0x00208ff6, 0x00000000, 0x00000002, 0x00208246, 0x00000000, 0x00000002,
0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x07000010, 0x00100012, 0x00000001,
0x00100246, 0x00000001, 0x00100246, 0x00000000, 0x09000038, 0x00100072, 0x00000002, 0x00208ff6,
0x00000000, 0x00000003, 0x00208246, 0x00000000, 0x00000003, 0x07000010, 0x00100022, 0x00000001,
0x00100246, 0x00000002, 0x00100246, 0x00000000, 0x0a000000, 0x00102032, 0x00000000, 0x00100046,
0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x001020c2,
0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e,
};
static const DWORD vs_code_triangle[] =
{
......
......@@ -3680,6 +3680,7 @@ static void test_draw_geometry(void)
ID2D1GeometrySink_SetFillMode(sink, D2D1_FILL_MODE_ALTERNATE);
hr = ID2D1GeometrySink_Close(sink);
ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr);
ID2D1GeometrySink_Release(sink);
ID2D1RenderTarget_BeginDraw(rt);
......@@ -3738,7 +3739,7 @@ static void test_draw_geometry(void)
"CgIKiwEUjAEUjQESjgESjwEQkAEQkQEOkgEOkwEMlAEMlQEKlgEKlwEImAEImQEGmgEGmwEEnAEE"
"nQECngECrycA");
ok(match, "Figure does not match.\n");
match = compare_figure(surface, 320, 320, 160, 160, 0xff652e89, 2,
match = compare_figure(surface, 320, 320, 160, 160, 0xff652e89, 0,
"rycCngECnQEEnAEEmwEGmgEGmQEImAEIlwEKlgEKlQEMlAEMkwEOkgEOkQEQkAEQjwESjgESjQEU"
"jAEUiwEKAgqKAQoCCokBCgQKiAEKBAqHAQoGCoYBCgYKhQEKCAqEAQoICoMBCgoKggEKCgqBAQoM"
"CoABCgwKfwoOCn4KDgp9ChAKfAoQCnsKEgp6ChIKeQoUCngKFAp3ChYKdgoWCnUKGAp0ChgKcwoa"
......
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