Nikolay Sivov : d2d1: Store stroke style properties, implement methods returning them.
Alexandre Julliard
julliard at winehq.org
Tue Nov 22 16:34:01 CST 2016
Module: wine
Branch: master
Commit: 786633e311703fe471e00b49c1fcbdf39d12bc6c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=786633e311703fe471e00b49c1fcbdf39d12bc6c
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Nov 21 16:38:36 2016 +0300
d2d1: Store stroke style properties, implement methods returning them.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d2d1/d2d1_private.h | 1 +
dlls/d2d1/stroke.c | 43 +++++++++++++++++++++++------------
dlls/d2d1/tests/d2d1.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 14 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index a6bc4f3..bfe60ee 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -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,
diff --git a/dlls/d2d1/stroke.c b/dlls/d2d1/stroke.c
index 167db67..3b5dbfd 100644
--- a/dlls/d2d1/stroke.c
+++ b/dlls/d2d1/stroke.c
@@ -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);
+
+ TRACE("iface %p.\n", iface);
- return D2D1_CAP_STYLE_FLAT;
+ 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);
+
+ TRACE("iface %p.\n", iface);
- return D2D1_CAP_STYLE_FLAT;
+ 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);
+
+ TRACE("iface %p.\n", iface);
- return D2D1_CAP_STYLE_FLAT;
+ 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);
+
+ TRACE("iface %p.\n", iface);
- return 0.0f;
+ 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);
+
+ TRACE("iface %p.\n", iface);
- return D2D1_DASH_STYLE_SOLID;
+ 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;
}
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 04ce2b5..857cba2 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -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();
}
More information about the wine-cvs
mailing list