ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

core.c
Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright 2002 Raphael Junqueira
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include <stdarg.h>
00021 
00022 #define COBJMACROS
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "wingdi.h"
00026 #include "wine/debug.h"
00027 #include "wine/unicode.h"
00028 
00029 #include "d3dx9_36_private.h"
00030 
00031 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
00032 
00033 /* ID3DXBuffer IUnknown parts follow: */
00034 static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj)
00035 {
00036     ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
00037 
00038     if (IsEqualGUID(riid, &IID_IUnknown)
00039       || IsEqualGUID(riid, &IID_ID3DXBuffer))
00040     {
00041         IUnknown_AddRef(iface);
00042         *ppobj = This;
00043         return D3D_OK;
00044     }
00045 
00046     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
00047     return E_NOINTERFACE;
00048 }
00049 
00050 static ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface)
00051 {
00052     ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
00053     ULONG ref = InterlockedIncrement(&This->ref);
00054 
00055     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
00056 
00057     return ref;
00058 }
00059 
00060 static ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface)
00061 {
00062     ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
00063     ULONG ref = InterlockedDecrement(&This->ref);
00064 
00065     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
00066 
00067     if (ref == 0)
00068     {
00069         HeapFree(GetProcessHeap(), 0, This->buffer);
00070         HeapFree(GetProcessHeap(), 0, This);
00071     }
00072     return ref;
00073 }
00074 
00075 /* ID3DXBuffer Interface follow: */
00076 static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface)
00077 {
00078     ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
00079     return This->buffer;
00080 }
00081 
00082 static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface)
00083 {
00084     ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
00085     return This->bufferSize;
00086 }
00087 
00088 const ID3DXBufferVtbl D3DXBuffer_Vtbl =
00089 {
00090     ID3DXBufferImpl_QueryInterface,
00091     ID3DXBufferImpl_AddRef,
00092     ID3DXBufferImpl_Release,
00093     ID3DXBufferImpl_GetBufferPointer,
00094     ID3DXBufferImpl_GetBufferSize
00095 };
00096 
00097 HRESULT WINAPI D3DXCreateBuffer(DWORD NumBytes, LPD3DXBUFFER* ppBuffer)
00098 {
00099     ID3DXBufferImpl *object;
00100 
00101     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ID3DXBufferImpl));
00102     if (object == NULL)
00103     {
00104         *ppBuffer = NULL;
00105         return E_OUTOFMEMORY;
00106     }
00107     object->lpVtbl = &D3DXBuffer_Vtbl;
00108     object->ref = 1;
00109     object->bufferSize = NumBytes;
00110     object->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, NumBytes);
00111     if (object->buffer == NULL)
00112     {
00113         HeapFree(GetProcessHeap(), 0, object);
00114         *ppBuffer = NULL;
00115         return E_OUTOFMEMORY;
00116     }
00117 
00118     *ppBuffer = (LPD3DXBUFFER)object;
00119     return D3D_OK;
00120 }

Generated on Sat May 26 2012 04:20:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.