1 | /*
|
---|
2 | * Copyright 2012 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 |
|
---|
20 | /*
|
---|
21 | * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
22 | * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
|
---|
23 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
24 | * a choice of LGPL license versions is made available with the language indicating
|
---|
25 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
26 | * of the LGPL is applied is otherwise unspecified.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #include "config.h"
|
---|
30 | #include "wine/port.h"
|
---|
31 |
|
---|
32 | #include "wined3d_private.h"
|
---|
33 |
|
---|
34 | WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
---|
35 |
|
---|
36 | ULONG CDECL wined3d_sampler_incref(struct wined3d_sampler *sampler)
|
---|
37 | {
|
---|
38 | ULONG refcount = InterlockedIncrement(&sampler->refcount);
|
---|
39 |
|
---|
40 | TRACE("%p increasing refcount to %u.\n", sampler, refcount);
|
---|
41 |
|
---|
42 | return refcount;
|
---|
43 | }
|
---|
44 |
|
---|
45 | ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
|
---|
46 | {
|
---|
47 | ULONG refcount = InterlockedDecrement(&sampler->refcount);
|
---|
48 |
|
---|
49 | TRACE("%p decreasing refcount to %u.\n", sampler, refcount);
|
---|
50 |
|
---|
51 | if (!refcount)
|
---|
52 | HeapFree(GetProcessHeap(), 0, sampler);
|
---|
53 |
|
---|
54 | return refcount;
|
---|
55 | }
|
---|
56 |
|
---|
57 | void * CDECL wined3d_sampler_get_parent(const struct wined3d_sampler *sampler)
|
---|
58 | {
|
---|
59 | TRACE("sampler %p.\n", sampler);
|
---|
60 |
|
---|
61 | return sampler->parent;
|
---|
62 | }
|
---|
63 |
|
---|
64 | static void wined3d_sampler_init(struct wined3d_sampler *sampler, void *parent)
|
---|
65 | {
|
---|
66 | sampler->refcount = 1;
|
---|
67 | sampler->parent = parent;
|
---|
68 | }
|
---|
69 |
|
---|
70 | HRESULT CDECL wined3d_sampler_create(void *parent, struct wined3d_sampler **sampler)
|
---|
71 | {
|
---|
72 | struct wined3d_sampler *object;
|
---|
73 |
|
---|
74 | TRACE("parent %p, sampler %p.\n", parent, sampler);
|
---|
75 |
|
---|
76 | if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
---|
77 | return E_OUTOFMEMORY;
|
---|
78 |
|
---|
79 | wined3d_sampler_init(object, parent);
|
---|
80 |
|
---|
81 | TRACE("Created sampler %p.\n", object);
|
---|
82 | *sampler = object;
|
---|
83 |
|
---|
84 | return WINED3D_OK;
|
---|
85 | }
|
---|