ReactOS 0.4.17-dev-934-g091855f
state_block.c
Go to the documentation of this file.
1/*
2 * Copyright 2015 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_ID2D1DrawingStateBlock1)
33 || IsEqualGUID(iid, &IID_ID2D1DrawingStateBlock)
34 || IsEqualGUID(iid, &IID_ID2D1Resource)
35 || IsEqualGUID(iid, &IID_IUnknown))
36 {
37 ID2D1DrawingStateBlock1_AddRef(iface);
38 *out = iface;
39 return S_OK;
40 }
41
42 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
43
44 *out = NULL;
45 return E_NOINTERFACE;
46}
47
49{
50 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
52
53 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
54
55 return refcount;
56}
57
59{
60 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
62
63 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
64
65 if (!refcount)
66 {
67 if (state_block->text_rendering_params)
68 IDWriteRenderingParams_Release(state_block->text_rendering_params);
69 ID2D1Factory_Release(state_block->factory);
70 free(state_block);
71 }
72
73 return refcount;
74}
75
77{
78 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
79
80 TRACE("iface %p, factory %p.\n", iface, factory);
81
82 ID2D1Factory_AddRef(*factory = state_block->factory);
83}
84
87{
88 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
89
90 TRACE("iface %p, desc %p.\n", iface, desc);
91
92 memcpy(desc, &state_block->drawing_state, sizeof(*desc));
93}
94
97{
98 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
99
100 TRACE("iface %p, desc %p.\n", iface, desc);
101
102 memcpy(&state_block->drawing_state, desc, sizeof(*desc));
103}
104
107{
108 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
109
110 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
111
113 IDWriteRenderingParams_AddRef(text_rendering_params);
114 if (state_block->text_rendering_params)
115 IDWriteRenderingParams_Release(state_block->text_rendering_params);
117}
118
121{
122 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
123
124 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
125
126 if ((*text_rendering_params = state_block->text_rendering_params))
127 IDWriteRenderingParams_AddRef(*text_rendering_params);
128}
129
132{
133 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
134
135 TRACE("iface %p, desc %p.\n", iface, desc);
136
137 *desc = state_block->drawing_state;
138}
139
142{
143 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock1(iface);
144
145 TRACE("iface %p, desc %p.\n", iface, desc);
146
147 state_block->drawing_state = *desc;
148}
149
150static const struct ID2D1DrawingStateBlock1Vtbl d2d_state_block_vtbl =
151{
162};
163
165 const D2D1_DRAWING_STATE_DESCRIPTION1 *desc, IDWriteRenderingParams *text_rendering_params)
166{
167 static const D2D1_MATRIX_3X2_F identity =
168 {{{
169 1.0f, 0.0f,
170 0.0f, 1.0f,
171 0.0f, 0.0f,
172 }}};
173
175 state_block->refcount = 1;
176 ID2D1Factory_AddRef(state_block->factory = factory);
177 if (desc)
178 state_block->drawing_state = *desc;
179 else
180 state_block->drawing_state.transform = identity;
181 if ((state_block->text_rendering_params = text_rendering_params))
182 IDWriteRenderingParams_AddRef(state_block->text_rendering_params);
183}
184
186{
187 if (!iface)
188 return NULL;
189 if (iface->lpVtbl != (ID2D1DrawingStateBlockVtbl *)&d2d_state_block_vtbl)
190 {
191 WARN("Unexpected state block vtbl %p.\n", iface->lpVtbl);
192 return NULL;
193 }
195}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#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 IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
static ULONG STDMETHODCALLTYPE d2d_state_block_AddRef(ID2D1DrawingStateBlock1 *iface)
Definition: state_block.c:48
static void STDMETHODCALLTYPE d2d_state_block_SetDescription(ID2D1DrawingStateBlock1 *iface, const D2D1_DRAWING_STATE_DESCRIPTION *desc)
Definition: state_block.c:95
static void STDMETHODCALLTYPE d2d_state_block_GetTextRenderingParams(ID2D1DrawingStateBlock1 *iface, IDWriteRenderingParams **text_rendering_params)
Definition: state_block.c:119
static void STDMETHODCALLTYPE d2d_state_block_GetDescription(ID2D1DrawingStateBlock1 *iface, D2D1_DRAWING_STATE_DESCRIPTION *desc)
Definition: state_block.c:85
static void STDMETHODCALLTYPE d2d_state_block_SetDescription1(ID2D1DrawingStateBlock1 *iface, const D2D1_DRAWING_STATE_DESCRIPTION1 *desc)
Definition: state_block.c:140
static void STDMETHODCALLTYPE d2d_state_block_SetTextRenderingParams(ID2D1DrawingStateBlock1 *iface, IDWriteRenderingParams *text_rendering_params)
Definition: state_block.c:105
struct d2d_state_block * unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface)
Definition: state_block.c:185
static struct d2d_state_block * impl_from_ID2D1DrawingStateBlock1(ID2D1DrawingStateBlock1 *iface)
Definition: state_block.c:23
static const struct ID2D1DrawingStateBlock1Vtbl d2d_state_block_vtbl
Definition: state_block.c:150
static void STDMETHODCALLTYPE d2d_state_block_GetFactory(ID2D1DrawingStateBlock1 *iface, ID2D1Factory **factory)
Definition: state_block.c:76
static HRESULT STDMETHODCALLTYPE d2d_state_block_QueryInterface(ID2D1DrawingStateBlock1 *iface, REFIID iid, void **out)
Definition: state_block.c:28
static void STDMETHODCALLTYPE d2d_state_block_GetDescription1(ID2D1DrawingStateBlock1 *iface, D2D1_DRAWING_STATE_DESCRIPTION1 *desc)
Definition: state_block.c:130
static ULONG STDMETHODCALLTYPE d2d_state_block_Release(ID2D1DrawingStateBlock1 *iface)
Definition: state_block.c:58
void d2d_state_block_init(struct d2d_state_block *state_block, ID2D1Factory *factory, const D2D1_DRAWING_STATE_DESCRIPTION1 *desc, IDWriteRenderingParams *text_rendering_params)
Definition: state_block.c:164
D2D1_MATRIX_3X2_F transform
Definition: d2d1_1.idl:246
IDWriteRenderingParams * text_rendering_params
Definition: d2d1_private.h:457
ID2D1DrawingStateBlock1 ID2D1DrawingStateBlock1_iface
Definition: d2d1_private.h:452
ID2D1Factory * factory
Definition: d2d1_private.h:455
D2D1_DRAWING_STATE_DESCRIPTION1 drawing_state
Definition: d2d1_private.h:456
Definition: main.c:439
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
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