From c903192243e4438ab08e5426e24604b93c231493 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 18 Jul 2014 10:37:56 +0200 Subject: [PATCH] d2d1: Implement d2d_factory_CreateStrokeStyle(). --- dlls/d2d1/Makefile.in | 3 +- dlls/d2d1/d2d1_private.h | 9 +++ dlls/d2d1/factory.c | 14 +++- dlls/d2d1/stroke.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 dlls/d2d1/stroke.c diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index ed451efaaf3..3c019579106 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -5,6 +5,7 @@ IMPORTS = uuid C_SRCS = \ brush.c \ factory.c \ - render_target.c + render_target.c \ + stroke.c RC_SRCS = version.rc diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 2bcb594d524..720a96d49af 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -55,4 +55,13 @@ void d2d_linear_gradient_brush_init(struct d2d_brush *brush, ID2D1RenderTarget * const D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES *gradient_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc, ID2D1GradientStopCollection *gradient) DECLSPEC_HIDDEN; +struct d2d_stroke_style +{ + ID2D1StrokeStyle ID2D1StrokeStyle_iface; + LONG refcount; +}; + +void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory, + const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count) DECLSPEC_HIDDEN; + #endif /* __WINE_D2D1_PRIVATE_H */ diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index 139c478b97d..1003f0d22f2 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -144,10 +144,20 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle(ID2D1Factory *ifa const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count, ID2D1StrokeStyle **stroke_style) { - FIXME("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p stub!\n", + struct d2d_stroke_style *object; + + TRACE("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p.\n", iface, desc, dashes, dash_count, stroke_style); - return E_NOTIMPL; + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + d2d_stroke_style_init(object, iface, desc, dashes, dash_count); + + TRACE("Created stroke style %p.\n", object); + *stroke_style = &object->ID2D1StrokeStyle_iface; + + return S_OK; } static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDrawingStateBlock(ID2D1Factory *iface, diff --git a/dlls/d2d1/stroke.c b/dlls/d2d1/stroke.c new file mode 100644 index 00000000000..81d3dde2a57 --- /dev/null +++ b/dlls/d2d1/stroke.c @@ -0,0 +1,165 @@ +/* + * Copyright 2014 Henri Verbeet for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include "d2d1_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(d2d); + +static inline struct d2d_stroke_style *impl_from_ID2D1StrokeStyle(ID2D1StrokeStyle *iface) +{ + return CONTAINING_RECORD(iface, struct d2d_stroke_style, ID2D1StrokeStyle_iface); +} + +static HRESULT STDMETHODCALLTYPE d2d_stroke_style_QueryInterface(ID2D1StrokeStyle *iface, REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID2D1StrokeStyle) + || IsEqualGUID(iid, &IID_ID2D1Resource) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID2D1StrokeStyle_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d2d_stroke_style_AddRef(ID2D1StrokeStyle *iface) +{ + struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface); + ULONG refcount = InterlockedIncrement(&style->refcount); + + TRACE("%p increasing refcount to %u.\n", iface, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d2d_stroke_style_Release(ID2D1StrokeStyle *iface) +{ + struct d2d_stroke_style *style = impl_from_ID2D1StrokeStyle(iface); + ULONG refcount = InterlockedDecrement(&style->refcount); + + TRACE("%p decreasing refcount to %u.\n", iface, refcount); + + if (!refcount) + HeapFree(GetProcessHeap(), 0, style); + + return refcount; +} + +static void STDMETHODCALLTYPE d2d_stroke_style_GetFactory(ID2D1StrokeStyle *iface, ID2D1Factory **factory) +{ + FIXME("iface %p, factory %p stub!\n", iface, factory); + + *factory = NULL; +} + +static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetStartCap(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return D2D1_CAP_STYLE_FLAT; +} + +static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetEndCap(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return D2D1_CAP_STYLE_FLAT; +} + +static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashCap(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return D2D1_CAP_STYLE_FLAT; +} + +static float STDMETHODCALLTYPE d2d_stroke_style_GetMiterLimit(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0.0f; +} + +static D2D1_LINE_JOIN STDMETHODCALLTYPE d2d_stroke_style_GetLineJoin(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return D2D1_LINE_JOIN_MITER; +} + +static float STDMETHODCALLTYPE d2d_stroke_style_GetDashOffset(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0.0f; +} + +static D2D1_DASH_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashStyle(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return D2D1_DASH_STYLE_SOLID; +} + +static UINT32 STDMETHODCALLTYPE d2d_stroke_style_GetDashesCount(ID2D1StrokeStyle *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static void STDMETHODCALLTYPE d2d_stroke_style_GetDashes(ID2D1StrokeStyle *iface, float *dashes, UINT32 count) +{ + FIXME("iface %p, dashes %p, count %u stub!\n", iface, dashes, count); +} + +static const struct ID2D1StrokeStyleVtbl d2d_stroke_style_vtbl = +{ + d2d_stroke_style_QueryInterface, + d2d_stroke_style_AddRef, + d2d_stroke_style_Release, + d2d_stroke_style_GetFactory, + d2d_stroke_style_GetStartCap, + d2d_stroke_style_GetEndCap, + d2d_stroke_style_GetDashCap, + d2d_stroke_style_GetMiterLimit, + d2d_stroke_style_GetLineJoin, + d2d_stroke_style_GetDashOffset, + d2d_stroke_style_GetDashStyle, + d2d_stroke_style_GetDashesCount, + d2d_stroke_style_GetDashes, +}; + +void d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory, + const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count) +{ + FIXME("Ignoring stroke style properties.\n"); + + style->ID2D1StrokeStyle_iface.lpVtbl = &d2d_stroke_style_vtbl; + style->refcount = 1; +} -- 2.11.4.GIT