wined3d: Don't allow 3D depth textures.
[wine.git] / dlls / d2d1 / state_block.c
blob83fd16232bc0c5ef361ac104bca90974ce9579dc
1 /*
2 * Copyright 2015 Henri Verbeet for CodeWeavers
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.
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.
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
19 #include "config.h"
20 #include "wine/port.h"
22 #include "d2d1_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d2d);
26 static inline struct d2d_state_block *impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface)
28 return CONTAINING_RECORD(iface, struct d2d_state_block, ID2D1DrawingStateBlock_iface);
31 static HRESULT STDMETHODCALLTYPE d2d_state_block_QueryInterface(ID2D1DrawingStateBlock *iface, REFIID iid, void **out)
33 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
35 if (IsEqualGUID(iid, &IID_ID2D1DrawingStateBlock)
36 || IsEqualGUID(iid, &IID_ID2D1Resource)
37 || IsEqualGUID(iid, &IID_IUnknown))
39 ID2D1DrawingStateBlock_AddRef(iface);
40 *out = iface;
41 return S_OK;
44 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
46 *out = NULL;
47 return E_NOINTERFACE;
50 static ULONG STDMETHODCALLTYPE d2d_state_block_AddRef(ID2D1DrawingStateBlock *iface)
52 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
53 ULONG refcount = InterlockedIncrement(&state_block->refcount);
55 TRACE("%p increasing refcount to %u.\n", iface, refcount);
57 return refcount;
60 static ULONG STDMETHODCALLTYPE d2d_state_block_Release(ID2D1DrawingStateBlock *iface)
62 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
63 ULONG refcount = InterlockedDecrement(&state_block->refcount);
65 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
67 if (!refcount)
69 if (state_block->text_rendering_params)
70 IDWriteRenderingParams_Release(state_block->text_rendering_params);
71 HeapFree(GetProcessHeap(), 0, state_block);
74 return refcount;
77 static void STDMETHODCALLTYPE d2d_state_block_GetFactory(ID2D1DrawingStateBlock *iface, ID2D1Factory **factory)
79 FIXME("iface %p, factory %p stub!\n", iface, factory);
81 *factory = NULL;
84 static void STDMETHODCALLTYPE d2d_state_block_GetDescription(ID2D1DrawingStateBlock *iface,
85 D2D1_DRAWING_STATE_DESCRIPTION *desc)
87 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
89 TRACE("iface %p, desc %p.\n", iface, desc);
91 *desc = state_block->drawing_state;
94 static void STDMETHODCALLTYPE d2d_state_block_SetDescription(ID2D1DrawingStateBlock *iface,
95 const D2D1_DRAWING_STATE_DESCRIPTION *desc)
97 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
99 TRACE("iface %p, desc %p.\n", iface, desc);
101 state_block->drawing_state = *desc;
104 static void STDMETHODCALLTYPE d2d_state_block_SetTextRenderingParams(ID2D1DrawingStateBlock *iface,
105 IDWriteRenderingParams *text_rendering_params)
107 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
109 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
111 if (text_rendering_params)
112 IDWriteRenderingParams_AddRef(text_rendering_params);
113 if (state_block->text_rendering_params)
114 IDWriteRenderingParams_Release(state_block->text_rendering_params);
115 state_block->text_rendering_params = text_rendering_params;
118 static void STDMETHODCALLTYPE d2d_state_block_GetTextRenderingParams(ID2D1DrawingStateBlock *iface,
119 IDWriteRenderingParams **text_rendering_params)
121 struct d2d_state_block *state_block = impl_from_ID2D1DrawingStateBlock(iface);
123 TRACE("iface %p, text_rendering_params %p.\n", iface, text_rendering_params);
125 if ((*text_rendering_params = state_block->text_rendering_params))
126 IDWriteRenderingParams_AddRef(*text_rendering_params);
129 static const struct ID2D1DrawingStateBlockVtbl d2d_state_block_vtbl =
131 d2d_state_block_QueryInterface,
132 d2d_state_block_AddRef,
133 d2d_state_block_Release,
134 d2d_state_block_GetFactory,
135 d2d_state_block_GetDescription,
136 d2d_state_block_SetDescription,
137 d2d_state_block_SetTextRenderingParams,
138 d2d_state_block_GetTextRenderingParams,
141 void d2d_state_block_init(struct d2d_state_block *state_block, const D2D1_DRAWING_STATE_DESCRIPTION *desc,
142 IDWriteRenderingParams *text_rendering_params)
144 static const D2D1_MATRIX_3X2_F identity =
146 1.0f, 0.0f,
147 0.0f, 1.0f,
148 0.0f, 0.0f,
151 state_block->ID2D1DrawingStateBlock_iface.lpVtbl = &d2d_state_block_vtbl;
152 state_block->refcount = 1;
153 if (desc)
154 state_block->drawing_state = *desc;
155 else
156 state_block->drawing_state.transform = identity;
157 if ((state_block->text_rendering_params = text_rendering_params))
158 IDWriteRenderingParams_AddRef(state_block->text_rendering_params);
161 struct d2d_state_block *unsafe_impl_from_ID2D1DrawingStateBlock(ID2D1DrawingStateBlock *iface)
163 if (!iface)
164 return NULL;
165 assert(iface->lpVtbl == &d2d_state_block_vtbl);
166 return CONTAINING_RECORD(iface, struct d2d_state_block, ID2D1DrawingStateBlock_iface);