Author: gbrunmar
Date: Mon Sep 1 20:32:57 2008
New Revision: 35860
URL:
http://svn.reactos.org/svn/reactos?rev=35860&view=rev
Log:
D3D9:
* Initial cursor creation in swap chain
* Changed from screen width/height in swap chains to back buffer width/height
Added:
trunk/reactos/dll/directx/d3d9/d3d9_cursor.c (with props)
trunk/reactos/dll/directx/d3d9/d3d9_cursor.h (with props)
Modified:
trunk/reactos/dll/directx/d3d9/d3d9.rbuild
trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c
trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h
trunk/reactos/dll/directx/d3d9/d3d9_device.c
trunk/reactos/dll/directx/d3d9/d3d9_device.h
trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c
trunk/reactos/dll/directx/d3d9/d3d9_swapchain.h
trunk/reactos/dll/directx/d3d9/device.c
Modified: trunk/reactos/dll/directx/d3d9/d3d9.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9.rbui…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9.rbuild [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9.rbuild [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -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_puredevice.c</file>
<file>d3d9_swapchain.c</file>
- <file>d3d9_puredevice.c</file>
- <file>d3d9_haldevice.c</file>
<file>adapter.c</file>
<file>device.c</file>
<file>format.c</file>
Modified: trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_base…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_baseobject.c [iso-8859-1] Mon Sep 1 20:32:57
2008
@@ -71,3 +71,18 @@
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;
+}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_base…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_baseobject.h [iso-8859-1] Mon Sep 1 20:32:57
2008
@@ -12,6 +12,7 @@
#include <d3d9.h>
struct _D3D9BaseObject;
+struct _Direct3DDevice9_INT;
enum REF_TYPE
{
@@ -42,5 +43,6 @@
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_
Added: trunk/reactos/dll/directx/d3d9/d3d9_cursor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_curs…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_cursor.c (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_cursor.c [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -1,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;
+}
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_cursor.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/directx/d3d9/d3d9_cursor.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_curs…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_cursor.h (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_cursor.h [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -1,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
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_cursor.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/directx/d3d9/d3d9_device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_devi…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_device.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_device.c [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -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 @@
{
DestroyD3D9DeviceData(&This->DeviceData[iAdapter]);
}
+ This->lpVtbl->VirtualDestructor(iface);
LeaveCriticalSection(&This->CriticalSection);
AlignedFree(This);
@@ -71,7 +72,7 @@
return ref;
}
-/* IDirect3D9Device interface */
+/* IDirect3DDevice9 public interface */
HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface)
{
UNIMPLEMENTED
@@ -544,3 +545,14 @@
return D3D_OK;
}
+
+/* IDirect3DDevice9 private interface */
+VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface)
+{
+ UNIMPLEMENTED
+}
+
+VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface)
+{
+ UNIMPLEMENTED
+}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_device.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_devi…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_device.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_device.h [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -82,25 +82,6 @@
/* 0x0010 - 0x0170 */ DWORD dwUnknown0010;
/* 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
{
@@ -204,12 +185,15 @@
/* 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_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_ */
Modified: trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_swap…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_swapchain.c [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -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 @@
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 @@
return pThisSwapChain;
}
-VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain,
D3DDISPLAYMODE* pMode)
-{
- pThisSwapChain->dwWidth = pMode->Width;
- pThisSwapChain->dwHeight = pMode->Height;
+VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain,
D3DPRESENT_PARAMETERS* pPresentationParameters)
+{
+ 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 @@
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);
}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_swapchain.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_swap…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_swapchain.h [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_swapchain.h [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -74,7 +74,7 @@
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);
Modified: trunk/reactos/dll/directx/d3d9/device.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/device.c?…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/device.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/d3d9/device.c [iso-8859-1] Mon Sep 1 20:32:57 2008
@@ -81,7 +81,6 @@
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)))
{