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

d2d1: Implement d2d_path_geometry_GetSegmentCount().

parent dfe1486e
......@@ -205,7 +205,7 @@ struct d2d_geometry
LONG refcount;
enum d2d_geometry_state state;
UINT32 figure_count;
UINT32 figure_count, segment_count;
};
void d2d_path_geometry_init(struct d2d_geometry *geometry) DECLSPEC_HIDDEN;
......
......@@ -90,6 +90,7 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_BeginFigure(ID2D1GeometrySink *i
}
geometry->state = D2D_GEOMETRY_STATE_FIGURE;
++geometry->figure_count;
++geometry->segment_count;
}
static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *iface,
......@@ -100,7 +101,12 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *ifac
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;
return;
}
geometry->segment_count += count;
}
static void STDMETHODCALLTYPE d2d_geometry_sink_AddBeziers(ID2D1GeometrySink *iface,
......@@ -111,7 +117,12 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddBeziers(ID2D1GeometrySink *if
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;
return;
}
geometry->segment_count += count;
}
static void STDMETHODCALLTYPE d2d_geometry_sink_EndFigure(ID2D1GeometrySink *iface, D2D1_FIGURE_END figure_end)
......@@ -175,7 +186,12 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBeziers(ID2D1Geometr
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;
return;
}
geometry->segment_count += bezier_count;
}
static void STDMETHODCALLTYPE d2d_geometry_sink_AddArc(ID2D1GeometrySink *iface, const D2D1_ARC_SEGMENT *arc)
......@@ -185,7 +201,12 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddArc(ID2D1GeometrySink *iface,
FIXME("iface %p, arc %p stub!\n", iface, arc);
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
{
geometry->state = D2D_GEOMETRY_STATE_ERROR;
return;
}
++geometry->segment_count;
}
struct ID2D1GeometrySinkVtbl d2d_geometry_sink_vtbl =
......@@ -405,9 +426,16 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_Stream(ID2D1PathGeometry *ifa
static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetSegmentCount(ID2D1PathGeometry *iface, UINT32 *count)
{
FIXME("iface %p, count %p stub!\n", iface, count);
struct d2d_geometry *geometry = impl_from_ID2D1PathGeometry(iface);
return E_NOTIMPL;
TRACE("iface %p, count %p.\n", iface, count);
if (geometry->state != D2D_GEOMETRY_STATE_CLOSED)
return D2DERR_WRONG_STATE;
*count = geometry->segment_count;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetFigureCount(ID2D1PathGeometry *iface, UINT32 *count)
......
......@@ -907,21 +907,31 @@ static void test_path_geometry(void)
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_Open(geometry, &sink);
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1GeometrySink_Close(sink);
ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr);
ok(!count, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
ok(!count, "Got unexpected segment count %u.\n", count);
hr = ID2D1GeometrySink_Close(sink);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1GeometrySink_Release(sink);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr);
ok(!count, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
ok(!count, "Got unexpected segment count %u.\n", count);
ID2D1PathGeometry_Release(geometry);
/* Open() when closed. */
......@@ -937,6 +947,9 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr);
ok(!count, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
ok(!count, "Got unexpected segment count %u.\n", count);
ID2D1PathGeometry_Release(geometry);
/* Open() when open. */
......@@ -952,6 +965,9 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr);
ok(!count, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
ok(!count, "Got unexpected segment count %u.\n", count);
ID2D1PathGeometry_Release(geometry);
/* BeginFigure() without EndFigure(). */
......@@ -968,6 +984,8 @@ static void test_path_geometry(void)
ID2D1GeometrySink_Release(sink);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1PathGeometry_Release(geometry);
/* EndFigure() without BeginFigure(). */
......@@ -981,6 +999,8 @@ static void test_path_geometry(void)
ID2D1GeometrySink_Release(sink);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1PathGeometry_Release(geometry);
/* BeginFigure()/EndFigure() mismatch. */
......@@ -1012,6 +1032,8 @@ static void test_path_geometry(void)
ID2D1GeometrySink_Release(sink);
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
ID2D1PathGeometry_Release(geometry);
/* Empty figure. */
......@@ -1027,6 +1049,9 @@ static void test_path_geometry(void)
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get figure count, hr %#x.\n", hr);
ok(count == 1, "Got unexpected figure count %u.\n", count);
hr = ID2D1PathGeometry_GetSegmentCount(geometry, &count);
ok(SUCCEEDED(hr), "Failed to get segment count, hr %#x.\n", hr);
ok(count == 1, "Got unexpected segment count %u.\n", count);
ID2D1PathGeometry_Release(geometry);
ID2D1RenderTarget_Release(rt);
......
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