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 "d2d1_private.h"
21 WINE_DEFAULT_DEBUG_CHANNEL(d2d
);
23 static inline struct d2d_layer
*impl_from_ID2D1Layer(ID2D1Layer
*iface
)
25 return CONTAINING_RECORD(iface
, struct d2d_layer
, ID2D1Layer_iface
);
28 static HRESULT STDMETHODCALLTYPE
d2d_layer_QueryInterface(ID2D1Layer
*iface
, REFIID iid
, void **out
)
30 TRACE("iface %p, iid %s, out %p.\n", iface
, debugstr_guid(iid
), out
);
32 if (IsEqualGUID(iid
, &IID_ID2D1Layer
)
33 || IsEqualGUID(iid
, &IID_ID2D1Resource
)
34 || IsEqualGUID(iid
, &IID_IUnknown
))
36 ID2D1Layer_AddRef(iface
);
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
47 static ULONG STDMETHODCALLTYPE
d2d_layer_AddRef(ID2D1Layer
*iface
)
49 struct d2d_layer
*layer
= impl_from_ID2D1Layer(iface
);
50 ULONG refcount
= InterlockedIncrement(&layer
->refcount
);
52 TRACE("%p increasing refcount to %u.\n", iface
, refcount
);
57 static ULONG STDMETHODCALLTYPE
d2d_layer_Release(ID2D1Layer
*iface
)
59 struct d2d_layer
*layer
= impl_from_ID2D1Layer(iface
);
60 ULONG refcount
= InterlockedDecrement(&layer
->refcount
);
62 TRACE("%p decreasing refcount to %u.\n", iface
, refcount
);
66 ID2D1Factory_Release(layer
->factory
);
73 static void STDMETHODCALLTYPE
d2d_layer_GetFactory(ID2D1Layer
*iface
, ID2D1Factory
**factory
)
75 struct d2d_layer
*layer
= impl_from_ID2D1Layer(iface
);
77 TRACE("iface %p, factory %p.\n", iface
, factory
);
79 ID2D1Factory_AddRef(*factory
= layer
->factory
);
82 static D2D1_SIZE_F
* STDMETHODCALLTYPE
d2d_layer_GetSize(ID2D1Layer
*iface
, D2D1_SIZE_F
*size
)
84 struct d2d_layer
*layer
= impl_from_ID2D1Layer(iface
);
86 TRACE("iface %p, size %p.\n", iface
, size
);
92 static const struct ID2D1LayerVtbl d2d_layer_vtbl
=
94 d2d_layer_QueryInterface
,
101 HRESULT
d2d_layer_create(ID2D1Factory
*factory
, const D2D1_SIZE_F
*size
, struct d2d_layer
**layer
)
103 if (!(*layer
= heap_alloc_zero(sizeof(**layer
))))
104 return E_OUTOFMEMORY
;
106 (*layer
)->ID2D1Layer_iface
.lpVtbl
= &d2d_layer_vtbl
;
107 (*layer
)->refcount
= 1;
108 ID2D1Factory_AddRef((*layer
)->factory
= factory
);
110 (*layer
)->size
= *size
;
112 TRACE("Created layer %p.\n", *layer
);