ntdll: Translate signal to trap when trap code is 0 on ARM.
[wine.git] / dlls / d2d1 / layer.c
blob0f7ade2476165357d20da5a30fc0d935a8b69623
1 /*
2 * Copyright 2017 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_layer *impl_from_ID2D1Layer(ID2D1Layer *iface)
28 return CONTAINING_RECORD(iface, struct d2d_layer, ID2D1Layer_iface);
31 static HRESULT STDMETHODCALLTYPE d2d_layer_QueryInterface(ID2D1Layer *iface, REFIID iid, void **out)
33 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
35 if (IsEqualGUID(iid, &IID_ID2D1Layer)
36 || IsEqualGUID(iid, &IID_ID2D1Resource)
37 || IsEqualGUID(iid, &IID_IUnknown))
39 ID2D1Layer_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_layer_AddRef(ID2D1Layer *iface)
52 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
53 ULONG refcount = InterlockedIncrement(&layer->refcount);
55 TRACE("%p increasing refcount to %u.\n", iface, refcount);
57 return refcount;
60 static ULONG STDMETHODCALLTYPE d2d_layer_Release(ID2D1Layer *iface)
62 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
63 ULONG refcount = InterlockedDecrement(&layer->refcount);
65 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
67 if (!refcount)
69 ID2D1Factory_Release(layer->factory);
70 heap_free(layer);
73 return refcount;
76 static void STDMETHODCALLTYPE d2d_layer_GetFactory(ID2D1Layer *iface, ID2D1Factory **factory)
78 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
80 TRACE("iface %p, factory %p.\n", iface, factory);
82 ID2D1Factory_AddRef(*factory = layer->factory);
85 static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_layer_GetSize(ID2D1Layer *iface, D2D1_SIZE_F *size)
87 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
89 TRACE("iface %p, size %p.\n", iface, size);
91 *size = layer->size;
92 return size;
95 static const struct ID2D1LayerVtbl d2d_layer_vtbl =
97 d2d_layer_QueryInterface,
98 d2d_layer_AddRef,
99 d2d_layer_Release,
100 d2d_layer_GetFactory,
101 d2d_layer_GetSize,
104 HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer)
106 if (!(*layer = heap_alloc_zero(sizeof(**layer))))
107 return E_OUTOFMEMORY;
109 (*layer)->ID2D1Layer_iface.lpVtbl = &d2d_layer_vtbl;
110 (*layer)->refcount = 1;
111 ID2D1Factory_AddRef((*layer)->factory = factory);
112 if (size)
113 (*layer)->size = *size;
115 TRACE("Created layer %p.\n", *layer);
117 return S_OK;