Commit a6bf2c42 authored by Giovanni Mascellani's avatar Giovanni Mascellani Committed by Alexandre Julliard

d2d1: Implement ellipse and rounded rectangle filling with arcs.

parent 4e98b081
......@@ -1262,7 +1262,7 @@ static BOOL d2d_brush_fill_cb(const struct d2d_brush *brush,
}
HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_brush,
BOOL outline, struct d2d_device_context *render_target, ID3D10Buffer **ps_cb)
BOOL outline, BOOL is_arc, struct d2d_device_context *render_target, ID3D10Buffer **ps_cb)
{
D3D10_SUBRESOURCE_DATA buffer_data;
struct d2d_ps_cb cb_data = {0};
......@@ -1270,6 +1270,7 @@ HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_b
HRESULT hr;
cb_data.outline = outline;
cb_data.is_arc = is_arc;
if (!d2d_brush_fill_cb(brush, render_target, &cb_data.colour_brush))
return E_NOTIMPL;
if (!d2d_brush_fill_cb(opacity_brush, render_target, &cb_data.opacity_brush))
......
......@@ -46,7 +46,7 @@ enum d2d_shape_type
D2D_SHAPE_TYPE_OUTLINE,
D2D_SHAPE_TYPE_BEZIER_OUTLINE,
D2D_SHAPE_TYPE_TRIANGLE,
D2D_SHAPE_TYPE_BEZIER,
D2D_SHAPE_TYPE_CURVE,
D2D_SHAPE_TYPE_COUNT,
};
......@@ -113,7 +113,8 @@ struct d2d_brush_cb
struct d2d_ps_cb
{
BOOL outline;
BOOL pad[3];
BOOL is_arc;
BOOL pad[2];
struct d2d_brush_cb colour_brush;
struct d2d_brush_cb opacity_brush;
};
......@@ -301,7 +302,7 @@ HRESULT d2d_bitmap_brush_create(ID2D1Factory *factory, ID2D1Bitmap *bitmap,
const D2D1_BITMAP_BRUSH_PROPERTIES1 *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc,
struct d2d_brush **brush) DECLSPEC_HIDDEN;
void d2d_brush_bind_resources(struct d2d_brush *brush, ID3D10Device *device, unsigned int brush_idx) DECLSPEC_HIDDEN;
HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline,
HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline, BOOL is_arc,
struct d2d_device_context *render_target, ID3D10Buffer **ps_cb) DECLSPEC_HIDDEN;
struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) DECLSPEC_HIDDEN;
......@@ -388,7 +389,7 @@ enum d2d_geometry_state
D2D_GEOMETRY_STATE_FIGURE,
};
struct d2d_bezier_vertex
struct d2d_curve_vertex
{
D2D1_POINT_2F position;
struct
......@@ -439,9 +440,13 @@ struct d2d_geometry
size_t faces_size;
size_t face_count;
struct d2d_bezier_vertex *bezier_vertices;
struct d2d_curve_vertex *bezier_vertices;
size_t bezier_vertices_size;
size_t bezier_vertex_count;
struct d2d_curve_vertex *arc_vertices;
size_t arc_vertices_size;
size_t arc_vertex_count;
} fill;
struct
......
......@@ -129,7 +129,7 @@ struct d2d_fp_fin
size_t length;
};
static void d2d_bezier_vertex_set(struct d2d_bezier_vertex *b,
static void d2d_curve_vertex_set(struct d2d_curve_vertex *b,
const D2D1_POINT_2F *p, float u, float v, float sign)
{
b->position = *p;
......@@ -2351,19 +2351,17 @@ static BOOL d2d_geometry_add_figure_outline(struct d2d_geometry *geometry,
static BOOL d2d_geometry_fill_add_arc_triangle(struct d2d_geometry *geometry,
const D2D1_POINT_2F *p0, const D2D1_POINT_2F *p1, const D2D1_POINT_2F *p2)
{
struct d2d_bezier_vertex *b;
struct d2d_curve_vertex *a;
FIXME("Approximating arc triangle with Bezier triangle.\n");
if (!d2d_array_reserve((void **)&geometry->fill.bezier_vertices, &geometry->fill.bezier_vertices_size,
geometry->fill.bezier_vertex_count + 3, sizeof(*geometry->fill.bezier_vertices)))
if (!d2d_array_reserve((void **)&geometry->fill.arc_vertices, &geometry->fill.arc_vertices_size,
geometry->fill.arc_vertex_count + 3, sizeof(*geometry->fill.arc_vertices)))
return FALSE;
b = &geometry->fill.bezier_vertices[geometry->fill.bezier_vertex_count];
d2d_bezier_vertex_set(&b[0], p0, 0.0f, 0.0f, -1.0f);
d2d_bezier_vertex_set(&b[1], p1, 0.5f, 0.0f, -1.0f);
d2d_bezier_vertex_set(&b[2], p2, 1.0f, 1.0f, -1.0f);
geometry->fill.bezier_vertex_count += 3;
a = &geometry->fill.arc_vertices[geometry->fill.arc_vertex_count];
d2d_curve_vertex_set(&a[0], p0, 0.0f, 1.0f, -1.0f);
d2d_curve_vertex_set(&a[1], p1, 1.0f, 1.0f, -1.0f);
d2d_curve_vertex_set(&a[2], p2, 1.0f, 0.0f, -1.0f);
geometry->fill.arc_vertex_count += 3;
return TRUE;
}
......@@ -2374,6 +2372,7 @@ static void d2d_geometry_cleanup(struct d2d_geometry *geometry)
heap_free(geometry->outline.beziers);
heap_free(geometry->outline.faces);
heap_free(geometry->outline.vertices);
heap_free(geometry->fill.arc_vertices);
heap_free(geometry->fill.bezier_vertices);
heap_free(geometry->fill.faces);
heap_free(geometry->fill.vertices);
......@@ -2782,7 +2781,7 @@ static BOOL d2d_geometry_split_bezier(struct d2d_geometry *geometry, const struc
static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
{
struct d2d_segment_idx idx_p, idx_q;
struct d2d_bezier_vertex *b;
struct d2d_curve_vertex *b;
const D2D1_POINT_2F *p[3];
struct d2d_figure *figure;
size_t bezier_idx, i;
......@@ -2858,9 +2857,9 @@ static HRESULT d2d_geometry_resolve_beziers(struct d2d_geometry *geometry)
p[2] = &figure->vertices[i];
b = &geometry->fill.bezier_vertices[bezier_idx * 3];
d2d_bezier_vertex_set(&b[0], p[0], 0.0f, 0.0f, sign);
d2d_bezier_vertex_set(&b[1], p[1], 0.5f, 0.0f, sign);
d2d_bezier_vertex_set(&b[2], p[2], 1.0f, 1.0f, sign);
d2d_curve_vertex_set(&b[0], p[0], 0.0f, 0.0f, sign);
d2d_curve_vertex_set(&b[1], p[1], 0.5f, 0.0f, sign);
d2d_curve_vertex_set(&b[2], p[2], 1.0f, 1.0f, sign);
if (!d2d_geometry_get_next_bezier_segment_idx(geometry, &idx_p))
break;
......@@ -4524,6 +4523,7 @@ static ULONG STDMETHODCALLTYPE d2d_transformed_geometry_Release(ID2D1Transformed
geometry->outline.beziers = NULL;
geometry->outline.faces = NULL;
geometry->outline.vertices = NULL;
geometry->fill.arc_vertices = NULL;
geometry->fill.bezier_vertices = NULL;
geometry->fill.faces = NULL;
geometry->fill.vertices = NULL;
......
......@@ -6846,7 +6846,7 @@ static void test_fill_geometry(void)
"yjIMjwEWhwEcggEgfiR6KHYscy5xMG40azZpOGc6ZTxjPmI+YUBfQl1EXERbRlpGWUhYSFdKVkpV"
"TFRMVExTTlJOUk5STlJOUVBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUU5STlJOUk5STlNMVExUTFVK"
"VkpXSFhIWUZaRltEXERdQl9AYT5iPmM8ZTpnOGk2azRuMHEucyx2KHokfiCCARyHARaPAQzKMgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
ID2D1RenderTarget_BeginDraw(rt);
set_color(&color, 0.396f, 0.180f, 0.537f, 1.0f);
......@@ -6892,7 +6892,7 @@ static void test_fill_geometry(void)
"szI6YURZSlROUVBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUU5USllEYTqzMgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
match = compare_figure(surface, 0, 160, 160, 160, 0xff652e89, 0, "gMgB");
ok(match, "Figure does not match.\n");
......@@ -6904,7 +6904,7 @@ static void test_fill_geometry(void)
"tjI0aDxhQlxGWEpVTFNOUk5RUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFFOUk5TTFVKWEZcQmA+ZzS2MgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
match = compare_figure(surface, 0, 320, 160, 160, 0xff652e89, 0, "gMgB");
ok(match, "Figure does not match.\n");
......@@ -6916,7 +6916,7 @@ static void test_fill_geometry(void)
"sDJAWkxSUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFJMWkCwMgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
ID2D1RenderTarget_BeginDraw(rt);
set_color(&color, 0.396f, 0.180f, 0.537f, 1.0f);
......@@ -6962,7 +6962,7 @@ static void test_fill_geometry(void)
"yjIMjwEWhwEcggEgfiR6KHYscy5xMG40azZpOGc6ZTxjPmI+YUBfQl1EXERbRlpGWUhYSFdKVkpV"
"TFRMVExTTlJOUk5STlJOUVBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUU5STlJOUk5STlNMVExUTFVK"
"VkpXSFhIWUZaRltEXERdQl9AYT5iPmM8ZTpnOGk2azRuMHEucyx2KHokfiCCARyHARaPAQzKMgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
match = compare_figure(surface, 0, 160, 160, 160, 0xff652e89, 0, "gMgB");
ok(match, "Figure does not match.\n");
......@@ -6974,7 +6974,7 @@ static void test_fill_geometry(void)
"uTIucDJsNmk4ZzplPGM+YUBgQF9CXkJdRFxEW0ZaRllIWEhXSlZKVkpWSlVMVExUTFRMU05STlJO"
"Uk5STlJOUk9QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFFPUU5STlJOUk5STlJOU0xU"
"TFRMVExVSlZKVkpWSldIWEhZRlpGW0RcRF1CXkJfQGBAYT5jPGU6ZzhpNmwycC65MgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
match = compare_figure(surface, 0, 320, 160, 160, 0xff652e89, 0, "gMgB");
ok(match, "Figure does not match.\n");
......@@ -6986,7 +6986,7 @@ static void test_fill_geometry(void)
"vzIiczhhRldMUlBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQ"
"UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUkxXRmA6cSS+MgAA");
todo_wine ok(match, "Figure does not match.\n");
ok(match, "Figure does not match.\n");
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
......
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