Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / d3d8 / resource.c
blob0e34f3f0c17a6add2e1e5dd152a77e6884de4ae1
1 /*
2 * IDirect3DResource8 implementation
4 * Copyright 2002 Jason Edmeades
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "wingdi.h"
29 #include "wine/debug.h"
31 #include "d3d8_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
35 /* IDirect3DResource IUnknown parts follow: */
36 HRESULT WINAPI IDirect3DResource8Impl_QueryInterface(LPDIRECT3DRESOURCE8 iface,REFIID riid,LPVOID *ppobj)
38 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DResource8)) {
42 IDirect3DResource8Impl_AddRef(iface);
43 *ppobj = This;
44 return D3D_OK;
47 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
48 return E_NOINTERFACE;
51 ULONG WINAPI IDirect3DResource8Impl_AddRef(LPDIRECT3DRESOURCE8 iface) {
52 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
53 ULONG ref = InterlockedIncrement(&This->ref);
55 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
57 return ref;
60 ULONG WINAPI IDirect3DResource8Impl_Release(LPDIRECT3DRESOURCE8 iface) {
61 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
62 ULONG ref = InterlockedDecrement(&This->ref);
64 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
66 if (ref == 0)
67 HeapFree(GetProcessHeap(), 0, This);
68 return ref;
71 /* IDirect3DResource Interface follow: */
72 HRESULT WINAPI IDirect3DResource8Impl_GetDevice(LPDIRECT3DRESOURCE8 iface, IDirect3DDevice8** ppDevice) {
73 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
74 TRACE("(%p) : returning %p\n", This, This->Device);
75 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
76 IDirect3DDevice8Impl_AddRef(*ppDevice);
77 return D3D_OK;
79 HRESULT WINAPI IDirect3DResource8Impl_SetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
80 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
81 FIXME("(%p) : stub\n", This); return D3D_OK;
83 HRESULT WINAPI IDirect3DResource8Impl_GetPrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
84 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
85 FIXME("(%p) : stub\n", This); return D3D_OK;
87 HRESULT WINAPI IDirect3DResource8Impl_FreePrivateData(LPDIRECT3DRESOURCE8 iface, REFGUID refguid) {
88 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
89 FIXME("(%p) : stub\n", This); return D3D_OK;
91 DWORD WINAPI IDirect3DResource8Impl_SetPriority(LPDIRECT3DRESOURCE8 iface, DWORD PriorityNew) {
92 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
93 FIXME("(%p) : stub\n", This);
94 return 0;
96 DWORD WINAPI IDirect3DResource8Impl_GetPriority(LPDIRECT3DRESOURCE8 iface) {
97 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
98 FIXME("(%p) : stub\n", This);
99 return 0;
101 void WINAPI IDirect3DResource8Impl_PreLoad(LPDIRECT3DRESOURCE8 iface) {
102 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
103 FIXME("(%p) : stub\n", This);
105 D3DRESOURCETYPE WINAPI IDirect3DResource8Impl_GetType(LPDIRECT3DRESOURCE8 iface) {
106 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
107 TRACE("(%p) : returning %d\n", This, This->ResourceType);
108 return This->ResourceType;
111 D3DPOOL WINAPI IDirect3DResource8Impl_GetPool(LPDIRECT3DRESOURCE8 iface) {
112 IDirect3DResource8Impl *This = (IDirect3DResource8Impl *)iface;
114 switch (This->ResourceType) {
115 case D3DRTYPE_SURFACE:
116 return ((IDirect3DSurface8Impl*) This)->myDesc.Pool;
117 case D3DRTYPE_TEXTURE:
118 return ((IDirect3DTexture8Impl*) This)->surfaces[0]->myDesc.Pool;
119 case D3DRTYPE_VOLUME:
120 return ((IDirect3DVolume8Impl*) This)->myDesc.Pool;
121 case D3DRTYPE_VOLUMETEXTURE:
122 return ((IDirect3DVolumeTexture8Impl*) This)->volumes[0]->myDesc.Pool;
123 case D3DRTYPE_CUBETEXTURE:
124 return ((IDirect3DCubeTexture8Impl*) This)->surfaces[0][0]->myDesc.Pool;
125 case D3DRTYPE_VERTEXBUFFER:
126 return ((IDirect3DVertexBuffer8Impl*) This)->currentDesc.Pool;
127 case D3DRTYPE_INDEXBUFFER:
128 return ((IDirect3DIndexBuffer8Impl*) This)->currentDesc.Pool;
129 default:
130 FIXME("(%p) Unrecognized type(%d,%s)\n", This, This->ResourceType, debug_d3dressourcetype(This->ResourceType));
131 return D3DPOOL_DEFAULT;
135 IDirect3DResource8Vtbl Direct3DResource8_Vtbl =
137 IDirect3DResource8Impl_QueryInterface,
138 IDirect3DResource8Impl_AddRef,
139 IDirect3DResource8Impl_Release,
140 IDirect3DResource8Impl_GetDevice,
141 IDirect3DResource8Impl_SetPrivateData,
142 IDirect3DResource8Impl_GetPrivateData,
143 IDirect3DResource8Impl_FreePrivateData,
144 IDirect3DResource8Impl_SetPriority,
145 IDirect3DResource8Impl_GetPriority,
146 IDirect3DResource8Impl_PreLoad,
147 IDirect3DResource8Impl_GetType