ntdll: Validate blocks in the heap pending free request list.
[wine.git] / dlls / d2d1 / mesh.c
blobcd6a5d13a8939993929dc8a254fc9c939472c061
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 "d2d1_private.h"
21 WINE_DEFAULT_DEBUG_CHANNEL(d2d);
23 static inline struct d2d_mesh *impl_from_ID2D1Mesh(ID2D1Mesh *iface)
25 return CONTAINING_RECORD(iface, struct d2d_mesh, ID2D1Mesh_iface);
28 static HRESULT STDMETHODCALLTYPE d2d_mesh_QueryInterface(ID2D1Mesh *iface, REFIID iid, void **out)
30 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
32 if (IsEqualGUID(iid, &IID_ID2D1Mesh)
33 || IsEqualGUID(iid, &IID_ID2D1Resource)
34 || IsEqualGUID(iid, &IID_IUnknown))
36 ID2D1Mesh_AddRef(iface);
37 *out = iface;
38 return S_OK;
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
43 *out = NULL;
44 return E_NOINTERFACE;
47 static ULONG STDMETHODCALLTYPE d2d_mesh_AddRef(ID2D1Mesh *iface)
49 struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface);
50 ULONG refcount = InterlockedIncrement(&mesh->refcount);
52 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
54 return refcount;
57 static ULONG STDMETHODCALLTYPE d2d_mesh_Release(ID2D1Mesh *iface)
59 struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface);
60 ULONG refcount = InterlockedDecrement(&mesh->refcount);
62 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
64 if (!refcount)
66 ID2D1Factory_Release(mesh->factory);
67 free(mesh);
70 return refcount;
73 static void STDMETHODCALLTYPE d2d_mesh_GetFactory(ID2D1Mesh *iface, ID2D1Factory **factory)
75 struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface);
77 TRACE("iface %p, factory %p.\n", iface, factory);
79 ID2D1Factory_AddRef(*factory = mesh->factory);
82 static HRESULT STDMETHODCALLTYPE d2d_mesh_Open(ID2D1Mesh *iface, ID2D1TessellationSink **sink)
84 FIXME("iface %p, sink %p stub!\n", iface, sink);
86 return E_NOTIMPL;
89 static const struct ID2D1MeshVtbl d2d_mesh_vtbl =
91 d2d_mesh_QueryInterface,
92 d2d_mesh_AddRef,
93 d2d_mesh_Release,
94 d2d_mesh_GetFactory,
95 d2d_mesh_Open,
98 HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh)
100 if (!(*mesh = calloc(1, sizeof(**mesh))))
101 return E_OUTOFMEMORY;
103 (*mesh)->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl;
104 (*mesh)->refcount = 1;
105 ID2D1Factory_AddRef((*mesh)->factory = factory);
107 TRACE("Created mesh %p.\n", *mesh);
108 return S_OK;