ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

d3d9_device.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS ReactX
00004  * FILE:            dll/directx/d3d9/d3d9_device.c
00005  * PURPOSE:         d3d9.dll internal device methods
00006  * PROGRAMERS:      Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
00007  */
00008 #include "d3d9_device.h"
00009 #include "d3d9_helpers.h"
00010 #include "adapter.h"
00011 #include <debug.h>
00012 #include "d3d9_create.h"
00013 #include "d3d9_mipmap.h"
00014 
00015 #define LOCK_D3DDEVICE9()     if (This->bLockDevice) EnterCriticalSection(&This->CriticalSection);
00016 #define UNLOCK_D3DDEVICE9()   if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
00017 
00018 /* Convert a IDirect3DDevice9 pointer safely to the internal implementation struct */
00019 LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
00020 {
00021     if (NULL == iface)
00022         return NULL;
00023 
00024     return (LPDIRECT3DDEVICE9_INT)((ULONG_PTR)iface - FIELD_OFFSET(DIRECT3DDEVICE9_INT, lpVtbl));
00025 }
00026 
00027 static HRESULT InvalidCall(LPDIRECT3DDEVICE9_INT This, LPSTR ErrorMsg)
00028 {
00029     DPRINT1("%s",ErrorMsg);
00030     UNLOCK_D3DDEVICE9();
00031     return D3DERR_INVALIDCALL;
00032 }
00033 
00034 /* IDirect3DDevice9: IUnknown implementation */
00035 HRESULT WINAPI IDirect3DDevice9Base_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, void** ppvObject)
00036 {
00037     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00038 
00039     if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3DDevice9))
00040     {
00041         IUnknown_AddRef(iface);
00042         *ppvObject = &This->lpVtbl;
00043         return D3D_OK;
00044     }
00045 
00046     *ppvObject = NULL;
00047     return E_NOINTERFACE;
00048 }
00049 
00050 ULONG WINAPI IDirect3DDevice9Base_AddRef(LPDIRECT3DDEVICE9 iface)
00051 {
00052     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00053     ULONG ref = InterlockedIncrement(&This->lRefCnt);
00054 
00055     return ref;
00056 }
00057 
00058 ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface)
00059 {
00060     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00061     ULONG ref = InterlockedDecrement(&This->lRefCnt);
00062 
00063     if (ref == 0)
00064     {
00065         DWORD iAdapter;
00066 
00067         EnterCriticalSection(&This->CriticalSection);
00068         
00069         /* TODO: Free resources here */
00070         for (iAdapter = 0; iAdapter < This->NumAdaptersInDevice; iAdapter++)
00071         {
00072             DestroyD3D9DeviceData(&This->DeviceData[iAdapter]);
00073         }
00074         This->lpVtbl->VirtualDestructor(iface);
00075 
00076         LeaveCriticalSection(&This->CriticalSection);
00077         AlignedFree(This);
00078     }
00079 
00080     return ref;
00081 }
00082 
00083 /* IDirect3DDevice9 public interface */
00084 HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface)
00085 {
00086     UNIMPLEMENTED
00087 
00088     return D3D_OK;
00089 }
00090 
00091 /*++
00092 * @name IDirect3DDevice9::GetAvailableTextureMem
00093 * @implemented
00094 *
00095 * The function IDirect3DDevice9Base_GetAvailableTextureMem returns a pointer to the IDirect3D9 object
00096 * that created this device.
00097 *
00098 * @param LPDIRECT3D iface
00099 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
00100 *
00101 * @return UINT
00102 * The method returns an estimated the currently available texture memory in bytes rounded
00103 * to the nearest MB. Applications should NOT use this as an exact number.
00104 *
00105 */
00106 UINT WINAPI IDirect3DDevice9Base_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface)
00107 {
00108     UINT AvailableTextureMemory = 0;
00109     D3D9_GETAVAILDRIVERMEMORYDATA d3d9GetAvailDriverMemoryData;
00110 
00111     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00112     LOCK_D3DDEVICE9();
00113 
00114     memset(&d3d9GetAvailDriverMemoryData, 0, sizeof(d3d9GetAvailDriverMemoryData));
00115     d3d9GetAvailDriverMemoryData.pUnknown6BC = This->DeviceData[0].pUnknown6BC;
00116     d3d9GetAvailDriverMemoryData.dwMemoryType = D3D9_GETAVAILDRIVERMEMORY_TYPE_ALL;
00117 
00118     if (TRUE == (*This->DeviceData[0].D3D9Callbacks.DdGetAvailDriverMemory)(&d3d9GetAvailDriverMemoryData))
00119     {
00120         /* Round it up to the nearest MB */
00121         AvailableTextureMemory = (d3d9GetAvailDriverMemoryData.dwFree + 0x80000) & 0xFFF00000;
00122     }
00123 
00124     UNLOCK_D3DDEVICE9();
00125     return AvailableTextureMemory;
00126 }
00127 
00128 HRESULT WINAPI IDirect3DDevice9Base_EvictManagedResources(LPDIRECT3DDEVICE9 iface)
00129 {
00130     UNIMPLEMENTED
00131 
00132     return D3D_OK;
00133 }
00134 
00135 /*++
00136 * @name IDirect3DDevice9::GetDirect3D
00137 * @implemented
00138 *
00139 * The function IDirect3DDevice9Base_GetDirect3D returns a pointer to the IDirect3D9 object
00140 * that created this device.
00141 *
00142 * @param LPDIRECT3D iface
00143 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
00144 *
00145 * @param IDirect3D9** ppD3D9
00146 * Pointer to a IDirect3D9* to receive the IDirect3D9 object pointer.
00147 *
00148 * @return HRESULT
00149 * If the method successfully fills the ppD3D9 structure, the return value is D3D_OK.
00150 * If ppD3D9 is a bad pointer, the return value will be D3DERR_INVALIDCALL.
00151 *
00152 */
00153 HRESULT WINAPI IDirect3DDevice9Base_GetDirect3D(LPDIRECT3DDEVICE9 iface, IDirect3D9** ppD3D9)
00154 {
00155     IDirect3D9* pDirect3D9;
00156     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00157     LOCK_D3DDEVICE9();
00158 
00159     if (NULL == ppD3D9)
00160     {
00161         DPRINT1("Invalid ppD3D9 parameter specified");
00162         UNLOCK_D3DDEVICE9();
00163         return D3DERR_INVALIDCALL;
00164     }
00165 
00166     pDirect3D9 = (IDirect3D9*)&This->pDirect3D9->lpVtbl;
00167     IDirect3D9_AddRef(pDirect3D9);
00168     *ppD3D9 = pDirect3D9;
00169 
00170     UNLOCK_D3DDEVICE9();
00171     return D3D_OK;
00172 }
00173 
00174 /*++
00175 * @name IDirect3DDevice9::GetDeviceCaps
00176 * @implemented
00177 *
00178 * The function IDirect3DDevice9Base_GetDeviceCaps fills the pCaps argument with the
00179 * capabilities of the device.
00180 *
00181 * @param LPDIRECT3D iface
00182 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
00183 *
00184 * @param D3DCAPS9* pCaps
00185 * Pointer to a D3DCAPS9 structure to be filled with the device's capabilities.
00186 *
00187 * @return HRESULT
00188 * If the method successfully fills the pCaps structure, the return value is D3D_OK.
00189 * If pCaps is a bad pointer the return value will be D3DERR_INVALIDCALL.
00190 *
00191 */
00192 HRESULT WINAPI IDirect3DDevice9Base_GetDeviceCaps(LPDIRECT3DDEVICE9 iface, D3DCAPS9* pCaps)
00193 {
00194     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00195     LOCK_D3DDEVICE9();
00196 
00197     if (NULL == pCaps)
00198     {
00199         DPRINT1("Invalid pCaps parameter specified");
00200         UNLOCK_D3DDEVICE9();
00201         return D3DERR_INVALIDCALL;
00202     }
00203 
00204     GetAdapterCaps(&This->pDirect3D9->DisplayAdapters[0], This->DeviceData[0].DeviceType, pCaps);
00205 
00206     UNLOCK_D3DDEVICE9();
00207     return D3D_OK;
00208 }
00209 
00210 /*++
00211 * @name IDirect3DDevice9::GetDisplayMode
00212 * @implemented
00213 *
00214 * The function IDirect3DDevice9Base_GetDisplayMode fills the pMode argument with the
00215 * display mode for the specified swap chain.
00216 *
00217 * @param LPDIRECT3D iface
00218 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
00219 *
00220 * @param UINT iSwapChain
00221 * Swap chain index to get object for.
00222 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00223 *
00224 * @param D3DDISPLAYMODE* pMode
00225 * Pointer to a D3DDISPLAYMODE structure to be filled with the current swap chain's display mode information.
00226 *
00227 * @return HRESULT
00228 * If the method successfully fills the pMode structure, the return value is D3D_OK.
00229 * If iSwapChain is out of range or pMode is a bad pointer, the return value will be D3DERR_INVALIDCALL.
00230 *
00231 */
00232 HRESULT WINAPI IDirect3DDevice9Base_GetDisplayMode(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DDISPLAYMODE* pMode)
00233 {
00234     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00235     LOCK_D3DDEVICE9();
00236 
00237     if (iSwapChain >= IDirect3DDevice9_GetNumberOfSwapChains(iface))
00238     {
00239         DPRINT1("Invalid iSwapChain parameter specified");
00240         UNLOCK_D3DDEVICE9();
00241         return D3DERR_INVALIDCALL;
00242     }
00243 
00244     if (NULL == pMode)
00245     {
00246         DPRINT1("Invalid pMode parameter specified");
00247         UNLOCK_D3DDEVICE9();
00248         return D3DERR_INVALIDCALL;
00249     }
00250 
00251     pMode->Width = This->DeviceData[iSwapChain].DriverCaps.dwDisplayWidth;
00252     pMode->Height = This->DeviceData[iSwapChain].DriverCaps.dwDisplayHeight;
00253     pMode->Format = This->DeviceData[iSwapChain].DriverCaps.RawDisplayFormat;
00254     pMode->RefreshRate = This->DeviceData[iSwapChain].DriverCaps.dwRefreshRate;
00255 
00256     UNLOCK_D3DDEVICE9();
00257     return D3D_OK;
00258 }
00259 
00260 /*++
00261 * @name IDirect3DDevice9::GetCreationParameters
00262 * @implemented
00263 *
00264 * The function IDirect3DDevice9Base_GetCreationParameters fills the pParameters argument with the
00265 * parameters the device was created with.
00266 *
00267 * @param LPDIRECT3D iface
00268 * Pointer to the IDirect3D9 object returned from Direct3DCreate9()
00269 *
00270 * @param D3DDEVICE_CREATION_PARAMETERS* pParameters
00271 * Pointer to a D3DDEVICE_CREATION_PARAMETERS structure to be filled with the creation parameter
00272 * information for this device.
00273 *
00274 * @return HRESULT
00275 * If the method successfully fills the pParameters structure, the return value is D3D_OK.
00276 * If pParameters is a bad pointer, the return value will be D3DERR_INVALIDCALL.
00277 *
00278 */
00279 HRESULT WINAPI IDirect3DDevice9Base_GetCreationParameters(LPDIRECT3DDEVICE9 iface, D3DDEVICE_CREATION_PARAMETERS* pParameters)
00280 {
00281     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00282     LOCK_D3DDEVICE9();
00283 
00284     if (NULL == pParameters)
00285     {
00286         DPRINT1("Invalid pParameters parameter specified");
00287         UNLOCK_D3DDEVICE9();
00288         return D3DERR_INVALIDCALL;
00289     }
00290 
00291     pParameters->AdapterOrdinal = This->AdapterIndexInGroup[0];
00292     pParameters->DeviceType = This->DeviceType;
00293     pParameters->hFocusWindow = This->hWnd;
00294     pParameters->BehaviorFlags = This->BehaviourFlags;
00295 
00296     UNLOCK_D3DDEVICE9();
00297     return D3D_OK;
00298 }
00299 
00300 HRESULT WINAPI IDirect3DDevice9Base_SetCursorProperties(LPDIRECT3DDEVICE9 iface, UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9* pCursorBitmap)
00301 {
00302     UNIMPLEMENTED
00303 
00304     return D3D_OK;
00305 }
00306 
00307 VOID WINAPI IDirect3DDevice9Base_SetCursorPosition(LPDIRECT3DDEVICE9 iface, int X, int Y, DWORD Flags)
00308 {
00309     UNIMPLEMENTED
00310 }
00311 
00312 BOOL WINAPI IDirect3DDevice9Base_ShowCursor(LPDIRECT3DDEVICE9 iface, BOOL bShow)
00313 {
00314     UNIMPLEMENTED
00315 
00316     return TRUE;
00317 }
00318 
00319 /*++
00320 * @name IDirect3DDevice9::CreateAdditionalSwapChain
00321 * @implemented
00322 *
00323 * The function IDirect3DDevice9Base_CreateAdditionalSwapChain creates a swap chain object,
00324 * useful when rendering multiple views.
00325 *
00326 * @param LPDIRECT3D iface
00327 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
00328 *
00329 * @param D3DPRESENT_PARAMETERS* pPresentationParameters
00330 * Pointer to a D3DPRESENT_PARAMETERS structure describing the parameters for the swap chain
00331 * to be created.
00332 *
00333 * @param IDirect3DSwapChain9** ppSwapChain
00334 * Pointer to a IDirect3DSwapChain9* to receive the swap chain object pointer.
00335 *
00336 * @return HRESULT
00337 * If the method successfully fills the ppSwapChain structure, the return value is D3D_OK.
00338 * If iSwapChain is out of range or ppSwapChain is a bad pointer, the return value
00339 * will be D3DERR_INVALIDCALL. Also D3DERR_OUTOFVIDEOMEMORY can be returned if allocation
00340 * of the new swap chain object failed.
00341 *
00342 */
00343 HRESULT WINAPI IDirect3DDevice9Base_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** ppSwapChain)
00344 {
00345     UINT iSwapChain;
00346     IDirect3DSwapChain9* pSwapChain;
00347     Direct3DSwapChain9_INT* pSwapChain_INT;
00348     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00349     LOCK_D3DDEVICE9();
00350 
00351     if (NULL == ppSwapChain)
00352     {
00353         DPRINT1("Invalid ppSwapChain parameter specified");
00354         UNLOCK_D3DDEVICE9();
00355         return D3DERR_INVALIDCALL;
00356     }
00357 
00358     *ppSwapChain = NULL;
00359     iSwapChain = IDirect3DDevice9_GetNumberOfSwapChains(iface) + 1;
00360 
00361     pSwapChain_INT = CreateDirect3DSwapChain9(RT_EXTERNAL, This, iSwapChain);
00362     if (NULL == pSwapChain_INT)
00363     {
00364         DPRINT1("Out of memory");
00365         UNLOCK_D3DDEVICE9();
00366         return D3DERR_OUTOFVIDEOMEMORY;
00367     }
00368 
00369     Direct3DSwapChain9_Init(pSwapChain_INT, pPresentationParameters);
00370 
00371     This->pSwapChains[iSwapChain] = pSwapChain_INT;
00372     pSwapChain = (IDirect3DSwapChain9*)&pSwapChain_INT->lpVtbl;
00373     IDirect3DSwapChain9_AddRef(pSwapChain);
00374     *ppSwapChain = pSwapChain;
00375 
00376     UNLOCK_D3DDEVICE9();
00377     return D3D_OK;
00378 }
00379 
00380 /*++
00381 * @name IDirect3DDevice9::GetSwapChain
00382 * @implemented
00383 *
00384 * The function IDirect3DDevice9Base_GetSwapChain returns a pointer to a swap chain object.
00385 *
00386 * @param LPDIRECT3D iface
00387 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
00388 *
00389 * @param UINT iSwapChain
00390 * Swap chain index to get object for.
00391 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00392 *
00393 * @param IDirect3DSwapChain9** ppSwapChain
00394 * Pointer to a IDirect3DSwapChain9* to receive the swap chain object pointer.
00395 *
00396 * @return HRESULT
00397 * If the method successfully fills the ppSwapChain structure, the return value is D3D_OK.
00398 * If iSwapChain is out of range or ppSwapChain is a bad pointer, the return value
00399 * will be D3DERR_INVALIDCALL.
00400 *
00401 */
00402 HRESULT WINAPI IDirect3DDevice9Base_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSwapChain9** ppSwapChain)
00403 {
00404     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00405     LOCK_D3DDEVICE9();
00406 
00407     if (NULL == ppSwapChain)
00408     {
00409         DPRINT1("Invalid ppSwapChain parameter specified");
00410         UNLOCK_D3DDEVICE9();
00411         return D3DERR_INVALIDCALL;
00412     }
00413 
00414     *ppSwapChain = NULL;
00415 
00416     if (iSwapChain >= IDirect3DDevice9_GetNumberOfSwapChains(iface))
00417     {
00418         DPRINT1("Invalid iSwapChain parameter specified");
00419         UNLOCK_D3DDEVICE9();
00420         return D3DERR_INVALIDCALL;
00421     }
00422 
00423     if (This->pSwapChains[iSwapChain] != NULL)
00424     {
00425         IDirect3DSwapChain9* pSwapChain = (IDirect3DSwapChain9*)&This->pSwapChains[iSwapChain]->lpVtbl;
00426         IDirect3DSwapChain9_AddRef(pSwapChain);
00427         *ppSwapChain = pSwapChain;
00428     }
00429     else
00430     {
00431         *ppSwapChain = NULL;
00432     }
00433 
00434     UNLOCK_D3DDEVICE9();
00435     return D3D_OK;
00436 }
00437 
00438 /*++
00439 * @name IDirect3DDevice9::GetNumberOfSwapChains
00440 * @implemented
00441 *
00442 * The function IDirect3DDevice9Base_GetNumberOfSwapChains returns the number of swap chains
00443 * created by IDirect3D9::CreateDevice().
00444 *
00445 * @param LPDIRECT3D iface
00446 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00447 *
00448 * @return UINT
00449 * Returns the number of swap chains created by IDirect3D9::CreateDevice().
00450 *
00451 * NOTE: An application can create additional swap chains using the
00452 *       IDirect3DDevice9::CreateAdditionalSwapChain() method.
00453 *
00454 */
00455 UINT WINAPI IDirect3DDevice9Base_GetNumberOfSwapChains(LPDIRECT3DDEVICE9 iface)
00456 {
00457     UINT NumSwapChains;
00458 
00459     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00460     LOCK_D3DDEVICE9();
00461 
00462     NumSwapChains = This->NumAdaptersInDevice;
00463 
00464     UNLOCK_D3DDEVICE9();
00465     return NumSwapChains;
00466 }
00467 
00468 HRESULT WINAPI IDirect3DDevice9Base_Reset(LPDIRECT3DDEVICE9 iface, D3DPRESENT_PARAMETERS* pPresentationParameters)
00469 {
00470     UNIMPLEMENTED
00471 
00472     return D3D_OK;
00473 }
00474 
00475 /*++
00476 * @name IDirect3DDevice9::Present
00477 * @implemented
00478 *
00479 * The function IDirect3DDevice9Base_Present displays the content of the next
00480 * back buffer in sequence for the device.
00481 *
00482 * @param LPDIRECT3D iface
00483 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00484 *
00485 * @param CONST RECT* pSourceRect
00486 * A pointer to a RECT structure representing an area of the back buffer to display where
00487 * NULL means the whole back buffer. This parameter MUST be NULL unless the back buffer
00488 * was created with the D3DSWAPEFFECT_COPY flag.
00489 *
00490 * @param CONST RECT* pDestRect
00491 * A pointer to a RECT structure representing an area of the back buffer where the content
00492 * will be displayed where NULL means the whole back buffer starting at (0,0).
00493 * This parameter MUST be NULL unless the back buffer was created with the D3DSWAPEFFECT_COPY flag.
00494 *
00495 * @param HWND hDestWindowOverride
00496 * A destination window where NULL means the window specified in the hWndDeviceWindow of the
00497 * D3DPRESENT_PARAMETERS structure.
00498 *
00499 * @param CONST RGNDATA* pDirtyRegion
00500 * A pointer to a RGNDATA structure representing an area of the back buffer to display where
00501 * NULL means the whole back buffer. This parameter MUST be NULL unless the back buffer
00502 * was created with the D3DSWAPEFFECT_COPY flag. This is an opimization region only.
00503 *
00504 * @return HRESULT
00505 * If the method successfully displays the back buffer content, the return value is D3D_OK.
00506 * If no swap chains are available, the return value will be D3DERR_INVALIDCALL.
00507 */
00508 HRESULT WINAPI IDirect3DDevice9Base_Present(LPDIRECT3DDEVICE9 iface, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
00509 {
00510     UINT i;
00511     UINT iNumSwapChains;
00512     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00513     LOCK_D3DDEVICE9();
00514 
00515     iNumSwapChains = IDirect3DDevice9Base_GetNumberOfSwapChains(iface);
00516     if (0 == iNumSwapChains)
00517     {
00518         DPRINT1("Not enough swap chains, Present() fails");
00519         UNLOCK_D3DDEVICE9();
00520         return D3DERR_INVALIDCALL;
00521     }
00522 
00523     for (i = 0; i < iNumSwapChains; i++)
00524     {
00525         HRESULT hResult;
00526         IDirect3DSwapChain9* pSwapChain;
00527         
00528         IDirect3DDevice9Base_GetSwapChain(iface, i, &pSwapChain);
00529         hResult = IDirect3DSwapChain9_Present(pSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
00530 
00531         if (FAILED(hResult))
00532         {
00533             UNLOCK_D3DDEVICE9();
00534             return hResult;
00535         }
00536     }
00537 
00538     UNLOCK_D3DDEVICE9();
00539     return D3D_OK;
00540 }
00541 
00542 /*++
00543 * @name IDirect3DDevice9::GetBackBuffer
00544 * @implemented
00545 *
00546 * The function IDirect3DDevice9Base_GetBackBuffer retrieves the back buffer
00547 * for the specified swap chain.
00548 *
00549 * @param LPDIRECT3D iface
00550 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00551 *
00552 * @param UINT iSwapChain
00553 * Swap chain index to get object for.
00554 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00555 *
00556 * @param UINT iBackBuffer
00557 * Back buffer index to get object for.
00558 * The maximum value for this is the the total number of back buffers - 1, as indexing starts at 0.
00559 *
00560 * @param IDirect3DSurface9** ppBackBuffer
00561 * Pointer to a IDirect3DSurface9* to receive the back buffer object
00562 *
00563 * @return HRESULT
00564 * If the method successfully sets the ppBackBuffer pointer, the return value is D3D_OK.
00565 * If iSwapChain or iBackBuffer is out of range, Type is invalid or ppBackBuffer is a bad pointer,
00566 * the return value will be D3DERR_INVALIDCALL.
00567 */
00568 HRESULT WINAPI IDirect3DDevice9Base_GetBackBuffer(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, UINT iBackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface9** ppBackBuffer)
00569 {
00570     HRESULT hResult;
00571     IDirect3DSwapChain9* pSwapChain = NULL;
00572     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00573     LOCK_D3DDEVICE9();
00574 
00575     IDirect3DDevice9Base_GetSwapChain(iface, iSwapChain, &pSwapChain);
00576     if (NULL == pSwapChain)
00577     {
00578         DPRINT1("Invalid iSwapChain parameter specified");
00579         UNLOCK_D3DDEVICE9();
00580         return D3DERR_INVALIDCALL;
00581     }
00582 
00583     if (NULL == ppBackBuffer)
00584     {
00585         DPRINT1("Invalid ppBackBuffer parameter specified");
00586         UNLOCK_D3DDEVICE9();
00587         return D3DERR_INVALIDCALL;
00588     }
00589 
00590     hResult = IDirect3DSwapChain9_GetBackBuffer(pSwapChain, iBackBuffer, Type, ppBackBuffer);
00591 
00592     UNLOCK_D3DDEVICE9();
00593     return hResult;
00594 }
00595 
00596 /*++
00597 * @name IDirect3DDevice9::GetRasterStatus
00598 * @implemented
00599 *
00600 * The function IDirect3DDevice9Base_GetRasterStatus retrieves raster information
00601 * of the monitor for the specified swap chain.
00602 *
00603 * @param LPDIRECT3D iface
00604 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00605 *
00606 * @param UINT iSwapChain
00607 * Swap chain index to get object for.
00608 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00609 *
00610 * @param D3DRASTER_STATUS* pRasterStatus
00611 * Pointer to a D3DRASTER_STATUS to receive the raster information
00612 *
00613 * @return HRESULT
00614 * If the method successfully fills the pRasterStatus structure, the return value is D3D_OK.
00615 * If iSwapChain is out of range or pRasterStatus is a bad pointer, the return value
00616 * will be D3DERR_INVALIDCALL.
00617 */
00618 HRESULT WINAPI IDirect3DDevice9Base_GetRasterStatus(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus)
00619 {
00620     HRESULT hResult;
00621     IDirect3DSwapChain9* pSwapChain = NULL;
00622     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00623     LOCK_D3DDEVICE9();
00624 
00625     IDirect3DDevice9Base_GetSwapChain(iface, iSwapChain, &pSwapChain);
00626     if (NULL == pSwapChain)
00627     {
00628         DPRINT1("Invalid iSwapChain parameter specified");
00629         UNLOCK_D3DDEVICE9();
00630         return D3DERR_INVALIDCALL;
00631     }
00632 
00633     if (NULL == pRasterStatus)
00634     {
00635         DPRINT1("Invalid pRasterStatus parameter specified");
00636         UNLOCK_D3DDEVICE9();
00637         return D3DERR_INVALIDCALL;
00638     }
00639 
00640     hResult = IDirect3DSwapChain9_GetRasterStatus(pSwapChain, pRasterStatus);
00641 
00642     UNLOCK_D3DDEVICE9();
00643     return hResult;
00644 }
00645 
00646 HRESULT WINAPI IDirect3DDevice9Base_SetDialogBoxMode(LPDIRECT3DDEVICE9 iface, BOOL bEnableDialogs)
00647 {
00648     UNIMPLEMENTED
00649 
00650     return D3D_OK;
00651 }
00652 
00653 /*++
00654 * @name IDirect3DDevice9::SetGammaRamp
00655 * @implemented
00656 *
00657 * The function IDirect3DDevice9Base_SetGammaRamp sets the gamma correction ramp values
00658 * for the specified swap chain.
00659 *
00660 * @param LPDIRECT3D iface
00661 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00662 *
00663 * @param UINT iSwapChain
00664 * Swap chain index to get object for.
00665 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00666 *
00667 * @param UINT Flags
00668 * Can be on of the following:
00669 * D3DSGR_CALIBRATE - Detects if a gamma calibrator is installed and if so modifies the values to correspond to
00670 *                    the monitor and system settings before sending them to the display device.
00671 * D3DSGR_NO_CALIBRATION - The gamma calibrations values are sent directly to the display device without
00672 *                         any modification.
00673 *
00674 * @param CONST D3DGAMMARAMP* pRamp
00675 * Pointer to a D3DGAMMARAMP representing the gamma correction ramp values to be set.
00676 *
00677 */
00678 VOID WINAPI IDirect3DDevice9Base_SetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, DWORD Flags, CONST D3DGAMMARAMP* pRamp)
00679 {
00680     IDirect3DSwapChain9* pSwapChain = NULL;
00681     Direct3DSwapChain9_INT* pSwapChain_INT;
00682     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00683     LOCK_D3DDEVICE9();
00684 
00685     IDirect3DDevice9Base_GetSwapChain(iface, iSwapChain, &pSwapChain);
00686     if (NULL == pSwapChain)
00687     {
00688         DPRINT1("Invalid iSwapChain parameter specified");
00689         UNLOCK_D3DDEVICE9();
00690         return;
00691     }
00692 
00693     if (NULL == pRamp)
00694     {
00695         DPRINT1("Invalid pRamp parameter specified");
00696         UNLOCK_D3DDEVICE9();
00697         return;
00698     }
00699 
00700     pSwapChain_INT = IDirect3DSwapChain9ToImpl(pSwapChain);
00701     Direct3DSwapChain9_SetGammaRamp(pSwapChain_INT, Flags, pRamp);
00702 
00703     UNLOCK_D3DDEVICE9();
00704 }
00705 
00706 /*++
00707 * @name IDirect3DDevice9::GetGammaRamp
00708 * @implemented
00709 *
00710 * The function IDirect3DDevice9Base_GetGammaRamp retrieves the gamma correction ramp values
00711 * for the specified swap chain.
00712 *
00713 * @param LPDIRECT3D iface
00714 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00715 *
00716 * @param UINT iSwapChain
00717 * Swap chain index to get object for.
00718 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00719 *
00720 * @param D3DGAMMARAMP* pRamp
00721 * Pointer to a D3DGAMMARAMP to receive the gamma correction ramp values.
00722 *
00723 */
00724 VOID WINAPI IDirect3DDevice9Base_GetGammaRamp(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, D3DGAMMARAMP* pRamp)
00725 {
00726     IDirect3DSwapChain9* pSwapChain = NULL;
00727     Direct3DSwapChain9_INT* pSwapChain_INT;
00728     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00729     LOCK_D3DDEVICE9();
00730 
00731     IDirect3DDevice9Base_GetSwapChain(iface, iSwapChain, &pSwapChain);
00732     if (NULL == pSwapChain)
00733     {
00734         DPRINT1("Invalid iSwapChain parameter specified");
00735         UNLOCK_D3DDEVICE9();
00736         return;
00737     }
00738 
00739     if (NULL == pRamp)
00740     {
00741         DPRINT1("Invalid pRamp parameter specified");
00742         UNLOCK_D3DDEVICE9();
00743         return;
00744     }
00745 
00746     pSwapChain_INT = IDirect3DSwapChain9ToImpl(pSwapChain);
00747     Direct3DSwapChain9_GetGammaRamp(pSwapChain_INT, pRamp);
00748 
00749     UNLOCK_D3DDEVICE9();
00750 }
00751 
00752 /*++
00753 * @name IDirect3DDevice9::CreateTexture
00754 * @implemented
00755 *
00756 * The function IDirect3DDevice9Base_CreateTexture creates a D3D9 texture.
00757 *
00758 * @param LPDIRECT3D iface
00759 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice()
00760 *
00761 * @param UINT Width
00762 * Desired width of the texture
00763 *
00764 * @param UINT Height
00765 * Desired height of the texture
00766 *
00767 * @param UINT Levels
00768 * Number of mip-maps. If Levels are zero, mip-maps down to size 1x1 will be generated.
00769 *
00770 * @param DWORD Usage
00771 * Valid combinations of the D3DUSAGE constants.
00772 *
00773 * @param D3DFORMAT Format
00774 * One of the D3DFORMAT enum members for the surface format.
00775 *
00776 * @param D3DPOOL Pool
00777 * One of the D3DPOOL enum members for where the texture should be placed.
00778 *
00779 * @param IDirect3DTexture9** ppTexture
00780 * Return parameter for the created texture
00781 *
00782 * @param HANDLE* pSharedHandle
00783 * Set to NULL, shared resources are not implemented yet
00784 *
00785 * @return HRESULT
00786 * Returns D3D_OK if everything went well.
00787 *
00788 */
00789 HRESULT WINAPI IDirect3DDevice9Base_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle)
00790 {
00791     HRESULT hResult;
00792     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00793     LOCK_D3DDEVICE9();
00794 
00795     if (NULL == This)
00796         return InvalidCall(This, "Invalid 'this' parameter specified");
00797 
00798     if (NULL == ppTexture)
00799         return InvalidCall(This, "Invalid ppTexture parameter specified");
00800 
00801     *ppTexture = NULL;
00802 
00803     if (D3DFMT_UNKNOWN == Format)
00804         return InvalidCall(This, "Invalid Format parameter specified, D3DFMT_UNKNOWN is not a valid Format");
00805 
00806     if (NULL != pSharedHandle)
00807     {
00808         UNIMPLEMENTED;
00809         return InvalidCall(This, "Invalid pSharedHandle parameter specified, only NULL is supported at the moment");
00810     }
00811 
00812     hResult = CreateD3D9MipMap(This, Width, Height, Levels, Usage, Format, Pool, ppTexture);
00813     if (FAILED(hResult))
00814         DPRINT1("Failed to create texture");
00815 
00816     UNLOCK_D3DDEVICE9();
00817     return hResult;
00818 }
00819 
00820 HRESULT WINAPI IDirect3DDevice9Base_CreateVolumeTexture(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DVolumeTexture9** ppVolumeTexture, HANDLE* pSharedHandle)
00821 {
00822     UNIMPLEMENTED
00823 
00824     return D3D_OK;
00825 }
00826 
00827 HRESULT WINAPI IDirect3DDevice9Base_CreateCubeTexture(LPDIRECT3DDEVICE9 iface, UINT EdgeLength, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture9** ppCubeTexture, HANDLE* pSharedHandle)
00828 {
00829     UNIMPLEMENTED
00830 
00831     return D3D_OK;
00832 }
00833 
00834 HRESULT WINAPI IDirect3DDevice9Base_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool, IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle)
00835 {
00836     UNIMPLEMENTED
00837 
00838     return D3D_OK;
00839 }
00840 
00841 HRESULT WINAPI IDirect3DDevice9Base_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface, UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle)
00842 {
00843     UNIMPLEMENTED
00844 
00845     return D3D_OK;
00846 }
00847 
00848 HRESULT WINAPI IDirect3DDevice9Base_CreateRenderTarget(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Lockable, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle)
00849 {
00850     UNIMPLEMENTED
00851 
00852     return D3D_OK;
00853 }
00854 
00855 HRESULT WINAPI IDirect3DDevice9Base_CreateDepthStencilSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle)
00856 {
00857     UNIMPLEMENTED
00858 
00859     return D3D_OK;
00860 }
00861 
00862 HRESULT WINAPI IDirect3DDevice9Base_UpdateSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestinationSurface, CONST POINT* pDestPoint)
00863 {
00864     UNIMPLEMENTED
00865 
00866     return D3D_OK;
00867 }
00868 
00869 HRESULT WINAPI IDirect3DDevice9Base_UpdateTexture(LPDIRECT3DDEVICE9 iface, IDirect3DBaseTexture9* pSourceTexture, IDirect3DBaseTexture9* pDestinationTexture)
00870 {
00871     UNIMPLEMENTED
00872 
00873     return D3D_OK;
00874 }
00875 
00876 HRESULT WINAPI IDirect3DDevice9Base_GetRenderTargetData(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface)
00877 {
00878     UNIMPLEMENTED
00879 
00880     return D3D_OK;
00881 }
00882 
00883 /*++
00884 * @name IDirect3DDevice9::GetFrontBufferData
00885 * @implemented
00886 *
00887 * The function IDirect3DDevice9Base_GetFrontBufferData copies the content of
00888 * the display device's front buffer in a system memory surface buffer.
00889 *
00890 * @param LPDIRECT3D iface
00891 * Pointer to the IDirect3DDevice9 object returned from IDirect3D9::CreateDevice().
00892 *
00893 * @param UINT iSwapChain
00894 * Swap chain index to get object for.
00895 * The maximum value for this is the value returned by IDirect3DDevice9::GetNumberOfSwapChains() - 1.
00896 *
00897 * @param IDirect3DSurface9* pDestSurface
00898 * Pointer to a IDirect3DSurface9 to receive front buffer content
00899 *
00900 * @return HRESULT
00901 * If the method successfully fills the pDestSurface buffer, the return value is D3D_OK.
00902 * If iSwapChain is out of range or pDestSurface is a bad pointer, the return value
00903 * will be D3DERR_INVALIDCALL.
00904 */
00905 HRESULT WINAPI IDirect3DDevice9Base_GetFrontBufferData(LPDIRECT3DDEVICE9 iface, UINT iSwapChain, IDirect3DSurface9* pDestSurface)
00906 {
00907     HRESULT hResult;
00908     IDirect3DSwapChain9* pSwapChain = NULL;
00909     LPDIRECT3DDEVICE9_INT This = IDirect3DDevice9ToImpl(iface);
00910     LOCK_D3DDEVICE9();
00911 
00912     IDirect3DDevice9Base_GetSwapChain(iface, iSwapChain, &pSwapChain);
00913     if (NULL == pSwapChain)
00914     {
00915         DPRINT1("Invalid iSwapChain parameter specified");
00916         UNLOCK_D3DDEVICE9();
00917         return D3DERR_INVALIDCALL;
00918     }
00919 
00920     if (NULL == pDestSurface)
00921     {
00922         DPRINT1("Invalid pDestSurface parameter specified");
00923         UNLOCK_D3DDEVICE9();
00924         return D3DERR_INVALIDCALL;
00925     }
00926 
00927     hResult = IDirect3DSwapChain9_GetFrontBufferData(pSwapChain, pDestSurface);
00928 
00929     UNLOCK_D3DDEVICE9();
00930     return hResult;
00931 }
00932 
00933 HRESULT WINAPI IDirect3DDevice9Base_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSourceSurface, CONST RECT* pSourceRect, IDirect3DSurface9* pDestSurface, CONST RECT* pDestRect, D3DTEXTUREFILTERTYPE Filter)
00934 {
00935     UNIMPLEMENTED
00936 
00937     return D3D_OK;
00938 }
00939 
00940 HRESULT WINAPI IDirect3DDevice9Base_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color)
00941 {
00942     UNIMPLEMENTED
00943 
00944     return D3D_OK;
00945 }
00946 
00947 HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle)
00948 {
00949     UNIMPLEMENTED
00950 
00951     return D3D_OK;
00952 }
00953 
00954 /* IDirect3DDevice9 private interface */
00955 VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface)
00956 {
00957     UNIMPLEMENTED
00958 }
00959 
00960 VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface)
00961 {
00962     UNIMPLEMENTED
00963 }

Generated on Sun May 27 2012 04:21:13 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.