msvcrt: Add small blocks heap tests.
[wine.git] / dlls / d2d1 / factory.c
blob139c478b97d2f89ffb81c2e61b6d61bc5677a183
1 /*
2 * Copyright 2014 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 struct d2d_factory
28 ID2D1Factory ID2D1Factory_iface;
29 LONG refcount;
32 static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface)
34 return CONTAINING_RECORD(iface, struct d2d_factory, ID2D1Factory_iface);
37 static HRESULT STDMETHODCALLTYPE d2d_factory_QueryInterface(ID2D1Factory *iface, REFIID iid, void **out)
39 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
41 if (IsEqualGUID(iid, &IID_ID2D1Factory)
42 || IsEqualGUID(iid, &IID_IUnknown))
44 ID2D1Factory_AddRef(iface);
45 *out = iface;
46 return S_OK;
49 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
51 *out = NULL;
52 return E_NOINTERFACE;
55 static ULONG STDMETHODCALLTYPE d2d_factory_AddRef(ID2D1Factory *iface)
57 struct d2d_factory *factory = impl_from_ID2D1Factory(iface);
58 ULONG refcount = InterlockedIncrement(&factory->refcount);
60 TRACE("%p increasing refcount to %u.\n", iface, refcount);
62 return refcount;
65 static ULONG STDMETHODCALLTYPE d2d_factory_Release(ID2D1Factory *iface)
67 struct d2d_factory *factory = impl_from_ID2D1Factory(iface);
68 ULONG refcount = InterlockedDecrement(&factory->refcount);
70 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
72 if (!refcount)
73 HeapFree(GetProcessHeap(), 0, factory);
75 return refcount;
78 static HRESULT STDMETHODCALLTYPE d2d_factory_ReloadSystemMetrics(ID2D1Factory *iface)
80 FIXME("iface %p stub!\n", iface);
82 return E_NOTIMPL;
85 static void STDMETHODCALLTYPE d2d_factory_GetDesktopDpi(ID2D1Factory *iface, float *dpi_x, float *dpi_y)
87 FIXME("iface %p, dpi_x %p, dpi_y %p stub!\n", iface, dpi_x, dpi_y);
89 *dpi_x = 96.0f;
90 *dpi_y = 96.0f;
93 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factory *iface,
94 const D2D1_RECT_F *rect, ID2D1RectangleGeometry **geometry)
96 FIXME("iface %p, rect %p, geometry %p stub!\n", iface, rect, geometry);
98 return E_NOTIMPL;
101 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRoundedRectangleGeometry(ID2D1Factory *iface,
102 const D2D1_ROUNDED_RECT *rect, ID2D1RoundedRectangleGeometry **geometry)
104 FIXME("iface %p, rect %p, geometry %p stub!\n", iface, rect, geometry);
106 return E_NOTIMPL;
109 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateEllipseGeometry(ID2D1Factory *iface,
110 const D2D1_ELLIPSE *ellipse, ID2D1EllipseGeometry **geometry)
112 FIXME("iface %p, ellipse %p, geometry %p stub!\n", iface, ellipse, geometry);
114 return E_NOTIMPL;
117 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateGeometryGroup(ID2D1Factory *iface,
118 D2D1_FILL_MODE fill_mode, ID2D1Geometry *geometry, UINT32 geometry_count, ID2D1GeometryGroup **group)
120 FIXME("iface %p, fill_mode %#x, geometry %p, geometry_count %u, group %p stub!\n",
121 iface, fill_mode, geometry, geometry_count, group);
123 return E_NOTIMPL;
126 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateTransformedGeometry(ID2D1Factory *iface,
127 ID2D1Geometry *src_geometry, const D2D1_MATRIX_3X2_F *transform,
128 ID2D1TransformedGeometry **transformed_geometry)
130 FIXME("iface %p, src_geometry %p, transform %p, transformed_geometry %p stub!\n",
131 iface, src_geometry, transform, transformed_geometry);
133 return E_NOTIMPL;
136 static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry(ID2D1Factory *iface, ID2D1PathGeometry *geometry)
138 FIXME("iface %p, geometry %p stub!\n", iface, geometry);
140 return E_NOTIMPL;
143 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateStrokeStyle(ID2D1Factory *iface,
144 const D2D1_STROKE_STYLE_PROPERTIES *desc, const float *dashes, UINT32 dash_count,
145 ID2D1StrokeStyle **stroke_style)
147 FIXME("iface %p, desc %p, dashes %p, dash_count %u, stroke_style %p stub!\n",
148 iface, desc, dashes, dash_count, stroke_style);
150 return E_NOTIMPL;
153 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDrawingStateBlock(ID2D1Factory *iface,
154 const D2D1_DRAWING_STATE_DESCRIPTION *desc, IDWriteRenderingParams *text_rendering_params,
155 ID2D1DrawingStateBlock **state_block)
157 FIXME("iface %p, desc %p, text_rendering_params %p, state_block %p stub!\n",
158 iface, desc, text_rendering_params, state_block);
160 return E_NOTIMPL;
163 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateWicBitmapRenderTarget(ID2D1Factory *iface,
164 IWICBitmap *target, const D2D1_RENDER_TARGET_PROPERTIES *desc, ID2D1RenderTarget **render_target)
166 FIXME("iface %p, target %p, desc %p, render_target %p stub!\n", iface, target, desc, render_target);
168 return E_NOTIMPL;
171 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateHwndRenderTarget(ID2D1Factory *iface,
172 const D2D1_RENDER_TARGET_PROPERTIES *desc, const D2D1_HWND_RENDER_TARGET_PROPERTIES *hwnd_rt_desc,
173 ID2D1HwndRenderTarget **render_target)
175 FIXME("iface %p, desc %p, hwnd_rt_desc %p, render_target %p stub!\n", iface, desc, hwnd_rt_desc, render_target);
177 return E_NOTIMPL;
180 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1Factory *iface,
181 IDXGISurface *surface, const D2D1_RENDER_TARGET_PROPERTIES *desc, ID2D1RenderTarget **render_target)
183 struct d2d_d3d_render_target *object;
185 TRACE("iface %p, surface %p, desc %p, render_target %p.\n", iface, surface, desc, render_target);
187 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
188 return E_OUTOFMEMORY;
190 d2d_d3d_render_target_init(object, iface, surface, desc);
192 TRACE("Created render target %p.\n", object);
193 *render_target = &object->ID2D1RenderTarget_iface;
195 return S_OK;
198 static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDCRenderTarget(ID2D1Factory *iface,
199 const D2D1_RENDER_TARGET_PROPERTIES *desc, ID2D1DCRenderTarget **render_target)
201 FIXME("iface %p, desc %p, render_target %p stub!\n", iface, desc, render_target);
203 return E_NOTIMPL;
206 static const struct ID2D1FactoryVtbl d2d_factory_vtbl =
208 d2d_factory_QueryInterface,
209 d2d_factory_AddRef,
210 d2d_factory_Release,
211 d2d_factory_ReloadSystemMetrics,
212 d2d_factory_GetDesktopDpi,
213 d2d_factory_CreateRectangleGeometry,
214 d2d_factory_CreateRoundedRectangleGeometry,
215 d2d_factory_CreateEllipseGeometry,
216 d2d_factory_CreateGeometryGroup,
217 d2d_factory_CreateTransformedGeometry,
218 d2d_factory_CreatePathGeometry,
219 d2d_factory_CreateStrokeStyle,
220 d2d_factory_CreateDrawingStateBlock,
221 d2d_factory_CreateWicBitmapRenderTarget,
222 d2d_factory_CreateHwndRenderTarget,
223 d2d_factory_CreateDxgiSurfaceRenderTarget,
224 d2d_factory_CreateDCRenderTarget,
227 static void d2d_factory_init(struct d2d_factory *factory, D2D1_FACTORY_TYPE factory_type,
228 const D2D1_FACTORY_OPTIONS *factory_options)
230 FIXME("Ignoring factory type and options.\n");
232 factory->ID2D1Factory_iface.lpVtbl = &d2d_factory_vtbl;
233 factory->refcount = 1;
236 HRESULT WINAPI D2D1CreateFactory(D2D1_FACTORY_TYPE factory_type, REFIID iid,
237 const D2D1_FACTORY_OPTIONS *factory_options, void **factory)
239 struct d2d_factory *object;
240 HRESULT hr;
242 TRACE("factory_type %#x, iid %s, factory_options %p, factory %p.\n",
243 factory_type, debugstr_guid(iid), factory_options, factory);
245 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
246 return E_OUTOFMEMORY;
248 d2d_factory_init(object, factory_type, factory_options);
250 TRACE("Created factory %p.\n", object);
252 hr = ID2D1Factory_QueryInterface(&object->ID2D1Factory_iface, iid, factory);
253 ID2D1Factory_Release(&object->ID2D1Factory_iface);
255 return hr;