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

d2d1: Implement d2d_geometry_sink_BeginFigure() and d2d_geometry_sink_EndFigure().

parent 2f6f8f12
...@@ -192,8 +192,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat ...@@ -192,8 +192,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat
enum d2d_geometry_state enum d2d_geometry_state
{ {
D2D_GEOMETRY_STATE_INITIAL = 0, D2D_GEOMETRY_STATE_INITIAL = 0,
D2D_GEOMETRY_STATE_ERROR,
D2D_GEOMETRY_STATE_OPEN, D2D_GEOMETRY_STATE_OPEN,
D2D_GEOMETRY_STATE_CLOSED, D2D_GEOMETRY_STATE_CLOSED,
D2D_GEOMETRY_STATE_FIGURE,
}; };
struct d2d_geometry struct d2d_geometry
......
...@@ -78,25 +78,53 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_SetSegmentFlags(ID2D1GeometrySin ...@@ -78,25 +78,53 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_SetSegmentFlags(ID2D1GeometrySin
static void STDMETHODCALLTYPE d2d_geometry_sink_BeginFigure(ID2D1GeometrySink *iface, static void STDMETHODCALLTYPE d2d_geometry_sink_BeginFigure(ID2D1GeometrySink *iface,
D2D1_POINT_2F start_point, D2D1_FIGURE_BEGIN figure_begin) D2D1_POINT_2F start_point, D2D1_FIGURE_BEGIN figure_begin)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, start_point {%.8e, %.8e}, figure_begin %#x stub!\n", FIXME("iface %p, start_point {%.8e, %.8e}, figure_begin %#x stub!\n",
iface, start_point.x, start_point.y, figure_begin); iface, start_point.x, start_point.y, figure_begin);
if (geometry->state != D2D_GEOMETRY_STATE_OPEN)
{
geometry->state = D2D_GEOMETRY_STATE_ERROR;
return;
}
geometry->state = D2D_GEOMETRY_STATE_FIGURE;
} }
static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *iface, static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *iface,
const D2D1_POINT_2F *points, UINT32 count) const D2D1_POINT_2F *points, UINT32 count)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, points %p, count %u stub!\n", iface, points, count); FIXME("iface %p, points %p, count %u stub!\n", iface, points, count);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
geometry->state = D2D_GEOMETRY_STATE_ERROR;
} }
static void STDMETHODCALLTYPE d2d_geometry_sink_AddBeziers(ID2D1GeometrySink *iface, static void STDMETHODCALLTYPE d2d_geometry_sink_AddBeziers(ID2D1GeometrySink *iface,
const D2D1_BEZIER_SEGMENT *beziers, UINT32 count) const D2D1_BEZIER_SEGMENT *beziers, UINT32 count)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, beziers %p, count %u stub!\n", iface, beziers, count); FIXME("iface %p, beziers %p, count %u stub!\n", iface, beziers, count);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
geometry->state = D2D_GEOMETRY_STATE_ERROR;
} }
static void STDMETHODCALLTYPE d2d_geometry_sink_EndFigure(ID2D1GeometrySink *iface, D2D1_FIGURE_END figure_end) static void STDMETHODCALLTYPE d2d_geometry_sink_EndFigure(ID2D1GeometrySink *iface, D2D1_FIGURE_END figure_end)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, figure_end %#x stub!\n", iface, figure_end); FIXME("iface %p, figure_end %#x stub!\n", iface, figure_end);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
{
geometry->state = D2D_GEOMETRY_STATE_ERROR;
return;
}
geometry->state = D2D_GEOMETRY_STATE_OPEN;
} }
static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *iface) static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *iface)
...@@ -106,7 +134,11 @@ static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *ifac ...@@ -106,7 +134,11 @@ static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *ifac
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
if (geometry->state != D2D_GEOMETRY_STATE_OPEN) if (geometry->state != D2D_GEOMETRY_STATE_OPEN)
{
if (geometry->state != D2D_GEOMETRY_STATE_CLOSED)
geometry->state = D2D_GEOMETRY_STATE_ERROR;
return D2DERR_WRONG_STATE; return D2DERR_WRONG_STATE;
}
geometry->state = D2D_GEOMETRY_STATE_CLOSED; geometry->state = D2D_GEOMETRY_STATE_CLOSED;
return S_OK; return S_OK;
...@@ -137,12 +169,22 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBezier(ID2D1Geometry ...@@ -137,12 +169,22 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBezier(ID2D1Geometry
static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBeziers(ID2D1GeometrySink *iface, static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBeziers(ID2D1GeometrySink *iface,
const D2D1_QUADRATIC_BEZIER_SEGMENT *beziers, UINT32 bezier_count) const D2D1_QUADRATIC_BEZIER_SEGMENT *beziers, UINT32 bezier_count)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, beziers %p, bezier_count %u stub!\n", iface, beziers, bezier_count); FIXME("iface %p, beziers %p, bezier_count %u stub!\n", iface, beziers, bezier_count);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
geometry->state = D2D_GEOMETRY_STATE_ERROR;
} }
static void STDMETHODCALLTYPE d2d_geometry_sink_AddArc(ID2D1GeometrySink *iface, const D2D1_ARC_SEGMENT *arc) static void STDMETHODCALLTYPE d2d_geometry_sink_AddArc(ID2D1GeometrySink *iface, const D2D1_ARC_SEGMENT *arc)
{ {
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
FIXME("iface %p, arc %p stub!\n", iface, arc); FIXME("iface %p, arc %p stub!\n", iface, arc);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
geometry->state = D2D_GEOMETRY_STATE_ERROR;
} }
struct ID2D1GeometrySinkVtbl d2d_geometry_sink_vtbl = struct ID2D1GeometrySinkVtbl d2d_geometry_sink_vtbl =
......
...@@ -876,6 +876,7 @@ static void test_bitmap_brush(void) ...@@ -876,6 +876,7 @@ static void test_bitmap_brush(void)
static void test_path_geometry(void) static void test_path_geometry(void)
{ {
ID2D1GeometrySink *sink, *tmp_sink; ID2D1GeometrySink *sink, *tmp_sink;
D2D1_POINT_2F point = {0.0f, 0.0f};
ID2D1PathGeometry *geometry; ID2D1PathGeometry *geometry;
IDXGISwapChain *swapchain; IDXGISwapChain *swapchain;
ID2D1RenderTarget *rt; ID2D1RenderTarget *rt;
...@@ -936,6 +937,60 @@ static void test_path_geometry(void) ...@@ -936,6 +937,60 @@ static void test_path_geometry(void)
ID2D1GeometrySink_Release(sink); ID2D1GeometrySink_Release(sink);
ID2D1PathGeometry_Release(geometry); ID2D1PathGeometry_Release(geometry);
/* BeginFigure() without EndFigure(). */
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
hr = ID2D1PathGeometry_Open(geometry, &sink);
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_Release(sink);
ID2D1PathGeometry_Release(geometry);
/* EndFigure() without BeginFigure(). */
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
hr = ID2D1PathGeometry_Open(geometry, &sink);
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_Release(sink);
ID2D1PathGeometry_Release(geometry);
/* BeginFigure()/EndFigure() mismatch. */
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
hr = ID2D1PathGeometry_Open(geometry, &sink);
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
ID2D1GeometrySink_BeginFigure(sink, point, D2D1_FIGURE_BEGIN_FILLED);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_Release(sink);
ID2D1PathGeometry_Release(geometry);
/* AddLine() outside BeginFigure()/EndFigure(). */
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
hr = ID2D1PathGeometry_Open(geometry, &sink);
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
ID2D1GeometrySink_AddLine(sink, point);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_AddLine(sink, point);
ID2D1GeometrySink_Release(sink);
ID2D1PathGeometry_Release(geometry);
ID2D1RenderTarget_Release(rt); ID2D1RenderTarget_Release(rt);
refcount = ID2D1Factory_Release(factory); refcount = ID2D1Factory_Release(factory);
ok(!refcount, "Factory has %u references left.\n", refcount); ok(!refcount, "Factory has %u references left.\n", refcount);
......
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