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

d2d1: Implement rounded rectangle drawing.

Currently rounded parts are approximated with quadratic Bézier curves. Signed-off-by: 's avatarGiovanni Mascellani <gio@debian.org> Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5f9ceed1
......@@ -440,6 +440,7 @@ struct d2d_geometry
size_t face_count;
struct d2d_bezier_vertex *bezier_vertices;
size_t bezier_vertices_size;
size_t bezier_vertex_count;
} fill;
......@@ -484,6 +485,10 @@ struct d2d_geometry
} rectangle;
struct
{
D2D1_ROUNDED_RECT rounded_rect;
} rounded_rectangle;
struct
{
ID2D1Geometry *src_geometry;
D2D_MATRIX_3X2_F transform;
} transformed;
......@@ -499,6 +504,8 @@ struct d2d_geometry
void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory) DECLSPEC_HIDDEN;
HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
ID2D1Factory *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
HRESULT d2d_rounded_rectangle_geometry_init(struct d2d_geometry *geometry,
ID2D1Factory *factory, const D2D1_ROUNDED_RECT *rounded_rect) DECLSPEC_HIDDEN;
void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
......@@ -616,8 +623,17 @@ static inline const char *debug_d2d_point_2f(const D2D1_POINT_2F *point)
static inline const char *debug_d2d_rect_f(const D2D1_RECT_F *rect)
{
if (!rect) return "(null)";
return wine_dbg_sprintf("(%.8e,%.8e)-(%.8e,%.8e)", rect->left, rect->top, rect->right, rect->bottom );
if (!rect)
return "(null)";
return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)", rect->left, rect->top, rect->right, rect->bottom);
}
static inline const char *debug_d2d_rounded_rect(const D2D1_ROUNDED_RECT *rounded_rect)
{
if (!rounded_rect)
return "(null)";
return wine_dbg_sprintf("(%.8e, %.8e)-(%.8e, %.8e)[%.8e, %.8e]", rounded_rect->rect.left, rounded_rect->rect.top,
rounded_rect->rect.right, rounded_rect->rect.bottom, rounded_rect->radiusX, rounded_rect->radiusY);
}
#endif /* __WINE_D2D1_PRIVATE_H */
......@@ -152,11 +152,27 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factor
}
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRoundedRectangleGeometry(ID2D1Factory2 *iface,
const D2D1_ROUNDED_RECT *rect, ID2D1RoundedRectangleGeometry **geometry)
const D2D1_ROUNDED_RECT *rounded_rect, ID2D1RoundedRectangleGeometry **geometry)
{
FIXME("iface %p, rect %p, geometry %p stub!\n", iface, rect, geometry);
struct d2d_geometry *object;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, rounded_rect %s, geometry %p.\n", iface, debug_d2d_rounded_rect(rounded_rect), geometry);
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d2d_rounded_rectangle_geometry_init(object, (ID2D1Factory *)iface, rounded_rect)))
{
WARN("Failed to initialize rounded rectangle geometry, hr %#x.\n", hr);
heap_free(object);
return hr;
}
TRACE("Created rounded rectangle geometry %p.\n", object);
*geometry = (ID2D1RoundedRectangleGeometry *)&object->ID2D1Geometry_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateEllipseGeometry(ID2D1Factory2 *iface,
......
......@@ -3790,13 +3790,7 @@ static void test_rounded_rectangle_geometry(void)
set_rounded_rect(&rect, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
hr = ID2D1Factory_CreateRoundedRectangleGeometry(factory, &rect, &geometry);
todo_wine
ok(SUCCEEDED(hr), "Failed to create geometry, hr %#x.\n", hr);
if (FAILED(hr))
{
ID2D1Factory_Release(factory);
return;
}
ID2D1RoundedRectangleGeometry_GetRoundedRect(geometry, &rect2);
ok(!memcmp(&rect, &rect2, sizeof(rect)), "Got unexpected rectangle {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n",
......
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