d2d1: Implement d2d_path_geometry_GetFigureCount().
This commit is contained in:
parent
ddec784aee
commit
dfe1486e4b
|
@ -205,6 +205,7 @@ struct d2d_geometry
|
||||||
LONG refcount;
|
LONG refcount;
|
||||||
|
|
||||||
enum d2d_geometry_state state;
|
enum d2d_geometry_state state;
|
||||||
|
UINT32 figure_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
void d2d_path_geometry_init(struct d2d_geometry *geometry) DECLSPEC_HIDDEN;
|
void d2d_path_geometry_init(struct d2d_geometry *geometry) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -89,6 +89,7 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_BeginFigure(ID2D1GeometrySink *i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
geometry->state = D2D_GEOMETRY_STATE_FIGURE;
|
geometry->state = D2D_GEOMETRY_STATE_FIGURE;
|
||||||
|
++geometry->figure_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *iface,
|
static void STDMETHODCALLTYPE d2d_geometry_sink_AddLines(ID2D1GeometrySink *iface,
|
||||||
|
@ -411,9 +412,16 @@ static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetSegmentCount(ID2D1PathGeom
|
||||||
|
|
||||||
static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetFigureCount(ID2D1PathGeometry *iface, UINT32 *count)
|
static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetFigureCount(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->figure_count;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ID2D1PathGeometryVtbl d2d_path_geometry_vtbl =
|
static const struct ID2D1PathGeometryVtbl d2d_path_geometry_vtbl =
|
||||||
|
|
|
@ -884,6 +884,7 @@ static void test_path_geometry(void)
|
||||||
IDXGISurface *surface;
|
IDXGISurface *surface;
|
||||||
ID2D1Factory *factory;
|
ID2D1Factory *factory;
|
||||||
ULONG refcount;
|
ULONG refcount;
|
||||||
|
UINT32 count;
|
||||||
HWND window;
|
HWND window;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
@ -904,13 +905,23 @@ static void test_path_geometry(void)
|
||||||
/* Close() when closed. */
|
/* Close() when closed. */
|
||||||
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
|
hr = ID2D1Factory_CreatePathGeometry(factory, &geometry);
|
||||||
ok(SUCCEEDED(hr), "Failed to create path geometry, hr %#x.\n", hr);
|
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_Open(geometry, &sink);
|
hr = ID2D1PathGeometry_Open(geometry, &sink);
|
||||||
ok(SUCCEEDED(hr), "Failed to open geometry sink, hr %#x.\n", hr);
|
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 = ID2D1GeometrySink_Close(sink);
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr);
|
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 = ID2D1GeometrySink_Close(sink);
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1GeometrySink_Release(sink);
|
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);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
/* Open() when closed. */
|
/* Open() when closed. */
|
||||||
|
@ -923,6 +934,9 @@ static void test_path_geometry(void)
|
||||||
ID2D1GeometrySink_Release(sink);
|
ID2D1GeometrySink_Release(sink);
|
||||||
hr = ID2D1PathGeometry_Open(geometry, &sink);
|
hr = ID2D1PathGeometry_Open(geometry, &sink);
|
||||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected 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);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
/* Open() when open. */
|
/* Open() when open. */
|
||||||
|
@ -935,6 +949,9 @@ static void test_path_geometry(void)
|
||||||
hr = ID2D1GeometrySink_Close(sink);
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr);
|
ok(SUCCEEDED(hr), "Failed to close geometry sink, hr %#x.\n", hr);
|
||||||
ID2D1GeometrySink_Release(sink);
|
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);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
/* BeginFigure() without EndFigure(). */
|
/* BeginFigure() without EndFigure(). */
|
||||||
|
@ -949,6 +966,8 @@ static void test_path_geometry(void)
|
||||||
hr = ID2D1GeometrySink_Close(sink);
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1GeometrySink_Release(sink);
|
ID2D1GeometrySink_Release(sink);
|
||||||
|
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
|
||||||
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
/* EndFigure() without BeginFigure(). */
|
/* EndFigure() without BeginFigure(). */
|
||||||
|
@ -960,6 +979,8 @@ static void test_path_geometry(void)
|
||||||
hr = ID2D1GeometrySink_Close(sink);
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1GeometrySink_Release(sink);
|
ID2D1GeometrySink_Release(sink);
|
||||||
|
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
|
||||||
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
/* BeginFigure()/EndFigure() mismatch. */
|
/* BeginFigure()/EndFigure() mismatch. */
|
||||||
|
@ -989,6 +1010,23 @@ static void test_path_geometry(void)
|
||||||
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
ID2D1GeometrySink_AddLine(sink, point);
|
ID2D1GeometrySink_AddLine(sink, point);
|
||||||
ID2D1GeometrySink_Release(sink);
|
ID2D1GeometrySink_Release(sink);
|
||||||
|
hr = ID2D1PathGeometry_GetFigureCount(geometry, &count);
|
||||||
|
ok(hr == D2DERR_WRONG_STATE, "Got unexpected hr %#x.\n", hr);
|
||||||
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
|
/* Empty figure. */
|
||||||
|
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_EndFigure(sink, D2D1_FIGURE_END_CLOSED);
|
||||||
|
hr = ID2D1GeometrySink_Close(sink);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to close geometry sink, 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 == 1, "Got unexpected figure count %u.\n", count);
|
||||||
ID2D1PathGeometry_Release(geometry);
|
ID2D1PathGeometry_Release(geometry);
|
||||||
|
|
||||||
ID2D1RenderTarget_Release(rt);
|
ID2D1RenderTarget_Release(rt);
|
||||||
|
|
Loading…
Reference in New Issue