ReactOS 0.4.17-dev-934-g091855f
stroke.c
Go to the documentation of this file.
1/*
2 * Copyright 2014 Henri Verbeet for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "d2d1_private.h"
20
22
24{
26}
27
29{
30 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
31
32 if (IsEqualGUID(iid, &IID_ID2D1StrokeStyle)
33 || IsEqualGUID(iid, &IID_ID2D1Resource)
34 || IsEqualGUID(iid, &IID_IUnknown))
35 {
36 ID2D1StrokeStyle1_AddRef(iface);
37 *out = iface;
38 return S_OK;
39 }
40
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
42
43 *out = NULL;
44 return E_NOINTERFACE;
45}
46
48{
51
52 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
53
54 return refcount;
55}
56
58{
61
62 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
63
64 if (!refcount)
65 {
66 ID2D1Factory_Release(style->factory);
67 if (style->desc.dashStyle == D2D1_DASH_STYLE_CUSTOM)
68 free(style->dashes);
69 free(style);
70 }
71
72 return refcount;
73}
74
76{
78
79 TRACE("iface %p, factory %p.\n", iface, factory);
80
81 ID2D1Factory_AddRef(*factory = style->factory);
82}
83
85{
87
88 TRACE("iface %p.\n", iface);
89
90 return style->desc.startCap;
91}
92
94{
96
97 TRACE("iface %p.\n", iface);
98
99 return style->desc.endCap;
100}
101
103{
105
106 TRACE("iface %p.\n", iface);
107
108 return style->desc.dashCap;
109}
110
112{
114
115 TRACE("iface %p.\n", iface);
116
117 return style->desc.miterLimit;
118}
119
121{
123
124 TRACE("iface %p.\n", iface);
125
126 return style->desc.lineJoin;
127}
128
130{
132
133 TRACE("iface %p.\n", iface);
134
135 return style->desc.dashOffset;
136}
137
139{
141
142 TRACE("iface %p.\n", iface);
143
144 return style->desc.dashStyle;
145}
146
148{
150
151 TRACE("iface %p.\n", iface);
152
153 return style->dash_count;
154}
155
157{
159
160 TRACE("iface %p, dashes %p, count %u.\n", iface, dashes, dash_count);
161
162 memcpy(dashes, style->dashes, min(style->dash_count, dash_count) * sizeof(*dashes));
163 if (dash_count > style->dash_count)
164 memset(dashes + style->dash_count, 0, (dash_count - style->dash_count) * sizeof(*dashes));
165}
166
168{
170
171 TRACE("iface %p.\n", iface);
172
173 return style->desc.transformType;
174}
175
176static const struct ID2D1StrokeStyle1Vtbl d2d_stroke_style_vtbl =
177{
192};
193
195{
196 if (!iface)
197 return NULL;
198 assert((const struct ID2D1StrokeStyle1Vtbl *)iface->lpVtbl == &d2d_stroke_style_vtbl);
200}
201
204{
205 static const struct
206 {
208 float dashes[6];
209 }
210 builtin_dash_styles[] =
211 {
212 /* D2D1_DASH_STYLE_SOLID */ { 0 },
213 /* D2D1_DASH_STYLE_DASH */ { 2, {2.0f, 2.0f}},
214 /* D2D1_DASH_STYLE_DOT */ { 2, {0.0f, 2.0f}},
215 /* D2D1_DASH_STYLE_DASH_DOT */ { 4, {2.0f, 2.0f, 0.0f, 2.0f}},
216 /* D2D1_DASH_STYLE_DASH_DOT_DOT */ { 6, {2.0f, 2.0f, 0.0f, 2.0f, 0.0f, 2.0f}},
217 };
218
219 if (desc->dashStyle > D2D1_DASH_STYLE_CUSTOM)
220 return E_INVALIDARG;
221
222 if (desc->transformType != D2D1_STROKE_TRANSFORM_TYPE_NORMAL)
223 FIXME("transformType %d is not supported\n", desc->transformType);
224
225 style->ID2D1StrokeStyle1_iface.lpVtbl = &d2d_stroke_style_vtbl;
226 style->refcount = 1;
227
228 if (desc->dashStyle == D2D1_DASH_STYLE_CUSTOM)
229 {
230 if (!dashes || !dash_count)
231 return E_INVALIDARG;
232
233 if (!(style->dashes = calloc(dash_count, sizeof(*style->dashes))))
234 return E_OUTOFMEMORY;
235 memcpy(style->dashes, dashes, dash_count * sizeof(*style->dashes));
236 style->dash_count = dash_count;
237 }
238 else
239 {
240 if (dashes)
241 return E_INVALIDARG;
242
243 style->dashes = (float *)builtin_dash_styles[desc->dashStyle].dashes;
244 style->dash_count = builtin_dash_styles[desc->dashStyle].dash_count;
245 }
246
247 ID2D1Factory_AddRef(style->factory = factory);
248 style->desc = *desc;
249
250 return S_OK;
251}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
D2D1_CAP_STYLE
Definition: d2d1.idl:113
D2D1_LINE_JOIN
Definition: d2d1.idl:122
D2D1_DASH_STYLE
Definition: d2d1.idl:131
@ D2D1_DASH_STYLE_CUSTOM
Definition: d2d1.idl:137
D2D1_STROKE_TRANSFORM_TYPE
Definition: d2d1_1.idl:46
@ D2D1_STROKE_TRANSFORM_TYPE_NORMAL
Definition: d2d1_1.idl:47
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define assert(_expr)
Definition: assert.h:32
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define min(a, b)
Definition: monoChain.cc:55
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define calloc
Definition: rosglue.h:14
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT d2d_stroke_style_init(struct d2d_stroke_style *style, ID2D1Factory *factory, const D2D1_STROKE_STYLE_PROPERTIES1 *desc, const float *dashes, UINT32 dash_count)
Definition: stroke.c:202
static float STDMETHODCALLTYPE d2d_stroke_style_GetMiterLimit(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:111
static ULONG STDMETHODCALLTYPE d2d_stroke_style_Release(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:57
static struct d2d_stroke_style * impl_from_ID2D1StrokeStyle1(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:23
static D2D1_DASH_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashStyle(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:138
static D2D1_LINE_JOIN STDMETHODCALLTYPE d2d_stroke_style_GetLineJoin(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:120
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetDashCap(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:102
static void STDMETHODCALLTYPE d2d_stroke_style_GetFactory(ID2D1StrokeStyle1 *iface, ID2D1Factory **factory)
Definition: stroke.c:75
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetStartCap(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:84
static ULONG STDMETHODCALLTYPE d2d_stroke_style_AddRef(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:47
static const struct ID2D1StrokeStyle1Vtbl d2d_stroke_style_vtbl
Definition: stroke.c:176
static D2D1_STROKE_TRANSFORM_TYPE STDMETHODCALLTYPE d2d_stroke_style_GetStrokeTransformType(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:167
struct d2d_stroke_style * unsafe_impl_from_ID2D1StrokeStyle(ID2D1StrokeStyle *iface)
Definition: stroke.c:194
static UINT32 STDMETHODCALLTYPE d2d_stroke_style_GetDashesCount(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:147
static void STDMETHODCALLTYPE d2d_stroke_style_GetDashes(ID2D1StrokeStyle1 *iface, float *dashes, UINT32 dash_count)
Definition: stroke.c:156
static float STDMETHODCALLTYPE d2d_stroke_style_GetDashOffset(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:129
static D2D1_CAP_STYLE STDMETHODCALLTYPE d2d_stroke_style_GetEndCap(ID2D1StrokeStyle1 *iface)
Definition: stroke.c:93
static HRESULT STDMETHODCALLTYPE d2d_stroke_style_QueryInterface(ID2D1StrokeStyle1 *iface, REFIID iid, void **out)
Definition: stroke.c:28
ID2D1StrokeStyle1 ID2D1StrokeStyle1_iface
Definition: d2d1_private.h:389
Definition: main.c:439
Definition: style.c:91
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t UINT32
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define E_NOINTERFACE
Definition: winerror.h:3479