Author: gbrunmar
Date: Sun Jan 13 14:45:31 2008
New Revision: 31754
URL:
http://svn.reactos.org/svn/reactos?rev=31754&view=rev
Log:
Refactored d3d9 a bit
Added:
trunk/reactos/dll/directx/d3d9/d3d9_common.h (with props)
trunk/reactos/dll/directx/d3d9/d3d9_create.c (with props)
trunk/reactos/dll/directx/d3d9/d3d9_create.h (with props)
Modified:
trunk/reactos/dll/directx/d3d9/d3d9.c
trunk/reactos/dll/directx/d3d9/d3d9.rbuild
trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
trunk/reactos/dll/directx/d3d9/d3d9_helpers.h
trunk/reactos/dll/directx/d3d9/d3d9_impl.c
trunk/reactos/dll/directx/d3d9/d3d9_private.h
Modified: trunk/reactos/dll/directx/d3d9/d3d9.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9.c?re…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9.c Sun Jan 13 14:45:31 2008
@@ -7,13 +7,15 @@
* Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
-#include <windows.h>
-#include "d3d9_private.h"
+#include <d3d9.h>
#include "d3d9_helpers.h"
+#include "d3d9_create.h"
#include <debug.h>
#define DEBUG_MESSAGE_BUFFER_SIZE 512
+
+typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
static LPCSTR D3dError_WrongSdkVersion =
"D3D ERROR: D3D header version mismatch.\n"
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 (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9.rbuild Sun Jan 13 14:45:31 2008
@@ -13,5 +13,6 @@
<file>d3d9.c</file>
<file>d3d9_helpers.c</file>
<file>d3d9_impl.c</file>
+ <file>d3d9_create.c</file>
<file>d3d9.rc</file>
</module>
Added: trunk/reactos/dll/directx/d3d9/d3d9_common.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_comm…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_common.h (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_common.h Sun Jan 13 14:45:31 2008
@@ -1,0 +1,19 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_common.h
+ * PURPOSE: d3d9.dll common functions, defines and macros
+ * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
+ */
+#ifndef _D3D9_COMMON_H_
+#define _D3D9_COMMON_H_
+
+#define COBJMACROS
+#include <windows.h>
+
+#define DLLAPI __declspec(dllexport)
+#define DX_D3D9_DEBUG 0x80000000
+
+extern const struct IDirect3D9Vtbl Direct3D9_Vtbl;
+
+#endif // _D3D9_COMMON_H_
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_common.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/directx/d3d9/d3d9_create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_crea…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_create.c (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_create.c Sun Jan 13 14:45:31 2008
@@ -1,0 +1,128 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_create.c
+ * PURPOSE: d3d9.dll internal create functions and data
+ * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
+ */
+
+typedef struct IDirect3D9 *LPDIRECT3D9;
+
+#include "d3d9_create.h"
+#include "d3d9_helpers.h"
+#include <debug.h>
+#include <ddrawi.h>
+
+static const GUID DISPLAY_GUID = { 0x67685559, 0x3106, 0x11D0, { 0xB9, 0x71, 0x00, 0xAA,
0x00, 0x34, 0x2F, 0x9F } };
+
+static CHAR D3D9_PrimaryDeviceName[CCHDEVICENAME];
+
+static BOOL GetDisplayDeviceInfo(IN OUT LPDIRECT3D9_INT pDirect3D9)
+{
+ DISPLAY_DEVICEA DisplayDevice;
+ DWORD AdapterIndex;
+ DWORD Planes;
+ DWORD Bpp;
+ HDC hDC;
+
+ memset(&DisplayDevice, 0, sizeof(DISPLAY_DEVICEA));
+ DisplayDevice.cb = sizeof(DISPLAY_DEVICEA);
+
+ pDirect3D9->dwNumDisplayAdapters = 0;
+ D3D9_PrimaryDeviceName[0] = '\0';
+
+ AdapterIndex = 0;
+ while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE)
+ {
+ if ((DisplayDevice.StateFlags & (DISPLAY_DEVICE_DISCONNECT |
DISPLAY_DEVICE_MIRRORING_DRIVER)) == 0 &&
+ (DisplayDevice.StateFlags & (DISPLAY_DEVICE_PRIMARY_DEVICE |
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) != 0)
+ {
+ memcpy(&pDirect3D9->DisplayAdapters[0].DisplayGuid, &DISPLAY_GUID,
sizeof(GUID));
+
+ lstrcpynA(pDirect3D9->DisplayAdapters[0].szDeviceName,
DisplayDevice.DeviceName, MAX_PATH);
+
+ if (pDirect3D9->dwNumDisplayAdapters == 0)
+ lstrcpynA(D3D9_PrimaryDeviceName, DisplayDevice.DeviceName,
sizeof(D3D9_PrimaryDeviceName));
+
+ pDirect3D9->DisplayAdapters[0].dwStateFlags = DisplayDevice.StateFlags;
+ pDirect3D9->DisplayAdapters[0].bInUseFlag = TRUE;
+
+ ++pDirect3D9->dwNumDisplayAdapters;
+ break;
+ }
+ }
+
+ AdapterIndex = 0;
+ while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE)
+ {
+ if ((DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0
&&
+ (DisplayDevice.StateFlags & (DISPLAY_DEVICE_MIRRORING_DRIVER |
DISPLAY_DEVICE_PRIMARY_DEVICE)) == 0)
+ {
+
memcpy(&pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].DisplayGuid,
&DISPLAY_GUID, sizeof(GUID));
+
+
lstrcpynA(pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].szDeviceName,
DisplayDevice.DeviceName, MAX_PATH);
+
+
pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].dwStateFlags =
DisplayDevice.StateFlags;
+
pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].bInUseFlag = TRUE;
+
+ ++pDirect3D9->dwNumDisplayAdapters;
+ }
+ }
+
+ hDC = GetDC(NULL);
+ Planes = GetDeviceCaps(hDC, PLANES);
+ Bpp = GetDeviceCaps(hDC, BITSPIXEL);
+ ReleaseDC(NULL, hDC);
+
+ if (Planes * Bpp < 8)
+ return FALSE;
+
+ hDC = CreateDCA(NULL, D3D9_PrimaryDeviceName, NULL, NULL);
+
+ if (hDC == NULL)
+ return FALSE;
+
+ return TRUE;
+}
+
+HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
+{
+ LPDIRECT3D9_INT pDirect3D9;
+
+ if (ppDirect3D9 == 0)
+ return DDERR_INVALIDPARAMS;
+
+ if (AlignedAlloc((LPVOID *)&pDirect3D9, sizeof(DIRECT3D9_INT)) != S_OK)
+ return DDERR_OUTOFMEMORY;
+
+ if (pDirect3D9 == 0)
+ return DDERR_OUTOFMEMORY;
+
+ pDirect3D9->unknown000007 = 0;
+ pDirect3D9->lpInt = 0;
+
+ pDirect3D9->lpVtbl = &Direct3D9_Vtbl;
+ //pDirect3D9->dwProcessId = GetCurrentThreadId();
+ pDirect3D9->dwRefCnt = 1;
+
+ pDirect3D9->unknown004576 = 0;
+ pDirect3D9->unknown004578 = 0;
+ pDirect3D9->unknown004579 = 0;
+ pDirect3D9->unknown004580 = 0;
+ pDirect3D9->unknown004581 = 0;
+ pDirect3D9->unknown004582 = 0;
+ pDirect3D9->unknown004583 = 0;
+ pDirect3D9->unknown004589 = 0x20;
+
+ pDirect3D9->lpInt = pDirect3D9;
+ pDirect3D9->unknown000007 = 1;
+
+ //InitializeCriticalSection(&pDirect3D9->d3d9_cs);
+
+ //memset(pDirect3D9->DisplayAdapters, 0, sizeof(pDirect3D9->DisplayAdapters));
+ GetDisplayDeviceInfo(pDirect3D9);
+
+ *ppDirect3D9 = (LPDIRECT3D9)&pDirect3D9->lpVtbl;
+
+ return ERROR_SUCCESS;
+}
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_create.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/dll/directx/d3d9/d3d9_create.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_crea…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_create.h (added)
+++ trunk/reactos/dll/directx/d3d9/d3d9_create.h Sun Jan 13 14:45:31 2008
@@ -1,0 +1,16 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_create.h
+ * PURPOSE: d3d9.dll internal create functions and data
+ * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
+ */
+#ifndef _D3D9_CREATE_H_
+#define _D3D9_CREATE_H_
+
+#include "d3d9_private.h"
+
+/* Creates a Direct3D9 object */
+HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9);
+
+#endif // _D3D9_CREATE_H_
Propchange: trunk/reactos/dll/directx/d3d9/d3d9_create.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/directx/d3d9/d3d9_helpers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_help…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_helpers.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_helpers.c Sun Jan 13 14:45:31 2008
@@ -6,6 +6,7 @@
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
+#include <d3d9.h>
#include "d3d9_helpers.h"
#include <stdio.h>
#include <ddraw.h>
@@ -14,10 +15,6 @@
#define MEM_ALIGNMENT 0x20
static LPCSTR D3D9_DebugRegPath = "Software\\Microsoft\\Direct3D";
-
-static const GUID DISPLAY_GUID = { 0x67685559, 0x3106, 0x11D0, { 0xB9, 0x71, 0x00, 0xAA,
0x00, 0x34, 0x2F, 0x9F } };
-
-static CHAR D3D9_PrimaryDeviceName[32];
LPDIRECT3D9_INT impl_from_IDirect3D9(LPDIRECT3D9 iface)
{
@@ -63,110 +60,6 @@
Buffer[BufferSize-1] = '\0';
return 0;
-}
-
-static BOOL GetDisplayDeviceInfo(IN OUT LPDIRECT3D9_INT pDirect3D9)
-{
- DISPLAY_DEVICEA DisplayDevice;
- DWORD AdapterIndex;
- DWORD Planes;
- DWORD Bpp;
- HDC hDC;
-
- memset(&DisplayDevice, 0, sizeof(DISPLAY_DEVICEA));
- DisplayDevice.cb = sizeof(DISPLAY_DEVICEA);
-
- pDirect3D9->dwNumDisplayAdapters = 0;
- D3D9_PrimaryDeviceName[0] = '\0';
-
- AdapterIndex = 0;
- while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE)
- {
- if ((DisplayDevice.StateFlags & (DISPLAY_DEVICE_DISCONNECT |
DISPLAY_DEVICE_MIRRORING_DRIVER)) == 0 &&
- (DisplayDevice.StateFlags & (DISPLAY_DEVICE_PRIMARY_DEVICE |
DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) != 0)
- {
- memcpy(&pDirect3D9->DisplayAdapters[0].DisplayGuid, &DISPLAY_GUID,
sizeof(GUID));
-
- lstrcpynA(pDirect3D9->DisplayAdapters[0].szDeviceName,
DisplayDevice.DeviceName, MAX_PATH);
-
- if (pDirect3D9->dwNumDisplayAdapters == 0)
- lstrcpynA(D3D9_PrimaryDeviceName, DisplayDevice.DeviceName,
sizeof(D3D9_PrimaryDeviceName));
-
- pDirect3D9->DisplayAdapters[0].dwStateFlags = DisplayDevice.StateFlags;
- pDirect3D9->DisplayAdapters[0].bInUseFlag = TRUE;
-
- ++pDirect3D9->dwNumDisplayAdapters;
- }
- }
-
- AdapterIndex = 0;
- while (EnumDisplayDevicesA(NULL, AdapterIndex, &DisplayDevice, 0) == TRUE)
- {
- if ((DisplayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) != 0
&&
- (DisplayDevice.StateFlags & (DISPLAY_DEVICE_MIRRORING_DRIVER |
DISPLAY_DEVICE_PRIMARY_DEVICE)) == 0)
- {
-
memcpy(&pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].DisplayGuid,
&DISPLAY_GUID, sizeof(GUID));
-
-
lstrcpynA(pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].szDeviceName,
DisplayDevice.DeviceName, MAX_PATH);
-
-
pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].dwStateFlags =
DisplayDevice.StateFlags;
-
pDirect3D9->DisplayAdapters[pDirect3D9->dwNumDisplayAdapters].bInUseFlag = TRUE;
-
- ++pDirect3D9->dwNumDisplayAdapters;
- }
- }
-
- hDC = GetDC(NULL);
- Planes = GetDeviceCaps(hDC, PLANES);
- Bpp = GetDeviceCaps(hDC, BITSPIXEL);
- ReleaseDC(NULL, hDC);
-
- if (Planes * Bpp < 8)
- return FALSE;
-
- return TRUE;
-}
-
-HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
-{
- LPDIRECT3D9_INT pDirect3D9;
-
- if (ppDirect3D9 == 0)
- return DDERR_INVALIDPARAMS;
-
- if (AlignedAlloc((LPVOID *)&pDirect3D9, sizeof(DIRECT3D9_INT)) != S_OK)
- return DDERR_OUTOFMEMORY;
-
- if (pDirect3D9 == 0)
- return DDERR_OUTOFMEMORY;
-
- pDirect3D9->unknown000007 = 0;
- pDirect3D9->lpInt = 0;
-
- pDirect3D9->lpVtbl = &Direct3D9_Vtbl;
- //pDirect3D9->dwProcessId = GetCurrentThreadId();
- pDirect3D9->dwRefCnt = 1;
-
- pDirect3D9->unknown004576 = 0;
- pDirect3D9->unknown004578 = 0;
- pDirect3D9->unknown004579 = 0;
- pDirect3D9->unknown004580 = 0;
- pDirect3D9->unknown004581 = 0;
- pDirect3D9->unknown004582 = 0;
- pDirect3D9->unknown004583 = 0;
- pDirect3D9->unknown004589 = 0x20;
-
- pDirect3D9->lpInt = pDirect3D9;
- pDirect3D9->unknown000007 = 1;
-
- //InitializeCriticalSection(&pDirect3D9->d3d9_cs);
-
- //memset(pDirect3D9->DisplayAdapters, 0, sizeof(pDirect3D9->DisplayAdapters));
- GetDisplayDeviceInfo(pDirect3D9);
-
- *ppDirect3D9 = (LPDIRECT3D9)&pDirect3D9->lpVtbl;
-
- return ERROR_SUCCESS;
}
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize)
Modified: trunk/reactos/dll/directx/d3d9/d3d9_helpers.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_help…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_helpers.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_helpers.h Sun Jan 13 14:45:31 2008
@@ -8,6 +8,7 @@
#ifndef _D3D9_HELPERS_H_
#define _D3D9_HELPERS_H_
+#include "d3d9_common.h"
#include "d3d9_private.h"
/* Convert a IDirect3D9 pointer safely to the internal implementation struct */
@@ -19,9 +20,6 @@
/* Formats debug strings */
HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR
FormatString, ... );
-/* Creates a Direct3D9 object */
-HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9);
-
/* Allocates memory and returns an aligned pointer */
HRESULT AlignedAlloc(IN OUT LPVOID *ppObject, IN SIZE_T dwSize);
Modified: trunk/reactos/dll/directx/d3d9/d3d9_impl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_impl…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_impl.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_impl.c Sun Jan 13 14:45:31 2008
@@ -5,8 +5,10 @@
* PURPOSE: IDirect3D9 implementation
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
+
+#include "d3d9_common.h"
+#include <d3d9.h>
#include "d3d9_helpers.h"
-
#include <debug.h>
/* IDirect3D9: IUnknown implementation */
Modified: trunk/reactos/dll/directx/d3d9/d3d9_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_priv…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_private.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_private.h Sun Jan 13 14:45:31 2008
@@ -1,23 +1,14 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS ReactX
- * FILE: dll/directx/d3d9/d3d9_helpers.c
- * PURPOSE: d3d9.dll helper functions
+ * FILE: dll/directx/d3d9/d3d9_private.h
+ * PURPOSE: d3d9.dll internal structures
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/
#ifndef _D3D9_PRIVATE_H_
#define _D3D9_PRIVATE_H_
-#define COBJMACROS
#include <windows.h>
-#include <d3d9.h>
-
-#define DLLAPI __declspec(dllexport)
-#define DX_D3D9_DEBUG 0x80000000
-
-typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
-
-extern const IDirect3D9Vtbl Direct3D9_Vtbl;
typedef struct _tagDIRECT3D9DisplayAdapterInfo_
{
@@ -133,7 +124,7 @@
typedef struct _tagDIRECT3D9_INT_
{
-/* 0x0000 */ const IDirect3D9Vtbl *lpVtbl; /* LPDIRECTD3D9 functoions table */
+/* 0x0000 */ const struct IDirect3D9Vtbl *lpVtbl; /* LPDIRECTD3D9 functoions table */
/* 0x0004 */ CRITICAL_SECTION d3d9_cs;
/* 0x001c */ DWORD unknown000007; /* 0x00000001 */
/* 0x0020 */ DWORD dwProcessId;