2002-12-17 02:15:15 +01:00
|
|
|
/*
|
|
|
|
* ID3DXBuffer implementation
|
|
|
|
*
|
|
|
|
* Copyright 2002 Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-12-17 02:15:15 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2006-06-10 11:50:26 +02:00
|
|
|
#define COBJMACROS
|
2002-12-17 02:15:15 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "d3d8.h"
|
|
|
|
#include "d3dx8core_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
|
|
|
/* ID3DXBuffer IUnknown parts follow: */
|
2006-06-10 11:50:26 +02:00
|
|
|
static HRESULT WINAPI ID3DXBufferImpl_QueryInterface(LPD3DXBUFFER iface, REFIID riid, LPVOID* ppobj) {
|
2004-09-08 03:50:37 +02:00
|
|
|
ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
|
2002-12-17 02:15:15 +01:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3DXBuffer)) {
|
2006-06-10 11:50:26 +02:00
|
|
|
IUnknown_AddRef(iface);
|
2002-12-17 02:15:15 +01:00
|
|
|
*ppobj = This;
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:50:26 +02:00
|
|
|
static ULONG WINAPI ID3DXBufferImpl_AddRef(LPD3DXBUFFER iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
|
2005-01-21 11:18:16 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
|
|
|
|
|
|
|
|
return ref;
|
2002-12-17 02:15:15 +01:00
|
|
|
}
|
|
|
|
|
2006-06-10 11:50:26 +02:00
|
|
|
static ULONG WINAPI ID3DXBufferImpl_Release(LPD3DXBUFFER iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
|
2005-01-21 11:18:16 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
|
|
|
|
|
2002-12-17 02:15:15 +01:00
|
|
|
if (ref == 0) {
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->buffer);
|
2002-12-17 02:15:15 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3DXBuffer Interface follow: */
|
2006-06-10 11:50:26 +02:00
|
|
|
static LPVOID WINAPI ID3DXBufferImpl_GetBufferPointer(LPD3DXBUFFER iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
|
2002-12-17 02:15:15 +01:00
|
|
|
return This->buffer;
|
|
|
|
}
|
|
|
|
|
2006-06-10 11:50:26 +02:00
|
|
|
static DWORD WINAPI ID3DXBufferImpl_GetBufferSize(LPD3DXBUFFER iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
ID3DXBufferImpl *This = (ID3DXBufferImpl *)iface;
|
2002-12-17 02:15:15 +01:00
|
|
|
return This->bufferSize;
|
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
const ID3DXBufferVtbl D3DXBuffer_Vtbl =
|
2002-12-17 02:15:15 +01:00
|
|
|
{
|
|
|
|
ID3DXBufferImpl_QueryInterface,
|
|
|
|
ID3DXBufferImpl_AddRef,
|
|
|
|
ID3DXBufferImpl_Release,
|
|
|
|
ID3DXBufferImpl_GetBufferPointer,
|
|
|
|
ID3DXBufferImpl_GetBufferSize
|
|
|
|
};
|