~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d8/surface.c

Version: ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * IDirect3DSurface8 implementation
  3  *
  4  * Copyright 2005 Oliver Stieber
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #include "config.h"
 22 #include "d3d8_private.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
 25 
 26 /* IDirect3DSurface8 IUnknown parts follow: */
 27 static HRESULT WINAPI IDirect3DSurface8Impl_QueryInterface(LPDIRECT3DSURFACE8 iface, REFIID riid, LPVOID *ppobj) {
 28     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
 29 
 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;
 36     }
 37 
 38     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 39     *ppobj = NULL;
 40     return E_NOINTERFACE;
 41 }
 42 
 43 static ULONG WINAPI IDirect3DSurface8Impl_AddRef(LPDIRECT3DSURFACE8 iface) {
 44     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
 45 
 46     TRACE("(%p)\n", This);
 47 
 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;
 58     }
 59 }
 60 
 61 static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
 62     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
 63 
 64     TRACE("(%p)\n", This);
 65 
 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);
 74 
 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                 EnterCriticalSection(&d3d8_cs);
 80                 IWineD3DSurface_Release(This->wineD3DSurface);
 81                 LeaveCriticalSection(&d3d8_cs);
 82                 HeapFree(GetProcessHeap(), 0, This);
 83             }
 84         }
 85 
 86         return ref;
 87     }
 88 }
 89 
 90 /* IDirect3DSurface8 IDirect3DResource8 Interface follow: */
 91 static HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface, IDirect3DDevice8 **ppDevice) {
 92     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
 93     HRESULT hr;
 94     TRACE("(%p)->(%p)\n", This, ppDevice);
 95 
 96     EnterCriticalSection(&d3d8_cs);
 97     hr = IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
 98     LeaveCriticalSection(&d3d8_cs);
 99     return hr;
100 }
101 
102 static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
103     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
104     HRESULT hr;
105     TRACE("(%p) Relay\n", This);
106 
107     EnterCriticalSection(&d3d8_cs);
108     hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
109     LeaveCriticalSection(&d3d8_cs);
110     return hr;
111 }
112 
113 static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
114     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
115     HRESULT hr;
116     TRACE("(%p) Relay\n", This);
117 
118     EnterCriticalSection(&d3d8_cs);
119     hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
120     LeaveCriticalSection(&d3d8_cs);
121     return hr;
122 }
123 
124 static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid) {
125     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
126     HRESULT hr;
127     TRACE("(%p) Relay\n", This);
128 
129     EnterCriticalSection(&d3d8_cs);
130     hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
131     LeaveCriticalSection(&d3d8_cs);
132     return hr;
133 }
134 
135 /* IDirect3DSurface8 Interface follow: */
136 static HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void **ppContainer) {
137     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
138     HRESULT res;
139 
140     TRACE("(%p) Relay\n", This);
141 
142     if (!This->container) return E_NOINTERFACE;
143 
144     res = IUnknown_QueryInterface(This->container, riid, ppContainer);
145 
146     TRACE("(%p) : returning %p\n", This, *ppContainer);
147     return res;
148 }
149 
150 static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
151     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
152     WINED3DSURFACE_DESC    wined3ddesc;
153     HRESULT hr;
154     TRACE("(%p) Relay\n", This);
155 
156     /* As d3d8 and d3d9 structures differ, pass in ptrs to where data needs to go */
157     memset(&wined3ddesc, 0, sizeof(wined3ddesc));
158     wined3ddesc.Format              = (WINED3DFORMAT *)&pDesc->Format;
159     wined3ddesc.Type                = (WINED3DRESOURCETYPE *)&pDesc->Type;
160     wined3ddesc.Usage               = &pDesc->Usage;
161     wined3ddesc.Pool                = (WINED3DPOOL *) &pDesc->Pool;
162     wined3ddesc.Size                = &pDesc->Size;
163     wined3ddesc.MultiSampleType     = (WINED3DMULTISAMPLE_TYPE *) &pDesc->MultiSampleType;
164     wined3ddesc.Width               = &pDesc->Width;
165     wined3ddesc.Height              = &pDesc->Height;
166 
167     EnterCriticalSection(&d3d8_cs);
168     hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
169     LeaveCriticalSection(&d3d8_cs);
170     return hr;
171 }
172 
173 static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKED_RECT *pLockedRect, CONST RECT *pRect, DWORD Flags) {
174     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
175     HRESULT hr;
176     TRACE("(%p) Relay\n", This);
177     TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
178 
179     EnterCriticalSection(&d3d8_cs);
180     if (pRect) {
181         D3DSURFACE_DESC desc;
182         IDirect3DSurface8_GetDesc(iface, &desc);
183 
184         if ((pRect->left < 0)
185                 || (pRect->top < 0)
186                 || (pRect->left >= pRect->right)
187                 || (pRect->top >= pRect->bottom)
188                 || (pRect->right > desc.Width)
189                 || (pRect->bottom > desc.Height)) {
190             WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
191             LeaveCriticalSection(&d3d8_cs);
192             return D3DERR_INVALIDCALL;
193         }
194     }
195 
196     hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
197     LeaveCriticalSection(&d3d8_cs);
198     return hr;
199 }
200 
201 static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface) {
202     IDirect3DSurface8Impl *This = (IDirect3DSurface8Impl *)iface;
203     HRESULT hr;
204     TRACE("(%p) Relay\n", This);
205 
206     EnterCriticalSection(&d3d8_cs);
207     hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
208     LeaveCriticalSection(&d3d8_cs);
209     return hr;
210 }
211 
212 const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =
213 {
214     /* IUnknown */
215     IDirect3DSurface8Impl_QueryInterface,
216     IDirect3DSurface8Impl_AddRef,
217     IDirect3DSurface8Impl_Release,
218     /* IDirect3DResource8 */
219     IDirect3DSurface8Impl_GetDevice,
220     IDirect3DSurface8Impl_SetPrivateData,
221     IDirect3DSurface8Impl_GetPrivateData,
222     IDirect3DSurface8Impl_FreePrivateData,
223     /* IDirect3DSurface8 */
224     IDirect3DSurface8Impl_GetContainer,
225     IDirect3DSurface8Impl_GetDesc,
226     IDirect3DSurface8Impl_LockRect,
227     IDirect3DSurface8Impl_UnlockRect
228 };
229 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.