ReactOS 0.4.17-dev-934-g091855f
layer.c
Go to the documentation of this file.
1/*
2 * Copyright 2017 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
23static inline struct d2d_layer *impl_from_ID2D1Layer(ID2D1Layer *iface)
24{
25 return CONTAINING_RECORD(iface, struct d2d_layer, ID2D1Layer_iface);
26}
27
29{
30 TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
31
32 if (IsEqualGUID(iid, &IID_ID2D1Layer)
33 || IsEqualGUID(iid, &IID_ID2D1Resource)
34 || IsEqualGUID(iid, &IID_IUnknown))
35 {
36 ID2D1Layer_AddRef(iface);
37 *out = iface;
38 return S_OK;
39 }
40
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
42
43 *out = NULL;
44 return E_NOINTERFACE;
45}
46
48{
49 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
51
52 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
53
54 return refcount;
55}
56
58{
59 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
61
62 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
63
64 if (!refcount)
65 {
66 ID2D1Factory_Release(layer->factory);
67 free(layer);
68 }
69
70 return refcount;
71}
72
74{
75 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
76
77 TRACE("iface %p, factory %p.\n", iface, factory);
78
79 ID2D1Factory_AddRef(*factory = layer->factory);
80}
81
83{
84 struct d2d_layer *layer = impl_from_ID2D1Layer(iface);
85
86 TRACE("iface %p, size %p.\n", iface, size);
87
88 *size = layer->size;
89 return size;
90}
91
92static const struct ID2D1LayerVtbl d2d_layer_vtbl =
93{
99};
100
102{
103 if (!(*layer = calloc(1, sizeof(**layer))))
104 return E_OUTOFMEMORY;
105
106 (*layer)->ID2D1Layer_iface.lpVtbl = &d2d_layer_vtbl;
107 (*layer)->refcount = 1;
108 ID2D1Factory_AddRef((*layer)->factory = factory);
109 if (size)
110 (*layer)->size = *size;
111
112 TRACE("Created layer %p.\n", *layer);
113
114 return S_OK;
115}
#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 E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
static struct d2d_layer * impl_from_ID2D1Layer(ID2D1Layer *iface)
Definition: layer.c:23
static void STDMETHODCALLTYPE d2d_layer_GetFactory(ID2D1Layer *iface, ID2D1Factory **factory)
Definition: layer.c:73
HRESULT d2d_layer_create(ID2D1Factory *factory, const D2D1_SIZE_F *size, struct d2d_layer **layer)
Definition: layer.c:101
static ULONG STDMETHODCALLTYPE d2d_layer_Release(ID2D1Layer *iface)
Definition: layer.c:57
static HRESULT STDMETHODCALLTYPE d2d_layer_QueryInterface(ID2D1Layer *iface, REFIID iid, void **out)
Definition: layer.c:28
static ULONG STDMETHODCALLTYPE d2d_layer_AddRef(ID2D1Layer *iface)
Definition: layer.c:47
static D2D1_SIZE_F *STDMETHODCALLTYPE d2d_layer_GetSize(ID2D1Layer *iface, D2D1_SIZE_F *size)
Definition: layer.c:82
static const struct ID2D1LayerVtbl d2d_layer_vtbl
Definition: layer.c:92
#define NULL
Definition: types.h:112
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
ID2D1Layer ID2D1Layer_iface
Definition: d2d1_private.h:404
LONG refcount
Definition: d2d1_private.h:405
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