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

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

Version: ~ [ 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  * IDirect3DDevice8 implementation
  3  *
  4  * Copyright 2002-2004 Jason Edmeades
  5  * Copyright 2004 Christian Costa
  6  *
  7  * This library is free software; you can redistribute it and/or
  8  * modify it under the terms of the GNU Lesser General Public
  9  * License as published by the Free Software Foundation; either
 10  * version 2.1 of the License, or (at your option) any later version.
 11  *
 12  * This library is distributed in the hope that it will be useful,
 13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15  * Lesser General Public License for more details.
 16  *
 17  * You should have received a copy of the GNU Lesser General Public
 18  * License along with this library; if not, write to the Free Software
 19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 20  */
 21 
 22 #include "config.h"
 23 
 24 #include <math.h>
 25 #include <stdarg.h>
 26 
 27 #define NONAMELESSUNION
 28 #define NONAMELESSSTRUCT
 29 #include "windef.h"
 30 #include "winbase.h"
 31 #include "winuser.h"
 32 #include "wingdi.h"
 33 #include "wine/debug.h"
 34 
 35 #include "d3d8_private.h"
 36 
 37 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
 38 
 39 /* Shader handle functions */
 40 static shader_handle *alloc_shader_handle(IDirect3DDevice8Impl *This) {
 41     if (This->free_shader_handles) {
 42         /* Use a free handle */
 43         shader_handle *handle = This->free_shader_handles;
 44         This->free_shader_handles = *handle;
 45         return handle;
 46     }
 47     if (!(This->allocated_shader_handles < This->shader_handle_table_size)) {
 48         /* Grow the table */
 49         DWORD new_size = This->shader_handle_table_size + (This->shader_handle_table_size >> 1);
 50         shader_handle *new_handles = HeapReAlloc(GetProcessHeap(), 0, This->shader_handles, new_size * sizeof(shader_handle));
 51         if (!new_handles) return NULL;
 52         This->shader_handles = new_handles;
 53         This->shader_handle_table_size = new_size;
 54     }
 55 
 56     return &This->shader_handles[This->allocated_shader_handles++];
 57 }
 58 
 59 static void free_shader_handle(IDirect3DDevice8Impl *This, shader_handle *handle) {
 60     *handle = This->free_shader_handles;
 61     This->free_shader_handles = handle;
 62 }
 63 
 64 /* IDirect3D IUnknown parts follow: */
 65 static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 iface,REFIID riid,LPVOID *ppobj)
 66 {
 67     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
 68 
 69     if (IsEqualGUID(riid, &IID_IUnknown)
 70         || IsEqualGUID(riid, &IID_IDirect3DDevice8)) {
 71         IUnknown_AddRef(iface);
 72         *ppobj = This;
 73         return S_OK;
 74     }
 75 
 76     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 77     *ppobj = NULL;
 78     return E_NOINTERFACE;
 79 }
 80 
 81 static ULONG WINAPI IDirect3DDevice8Impl_AddRef(LPDIRECT3DDEVICE8 iface) {
 82     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
 83     ULONG ref = InterlockedIncrement(&This->ref);
 84 
 85     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
 86 
 87     return ref;
 88 }
 89 
 90 static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
 91     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
 92     ULONG ref;
 93 
 94     if (This->inDestruction) return 0;
 95     ref = InterlockedDecrement(&This->ref);
 96 
 97     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
 98 
 99     if (ref == 0) {
100         unsigned i;
101 
102         TRACE("Releasing wined3d device %p\n", This->WineD3DDevice);
103         EnterCriticalSection(&d3d8_cs);
104         This->inDestruction = TRUE;
105 
106         for(i = 0; i < This->numConvertedDecls; i++) {
107             IWineD3DVertexDeclaration_Release(This->decls[i].decl);
108         }
109         HeapFree(GetProcessHeap(), 0, This->decls);
110 
111         IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D8CB_DestroyDepthStencilSurface, D3D8CB_DestroySwapChain);
112         IWineD3DDevice_Release(This->WineD3DDevice);
113         HeapFree(GetProcessHeap(), 0, This->shader_handles);
114         HeapFree(GetProcessHeap(), 0, This);
115         LeaveCriticalSection(&d3d8_cs);
116     }
117     return ref;
118 }
119 
120 /* IDirect3DDevice Interface follow: */
121 static HRESULT WINAPI IDirect3DDevice8Impl_TestCooperativeLevel(LPDIRECT3DDEVICE8 iface) {
122     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
123     HRESULT hr;
124 
125     TRACE("(%p) : Relay\n", This);
126     EnterCriticalSection(&d3d8_cs);
127     hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
128     LeaveCriticalSection(&d3d8_cs);
129     return hr;
130 }
131 
132 static UINT WINAPI  IDirect3DDevice8Impl_GetAvailableTextureMem(LPDIRECT3DDEVICE8 iface) {
133     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
134     HRESULT hr;
135 
136     TRACE("(%p) Relay\n", This);
137     EnterCriticalSection(&d3d8_cs);
138     hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
139     LeaveCriticalSection(&d3d8_cs);
140     return hr;
141 }
142 
143 static HRESULT WINAPI IDirect3DDevice8Impl_ResourceManagerDiscardBytes(LPDIRECT3DDEVICE8 iface, DWORD Bytes) {
144     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
145     HRESULT hr;
146 
147     TRACE("(%p) : Relay bytes(%d)\n", This, Bytes);
148     EnterCriticalSection(&d3d8_cs);
149     hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
150     LeaveCriticalSection(&d3d8_cs);
151     return hr;
152 }
153 
154 static HRESULT WINAPI IDirect3DDevice8Impl_GetDirect3D(LPDIRECT3DDEVICE8 iface, IDirect3D8** ppD3D8) {
155     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
156     HRESULT hr = D3D_OK;
157     IWineD3D* pWineD3D;
158 
159     TRACE("(%p) Relay\n", This);
160 
161     if (NULL == ppD3D8) {
162         return D3DERR_INVALIDCALL;
163     }
164 
165     EnterCriticalSection(&d3d8_cs);
166     hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
167     if (hr == D3D_OK && pWineD3D != NULL)
168     {
169         IWineD3D_GetParent(pWineD3D,(IUnknown **)ppD3D8);
170         IWineD3D_Release(pWineD3D);
171     } else {
172         FIXME("Call to IWineD3DDevice_GetDirect3D failed\n");
173         *ppD3D8 = NULL;
174     }
175     TRACE("(%p) returning %p\n",This , *ppD3D8);
176     LeaveCriticalSection(&d3d8_cs);
177 
178     return hr;
179 }
180 
181 static HRESULT WINAPI IDirect3DDevice8Impl_GetDeviceCaps(LPDIRECT3DDEVICE8 iface, D3DCAPS8* pCaps) {
182     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
183     HRESULT hrc = D3D_OK;
184     WINED3DCAPS *pWineCaps;
185 
186     TRACE("(%p) : Relay pCaps %p\n", This, pCaps);
187     if(NULL == pCaps){
188         return D3DERR_INVALIDCALL;
189     }
190     pWineCaps = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WINED3DCAPS));
191     if(pWineCaps == NULL){
192         return D3DERR_INVALIDCALL; /* well this is what MSDN says to return */
193     }
194 
195     EnterCriticalSection(&d3d8_cs);
196     hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
197     LeaveCriticalSection(&d3d8_cs);
198     WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
199     HeapFree(GetProcessHeap(), 0, pWineCaps);
200 
201     /* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
202     if(pCaps->PixelShaderVersion > D3DPS_VERSION(1,4)){
203         pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
204     }
205     if(pCaps->VertexShaderVersion > D3DVS_VERSION(1,1)){
206         pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
207     }
208 
209     TRACE("Returning %p %p\n", This, pCaps);
210     return hrc;
211 }
212 
213 static HRESULT WINAPI IDirect3DDevice8Impl_GetDisplayMode(LPDIRECT3DDEVICE8 iface, D3DDISPLAYMODE* pMode) {
214     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
215     HRESULT hr;
216     TRACE("(%p) Relay\n", This);
217 
218     EnterCriticalSection(&d3d8_cs);
219     hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, 0, (WINED3DDISPLAYMODE *) pMode);
220     LeaveCriticalSection(&d3d8_cs);
221     return hr;
222 }
223 
224 static HRESULT WINAPI IDirect3DDevice8Impl_GetCreationParameters(LPDIRECT3DDEVICE8 iface, D3DDEVICE_CREATION_PARAMETERS *pParameters) {
225     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
226     HRESULT hr;
227     TRACE("(%p) Relay\n", This);
228 
229     EnterCriticalSection(&d3d8_cs);
230     hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
231     LeaveCriticalSection(&d3d8_cs);
232     return hr;
233 }
234 
235 static HRESULT WINAPI IDirect3DDevice8Impl_SetCursorProperties(LPDIRECT3DDEVICE8 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface8* pCursorBitmap) {
236     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
237     IDirect3DSurface8Impl *pSurface = (IDirect3DSurface8Impl*)pCursorBitmap;
238     HRESULT hr;
239     TRACE("(%p) Relay\n", This);
240     if(!pCursorBitmap) {
241         WARN("No cursor bitmap, returning WINED3DERR_INVALIDCALL\n");
242         return WINED3DERR_INVALIDCALL;
243     }
244 
245     EnterCriticalSection(&d3d8_cs);
246     hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice,XHotSpot,YHotSpot,pSurface->wineD3DSurface);
247     LeaveCriticalSection(&d3d8_cs);
248     return hr;
249 }
250 
251 static void WINAPI IDirect3DDevice8Impl_SetCursorPosition(LPDIRECT3DDEVICE8 iface, UINT XScreenSpace, UINT YScreenSpace, DWORD Flags) {
252     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
253     TRACE("(%p) Relay\n", This);
254 
255     EnterCriticalSection(&d3d8_cs);
256     IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
257     LeaveCriticalSection(&d3d8_cs);
258 }
259 
260 static BOOL WINAPI IDirect3DDevice8Impl_ShowCursor(LPDIRECT3DDEVICE8 iface, BOOL bShow) {
261     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
262     BOOL ret;
263     TRACE("(%p) Relay\n", This);
264 
265     EnterCriticalSection(&d3d8_cs);
266     ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
267     LeaveCriticalSection(&d3d8_cs);
268     return ret;
269 }
270 
271 static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain8** pSwapChain) {
272     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
273     IDirect3DSwapChain8Impl* object;
274     HRESULT hrc = D3D_OK;
275     WINED3DPRESENT_PARAMETERS localParameters;
276 
277     TRACE("(%p) Relay\n", This);
278 
279     /* Fix the back buffer count */
280     if(pPresentationParameters->BackBufferCount == 0) {
281         pPresentationParameters->BackBufferCount = 1;
282     }
283 
284     object = HeapAlloc(GetProcessHeap(),  HEAP_ZERO_MEMORY, sizeof(*object));
285     if (NULL == object) {
286         FIXME("Allocation of memory failed\n");
287         *pSwapChain = NULL;
288         return D3DERR_OUTOFVIDEOMEMORY;
289     }
290     object->ref = 1;
291     object->lpVtbl = &Direct3DSwapChain8_Vtbl;
292 
293     /* Allocate an associated WineD3DDevice object */
294     localParameters.BackBufferWidth                             = pPresentationParameters->BackBufferWidth;
295     localParameters.BackBufferHeight                            = pPresentationParameters->BackBufferHeight;
296     localParameters.BackBufferFormat                            = pPresentationParameters->BackBufferFormat;
297     localParameters.BackBufferCount                             = pPresentationParameters->BackBufferCount;
298     localParameters.MultiSampleType                             = pPresentationParameters->MultiSampleType;
299     localParameters.MultiSampleQuality                          = 0; /* d3d9 only */
300     localParameters.SwapEffect                                  = pPresentationParameters->SwapEffect;
301     localParameters.hDeviceWindow                               = pPresentationParameters->hDeviceWindow;
302     localParameters.Windowed                                    = pPresentationParameters->Windowed;
303     localParameters.EnableAutoDepthStencil                      = pPresentationParameters->EnableAutoDepthStencil;
304     localParameters.AutoDepthStencilFormat                      = pPresentationParameters->AutoDepthStencilFormat;
305     localParameters.Flags                                       = pPresentationParameters->Flags;
306     localParameters.FullScreen_RefreshRateInHz                  = pPresentationParameters->FullScreen_RefreshRateInHz;
307     localParameters.PresentationInterval                        = pPresentationParameters->FullScreen_PresentationInterval;
308 
309     EnterCriticalSection(&d3d8_cs);
310     hrc = IWineD3DDevice_CreateAdditionalSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D8CB_CreateRenderTarget, D3D8CB_CreateDepthStencilSurface, SURFACE_OPENGL);
311     LeaveCriticalSection(&d3d8_cs);
312 
313     pPresentationParameters->BackBufferWidth                    = localParameters.BackBufferWidth;
314     pPresentationParameters->BackBufferHeight                   = localParameters.BackBufferHeight;
315     pPresentationParameters->BackBufferFormat                   = localParameters.BackBufferFormat;
316     pPresentationParameters->BackBufferCount                    = localParameters.BackBufferCount;
317     pPresentationParameters->MultiSampleType                    = localParameters.MultiSampleType;
318     pPresentationParameters->SwapEffect                         = localParameters.SwapEffect;
319     pPresentationParameters->hDeviceWindow                      = localParameters.hDeviceWindow;
320     pPresentationParameters->Windowed                           = localParameters.Windowed;
321     pPresentationParameters->EnableAutoDepthStencil             = localParameters.EnableAutoDepthStencil;
322     pPresentationParameters->AutoDepthStencilFormat             = localParameters.AutoDepthStencilFormat;
323     pPresentationParameters->Flags                              = localParameters.Flags;
324     pPresentationParameters->FullScreen_RefreshRateInHz         = localParameters.FullScreen_RefreshRateInHz;
325     pPresentationParameters->FullScreen_PresentationInterval    = localParameters.PresentationInterval;
326 
327     if (hrc != D3D_OK) {
328         FIXME("(%p) call to IWineD3DDevice_CreateAdditionalSwapChain failed\n", This);
329         HeapFree(GetProcessHeap(), 0 , object);
330         *pSwapChain = NULL;
331     }else{
332         IUnknown_AddRef(iface);
333         object->parentDevice = iface;
334         *pSwapChain = (IDirect3DSwapChain8 *)object;
335     }
336     TRACE("(%p) returning %p\n", This, *pSwapChain);
337     return hrc;
338 }
339 
340 static HRESULT WINAPI IDirect3DDevice8Impl_Reset(LPDIRECT3DDEVICE8 iface, D3DPRESENT_PARAMETERS* pPresentationParameters) {
341     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
342     WINED3DPRESENT_PARAMETERS localParameters;
343     HRESULT hr;
344 
345     TRACE("(%p) Relay pPresentationParameters(%p)\n", This, pPresentationParameters);
346 
347     localParameters.BackBufferWidth                             = pPresentationParameters->BackBufferWidth;
348     localParameters.BackBufferHeight                            = pPresentationParameters->BackBufferHeight;
349     localParameters.BackBufferFormat                            = pPresentationParameters->BackBufferFormat;
350     localParameters.BackBufferCount                             = pPresentationParameters->BackBufferCount;
351     localParameters.MultiSampleType                             = pPresentationParameters->MultiSampleType;
352     localParameters.MultiSampleQuality                          = 0; /* d3d9 only */
353     localParameters.SwapEffect                                  = pPresentationParameters->SwapEffect;
354     localParameters.hDeviceWindow                               = pPresentationParameters->hDeviceWindow;
355     localParameters.Windowed                                    = pPresentationParameters->Windowed;
356     localParameters.EnableAutoDepthStencil                      = pPresentationParameters->EnableAutoDepthStencil;
357     localParameters.AutoDepthStencilFormat                      = pPresentationParameters->AutoDepthStencilFormat;
358     localParameters.Flags                                       = pPresentationParameters->Flags;
359     localParameters.FullScreen_RefreshRateInHz                  = pPresentationParameters->FullScreen_RefreshRateInHz;
360     localParameters.PresentationInterval                        = pPresentationParameters->FullScreen_PresentationInterval;
361 
362     EnterCriticalSection(&d3d8_cs);
363     hr = IWineD3DDevice_Reset(This->WineD3DDevice, &localParameters);
364     LeaveCriticalSection(&d3d8_cs);
365 
366     pPresentationParameters->BackBufferWidth                    = localParameters.BackBufferWidth;
367     pPresentationParameters->BackBufferHeight                   = localParameters.BackBufferHeight;
368     pPresentationParameters->BackBufferFormat                   = localParameters.BackBufferFormat;
369     pPresentationParameters->BackBufferCount                    = localParameters.BackBufferCount;
370     pPresentationParameters->MultiSampleType                    = localParameters.MultiSampleType;
371     pPresentationParameters->SwapEffect                         = localParameters.SwapEffect;
372     pPresentationParameters->hDeviceWindow                      = localParameters.hDeviceWindow;
373     pPresentationParameters->Windowed                           = localParameters.Windowed;
374     pPresentationParameters->EnableAutoDepthStencil             = localParameters.EnableAutoDepthStencil;
375     pPresentationParameters->AutoDepthStencilFormat             = localParameters.AutoDepthStencilFormat;
376     pPresentationParameters->Flags                              = localParameters.Flags;
377     pPresentationParameters->FullScreen_RefreshRateInHz         = localParameters.FullScreen_RefreshRateInHz;
378     pPresentationParameters->FullScreen_PresentationInterval    = localParameters.PresentationInterval;
379 
380     return hr;
381 }
382 
383 static HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) {
384     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
385     HRESULT hr;
386     TRACE("(%p) Relay\n", This);
387 
388     EnterCriticalSection(&d3d8_cs);
389     hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
390     LeaveCriticalSection(&d3d8_cs);
391     return hr;
392 }
393 
394 static HRESULT WINAPI IDirect3DDevice8Impl_GetBackBuffer(LPDIRECT3DDEVICE8 iface, UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) {
395     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
396     IWineD3DSurface *retSurface = NULL;
397     HRESULT rc = D3D_OK;
398 
399     TRACE("(%p) Relay\n", This);
400 
401     EnterCriticalSection(&d3d8_cs);
402     rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, 0, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
403     if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
404         IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
405         IWineD3DSurface_Release(retSurface);
406     }
407     LeaveCriticalSection(&d3d8_cs);
408     return rc;
409 }
410 
411 static HRESULT WINAPI IDirect3DDevice8Impl_GetRasterStatus(LPDIRECT3DDEVICE8 iface, D3DRASTER_STATUS* pRasterStatus) {
412     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
413     HRESULT hr;
414     TRACE("(%p) Relay\n", This);
415 
416     EnterCriticalSection(&d3d8_cs);
417     hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, 0, (WINED3DRASTER_STATUS *) pRasterStatus);
418     LeaveCriticalSection(&d3d8_cs);
419     return hr;
420 }
421 
422 static void WINAPI IDirect3DDevice8Impl_SetGammaRamp(LPDIRECT3DDEVICE8 iface, DWORD Flags, CONST D3DGAMMARAMP* pRamp) {
423     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
424     TRACE("(%p) Relay\n", This);
425 
426     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
427     EnterCriticalSection(&d3d8_cs);
428     IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, 0, Flags, (CONST WINED3DGAMMARAMP *) pRamp);
429     LeaveCriticalSection(&d3d8_cs);
430 }
431 
432 static void WINAPI IDirect3DDevice8Impl_GetGammaRamp(LPDIRECT3DDEVICE8 iface, D3DGAMMARAMP* pRamp) {
433     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
434     TRACE("(%p) Relay\n", This);
435 
436     /* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
437     EnterCriticalSection(&d3d8_cs);
438     IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, 0, (WINED3DGAMMARAMP *) pRamp);
439     LeaveCriticalSection(&d3d8_cs);
440 }
441 
442 static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
443                                                     D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture8 **ppTexture) {
444     IDirect3DTexture8Impl *object;
445     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
446     HRESULT hrc = D3D_OK;
447 
448     TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%u), Pool(%d)\n", This, Width, Height, Levels, Usage, Format,  Pool);
449 
450     /* Allocate the storage for the device */
451     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl));
452 
453     if (NULL == object) {
454         FIXME("Allocation of memory failed\n");
455 /*        *ppTexture = NULL; */
456         return D3DERR_OUTOFVIDEOMEMORY;
457     }
458 
459     object->lpVtbl = &Direct3DTexture8_Vtbl;
460     object->ref = 1;
461     EnterCriticalSection(&d3d8_cs);
462     hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
463                                  (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, NULL, (IUnknown *)object, D3D8CB_CreateSurface);
464     LeaveCriticalSection(&d3d8_cs);
465 
466     if (FAILED(hrc)) {
467         /* free up object */ 
468         FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
469         HeapFree(GetProcessHeap(), 0, object);
470 /*      *ppTexture = NULL; */
471    } else {
472         IUnknown_AddRef(iface);
473         object->parentDevice = iface;
474         *ppTexture = (LPDIRECT3DTEXTURE8) object;
475         TRACE("(%p) Created Texture %p, %p\n",This,object,object->wineD3DTexture);
476    }
477 
478    return hrc;
479 }
480 
481 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8 iface, 
482                                                           UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, 
483                                                           D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture8** ppVolumeTexture) {
484 
485     IDirect3DVolumeTexture8Impl *object;
486     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
487     HRESULT hrc = D3D_OK;
488 
489     TRACE("(%p) Relay\n", This);
490 
491     /* Allocate the storage for the device */
492     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture8Impl));
493     if (NULL == object) {
494         FIXME("(%p) allocation of memory failed\n", This);
495         *ppVolumeTexture = NULL;
496         return D3DERR_OUTOFVIDEOMEMORY;
497     }
498 
499     object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
500     object->ref = 1;
501     EnterCriticalSection(&d3d8_cs);
502     hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage & WINED3DUSAGE_MASK,
503                                  (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, NULL,
504                                  (IUnknown *)object, D3D8CB_CreateVolume);
505     LeaveCriticalSection(&d3d8_cs);
506 
507     if (hrc != D3D_OK) {
508 
509         /* free up object */
510         FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
511         HeapFree(GetProcessHeap(), 0, object);
512         *ppVolumeTexture = NULL;
513     } else {
514         IUnknown_AddRef(iface);
515         object->parentDevice = iface;
516         *ppVolumeTexture = (LPDIRECT3DVOLUMETEXTURE8) object;
517     }
518     TRACE("(%p)  returning %p\n", This , *ppVolumeTexture);
519     return hrc;
520 }
521 
522 static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 iface, UINT EdgeLength, UINT Levels, DWORD Usage, 
523                                                         D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8** ppCubeTexture) {
524 
525     IDirect3DCubeTexture8Impl *object;
526     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
527     HRESULT hr = D3D_OK;
528 
529     TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool);
530 
531     /* Allocate the storage for the device */
532     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
533 
534     if (NULL == object) {
535         FIXME("(%p) allocation of CubeTexture failed\n", This);
536         *ppCubeTexture = NULL;
537         return D3DERR_OUTOFVIDEOMEMORY;
538     }
539 
540     object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
541     object->ref = 1;
542     EnterCriticalSection(&d3d8_cs);
543     hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK,
544                                  (WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, NULL, (IUnknown*)object,
545                                  D3D8CB_CreateSurface);
546     LeaveCriticalSection(&d3d8_cs);
547 
548     if (hr != D3D_OK){
549 
550         /* free up object */
551         FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
552         HeapFree(GetProcessHeap(), 0, object);
553         *ppCubeTexture = NULL;
554     } else {
555         IUnknown_AddRef(iface);
556         object->parentDevice = iface;
557         *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
558     }
559 
560     TRACE("(%p) returning %p\n",This, *ppCubeTexture);
561     return hr;
562 }
563 
564 static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexBuffer(LPDIRECT3DDEVICE8 iface, UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer8** ppVertexBuffer) {
565     IDirect3DVertexBuffer8Impl *object;
566     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
567     HRESULT hrc = D3D_OK;
568 
569     TRACE("(%p) Relay\n", This);
570     /* Allocate the storage for the device */
571     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer8Impl));
572     if (NULL == object) {
573         FIXME("Allocation of memory failed\n");
574         *ppVertexBuffer = NULL;
575         return D3DERR_OUTOFVIDEOMEMORY;
576     }
577 
578     object->lpVtbl = &Direct3DVertexBuffer8_Vtbl;
579     object->ref = 1;
580     EnterCriticalSection(&d3d8_cs);
581     hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), NULL, (IUnknown *)object);
582     LeaveCriticalSection(&d3d8_cs);
583 
584     if (D3D_OK != hrc) {
585 
586         /* free up object */
587         FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
588         HeapFree(GetProcessHeap(), 0, object);
589         *ppVertexBuffer = NULL;
590     } else {
591         IUnknown_AddRef(iface);
592         object->parentDevice = iface;
593         *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER8) object;
594     }
595     return hrc;
596 }
597 
598 static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer8** ppIndexBuffer) {
599     IDirect3DIndexBuffer8Impl *object;
600     IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
601     HRESULT hrc = D3D_OK;
602 
603     TRACE("(%p) Relay\n", This);
604     /* Allocate the storage for the device */
605     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
606     if (NULL == object) {
607         FIXME("Allocation of memory failed\n");
608         *ppIndexBuffer = NULL;
609         return D3DERR_OUTOFVIDEOMEMORY;
610     }
611 
612     object->lpVtbl = &Direct3DIndexBuffer8_Vtbl;
613     object->ref = 1;
614     TRACE("Calling wined3d create index buffer\n");
615     EnterCriticalSection(&d3d8_cs);
616     hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, NULL, (IUnknown *)object);
617     LeaveCriticalSection(&d3d8_cs);
618 
619     if (D3D_OK != hrc) {
620 
621         /* free up object */
622         FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
623         HeapFree(GetProcessHeap(), 0, object);
624         *ppIndexBuffer = NULL;
625     } else {
626         IUnknown_AddRef(iface);
627         object->parentDevice = iface;
628         *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER8)object;
629     }
630     return hrc;
631 }
632 
633 static HRESULT WINAPI IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)  {
634     HRESULT hrc;
635     IDirect3DSurface8Impl *object;
636     IDirect3DDevice8Impl  *This = (IDirect3DDevice8Impl *)iface;
637     TRACE("(%p) Relay\n", This);
638 
639     if(MultisampleQuality > 0){
640         FIXME("MultisampleQuality set to %d, substituting 0\n" , MultisampleQuality);
641         /*
642         MultisampleQuality
643         [in] Quality level. The valid range is between zero and one less than the level returned by pQualityLevels used by IDirect3D8::CheckDeviceMultiSampleType. Passing a larger value returns the error D3DERR_INVALIDCALL. The MultisampleQuality values of paired render targets, depth stencil surfaces, and the MultiSample type must all match.
644         */
645         MultisampleQuality=0;
646     }
647     /*FIXME: Check MAX bounds of MultisampleQuality*/
648 
649     /* Allocate the storage for the device */
650     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface8Impl));
651     if (NULL == object) {
652         FIXME("Allocation of memory failed\n");
653         *ppSurface = NULL;
654         return D3DERR_OUTOFVIDEOMEMORY;
655     }
656 
657     object->lpVtbl = &Direct3DSurface8_Vtbl;
658     object->ref = 1;
659 
660     TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
661 
662     /* Not called from the VTable, no locking needed */
663     hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, Format, Lockable, Discard, Level,  &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL) Pool,MultiSample,MultisampleQuality, NULL, SURFACE_OPENGL, (IUnknown *)object);
664     if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
665        /* free up object */
666         FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
667         HeapFree(GetProcessHeap(), 0, object);
668         *ppSurface = NULL;
669     } else {
670         IUnknown_AddRef(iface);
671         object->parentDevice = iface;
672         *ppSurface = (LPDIRECT3DSURFACE8) object;
673     }
674     return hrc;
675 }
676 
677 static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, BOOL Lockable, IDirect3DSurface8** ppSurface) {
678     HRESULT hr;
679     TRACE("Relay\n");
680 
681     EnterCriticalSection(&d3d8_cs);
682     hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */, 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
683     LeaveCriticalSection(&d3d8_cs);
684     return hr;
685 }
686 
687 static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, IDirect3DSurface8** ppSurface) {
688     HRESULT hr;
689     TRACE("Relay\n");
690 
691     /* TODO: Verify that Discard is false */
692     EnterCriticalSection(&d3d8_cs);
693     hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE, 0 /* Level */
694                                                ,ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_DEPTHSTENCIL,
695                                                 D3DPOOL_DEFAULT, MultiSample, 0);
696     LeaveCriticalSection(&d3d8_cs);
697     return hr;
698 }
699 
700 /*  IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
701 static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, IDirect3DSurface8** ppSurface) {
702     HRESULT hr;
703     TRACE("Relay\n");
704 
705     EnterCriticalSection(&d3d8_cs);
706     hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface,
707                                             D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
708     LeaveCriticalSection(&d3d8_cs);
709     return hr;
710 }
711 
712 static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8 *pSourceSurface, CONST RECT *pSourceRects, UINT cRects, IDirect3DSurface8 *pDestinationSurface, CONST POINT *pDestPoints) {
713     IDirect3DSurface8Impl *Source = (IDirect3DSurface8Impl *) pSourceSurface;
714     IDirect3DSurface8Impl *Dest = (IDirect3DSurface8Impl *) pDestinationSurface;
715 
716     HRESULT              hr = WINED3D_OK;
717     WINED3DFORMAT        srcFormat, destFormat;
718     UINT                 srcWidth,  destWidth;
719     UINT                 srcHeight, destHeight;
720     UINT                 srcSize;
721     WINED3DSURFACE_DESC  winedesc;
722 
723     TRACE("(%p) pSrcSur=%p, pSourceRects=%p, cRects=%d, pDstSur=%p, pDestPtsArr=%p\n", iface,
724           pSourceSurface, pSourceRects, cRects, pDestinationSurface, pDestPoints);
725 
726 
727     /* Check that the source texture is in WINED3DPOOL_SYSTEMMEM and the destination texture is in WINED3DPOOL_DEFAULT */
728     memset(&winedesc, 0, sizeof(winedesc));
729 
730     winedesc.Format = &srcFormat;
731     winedesc.Width  = &srcWidth;
732     winedesc.Height = &srcHeight;
733     winedesc.Size   = &srcSize;
734     IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
735 
736     winedesc.Format = &destFormat;
737     winedesc.Width  = &destWidth;
738     winedesc.Height = &destHeight;
739     winedesc.Size   = NULL;
740     EnterCriticalSection(&d3d8_cs);
741     IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
742 
743     /* Check that the source and destination formats match */
744     if (srcFormat != destFormat && WINED3DFMT_UNKNOWN != destFormat) {
745         WARN("(%p) source %p format must match the dest %p format, returning WINED3DERR_INVALIDCALL\n", iface, pSourceSurface, pDestinationSurface);
746         LeaveCriticalSection(&d3d8_cs);
747         return WINED3DERR_INVALIDCALL;
748     } else if (WINED3DFMT_UNKNOWN == destFormat) {
749         TRACE("(%p) : Converting destination surface from WINED3DFMT_UNKNOWN to the source format\n", iface);
750         IWineD3DSurface_SetFormat(Dest->wineD3DSurface, srcFormat);
751         destFormat = srcFormat;
752     }
753 
754     /* Quick if complete copy ... */
755     if (cRects == 0 && pSourceRects == NULL && pDestPoints == NULL) {
756         IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
757     } else {
758         unsigned int i;
759         /* Copy rect by rect */
760         if (NULL != pSourceRects && NULL != pDestPoints) {
761             for (i = 0; i < cRects; ++i) {
762                 IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, (RECT *) &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
763             }
764         } else {
765             for (i = 0; i < cRects; ++i) {
766                 IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, (RECT *) &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
767             }
768         }
769     }
770     LeaveCriticalSection(&d3d8_cs);
771 
772     return hr;
773 }
774