resource.c 4.99 KB
Newer Older
1 2 3
/*
 * IDirect3DResource8 implementation
 *
4
 * Copyright 2005 Oliver Stieber
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * 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
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 20
 */

21
#include "config.h"
22 23
#include "d3d8_private.h"

24
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25

26
/* IDirect3DResource8 IUnknown parts follow: */
27
static HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface, REFIID riid, LPVOID* ppobj) {
28
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
29 30

    if (IsEqualGUID(riid, &IID_IUnknown)
31
        || IsEqualGUID(riid, &IID_IDirect3DResource8)) {
32
        IUnknown_AddRef(iface);
33
        *ppobj = This;
H. Verbeet's avatar
H. Verbeet committed
34
        return S_OK;
35 36
    }

37
    WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
H. Verbeet's avatar
H. Verbeet committed
38
    *ppobj = NULL;
39 40 41
    return E_NOINTERFACE;
}

42
static ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface) {
43
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
44 45
    ULONG ref = InterlockedIncrement(&This->ref);

46
    TRACE("(%p) : AddRef from %d\n", This, ref - 1);
47 48

    return ref;
49 50
}

51
static ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface) {
52
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
53 54
    ULONG ref = InterlockedDecrement(&This->ref);

55
    TRACE("(%p) : ReleaseRef to %d\n", This, ref);
56

57 58
    if (ref == 0) {
        IWineD3DResource_Release(This->wineD3DResource);
59
        HeapFree(GetProcessHeap(), 0, This);
60
    }
61 62 63
    return ref;
}

64 65
/* IDirect3DResource8 Interface follow: */
HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice) {
66
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
67 68 69 70 71 72 73
    IWineD3DDevice *myDevice = NULL;

    TRACE("(%p) Relay\n", This);

    IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
    IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
    IWineD3DDevice_Release(myDevice);
74 75
    return D3D_OK;
}
76

77
static HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
78
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
79 80
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_SetPrivateData(This->wineD3DResource, refguid, pData, SizeOfData, Flags);
81
}
82

83
static HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
84
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
85 86
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_GetPrivateData(This->wineD3DResource, refguid, pData, pSizeOfData);
87
}
88

89
static HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid) {
90
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
91 92
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_FreePrivateData(This->wineD3DResource, refguid);
93
}
94

95
static DWORD  WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew) {
96
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
97 98
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_SetPriority(This->wineD3DResource, PriorityNew);
99
}
100

101
static DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface) {
102
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
103 104
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_GetPriority(This->wineD3DResource);
105
}
106

107
static void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface) {
108
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
109 110 111
    TRACE("(%p) Relay\n", This);
    IWineD3DResource_PreLoad(This->wineD3DResource);
    return;
112
}
113

114
static D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface) {
115
    IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
116 117
    TRACE("(%p) Relay\n", This);
    return IWineD3DResource_GetType(This->wineD3DResource);
118 119
}

120
const IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
121 122 123 124 125 126 127 128 129 130 131 132 133
{
    IDirect3DResource8Impl_QueryInterface,
    IDirect3DResource8Impl_AddRef,
    IDirect3DResource8Impl_Release,
    IDirect3DResource8Impl_GetDevice,
    IDirect3DResource8Impl_SetPrivateData,
    IDirect3DResource8Impl_GetPrivateData,
    IDirect3DResource8Impl_FreePrivateData,
    IDirect3DResource8Impl_SetPriority,
    IDirect3DResource8Impl_GetPriority,
    IDirect3DResource8Impl_PreLoad,
    IDirect3DResource8Impl_GetType
};