comctl32: Constify some variables.
[wine/multimedia.git] / dlls / d3d8 / surface.c
blob93ea2f5f14e9c71344ae90f9797d056b26c4da46
1 /*
2 * IDirect3DSurface8 implementation
4 * Copyright 2005 Oliver Stieber
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DSurface8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
30 if (IsEqualGUID(riid, &IID_IUnknown)
31 || IsEqualGUID(riid, &IID_IDirect3DResource8)
32 || IsEqualGUID(riid, &IID_IDirect3DSurface8)) {
33 IUnknown_AddRef(iface);
34 *ppobj = This;
35 return S_OK;
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39 *ppobj = NULL;
40 return E_NOINTERFACE;
43 static ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
44 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
46 TRACE("(%p)\n", This);
48 if (This->forwardReference) {
49 /* Forward refcounting */
50 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
51 return IUnknown_AddRef(This->forwardReference);
52 } else {
53 /* No container, handle our own refcounting */
54 ULONG ref = InterlockedIncrement(&This->ref);
55 if(ref == 1 && This->parentDevice) IUnknown_AddRef(This->parentDevice);
56 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
57 return ref;
61 static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
62 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
64 TRACE("(%p)\n", This);
66 if (This->forwardReference) {
67 /* Forward refcounting */
68 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
69 return IUnknown_Release(This->forwardReference);
70 } else {
71 /* No container, handle our own refcounting */
72 ULONG ref = InterlockedDecrement(&This->ref);
73 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
75 if (ref == 0) {
76 if (This->parentDevice) IUnknown_Release(This->parentDevice);
77 /* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
78 if (!This->isImplicit) {
79 IWineD3DSurface_Release(This->wineD3DSurface);
80 HeapFree(GetProcessHeap(), 0, This);
84 return ref;
88 /* IDirect3DSurface8 IDirect3DResource8 Interface follow: */
89 static HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface, IDirect3DDevice8 **ppDevice) {
90 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
91 return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
94 static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
95 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
96 TRACE("(%p) Relay\n", This);
97 return IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
100 static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
101 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
102 TRACE("(%p) Relay\n", This);
103 return IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
106 static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid) {
107 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
108 TRACE("(%p) Relay\n", This);
109 return IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
112 /* IDirect3DSurface8 Interface follow: */
113 static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
114 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
115 HRESULT res;
117 TRACE("(%p) Relay\n", This);
119 if (!This->container) return E_NOINTERFACE;
121 res = IUnknown_QueryInterface(This->container, riid, ppContainer);
123 TRACE("(%p) : returning %p\n", This, *ppContainer);
124 return res;
127 static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
128 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
129 WINED3DSURFACE_DESC wined3ddesc;
130 TRACE("(%p) Relay\n", This);
132 /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
133 memset(&wined3ddesc, 0, sizeof(wined3ddesc));
134 wined3ddesc.Format = (WINED3DFORMAT *)&pDesc->Format;
135 wined3ddesc.Type = (WINED3DRESOURCETYPE *)&pDesc->Type;
136 wined3ddesc.Usage = &pDesc->Usage;
137 wined3ddesc.Pool = (WINED3DPOOL *) &pDesc->Pool;
138 wined3ddesc.Size = &pDesc->Size;
139 wined3ddesc.MultiSampleType = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
140 wined3ddesc.Width = &pDesc->Width;
141 wined3ddesc.Height = &pDesc->Height;
143 return IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
146 static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
147 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
148 TRACE("(%p) Relay\n", This);
149 TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
150 return IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
153 static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
154 IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
155 TRACE("(%p) Relay\n", This);
156 return IWineD3DSurface_UnlockRect(This->wineD3DSurface);
159 const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =
161 /* IUnknown */
162 IDirect3DSurface8Impl_QueryInterface,
163 IDirect3DSurface8Impl_AddRef,
164 IDirect3DSurface8Impl_Release,
165 /* IDirect3DResource8 */
166 IDirect3DSurface8Impl_GetDevice,
167 IDirect3DSurface8Impl_SetPrivateData,
168 IDirect3DSurface8Impl_GetPrivateData,
169 IDirect3DSurface8Impl_FreePrivateData,
170 /* IDirect3DSurface8 */
171 IDirect3DSurface8Impl_GetContainer,
172 IDirect3DSurface8Impl_GetDesc,
173 IDirect3DSurface8Impl_LockRect,
174 IDirect3DSurface8Impl_UnlockRect