From 24dc5c740944d6499835e38a949cf4a8ac7208ab Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 28 Sep 2017 13:14:18 +0200 Subject: [PATCH] d2d1: Implement radial gradient brushes. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d2d1/brush.c | 62 +++++++- dlls/d2d1/d2d1_private.h | 14 ++ dlls/d2d1/geometry.c | 5 - dlls/d2d1/render_target.c | 289 ++++++++++++++++++++++++++++---------- dlls/d2d1/tests/d2d1.c | 215 ++++++++++++++++++++++++++++ 5 files changed, 500 insertions(+), 85 deletions(-) diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index b6a47870622..ba07006c58f 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -225,6 +225,11 @@ static struct d2d_gradient *unsafe_impl_from_ID2D1GradientStopCollection(ID2D1Gr return CONTAINING_RECORD(iface, struct d2d_gradient, ID2D1GradientStopCollection_iface); } +static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D10Device *device, unsigned int brush_idx) +{ + ID3D10Device_PSSetShaderResources(device, 2 + brush_idx, 1, &gradient->view); +} + static void d2d_brush_destroy(struct d2d_brush *brush) { ID2D1Factory_Release(brush->factory); @@ -1083,10 +1088,12 @@ static D3D10_TEXTURE_ADDRESS_MODE texture_address_mode_from_extend_mode(D2D1_EXT static BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, const struct d2d_d3d_render_target *render_target, struct d2d_brush_cb *cb) { + float theta, sin_theta, cos_theta; + float dpi_scale, d, s1, s2, t, u; struct d2d_bitmap *bitmap; + D2D1_POINT_2F v_p, v_q; D2D1_COLOR_F *colour; D2D_MATRIX_3X2_F b; - float dpi_scale, d; if (!brush) { @@ -1117,6 +1124,48 @@ static BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, return TRUE; + case D2D_BRUSH_TYPE_RADIAL: + b = brush->transform; + d2d_point_transform(&cb->u.radial.centre, &b, brush->u.radial.centre.x, brush->u.radial.centre.y); + b._31 = b._32 = 0.0f; + d2d_point_transform(&cb->u.radial.offset, &b, brush->u.radial.offset.x, brush->u.radial.offset.y); + + /* After a transformation, the axes of the ellipse are no longer + * necessarily orthogonal, but they are conjugate diameters. + * + * A = ⎡a.x b.x⎤ + * ⎣a.y b.y⎦ + * + * = ⎡cos(θ) -sin(θ)⎤⎡σ₁ 0 ⎤⎡cos(φ) -sin(φ)⎤ + * ⎣sin(θ) cos(θ)⎦⎣0 σ₂⎦⎣sin(φ) cos(φ)⎦ + * + * a' = [σ₁· cos(θ) σ₁·sin(θ)] + * b' = [σ₂·-sin(θ) σ₂·cos(θ)] */ + + d2d_point_set(&v_p, brush->u.radial.radius.x * b._11, brush->u.radial.radius.y * b._21); + d2d_point_set(&v_q, brush->u.radial.radius.x * b._12, brush->u.radial.radius.y * b._22); + + t = 0.5f * d2d_point_dot(&v_p, &v_p); + u = 0.5f * d2d_point_dot(&v_q, &v_q); + s1 = t + u; + + t = t - u; + u = d2d_point_dot(&v_p, &v_q); + s2 = sqrtf(t * t + u * u); + + theta = 0.5f * atan2(u, t); + sin_theta = sinf(theta); + cos_theta = cosf(theta); + + t = sqrtf(s1 + s2); + d2d_point_set(&cb->u.radial.ra, t * cos_theta, t * sin_theta); + t = sqrtf(s1 - s2); + d2d_point_set(&cb->u.radial.rb, t * -sin_theta, t * cos_theta); + + cb->u.radial.stop_count = brush->u.linear.gradient->stop_count; + + return TRUE; + case D2D_BRUSH_TYPE_BITMAP: bitmap = brush->u.bitmap.bitmap; @@ -1183,11 +1232,6 @@ HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_b return hr; } -static void d2d_brush_bind_gradient(struct d2d_brush *brush, ID3D10Device *device, unsigned int brush_idx) -{ - ID3D10Device_PSSetShaderResources(device, 2 + brush_idx, 1, &brush->u.linear.gradient->view); -} - static void d2d_brush_bind_bitmap(struct d2d_brush *brush, ID3D10Device *device, unsigned int brush_idx) { HRESULT hr; @@ -1229,7 +1273,11 @@ void d2d_brush_bind_resources(struct d2d_brush *brush, ID3D10Device *device, uns break; case D2D_BRUSH_TYPE_LINEAR: - d2d_brush_bind_gradient(brush, device, brush_idx); + d2d_gradient_bind(brush->u.linear.gradient, device, brush_idx); + break; + + case D2D_BRUSH_TYPE_RADIAL: + d2d_gradient_bind(brush->u.radial.gradient, device, brush_idx); break; case D2D_BRUSH_TYPE_BITMAP: diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 9a4649007de..98298f892ad 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -89,6 +89,15 @@ struct d2d_brush_cb unsigned int stop_count; } linear; struct + { + D2D1_POINT_2F centre; + D2D1_POINT_2F offset; + D2D1_POINT_2F ra; + D2D1_POINT_2F rb; + unsigned int stop_count; + float pad[3]; + } radial; + struct { float _11, _21, _31, pad; float _12, _22, _32; @@ -496,6 +505,11 @@ static inline void d2d_point_set(D2D1_POINT_2F *dst, float x, float y) dst->y = y; } +static inline float d2d_point_dot(const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1) +{ + return p0->x * p1->x + p0->y * p1->y; +} + static inline void d2d_point_transform(D2D1_POINT_2F *dst, const D2D1_MATRIX_3X2_F *matrix, float x, float y) { dst->x = x * matrix->_11 + y * matrix->_21 + matrix->_31; diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c index a9588985642..ab5a0b59298 100644 --- a/dlls/d2d1/geometry.c +++ b/dlls/d2d1/geometry.c @@ -406,11 +406,6 @@ static void d2d_point_calculate_bezier(D2D1_POINT_2F *out, const D2D1_POINT_2F * out->y = t_c * (t_c * p0->y + t * p1->y) + t * (t_c * p1->y + t * p2->y); } -static float d2d_point_dot(const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1) -{ - return p0->x * p1->x + p0->y * p1->y; -} - static void d2d_point_normalise(D2D1_POINT_2F *p) { float l; diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index 2f41f44309d..0c44014ae18 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -2582,7 +2582,7 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t { uint type; float opacity; - float4 data[2]; + float4 data[3]; } colour_brush, opacity_brush; SamplerState s0, s1; @@ -2596,12 +2596,39 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; }; - float4 brush_linear(struct brush brush, Buffer b, float2 position) + float4 sample_gradient(Buffer gradient, uint stop_count, float position) + { + float4 c_low, c_high; + float p_low, p_high; + uint i; + + p_low = gradient.Load(0).x; + c_low = gradient.Load(1); + c_high = c_low; + + if (position < p_low) + return c_low; + + for (i = 1; i < stop_count; ++i) + { + p_high = gradient.Load(i * 2).x; + c_high = gradient.Load(i * 2 + 1); + + if (position >= p_low && position <= p_high) + return lerp(c_low, c_high, (position - p_low) / (p_high - p_low)); + + p_low = p_high; + c_low = c_high; + } + + return c_high; + } + + float4 brush_linear(struct brush brush, Buffer gradient, float2 position) { float2 start, end, v_p, v_q; - float p, p_low, p_high; - float4 c_low, c_high; - uint stop_count, i; + uint stop_count; + float p; start = brush.data[0].xy; end = brush.data[0].zw; @@ -2611,26 +2638,40 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t v_q = end - start; p = dot(v_q, v_p) / dot(v_q, v_q); - p_low = b.Load(0).x; - c_low = b.Load(1); - c_high = c_low; + return sample_gradient(gradient, stop_count, p); + } - if (p < p_low) - return c_low; + float4 brush_radial(struct brush brush, Buffer gradient, float2 position) + { + float2 centre, offset, ra, rb, v_p, v_q, r; + float b, c, l, t; + uint stop_count; - for (i = 1; i < stop_count; ++i) - { - p_high = b.Load(i * 2).x; - c_high = b.Load(i * 2 + 1); + centre = brush.data[0].xy; + offset = brush.data[0].zw; + ra = brush.data[1].xy; + rb = brush.data[1].zw; + stop_count = asuint(brush.data[2].x); - if (p >= p_low && p <= p_high) - return lerp(c_low, c_high, (p - p_low) / (p_high - p_low)); + /* Project onto ra, rb. */ + r = float2(dot(ra, ra), dot(rb, rb)); + v_p = position - (centre + offset); + v_p = float2(dot(v_p, ra), dot(v_p, rb)) / r; + v_q = float2(dot(offset, ra), dot(offset, rb)) / r; - p_low = p_high; - c_low = c_high; - } + /* ‖t·p̂ + q⃑‖ = 1 + * (t·p̂ + q⃑) · (t·p̂ + q⃑) = 1 + * t² + 2·(p̂·q⃑)·t + (q⃑·q⃑) = 1 + * + * b = p̂·q⃑ + * c = q⃑·q⃑ - 1 + * t = -b + √(b² - c) */ + l = length(v_p); + b = dot(v_p, v_q) / l; + c = dot(v_q, v_q) - 1.0; + t = -b + sqrt(b * b - c); - return c_high; + return sample_gradient(gradient, stop_count, l / t); } float4 brush_bitmap(struct brush brush, Texture2D t, SamplerState s, float2 position) @@ -2658,6 +2699,8 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t return brush.data[0] * brush.opacity; if (brush.type == BRUSH_TYPE_LINEAR) return brush_linear(brush, b, position) * brush.opacity; + if (brush.type == BRUSH_TYPE_RADIAL) + return brush_radial(brush, b, position) * brush.opacity; if (brush.type == BRUSH_TYPE_BITMAP) return brush_bitmap(brush, t, s, position) * brush.opacity; return float4(0.0, 0.0, 0.0, brush.opacity); @@ -2703,15 +2746,15 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t return colour; } #endif - 0x43425844, 0x6387f851, 0xd0684a53, 0xfac88e1c, 0xb2e1e70c, 0x00000001, 0x00001094, 0x00000003, + 0x43425844, 0xf3cbb8bd, 0x5f286454, 0x139976a7, 0x6817e876, 0x00000001, 0x00001d18, 0x00000003, 0x0000002c, 0x000000c4, 0x000000f8, 0x4e475349, 0x00000090, 0x00000004, 0x00000008, 0x00000068, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000077, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000f0f, 0x0000007e, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000303, 0x0000007e, 0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e, 0xab004d52, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, - 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000f94, - 0x00000040, 0x000003e5, 0x04000059, 0x00208e46, 0x00000000, 0x00000007, 0x0300005a, 0x00106000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00001c18, + 0x00000040, 0x00000706, 0x04000059, 0x00208e46, 0x00000000, 0x00000009, 0x0300005a, 0x00106000, 0x00000000, 0x0300005a, 0x00106000, 0x00000001, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04000858, 0x00107000, 0x00000002, 0x00005555, 0x04000858, 0x00107000, 0x00000003, 0x00005555, 0x03001062, 0x00101032, 0x00000000, 0x03001062, @@ -2755,6 +2798,56 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t 0x00100e46, 0x00000004, 0x00100e46, 0x00000006, 0x01000015, 0x08000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000003, 0x00208556, 0x00000000, 0x00000001, 0x01000015, 0x0300001f, 0x0010000a, 0x00000001, 0x08000020, 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000001, 0x00004001, + 0x00000002, 0x0304001f, 0x0010000a, 0x00000001, 0x0900000f, 0x00100012, 0x00000002, 0x00208046, + 0x00000000, 0x00000003, 0x00208046, 0x00000000, 0x00000003, 0x0900000f, 0x00100022, 0x00000002, + 0x00208ae6, 0x00000000, 0x00000003, 0x00208ae6, 0x00000000, 0x00000003, 0x09000000, 0x00100062, + 0x00000001, 0x00208ba6, 0x00000000, 0x00000002, 0x00208106, 0x00000000, 0x00000002, 0x08000000, + 0x00100062, 0x00000001, 0x80100656, 0x00000041, 0x00000001, 0x00101106, 0x00000000, 0x0800000f, + 0x00100012, 0x00000003, 0x00100596, 0x00000001, 0x00208046, 0x00000000, 0x00000003, 0x0800000f, + 0x00100022, 0x00000003, 0x00100596, 0x00000001, 0x00208ae6, 0x00000000, 0x00000003, 0x0700000e, + 0x00100062, 0x00000001, 0x00100106, 0x00000003, 0x00100106, 0x00000002, 0x0900000f, 0x00100012, + 0x00000003, 0x00208ae6, 0x00000000, 0x00000002, 0x00208046, 0x00000000, 0x00000003, 0x0900000f, + 0x00100022, 0x00000003, 0x00208ae6, 0x00000000, 0x00000002, 0x00208ae6, 0x00000000, 0x00000003, + 0x0700000e, 0x00100032, 0x00000002, 0x00100046, 0x00000003, 0x00100046, 0x00000002, 0x0700000f, + 0x00100082, 0x00000001, 0x00100596, 0x00000001, 0x00100596, 0x00000001, 0x0500004b, 0x00100082, + 0x00000001, 0x0010003a, 0x00000001, 0x0700000f, 0x00100022, 0x00000001, 0x00100596, 0x00000001, + 0x00100046, 0x00000002, 0x0700000e, 0x00100022, 0x00000001, 0x0010001a, 0x00000001, 0x0010003a, + 0x00000001, 0x0700000f, 0x00100042, 0x00000001, 0x00100046, 0x00000002, 0x00100046, 0x00000002, + 0x07000000, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, 0x00004001, 0xbf800000, 0x0a000032, + 0x00100042, 0x00000001, 0x0010001a, 0x00000001, 0x0010001a, 0x00000001, 0x8010002a, 0x00000041, + 0x00000001, 0x0500004b, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, 0x08000000, 0x00100022, + 0x00000001, 0x0010002a, 0x00000001, 0x8010001a, 0x00000041, 0x00000001, 0x0700000e, 0x00100022, + 0x00000001, 0x0010003a, 0x00000001, 0x0010001a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002, + 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000002, 0x0a00002d, + 0x001000f2, 0x00000003, 0x00004002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46, + 0x00000002, 0x0700001d, 0x00100042, 0x00000001, 0x0010001a, 0x00000001, 0x0010000a, 0x00000002, + 0x0304001f, 0x0010002a, 0x00000001, 0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000003, + 0x05000036, 0x001000f2, 0x00000005, 0x00100e46, 0x00000003, 0x05000036, 0x001000f2, 0x00000006, + 0x00100e46, 0x00000003, 0x05000036, 0x00100042, 0x00000001, 0x0010000a, 0x00000002, 0x05000036, + 0x00100082, 0x00000001, 0x00004001, 0x00000001, 0x05000036, 0x00100022, 0x00000002, 0x00004001, + 0x00000000, 0x01000030, 0x08000050, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x0020800a, + 0x00000000, 0x00000004, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0x00000000, 0x03040003, + 0x0010002a, 0x00000002, 0x07000029, 0x00100042, 0x00000002, 0x0010003a, 0x00000001, 0x00004001, + 0x00000001, 0x0700002d, 0x001000f2, 0x00000007, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002, + 0x0700001e, 0x00100042, 0x00000002, 0x0010002a, 0x00000002, 0x00004001, 0x00000001, 0x0700002d, + 0x001000f2, 0x00000008, 0x00100aa6, 0x00000002, 0x00107e46, 0x00000002, 0x0700001d, 0x00100042, + 0x00000002, 0x0010001a, 0x00000001, 0x0010002a, 0x00000001, 0x0700001d, 0x00100082, 0x00000002, + 0x0010000a, 0x00000007, 0x0010001a, 0x00000001, 0x07000001, 0x00100042, 0x00000002, 0x0010003a, + 0x00000002, 0x0010002a, 0x00000002, 0x0304001f, 0x0010002a, 0x00000002, 0x08000000, 0x00100082, + 0x00000002, 0x8010002a, 0x00000041, 0x00000001, 0x0010001a, 0x00000001, 0x08000000, 0x00100022, + 0x00000007, 0x8010002a, 0x00000041, 0x00000001, 0x0010000a, 0x00000007, 0x0700000e, 0x00100082, + 0x00000002, 0x0010003a, 0x00000002, 0x0010001a, 0x00000007, 0x08000000, 0x001000f2, 0x00000009, + 0x80100e46, 0x00000041, 0x00000005, 0x00100e46, 0x00000008, 0x09000032, 0x001000f2, 0x00000009, + 0x00100ff6, 0x00000002, 0x00100e46, 0x00000009, 0x00100e46, 0x00000005, 0x05000036, 0x001000f2, + 0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002, 0x00004001, 0xffffffff, + 0x05000036, 0x001000f2, 0x00000004, 0x00100e46, 0x00000009, 0x01000002, 0x01000015, 0x05000036, + 0x001000f2, 0x00000005, 0x00100e46, 0x00000008, 0x05000036, 0x00100042, 0x00000001, 0x0010000a, + 0x00000007, 0x0700001e, 0x00100082, 0x00000001, 0x0010003a, 0x00000001, 0x00004001, 0x00000001, + 0x05000036, 0x001000f2, 0x00000006, 0x00100e46, 0x00000008, 0x05000036, 0x00100022, 0x00000002, + 0x0010002a, 0x00000002, 0x01000016, 0x09000037, 0x001000f2, 0x00000003, 0x00100556, 0x00000002, + 0x00100e46, 0x00000004, 0x00100e46, 0x00000006, 0x01000015, 0x08000038, 0x001000f2, 0x00000000, + 0x00100e46, 0x00000003, 0x00208556, 0x00000000, 0x00000001, 0x01000015, 0x0300001f, 0x0010000a, + 0x00000001, 0x08000020, 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000001, 0x00004001, 0x00000003, 0x0304001f, 0x0010000a, 0x00000001, 0x0800000f, 0x00100022, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x08000000, 0x00100012, 0x00000002, 0x0010001a, 0x00000001, 0x0020802a, 0x00000000, 0x00000002, 0x0800000f, 0x00100022, 0x00000001, 0x00101046, @@ -2765,77 +2858,127 @@ static HRESULT d2d_d3d_render_target_init(struct d2d_d3d_render_target *render_t 0x001000f2, 0x00000000, 0x00100e46, 0x00000002, 0x00208556, 0x00000000, 0x00000001, 0x01000015, 0x05000036, 0x00100012, 0x00000002, 0x00004001, 0x00000000, 0x06000036, 0x00100082, 0x00000002, 0x0020801a, 0x00000000, 0x00000001, 0x09000037, 0x001000f2, 0x00000000, 0x00100006, 0x00000001, - 0x00100e46, 0x00000000, 0x00100c06, 0x00000002, 0x01000015, 0x01000015, 0x0800004f, 0x00100012, - 0x00000001, 0x0020800a, 0x00000000, 0x00000004, 0x00004001, 0x00000004, 0x0304001f, 0x0010000a, - 0x00000001, 0x09000038, 0x00100012, 0x00000001, 0x0020801a, 0x00000000, 0x00000004, 0x0020803a, - 0x00000000, 0x00000005, 0x0404001f, 0x0020800a, 0x00000000, 0x00000004, 0x08000020, 0x00100022, - 0x00000001, 0x0020800a, 0x00000000, 0x00000004, 0x00004001, 0x00000001, 0x0304001f, 0x0010001a, - 0x00000001, 0x09000000, 0x001000c2, 0x00000001, 0x00101406, 0x00000000, 0x80208406, 0x00000041, - 0x00000000, 0x00000005, 0x0a000000, 0x00100032, 0x00000002, 0x80208046, 0x00000041, 0x00000000, - 0x00000005, 0x00208ae6, 0x00000000, 0x00000005, 0x0700000f, 0x00100042, 0x00000001, 0x00100046, - 0x00000002, 0x00100ae6, 0x00000001, 0x0700000f, 0x00100082, 0x00000001, 0x00100046, 0x00000002, - 0x00100046, 0x00000002, 0x0700000e, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, 0x0010003a, + 0x00100e46, 0x00000000, 0x00100c06, 0x00000002, 0x01000015, 0x01000015, 0x01000015, 0x0800004f, + 0x00100012, 0x00000001, 0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000004, 0x0304001f, + 0x0010000a, 0x00000001, 0x09000038, 0x00100012, 0x00000001, 0x0020801a, 0x00000000, 0x00000005, + 0x0020803a, 0x00000000, 0x00000006, 0x0404001f, 0x0020800a, 0x00000000, 0x00000005, 0x08000020, + 0x00100022, 0x00000001, 0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000001, 0x0304001f, + 0x0010001a, 0x00000001, 0x09000000, 0x001000c2, 0x00000001, 0x00101406, 0x00000000, 0x80208406, + 0x00000041, 0x00000000, 0x00000006, 0x0a000000, 0x00100032, 0x00000002, 0x80208046, 0x00000041, + 0x00000000, 0x00000006, 0x00208ae6, 0x00000000, 0x00000006, 0x0700000f, 0x00100042, 0x00000001, + 0x00100046, 0x00000002, 0x00100ae6, 0x00000001, 0x0700000f, 0x00100082, 0x00000001, 0x00100046, + 0x00000002, 0x00100046, 0x00000002, 0x0700000e, 0x00100042, 0x00000001, 0x0010002a, 0x00000001, + 0x0010003a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002, 0x00004002, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00107e46, 0x00000003, 0x0a00002d, 0x001000f2, 0x00000003, 0x00004002, + 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46, 0x00000003, 0x0700001d, 0x00100082, + 0x00000001, 0x0010002a, 0x00000001, 0x0010000a, 0x00000002, 0x0304001f, 0x0010003a, 0x00000001, + 0x05000036, 0x00100082, 0x00000001, 0x0010003a, 0x00000003, 0x05000036, 0x00100062, 0x00000002, + 0x00100ff6, 0x00000003, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000002, 0x08000036, + 0x00100032, 0x00000003, 0x00004002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x01000030, + 0x08000050, 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x0020800a, 0x00000000, 0x00000007, + 0x05000036, 0x00100022, 0x00000003, 0x00004001, 0x00000000, 0x03040003, 0x0010002a, 0x00000003, + 0x07000029, 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, + 0x001000f2, 0x00000004, 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001e, 0x00100042, + 0x00000003, 0x0010002a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2, 0x00000005, + 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001d, 0x00100042, 0x00000003, 0x0010002a, + 0x00000001, 0x0010003a, 0x00000002, 0x0700001d, 0x00100022, 0x00000004, 0x0010000a, 0x00000004, + 0x0010002a, 0x00000001, 0x07000001, 0x00100042, 0x00000003, 0x0010002a, 0x00000003, 0x0010001a, + 0x00000004, 0x0304001f, 0x0010002a, 0x00000003, 0x08000000, 0x00100022, 0x00000004, 0x0010002a, + 0x00000001, 0x8010003a, 0x00000041, 0x00000002, 0x08000000, 0x00100042, 0x00000004, 0x8010003a, + 0x00000041, 0x00000002, 0x0010000a, 0x00000004, 0x0700000e, 0x00100022, 0x00000004, 0x0010001a, + 0x00000004, 0x0010002a, 0x00000004, 0x08000000, 0x00100042, 0x00000004, 0x8010001a, 0x00000041, + 0x00000002, 0x0010003a, 0x00000005, 0x09000032, 0x00100022, 0x00000004, 0x0010001a, 0x00000004, + 0x0010002a, 0x00000004, 0x0010001a, 0x00000002, 0x05000036, 0x00100042, 0x00000002, 0x0010003a, + 0x00000005, 0x05000036, 0x00100022, 0x00000003, 0x00004001, 0xffffffff, 0x05000036, 0x00100082, + 0x00000001, 0x0010001a, 0x00000004, 0x01000002, 0x01000015, 0x05000036, 0x00100022, 0x00000002, + 0x0010003a, 0x00000005, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000004, 0x0700001e, + 0x00100012, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x05000036, 0x00100042, + 0x00000002, 0x0010003a, 0x00000005, 0x05000036, 0x00100032, 0x00000003, 0x00100086, 0x00000003, + 0x01000016, 0x09000037, 0x00100042, 0x00000001, 0x0010001a, 0x00000003, 0x0010003a, 0x00000001, + 0x0010002a, 0x00000002, 0x01000012, 0x05000036, 0x00100042, 0x00000001, 0x0010003a, 0x00000003, + 0x01000015, 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, 0x00000000, + 0x00000005, 0x01000015, 0x0300001f, 0x0010001a, 0x00000001, 0x08000020, 0x00100022, 0x00000001, + 0x0020800a, 0x00000000, 0x00000005, 0x00004001, 0x00000002, 0x0304001f, 0x0010001a, 0x00000001, + 0x0900000f, 0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000007, 0x00208046, 0x00000000, + 0x00000007, 0x0900000f, 0x00100022, 0x00000002, 0x00208ae6, 0x00000000, 0x00000007, 0x00208ae6, + 0x00000000, 0x00000007, 0x09000000, 0x001000c2, 0x00000001, 0x00208ea6, 0x00000000, 0x00000006, + 0x00208406, 0x00000000, 0x00000006, 0x08000000, 0x001000c2, 0x00000001, 0x80100ea6, 0x00000041, + 0x00000001, 0x00101406, 0x00000000, 0x0800000f, 0x00100012, 0x00000003, 0x00100ae6, 0x00000001, + 0x00208046, 0x00000000, 0x00000007, 0x0800000f, 0x00100022, 0x00000003, 0x00100ae6, 0x00000001, + 0x00208ae6, 0x00000000, 0x00000007, 0x0700000e, 0x001000c2, 0x00000001, 0x00100406, 0x00000003, + 0x00100406, 0x00000002, 0x0900000f, 0x00100012, 0x00000003, 0x00208ae6, 0x00000000, 0x00000006, + 0x00208046, 0x00000000, 0x00000007, 0x0900000f, 0x00100022, 0x00000003, 0x00208ae6, 0x00000000, + 0x00000006, 0x00208ae6, 0x00000000, 0x00000007, 0x0700000e, 0x00100032, 0x00000002, 0x00100046, + 0x00000003, 0x00100046, 0x00000002, 0x0700000f, 0x00100042, 0x00000002, 0x00100ae6, 0x00000001, + 0x00100ae6, 0x00000001, 0x0500004b, 0x00100042, 0x00000002, 0x0010002a, 0x00000002, 0x0700000f, + 0x00100042, 0x00000001, 0x00100ae6, 0x00000001, 0x00100046, 0x00000002, 0x0700000e, 0x00100042, + 0x00000001, 0x0010002a, 0x00000001, 0x0010002a, 0x00000002, 0x0700000f, 0x00100082, 0x00000001, + 0x00100046, 0x00000002, 0x00100046, 0x00000002, 0x07000000, 0x00100082, 0x00000001, 0x0010003a, + 0x00000001, 0x00004001, 0xbf800000, 0x0a000032, 0x00100082, 0x00000001, 0x0010002a, 0x00000001, + 0x0010002a, 0x00000001, 0x8010003a, 0x00000041, 0x00000001, 0x0500004b, 0x00100082, 0x00000001, + 0x0010003a, 0x00000001, 0x08000000, 0x00100042, 0x00000001, 0x0010003a, 0x00000001, 0x8010002a, + 0x00000041, 0x00000001, 0x0700000e, 0x00100042, 0x00000001, 0x0010002a, 0x00000002, 0x0010002a, 0x00000001, 0x0a00002d, 0x001000f2, 0x00000002, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000003, 0x0a00002d, 0x001000f2, 0x00000003, 0x00004002, 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00107e46, 0x00000003, 0x0700001d, 0x00100082, 0x00000001, 0x0010002a, 0x00000001, 0x0010000a, 0x00000002, 0x0304001f, 0x0010003a, 0x00000001, 0x05000036, - 0x00100082, 0x00000001, 0x0010003a, 0x00000003, 0x05000036, 0x00100022, 0x00000002, 0x0010000a, - 0x00000002, 0x05000036, 0x001000c2, 0x00000002, 0x00100ff6, 0x00000003, 0x08000036, 0x00100032, + 0x00100082, 0x00000001, 0x0010003a, 0x00000003, 0x05000036, 0x00100062, 0x00000002, 0x00100ff6, + 0x00000003, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000002, 0x08000036, 0x00100032, 0x00000003, 0x00004002, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x01000030, 0x08000050, - 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x0020800a, 0x00000000, 0x00000006, 0x05000036, + 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x0020800a, 0x00000000, 0x00000008, 0x05000036, 0x00100022, 0x00000003, 0x00004001, 0x00000000, 0x03040003, 0x0010002a, 0x00000003, 0x07000029, 0x00100042, 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2, 0x00000004, 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001e, 0x00100042, 0x00000003, 0x0010002a, 0x00000003, 0x00004001, 0x00000001, 0x0700002d, 0x001000f2, 0x00000005, 0x00100aa6, 0x00000003, 0x00107e46, 0x00000003, 0x0700001d, 0x00100042, 0x00000003, 0x0010002a, 0x00000001, - 0x0010001a, 0x00000002, 0x0700001d, 0x00100022, 0x00000004, 0x0010000a, 0x00000004, 0x0010002a, + 0x0010003a, 0x00000002, 0x0700001d, 0x00100022, 0x00000004, 0x0010000a, 0x00000004, 0x0010002a, 0x00000001, 0x07000001, 0x00100042, 0x00000003, 0x0010002a, 0x00000003, 0x0010001a, 0x00000004, 0x0304001f, 0x0010002a, 0x00000003, 0x08000000, 0x00100022, 0x00000004, 0x0010002a, 0x00000001, - 0x8010001a, 0x00000041, 0x00000002, 0x08000000, 0x00100042, 0x00000004, 0x8010001a, 0x00000041, + 0x8010003a, 0x00000041, 0x00000002, 0x08000000, 0x00100042, 0x00000004, 0x8010003a, 0x00000041, 0x00000002, 0x0010000a, 0x00000004, 0x0700000e, 0x00100022, 0x00000004, 0x0010001a, 0x00000004, - 0x0010002a, 0x00000004, 0x08000000, 0x00100042, 0x00000004, 0x8010002a, 0x00000041, 0x00000002, + 0x0010002a, 0x00000004, 0x08000000, 0x00100042, 0x00000004, 0x8010001a, 0x00000041, 0x00000002, 0x0010003a, 0x00000005, 0x09000032, 0x00100022, 0x00000004, 0x0010001a, 0x00000004, 0x0010002a, - 0x00000004, 0x0010002a, 0x00000002, 0x05000036, 0x00100082, 0x00000002, 0x0010003a, 0x00000005, + 0x00000004, 0x0010001a, 0x00000002, 0x05000036, 0x00100042, 0x00000002, 0x0010003a, 0x00000005, 0x05000036, 0x00100022, 0x00000003, 0x00004001, 0xffffffff, 0x05000036, 0x00100082, 0x00000001, - 0x0010001a, 0x00000004, 0x01000002, 0x01000015, 0x05000036, 0x00100022, 0x00000002, 0x0010000a, - 0x00000004, 0x05000036, 0x00100042, 0x00000002, 0x0010003a, 0x00000005, 0x0700001e, 0x00100012, - 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x05000036, 0x00100082, 0x00000002, + 0x0010001a, 0x00000004, 0x01000002, 0x01000015, 0x05000036, 0x00100022, 0x00000002, 0x0010003a, + 0x00000005, 0x05000036, 0x00100082, 0x00000002, 0x0010000a, 0x00000004, 0x0700001e, 0x00100012, + 0x00000003, 0x0010000a, 0x00000003, 0x00004001, 0x00000001, 0x05000036, 0x00100042, 0x00000002, 0x0010003a, 0x00000005, 0x05000036, 0x00100032, 0x00000003, 0x00100086, 0x00000003, 0x01000016, - 0x09000037, 0x00100042, 0x00000001, 0x0010001a, 0x00000003, 0x0010003a, 0x00000001, 0x0010003a, + 0x09000037, 0x00100042, 0x00000001, 0x0010001a, 0x00000003, 0x0010003a, 0x00000001, 0x0010002a, 0x00000002, 0x01000012, 0x05000036, 0x00100042, 0x00000001, 0x0010003a, 0x00000003, 0x01000015, - 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, 0x00000000, 0x00000004, + 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, 0x00000000, 0x00000005, 0x01000015, 0x0300001f, 0x0010001a, 0x00000001, 0x08000020, 0x00100022, 0x00000001, 0x0020800a, - 0x00000000, 0x00000004, 0x00004001, 0x00000003, 0x0304001f, 0x0010001a, 0x00000001, 0x0800000f, - 0x00100042, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000005, 0x08000000, - 0x00100012, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000005, 0x0800000f, + 0x00000000, 0x00000005, 0x00004001, 0x00000003, 0x0304001f, 0x0010001a, 0x00000001, 0x0800000f, 0x00100042, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000006, 0x08000000, - 0x00100022, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000006, 0x09000045, + 0x00100012, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000006, 0x0800000f, + 0x00100042, 0x00000001, 0x00101046, 0x00000000, 0x00208046, 0x00000000, 0x00000007, 0x08000000, + 0x00100022, 0x00000002, 0x0010002a, 0x00000001, 0x0020802a, 0x00000000, 0x00000007, 0x09000045, 0x001000f2, 0x00000002, 0x00100046, 0x00000002, 0x00107e46, 0x00000001, 0x00106000, 0x00000001, - 0x0a000037, 0x00100042, 0x00000001, 0x0020803a, 0x00000000, 0x00000006, 0x00004001, 0x3f800000, + 0x0a000037, 0x00100042, 0x00000001, 0x0020803a, 0x00000000, 0x00000007, 0x00004001, 0x3f800000, 0x0010003a, 0x00000002, 0x08000038, 0x00100012, 0x00000001, 0x0010002a, 0x00000001, 0x0020801a, - 0x00000000, 0x00000004, 0x01000015, 0x0a000037, 0x00100012, 0x00000001, 0x0010001a, 0x00000001, - 0x0010000a, 0x00000001, 0x0020801a, 0x00000000, 0x00000004, 0x01000015, 0x01000015, 0x07000038, - 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100006, 0x00000001, 0x01000012, 0x05000036, - 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x01000015, 0x08000027, 0x00100012, 0x00000000, - 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000000, 0x0500003b, 0x00100022, 0x00000000, - 0x0010000a, 0x00000000, 0x0500000b, 0x00100032, 0x00000001, 0x00101046, 0x00000001, 0x0500000c, - 0x001000c2, 0x00000001, 0x00101406, 0x00000001, 0x07000000, 0x00100042, 0x00000000, 0x0010100a, - 0x00000001, 0x0010100a, 0x00000001, 0x0a000032, 0x001000c2, 0x00000000, 0x00100aa6, 0x00000000, - 0x00100806, 0x00000001, 0x80100d56, 0x00000041, 0x00000001, 0x0700000f, 0x00100012, 0x00000001, - 0x00100ae6, 0x00000000, 0x00101ae6, 0x00000001, 0x07000031, 0x00100012, 0x00000001, 0x0010000a, - 0x00000001, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, - 0x0010000a, 0x00000001, 0x0304000d, 0x0010000a, 0x00000001, 0x07000038, 0x00100032, 0x00000001, - 0x00100ff6, 0x00000000, 0x00101046, 0x00000003, 0x09000032, 0x001000c2, 0x00000000, 0x00101406, - 0x00000002, 0x00100aa6, 0x00000000, 0x00100406, 0x00000001, 0x0700000f, 0x00100042, 0x00000000, - 0x00100ae6, 0x00000000, 0x00100ae6, 0x00000000, 0x0500004b, 0x00100042, 0x00000000, 0x0010002a, - 0x00000000, 0x0a000032, 0x00100082, 0x00000000, 0x0010100a, 0x00000001, 0x0010100a, 0x00000001, - 0x8010101a, 0x00000041, 0x00000001, 0x08000000, 0x00100042, 0x00000000, 0x8010003a, 0x000000c1, - 0x00000000, 0x0010002a, 0x00000000, 0x07000031, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, - 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x0010002a, - 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x07000038, 0x00100012, 0x00000000, 0x0010003a, - 0x00000000, 0x0010102a, 0x00000001, 0x07000031, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, - 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, - 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x0100003e, + 0x00000000, 0x00000005, 0x01000015, 0x0a000037, 0x00100012, 0x00000001, 0x0010001a, 0x00000001, + 0x0010000a, 0x00000001, 0x0020801a, 0x00000000, 0x00000005, 0x01000015, 0x01000015, 0x01000015, + 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100006, 0x00000001, 0x01000012, + 0x05000036, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x01000015, 0x08000027, 0x00100012, + 0x00000000, 0x0020800a, 0x00000000, 0x00000000, 0x00004001, 0x00000000, 0x0500003b, 0x00100022, + 0x00000000, 0x0010000a, 0x00000000, 0x0500000b, 0x00100032, 0x00000001, 0x00101046, 0x00000001, + 0x0500000c, 0x001000c2, 0x00000001, 0x00101406, 0x00000001, 0x07000000, 0x00100042, 0x00000000, + 0x0010100a, 0x00000001, 0x0010100a, 0x00000001, 0x0a000032, 0x001000c2, 0x00000000, 0x00100aa6, + 0x00000000, 0x00100806, 0x00000001, 0x80100d56, 0x00000041, 0x00000001, 0x0700000f, 0x00100012, + 0x00000001, 0x00100ae6, 0x00000000, 0x00101ae6, 0x00000001, 0x07000031, 0x00100012, 0x00000001, + 0x0010000a, 0x00000001, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000001, 0x0010000a, + 0x00000000, 0x0010000a, 0x00000001, 0x0304000d, 0x0010000a, 0x00000001, 0x07000038, 0x00100032, + 0x00000001, 0x00100ff6, 0x00000000, 0x00101046, 0x00000003, 0x09000032, 0x001000c2, 0x00000000, + 0x00101406, 0x00000002, 0x00100aa6, 0x00000000, 0x00100406, 0x00000001, 0x0700000f, 0x00100042, + 0x00000000, 0x00100ae6, 0x00000000, 0x00100ae6, 0x00000000, 0x0500004b, 0x00100042, 0x00000000, + 0x0010002a, 0x00000000, 0x0a000032, 0x00100082, 0x00000000, 0x0010100a, 0x00000001, 0x0010100a, + 0x00000001, 0x8010101a, 0x00000041, 0x00000001, 0x08000000, 0x00100042, 0x00000000, 0x8010003a, + 0x000000c1, 0x00000000, 0x0010002a, 0x00000000, 0x07000031, 0x00100042, 0x00000000, 0x0010002a, + 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, + 0x0010002a, 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x07000038, 0x00100012, 0x00000000, + 0x0010003a, 0x00000000, 0x0010102a, 0x00000001, 0x07000031, 0x00100012, 0x00000000, 0x0010000a, + 0x00000000, 0x00004001, 0x00000000, 0x07000001, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, + 0x0010000a, 0x00000000, 0x0304000d, 0x0010000a, 0x00000000, 0x0100003e, }; static const struct shape_info { diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 6435dadb8ed..3a28e38d670 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -1901,6 +1901,220 @@ static void test_linear_brush(void) DestroyWindow(window); } +static void test_radial_brush(void) +{ + D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES gradient_properties; + ID2D1GradientStopCollection *gradient, *tmp_gradient; + ID2D1TransformedGeometry *transformed_geometry; + ID2D1RectangleGeometry *rectangle_geometry; + D2D1_MATRIX_3X2_F matrix, tmp_matrix; + ID2D1RadialGradientBrush *brush; + struct resource_readback rb; + IDXGISwapChain *swapchain; + ID2D1RenderTarget *rt; + ID3D10Device1 *device; + IDXGISurface *surface; + ID2D1Factory *factory; + D2D1_COLOR_F colour; + D2D1_POINT_2F p; + unsigned int i; + ULONG refcount; + D2D1_RECT_F r; + HWND window; + HRESULT hr; + float f; + + static const D2D1_GRADIENT_STOP stops[] = + { + {0.0f, {1.0f, 0.0f, 0.0f, 1.0f}}, + {0.5f, {0.0f, 1.0f, 0.0f, 1.0f}}, + {1.0f, {0.0f, 0.0f, 1.0f, 1.0f}}, + }; + static const struct + { + unsigned int x, y; + DWORD colour; + } + test1[] = + { + {80, 80, 0xff0000ff}, {240, 80, 0xff00a857}, {400, 80, 0xff00d728}, {560, 80, 0xff0000ff}, + {80, 240, 0xff006699}, {240, 240, 0xff29d600}, {400, 240, 0xff966900}, {560, 240, 0xff00a55a}, + {80, 400, 0xff0000ff}, {240, 400, 0xff006e91}, {400, 400, 0xff007d82}, {560, 400, 0xff0000ff}, + }, + test2[] = + { + { 40, 30, 0xff000df2}, {120, 30, 0xffffffff}, { 40, 60, 0xffffffff}, { 80, 60, 0xff00b04f}, + {120, 60, 0xff007689}, {200, 60, 0xffffffff}, { 40, 90, 0xffffffff}, {120, 90, 0xff47b800}, + {160, 90, 0xff00c13e}, {200, 90, 0xffffffff}, { 80, 120, 0xffffffff}, {120, 120, 0xff0000ff}, + {160, 120, 0xff6f9000}, {200, 120, 0xff00718e}, {240, 120, 0xffffffff}, {160, 150, 0xffffffff}, + {200, 150, 0xff00609f}, {240, 150, 0xffffffff}, {280, 150, 0xffffffff}, {320, 150, 0xffffffff}, + {240, 180, 0xffffffff}, {280, 180, 0xff4040ff}, {320, 180, 0xff40b788}, {380, 180, 0xffffffff}, + {200, 210, 0xffffffff}, {240, 210, 0xff4040ff}, {280, 210, 0xff4040ff}, {320, 210, 0xff76c940}, + {360, 210, 0xff40cc73}, {400, 210, 0xffffffff}, {200, 240, 0xffffffff}, {280, 240, 0xff4061de}, + {320, 240, 0xff9fa040}, {360, 240, 0xff404af5}, {440, 240, 0xffffffff}, {240, 270, 0xffffffff}, + {280, 270, 0xff40aa95}, {320, 270, 0xff4ef140}, {360, 270, 0xff4040ff}, {440, 270, 0xffffffff}, + {280, 300, 0xffffffff}, {320, 300, 0xff4093ac}, {360, 300, 0xff4040ff}, {400, 300, 0xff4040ff}, + {440, 300, 0xff404af5}, {480, 300, 0xff4045fa}, {520, 300, 0xff4040ff}, {280, 330, 0xffffffff}, + {360, 330, 0xffffffff}, {400, 330, 0xff4069d6}, {440, 330, 0xff40c579}, {480, 330, 0xff40e956}, + {520, 330, 0xff4072cd}, {400, 360, 0xff408ab4}, {440, 360, 0xff49f540}, {480, 360, 0xffb98640}, + {520, 360, 0xff40dc62}, {400, 390, 0xff405ee1}, {440, 390, 0xff40d56a}, {480, 390, 0xff62dd40}, + {520, 390, 0xff4059e6}, + }; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + window = create_window(); + swapchain = create_swapchain(device, window, TRUE); + hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); + ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); + rt = create_render_target(surface); + ok(!!rt, "Failed to create render target.\n"); + + ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); + ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); + + hr = ID2D1RenderTarget_CreateGradientStopCollection(rt, stops, sizeof(stops) / sizeof(*stops), + D2D1_GAMMA_2_2, D2D1_EXTEND_MODE_CLAMP, &gradient); + ok(SUCCEEDED(hr), "Failed to create stop collection, hr %#x.\n", hr); + + set_point(&gradient_properties.center, 160.0f, 480.0f); + set_point(&gradient_properties.gradientOriginOffset, 40.0f, -120.0f); + gradient_properties.radiusX = 160.0f; + gradient_properties.radiusY = 480.0f; + hr = ID2D1RenderTarget_CreateRadialGradientBrush(rt, &gradient_properties, NULL, gradient, &brush); + ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr); + + f = ID2D1RadialGradientBrush_GetOpacity(brush); + ok(f == 1.0f, "Got unexpected opacity %.8e.\n", f); + set_matrix_identity(&matrix); + ID2D1RadialGradientBrush_GetTransform(brush, &tmp_matrix); + ok(!memcmp(&tmp_matrix, &matrix, sizeof(matrix)), + "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", + tmp_matrix._11, tmp_matrix._12, tmp_matrix._21, + tmp_matrix._22, tmp_matrix._31, tmp_matrix._32); + p = ID2D1RadialGradientBrush_GetCenter(brush); + ok(compare_point(&p, 160.0f, 480.0f, 0), "Got unexpected center {%.8e, %.8e}.\n", p.x, p.y); + p = ID2D1RadialGradientBrush_GetGradientOriginOffset(brush); + ok(compare_point(&p, 40.0f, -120.0f, 0), "Got unexpected origin offset {%.8e, %.8e}.\n", p.x, p.y); + f = ID2D1RadialGradientBrush_GetRadiusX(brush); + ok(compare_float(f, 160.0f, 0), "Got unexpected x-radius %.8e.\n", f); + f = ID2D1RadialGradientBrush_GetRadiusY(brush); + ok(compare_float(f, 480.0f, 0), "Got unexpected y-radius %.8e.\n", f); + ID2D1RadialGradientBrush_GetGradientStopCollection(brush, &tmp_gradient); + ok(tmp_gradient == gradient, "Got unexpected gradient %p, expected %p.\n", tmp_gradient, gradient); + ID2D1GradientStopCollection_Release(tmp_gradient); + + ID2D1RenderTarget_BeginDraw(rt); + + set_color(&colour, 1.0f, 1.0f, 1.0f, 1.0f); + ID2D1RenderTarget_Clear(rt, &colour); + + set_rect(&r, 0.0f, 0.0f, 320.0f, 960.0f); + ID2D1RenderTarget_FillRectangle(rt, &r, (ID2D1Brush *)brush); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); + + get_surface_readback(surface, &rb); + for (i = 0; i < sizeof(test1) / sizeof(*test1); ++i) + { + DWORD colour; + + colour = get_readback_colour(&rb, test1[i].x, test1[i].y); + ok(compare_colour(colour, test1[i].colour, 1), + "Got unexpected colour 0x%08x at position {%u, %u}.\n", + colour, test1[i].x, test1[i].y); + } + release_resource_readback(&rb); + + ID2D1RenderTarget_BeginDraw(rt); + + ID2D1RenderTarget_Clear(rt, &colour); + + set_matrix_identity(&matrix); + skew_matrix(&matrix, 0.2146f, 1.575f); + ID2D1RenderTarget_SetTransform(rt, &matrix); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, 0.0f, 240.0f); + scale_matrix(&matrix, 0.25f, -0.25f); + ID2D1RadialGradientBrush_SetTransform(brush, &matrix); + + set_rect(&r, 0.0f, 0.0f, 80.0f, 240.0f); + ID2D1RenderTarget_FillRectangle(rt, &r, (ID2D1Brush *)brush); + + set_matrix_identity(&matrix); + scale_matrix(&matrix, 0.5f, 2.0f); + translate_matrix(&matrix, 320.0f, 240.0f); + rotate_matrix(&matrix, M_PI / 4.0f); + ID2D1RenderTarget_SetTransform(rt, &matrix); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, -75.0f, -50.0f); + scale_matrix(&matrix, 0.15f, 0.5f); + rotate_matrix(&matrix, -M_PI / 3.0f); + ID2D1RadialGradientBrush_SetTransform(brush, &matrix); + + ID2D1RadialGradientBrush_SetOpacity(brush, 0.75f); + set_rect(&r, -80.0f, -60.0f, 80.0f, 60.0f); + ID2D1RenderTarget_FillRectangle(rt, &r, (ID2D1Brush *)brush); + + ID2D1RenderTarget_GetFactory(rt, &factory); + + set_rect(&r, -1.0f, -1.0f, 1.0f, 1.0f); + hr = ID2D1Factory_CreateRectangleGeometry(factory, &r, &rectangle_geometry); + ok(SUCCEEDED(hr), "Failed to create geometry, hr %#x.\n", hr); + + set_matrix_identity(&matrix); + translate_matrix(&matrix, 228.5f, 714.0f); + scale_matrix(&matrix, 40.0f, 120.0f); + hr = ID2D1Factory_CreateTransformedGeometry(factory, (ID2D1Geometry *)rectangle_geometry, + &matrix, &transformed_geometry); + ok(SUCCEEDED(hr), "Failed to create geometry, hr %#x.\n", hr); + ID2D1RectangleGeometry_Release(rectangle_geometry); + + set_matrix_identity(&matrix); + ID2D1RenderTarget_SetTransform(rt, &matrix); + ID2D1RadialGradientBrush_SetTransform(brush, &matrix); + set_point(&p, 228.5f, 714.0f); + ID2D1RadialGradientBrush_SetCenter(brush, p); + ID2D1RadialGradientBrush_SetRadiusX(brush, -40.0f); + ID2D1RadialGradientBrush_SetRadiusY(brush, 120.0f); + set_point(&p, 20.0f, 30.0f); + ID2D1RadialGradientBrush_SetGradientOriginOffset(brush, p); + ID2D1RenderTarget_FillGeometry(rt, (ID2D1Geometry *)transformed_geometry, (ID2D1Brush *)brush, NULL); + ID2D1TransformedGeometry_Release(transformed_geometry); + + ID2D1Factory_Release(factory); + + hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); + ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); + + get_surface_readback(surface, &rb); + for (i = 0; i < sizeof(test2) / sizeof(*test2); ++i) + { + DWORD colour; + + colour = get_readback_colour(&rb, test2[i].x, test2[i].y); + ok(compare_colour(colour, test2[i].colour, 1), + "Got unexpected colour 0x%08x at position {%u, %u}.\n", + colour, test2[i].x, test2[i].y); + } + release_resource_readback(&rb); + + ID2D1RadialGradientBrush_Release(brush); + refcount = ID2D1GradientStopCollection_Release(gradient); + ok(!refcount, "Gradient has %u references left.\n", refcount); + ID2D1RenderTarget_Release(rt); + IDXGISurface_Release(surface); + IDXGISwapChain_Release(swapchain); + ID3D10Device1_Release(device); + DestroyWindow(window); +} + static void fill_geometry_sink(ID2D1GeometrySink *sink) { D2D1_POINT_2F point; @@ -6177,6 +6391,7 @@ START_TEST(d2d1) test_color_brush(); test_bitmap_brush(); test_linear_brush(); + test_radial_brush(); test_path_geometry(); test_rectangle_geometry(); test_rounded_rectangle_geometry();