mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
D3D9:
* Initial cursor creation in swap chain * Changed from screen width/height in swap chains to back buffer width/height svn path=/trunk/; revision=35860
This commit is contained in:
parent
7d5a02d484
commit
1d9ff6256c
10 changed files with 135 additions and 34 deletions
|
@ -13,15 +13,16 @@
|
|||
<library>d3d8thk</library>
|
||||
|
||||
<file>d3d9.c</file>
|
||||
<file>d3d9_baseobject.c</file>
|
||||
<file>d3d9_caps.c</file>
|
||||
<file>d3d9_create.c</file>
|
||||
<file>d3d9_cursor.c</file>
|
||||
<file>d3d9_device.c</file>
|
||||
<file>d3d9_haldevice.c</file>
|
||||
<file>d3d9_helpers.c</file>
|
||||
<file>d3d9_impl.c</file>
|
||||
<file>d3d9_baseobject.c</file>
|
||||
<file>d3d9_create.c</file>
|
||||
<file>d3d9_caps.c</file>
|
||||
<file>d3d9_device.c</file>
|
||||
<file>d3d9_swapchain.c</file>
|
||||
<file>d3d9_puredevice.c</file>
|
||||
<file>d3d9_haldevice.c</file>
|
||||
<file>d3d9_swapchain.c</file>
|
||||
<file>adapter.c</file>
|
||||
<file>device.c</file>
|
||||
<file>format.c</file>
|
||||
|
|
|
@ -71,3 +71,18 @@ HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9**
|
|||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, DIRECT3DDEVICE9_INT** ppDevice)
|
||||
{
|
||||
if (pBaseObject->pUnknown)
|
||||
{
|
||||
LPDIRECT3DDEVICE9 pDevice;
|
||||
if (FAILED(pBaseObject->pUnknown->lpVtbl->QueryInterface((IUnknown*) &pBaseObject->pUnknown->lpVtbl, &IID_IDirect3DDevice9, (void**)&pDevice)))
|
||||
return E_NOINTERFACE;
|
||||
|
||||
*ppDevice = IDirect3DDevice9ToImpl(pDevice);
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <d3d9.h>
|
||||
|
||||
struct _D3D9BaseObject;
|
||||
struct _Direct3DDevice9_INT;
|
||||
|
||||
enum REF_TYPE
|
||||
{
|
||||
|
@ -42,5 +43,6 @@ VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, IUnk
|
|||
ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject);
|
||||
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject);
|
||||
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9** ppDevice);
|
||||
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, struct _Direct3DDevice9_INT** ppDevice);
|
||||
|
||||
#endif // _D3D9_BASEOBJECT_H_
|
||||
|
|
34
reactos/dll/directx/d3d9/d3d9_cursor.c
Normal file
34
reactos/dll/directx/d3d9/d3d9_cursor.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS ReactX
|
||||
* FILE: dll/directx/d3d9/d3d9_cursor.h
|
||||
* PURPOSE: d3d9.dll internal cursor methods
|
||||
* PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
|
||||
*/
|
||||
#include "d3d9_cursor.h"
|
||||
|
||||
#include <debug.h>
|
||||
#include <d3d9.h>
|
||||
#include "d3d9_private.h"
|
||||
#include "adapter.h"
|
||||
#include "d3d9_device.h"
|
||||
#include "d3d9_swapchain.h"
|
||||
#include "d3d9_helpers.h"
|
||||
|
||||
D3D9Cursor* CreateD3D9Cursor(struct _Direct3DDevice9_INT* pBaseDevice, struct _Direct3DSwapChain9_INT* pSwapChain)
|
||||
{
|
||||
D3D9Cursor* pCursor;
|
||||
|
||||
if (FAILED(AlignedAlloc((LPVOID*)&pCursor, sizeof(D3D9Cursor))))
|
||||
{
|
||||
DPRINT1("Failed to allocate D3D9Cursor");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pCursor->pBaseDevice = pBaseDevice;
|
||||
pCursor->pSwapChain = pSwapChain;
|
||||
pCursor->dwWidth = pSwapChain->dwWidth / 2;
|
||||
pCursor->dwHeight = pSwapChain->dwHeight / 2;
|
||||
|
||||
return pCursor;
|
||||
}
|
34
reactos/dll/directx/d3d9/d3d9_cursor.h
Normal file
34
reactos/dll/directx/d3d9/d3d9_cursor.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS ReactX
|
||||
* FILE: dll/directx/d3d9/d3d9_cursor.h
|
||||
* PURPOSE: d3d9.dll internal cursor methods
|
||||
* PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
|
||||
*/
|
||||
#ifndef _D3D9_CURSOR_H
|
||||
#define _D3D9_CURSOR_H
|
||||
|
||||
#include "d3d9_common.h"
|
||||
|
||||
typedef struct _D3D9Cursor
|
||||
{
|
||||
/* 0x0000 */ DWORD dwUnknown0000;
|
||||
/* 0x0004 */ DWORD dwUnknown0004;
|
||||
/* 0x0008 */ DWORD dwUnknown0008;
|
||||
/* 0x000c */ DWORD dwUnknown000c;
|
||||
/* 0x0010 */ DWORD dwUnknown0010;
|
||||
/* 0x0014 */ DWORD dwUnknown0014;
|
||||
/* 0x0018 */ DWORD dwWidth;
|
||||
/* 0x001c */ DWORD dwHeight;
|
||||
/* 0x0020 */ DWORD dwUnknown0020[18];
|
||||
/* 0x0070 */ struct _Direct3DDevice9_INT* pBaseDevice;
|
||||
/* 0x0074 */ struct _Direct3DSwapChain9_INT* pSwapChain;
|
||||
/* 0x0078 */ DWORD dwUnknown0078;
|
||||
/* 0x007c */ DWORD dwMonitorVirtualX;
|
||||
/* 0x0080 */ DWORD dwMonitorVirtualY;
|
||||
/* 0x0084 */ DWORD dwUnknown0084;
|
||||
} D3D9Cursor;
|
||||
|
||||
D3D9Cursor* CreateD3D9Cursor(struct _Direct3DDevice9_INT* pBaseDevice, struct _Direct3DSwapChain9_INT* pSwapChain);
|
||||
|
||||
#endif // _D3D9_CURSOR_H
|
|
@ -15,7 +15,7 @@
|
|||
#define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
|
||||
|
||||
/* Convert a IDirect3D9 pointer safely to the internal implementation struct */
|
||||
static LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
|
||||
LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
|
||||
{
|
||||
if (NULL == iface)
|
||||
return NULL;
|
||||
|
@ -63,6 +63,7 @@ ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface)
|
|||
{
|
||||
DestroyD3D9DeviceData(&This->DeviceData[iAdapter]);
|
||||
}
|
||||
This->lpVtbl->VirtualDestructor(iface);
|
||||
|
||||
LeaveCriticalSection(&This->CriticalSection);
|
||||
AlignedFree(This);
|
||||
|
@ -71,7 +72,7 @@ ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface)
|
|||
return ref;
|
||||
}
|
||||
|
||||
/* IDirect3D9Device interface */
|
||||
/* IDirect3DDevice9 public interface */
|
||||
HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
|
@ -544,3 +545,14 @@ HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE
|
|||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
/* IDirect3DDevice9 private interface */
|
||||
VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
}
|
||||
|
||||
VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface)
|
||||
{
|
||||
UNIMPLEMENTED
|
||||
}
|
||||
|
|
|
@ -83,25 +83,6 @@ typedef struct _D3D9ResourceManager
|
|||
/* 0x0014 - 0x0174 */ D3D9HeapTexture* pTextureHeap;
|
||||
} D3D9ResourceManager;
|
||||
|
||||
typedef struct _D3D9Cursor
|
||||
{
|
||||
/* 0x0000 */ DWORD dwUnknown0000;
|
||||
/* 0x0004 */ DWORD dwUnknown0004;
|
||||
/* 0x0008 */ DWORD dwUnknown0008;
|
||||
/* 0x000c */ DWORD dwUnknown000c;
|
||||
/* 0x0010 */ DWORD dwUnknown0010;
|
||||
/* 0x0014 */ DWORD dwUnknown0014;
|
||||
/* 0x0018 */ DWORD dwWidth;
|
||||
/* 0x001c */ DWORD dwHeight;
|
||||
/* 0x0020 */ DWORD dwUnknown0020[18];
|
||||
/* 0x0070 */ struct _Direct3DDevice9_INT* pBaseDevice;
|
||||
/* 0x0074 */ struct _Direct3DSwapChain9_INT* pSwapChain;
|
||||
/* 0x0078 */ DWORD dwUnknown0078;
|
||||
/* 0x007c */ DWORD dwMonitorVirtualX;
|
||||
/* 0x0080 */ DWORD dwMonitorVirtualY;
|
||||
/* 0x0084 */ DWORD dwUnknown0084;
|
||||
} D3D9Cursor;
|
||||
|
||||
typedef struct _Direct3DDevice9_INT
|
||||
{
|
||||
/* 0x0000 */ struct _IDirect3DDevice9Vtbl_INT* lpVtbl;
|
||||
|
@ -204,12 +185,15 @@ typedef struct _Direct3DDevice9_INT
|
|||
/* 0x1f44 */ DWORD unknown002001;
|
||||
} DIRECT3DDEVICE9_INT, FAR* LPDIRECT3DDEVICE9_INT;
|
||||
|
||||
/* Helper functions */
|
||||
LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface);
|
||||
|
||||
/* IUnknown interface */
|
||||
HRESULT WINAPI IDirect3DDevice9Base_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, void** ppvObject);
|
||||
ULONG WINAPI IDirect3DDevice9Base_AddRef(LPDIRECT3DDEVICE9 iface);
|
||||
ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface);
|
||||
|
||||
/* IDirect3D9Device public interface */
|
||||
/* IDirect3DDevice9 public interface */
|
||||
HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface);
|
||||
UINT WINAPI IDirect3DDevice9Base_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface);
|
||||
HRESULT WINAPI IDirect3DDevice9Base_EvictManagedResources(LPDIRECT3DDEVICE9 iface);
|
||||
|
@ -245,4 +229,8 @@ HRESULT WINAPI IDirect3DDevice9Base_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect
|
|||
HRESULT WINAPI IDirect3DDevice9Base_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color);
|
||||
HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
|
||||
|
||||
/* IDirect3DDevice9 private interface */
|
||||
VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface);
|
||||
VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface);
|
||||
|
||||
#endif /* _D3D9_DEVICE_H_ */
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "d3d9_helpers.h"
|
||||
#include "d3d9_device.h"
|
||||
#include "d3d9_cursor.h"
|
||||
|
||||
#define LOCK_D3DDEVICE9() if (This->BaseObject.pUnknown && ((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->bLockDevice) \
|
||||
EnterCriticalSection(&((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->CriticalSection);
|
||||
|
@ -184,7 +185,7 @@ static IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl =
|
|||
Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice, DWORD ChainIndex)
|
||||
{
|
||||
Direct3DSwapChain9_INT* pThisSwapChain;
|
||||
if (FAILED(AlignedAlloc((LPVOID *)&pThisSwapChain, sizeof(Direct3DSwapChain9_INT))))
|
||||
if (FAILED(AlignedAlloc((LPVOID*)&pThisSwapChain, sizeof(Direct3DSwapChain9_INT))))
|
||||
{
|
||||
DPRINT1("Could not create Direct3DSwapChain9_INT");
|
||||
return NULL;
|
||||
|
@ -202,15 +203,16 @@ Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _
|
|||
return pThisSwapChain;
|
||||
}
|
||||
|
||||
VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DDISPLAYMODE* pMode)
|
||||
VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters)
|
||||
{
|
||||
pThisSwapChain->dwWidth = pMode->Width;
|
||||
pThisSwapChain->dwHeight = pMode->Height;
|
||||
pThisSwapChain->dwWidth = pPresentationParameters->BackBufferWidth;
|
||||
pThisSwapChain->dwHeight = pPresentationParameters->BackBufferHeight;
|
||||
}
|
||||
|
||||
HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters)
|
||||
{
|
||||
int i;
|
||||
DIRECT3DDEVICE9_INT* pDevice;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
@ -221,6 +223,20 @@ HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESE
|
|||
|
||||
pThisSwapChain->PresentParameters = pPresentationParameters[pThisSwapChain->ChainIndex];
|
||||
pThisSwapChain->SwapEffect = pPresentationParameters->SwapEffect;
|
||||
Direct3DSwapChain9_SetDisplayMode(pThisSwapChain, &pThisSwapChain->PresentParameters);
|
||||
|
||||
if (FAILED(D3D9BaseObject_GetDeviceInt(&pThisSwapChain->BaseObject, &pDevice)))
|
||||
{
|
||||
DPRINT1("Could not get the swapchain device");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
pThisSwapChain->pCursor = CreateD3D9Cursor(pDevice, pThisSwapChain);
|
||||
if (NULL == pThisSwapChain->pCursor)
|
||||
{
|
||||
DPRINT1("Could not allocate D3D9Cursor");
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
return Direct3DSwapChain9_Reset(pThisSwapChain, pPresentationParameters);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef struct _Direct3DSwapChain9_INT
|
|||
|
||||
Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice, DWORD ChainIndex);
|
||||
|
||||
VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DDISPLAYMODE* pMode);
|
||||
VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
HRESULT Direct3DSwapChain9_Reset(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ HRESULT InitD3D9BaseDevice(LPDIRECT3DDEVICE9_INT pThisBaseDevice, LPDIRECT3D9_IN
|
|||
|
||||
pThisBaseDevice->pSwapChains[i] = CreateDirect3DSwapChain9(RT_BUILTIN, pThisBaseDevice, i);
|
||||
pThisBaseDevice->pSwapChains2[i] = pThisBaseDevice->pSwapChains[i];
|
||||
Direct3DSwapChain9_SetDisplayMode(pThisBaseDevice->pSwapChains[i], &pThisBaseDevice->CurrentDisplayMode[i]);
|
||||
|
||||
if (FAILED(Direct3DSwapChain9_Init(pThisBaseDevice->pSwapChains[i], pPresentationParameters)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue