d2d1: Store stroke style properties, implement methods returning them.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-11-21 16:38:36 +03:00 committed by Alexandre Julliard
parent 7159479e11
commit 786633e311
3 changed files with 88 additions and 14 deletions

View file

@ -223,6 +223,7 @@ struct d2d_stroke_style
LONG refcount;
ID2D1Factory *factory;
D2D1_STROKE_STYLE_PROPERTIES desc;
};
void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory,

View file

@ -84,51 +84,65 @@ static void STDMETHODCALLTYPE d2d_stroke_style_GetFactory(ID2D1StrokeStyle *ifac
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetStartCap(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return D2D1_CAP_STYLE_FLAT;
TRACE("iface %p.\n", iface);
return style->desc.startCap;
}
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetEndCap(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return D2D1_CAP_STYLE_FLAT;
TRACE("iface %p.\n", iface);
return style->desc.endCap;
}
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashCap(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return D2D1_CAP_STYLE_FLAT;
TRACE("iface %p.\n", iface);
return style->desc.dashCap;
}
static float STDMETHODCALLTYPE d2d_stroke_style_GetMiterLimit(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return 0.0f;
TRACE("iface %p.\n", iface);
return style->desc.miterLimit;
}
static D2D1_LINE_JOIN STDMETHODCALLTYPE d2d_stroke_style_GetLineJoin(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return D2D1_LINE_JOIN_MITER;
TRACE("iface %p.\n", iface);
return style->desc.lineJoin;
}
static float STDMETHODCALLTYPE d2d_stroke_style_GetDashOffset(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return 0.0f;
TRACE("iface %p.\n", iface);
return style->desc.dashOffset;
}
static D2D1_DASH_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashStyle(ID2D1StrokeStyle *iface)
{
FIXME("iface %p stub!\n", iface);
struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface);
return D2D1_DASH_STYLE_SOLID;
TRACE("iface %p.\n", iface);
return style->desc.dashStyle;
}
static UINT32 STDMETHODCALLTYPE d2d_stroke_style_GetDashesCount(ID2D1StrokeStyle *iface)
@ -168,4 +182,5 @@ void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory
style->ID2D1StrokeStyle_iface.lpVtbl = &d2d_stroke_style_vtbl;
style->refcount = 1;
ID2D1Factory_AddRef(style->factory = factory);
style->desc = *desc;
}

View file

@ -3333,6 +3333,63 @@ static void test_desktop_dpi(void)
ID2D1Factory_Release(factory);
}
static void test_stroke_style(void)
{
D2D1_STROKE_STYLE_PROPERTIES desc;
ID2D1StrokeStyle *style;
ID2D1Factory *factory;
UINT32 count;
HRESULT hr;
D2D1_CAP_STYLE cap_style;
D2D1_LINE_JOIN line_join;
float miter_limit, dash_offset;
D2D1_DASH_STYLE dash_style;
hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory);
ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr);
desc.startCap = D2D1_CAP_STYLE_SQUARE;
desc.endCap = D2D1_CAP_STYLE_ROUND;
desc.dashCap = D2D1_CAP_STYLE_TRIANGLE;
desc.lineJoin = D2D1_LINE_JOIN_BEVEL;
desc.miterLimit = 1.5f;
desc.dashStyle = D2D1_DASH_STYLE_DOT;
desc.dashOffset = -1.0f;
hr = ID2D1Factory_CreateStrokeStyle(factory, &desc, NULL, 0, &style);
ok(SUCCEEDED(hr), "Failed to create stroke style, %#x.\n", hr);
cap_style = ID2D1StrokeStyle_GetStartCap(style);
ok(cap_style == D2D1_CAP_STYLE_SQUARE, "Unexpected cap style %d.\n", cap_style);
cap_style = ID2D1StrokeStyle_GetEndCap(style);
ok(cap_style == D2D1_CAP_STYLE_ROUND, "Unexpected cap style %d.\n", cap_style);
cap_style = ID2D1StrokeStyle_GetDashCap(style);
ok(cap_style == D2D1_CAP_STYLE_TRIANGLE, "Unexpected cap style %d.\n", cap_style);
line_join = ID2D1StrokeStyle_GetLineJoin(style);
ok(line_join == D2D1_LINE_JOIN_BEVEL, "Unexpected line joind %d.\n", line_join);
miter_limit = ID2D1StrokeStyle_GetMiterLimit(style);
ok(miter_limit == 1.5f, "Unexpected miter limit %f.\n", miter_limit);
dash_style = ID2D1StrokeStyle_GetDashStyle(style);
ok(dash_style == D2D1_DASH_STYLE_DOT, "Unexpected dash style %d.\n", dash_style);
dash_offset = ID2D1StrokeStyle_GetDashOffset(style);
ok(dash_offset == -1.0f, "Unexpected dash offset %f.\n", dash_offset);
ID2D1StrokeStyle_Release(style);
/* NULL dashes array, non-zero length. */
memset(&desc, 0, sizeof(desc));
hr = ID2D1Factory_CreateStrokeStyle(factory, &desc, NULL, 1, &style);
ok(SUCCEEDED(hr), "Failed to create stroke style, %#x.\n", hr);
count = ID2D1StrokeStyle_GetDashesCount(style);
ok(count == 0, "Unexpected dashes count %u.\n", count);
ID2D1StrokeStyle_Release(style);
ID2D1Factory_Release(factory);
}
START_TEST(d2d1)
{
test_clip();
@ -3353,4 +3410,5 @@ START_TEST(d2d1)
test_hwnd_target();
test_bitmap_target();
test_desktop_dpi();
test_stroke_style();
}