ReactOS  0.4.15-dev-3177-gd6a0299
core.c
Go to the documentation of this file.
1 #ifdef __REACTOS__
2 #include "precomp.h"
3 #else
4 /*
5  *
6  * Copyright 2002 Raphael Junqueira
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 
24 #include "d3dx9_private.h"
25 #endif /* __REACTOS__ */
26 
28 
30 {
33 
34  void *buffer;
36 };
37 
38 static inline struct ID3DXBufferImpl *impl_from_ID3DXBuffer(ID3DXBuffer *iface)
39 {
41 }
42 
44 {
45  TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), ppobj);
46 
48  || IsEqualGUID(riid, &IID_ID3DXBuffer))
49  {
50  IUnknown_AddRef(iface);
51  *ppobj = iface;
52  return D3D_OK;
53  }
54 
55  WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
56 
57  return E_NOINTERFACE;
58 }
59 
61 {
64 
65  TRACE("%p increasing refcount to %u\n", This, ref);
66 
67  return ref;
68 }
69 
71 {
74 
75  TRACE("%p decreasing refcount to %u\n", This, ref);
76 
77  if (ref == 0)
78  {
79  HeapFree(GetProcessHeap(), 0, This->buffer);
81  }
82 
83  return ref;
84 }
85 
87 {
89 
90  TRACE("iface %p\n", iface);
91 
92  return This->buffer;
93 }
94 
96 {
98 
99  TRACE("iface %p\n", iface);
100 
101  return This->size;
102 }
103 
104 static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl =
105 {
106  /* IUnknown methods */
110  /* ID3DXBuffer methods */
113 };
114 
116 {
117  buffer->ID3DXBuffer_iface.lpVtbl = &ID3DXBufferImpl_Vtbl;
118  buffer->ref = 1;
119  buffer->size = size;
120 
122  if (!buffer->buffer)
123  {
124  ERR("Failed to allocate buffer memory\n");
125  return E_OUTOFMEMORY;
126  }
127 
128  return D3D_OK;
129 }
130 
132 {
133  struct ID3DXBufferImpl *object;
134  HRESULT hr;
135 
136  TRACE("size %u, buffer %p.\n", size, buffer);
137 
138  if (!buffer)
139  {
140  WARN("Invalid buffer specified.\n");
141  return D3DERR_INVALIDCALL;
142  }
143 
144  object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
145  if (!object)
146  return E_OUTOFMEMORY;
147 
148  hr = d3dx9_buffer_init(object, size);
149  if (FAILED(hr))
150  {
151  WARN("Failed to initialize buffer, hr %#x.\n", hr);
152  HeapFree(GetProcessHeap(), 0, object);
153  return hr;
154  }
155 
156  *buffer = &object->ID3DXBuffer_iface;
157 
158  TRACE("Created ID3DXBuffer %p.\n", *buffer);
159 
160  return D3D_OK;
161 }
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI ID3DXBufferImpl_AddRef(ID3DXBuffer *iface)
Definition: core.c:60
coclass MSXML2::XSLTemplate40 object
HRESULT hr
Definition: shlfolder.c:183
WINE_DEFAULT_DEBUG_CHANNEL(d3dx)
REFIID riid
Definition: precomp.h:44
static void *WINAPI ID3DXBufferImpl_GetBufferPointer(ID3DXBuffer *iface)
Definition: core.c:86
#define WARN(fmt,...)
Definition: debug.h:112
HRESULT WINAPI D3DXCreateBuffer(DWORD size, ID3DXBuffer **buffer)
Definition: core.c:131
static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(ID3DXBuffer *iface, REFIID riid, void **ppobj)
Definition: core.c:43
#define D3DERR_INVALIDCALL
GLuint buffer
Definition: glext.h:5915
static HRESULT d3dx9_buffer_init(struct ID3DXBufferImpl *buffer, DWORD size)
Definition: core.c:115
Definition: send.c:48
LONG ref
Definition: core.c:32
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
struct ID3DXBuffer ID3DXBuffer
Definition: d3dx8core.h:51
#define debugstr_guid
Definition: kernel32.h:35
static struct ID3DXBufferImpl * impl_from_ID3DXBuffer(ID3DXBuffer *iface)
Definition: core.c:38
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void * buffer
Definition: core.c:34
LONG HRESULT
Definition: typedefs.h:79
const GUID IID_IUnknown
static const struct ID3DXBufferVtbl ID3DXBufferImpl_Vtbl
Definition: core.c:104
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define InterlockedDecrement
Definition: armddk.h:52
#define ERR(fmt,...)
Definition: debug.h:110
#define D3D_OK
Definition: d3d.h:106
#define InterlockedIncrement
Definition: armddk.h:53
static ULONG WINAPI ID3DXBufferImpl_Release(ID3DXBuffer *iface)
Definition: core.c:70
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
DWORD size
Definition: core.c:35
unsigned int ULONG
Definition: retypes.h:1
ID3DXBuffer ID3DXBuffer_iface
Definition: core.c:31
static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(ID3DXBuffer *iface)
Definition: core.c:95
#define HeapFree(x, y, z)
Definition: compat.h:594