mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-16 07:26:26 +00:00
d2d1: Implement d2d_geometry_sink_BeginFigure() and d2d_geometry_sink_EndFigure().
This commit is contained in:
parent
2f6f8f1242
commit
ddec784aee
|
@ -192,8 +192,10 @@ struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStat
|
|||
enum d2d_geometry_state
|
||||
{
|
||||
D2D_GEOMETRY_STATE_INITIAL = 0,
|
||||
D2D_GEOMETRY_STATE_ERROR,
|
||||
D2D_GEOMETRY_STATE_OPEN,
|
||||
D2D_GEOMETRY_STATE_CLOSED,
|
||||
D2D_GEOMETRY_STATE_FIGURE,
|
||||
};
|
||||
|
||||
struct d2d_geometry
|
||||
|
|
|
@ -78,25 +78,53 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_SetSegmentFlags(ID2D1GeometrySin
|
|||
static void STDMETHODCALLTYPE d2d_geometry_sink_BeginFigure(ID2D1GeometrySink *iface,
|
||||
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",
|
||||
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,
|
||||
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);
|
||||
|
||||
if (geometry->state != D2D_GEOMETRY_STATE_FIGURE)
|
||||
geometry->state = D2D_GEOMETRY_STATE_ERROR;
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d2d_geometry_sink_AddBeziers(ID2D1GeometrySink *iface,
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
|
||||
|
||||
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)
|
||||
|
@ -106,7 +134,11 @@ static HRESULT STDMETHODCALLTYPE d2d_geometry_sink_Close(ID2D1GeometrySink *ifac
|
|||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if (geometry->state != D2D_GEOMETRY_STATE_OPEN)
|
||||
{
|
||||
if (geometry->state != D2D_GEOMETRY_STATE_CLOSED)
|
||||
geometry->state = D2D_GEOMETRY_STATE_ERROR;
|
||||
return D2DERR_WRONG_STATE;
|
||||
}
|
||||
geometry->state = D2D_GEOMETRY_STATE_CLOSED;
|
||||
|
||||
return S_OK;
|
||||
|
@ -137,12 +169,22 @@ static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBezier(ID2D1Geometry
|
|||
static void STDMETHODCALLTYPE d2d_geometry_sink_AddQuadraticBeziers(ID2D1GeometrySink *iface,
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
struct d2d_geometry *geometry = impl_from_ID2D1GeometrySink(iface);
|
||||
|
||||
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 =
|
||||
|
|
|
@ -876,6 +876,7 @@ static void test_bitmap_brush(void)
|
|||
static void test_path_geometry(void)
|
||||
{
|
||||
ID2D1GeometrySink *sink, *tmp_sink;
|
||||
D2D1_POINT_2F point = {0.0f, 0.0f};
|
||||
ID2D1PathGeometry *geometry;
|
||||
IDXGISwapChain *swapchain;
|
||||
ID2D1RenderTarget *rt;
|
||||
|
@ -936,6 +937,60 @@ static void test_path_geometry(void)
|
|||
ID2D1GeometrySink_Release(sink);
|
||||
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);
|
||||
refcount = ID2D1Factory_Release(factory);
|
||||
ok(!refcount, "Factory has %u references left.\n", refcount);
|
||||
|
|
Loading…
Reference in a new issue