Author: mbosma
Date: Mon May 21 14:11:10 2007
New Revision: 26848
URL:
http://svn.reactos.org/svn/reactos?rev=26848&view=rev
Log:
- Implement IDirectDraw7::GetMonitorFrequency, GetDisplayMode
- Outsource display mode related APIs into own file
- Some formatting and spelling fixes
Added:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c (with props)
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c
trunk/reactos/dll/directx/ddraw/ddraw.rbuild
Added: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c (added)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c Mon May 21 14:11:10 2007
@@ -1,0 +1,107 @@
+/* $Id$
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS DirectX
+ * FILE: ddraw/ddraw/ddraw_displaymode.c
+ * PURPOSE: IDirectDraw7 Implementation
+ * PROGRAMMER: Maarten Bosma
+ *
+ */
+
+
+#include "rosdraw.h"
+
+HRESULT WINAPI
+Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
+ DWORD dwBPP, DWORD
dwRefreshRate, DWORD dwFlags)
+{
+ LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+ DX_WINDBG_trace();
+
+ // FIXME: Check primary if surface is locked / busy etc.
+
+ // Check Parameter
+ if(dwFlags != 0)
+ {
+ return DDERR_INVALIDPARAMS;
+ }
+
+ if ((!dwHeight || This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight)
&&
+ (!dwWidth || This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth)
&&
+ (!dwBPP || This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount ==
dwBPP) &&
+ (!dwRefreshRate || This->lpLcl->lpGbl->dwMonitorFrequency ==
dwRefreshRate))
+ {
+ return DD_OK; // nothing to do here for us
+ }
+
+ // Here we go
+ DEVMODE DevMode;
+ DevMode.dmFields = 0;
+ if(dwHeight)
+ DevMode.dmFields |= DM_PELSHEIGHT;
+ if(dwWidth)
+ DevMode.dmFields |= DM_PELSWIDTH;
+ if(dwBPP)
+ DevMode.dmFields |= DM_BITSPERPEL;
+ if(dwRefreshRate)
+ DevMode.dmFields |= DM_DISPLAYFREQUENCY;
+
+ DevMode.dmPelsHeight = dwHeight;
+ DevMode.dmPelsWidth = dwWidth;
+ DevMode.dmBitsPerPel = dwBPP;
+ DevMode.dmDisplayFrequency = dwRefreshRate;
+
+ LONG retval = ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN); /* FIXME: Are we
supposed to set CDS_SET_PRIMARY as well ? */
+
+ if(retval == DISP_CHANGE_BADMODE)
+ {
+ return DDERR_UNSUPPORTED;
+ }
+ else if(retval != DISP_CHANGE_SUCCESSFUL)
+ {
+ return DDERR_GENERIC;
+ }
+
+ // Update Interals
+ BOOL ModeChanged;
+ DdReenableDirectDrawObject(This->lpLcl->lpGbl, &ModeChanged);
+ StartDirectDraw((LPDIRECTDRAW)iface, 0, TRUE);
+
+ return DD_OK;
+}
+
+HRESULT WINAPI
+Main_DirectDraw_GetMonitorFrequency (LPDIRECTDRAW7 iface, LPDWORD lpFreq)
+{
+ LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+ DX_WINDBG_trace();
+
+ if (lpFreq == NULL)
+ return DDERR_INVALIDPARAMS;
+
+ *lpFreq = This->lpLcl->lpGbl->dwMonitorFrequency;
+
+ return DD_OK;
+}
+
+HRESULT WINAPI
+Main_DirectDraw_GetDisplayMode (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
+{
+ LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
+ DX_WINDBG_trace();
+
+ if (pDDSD == NULL)
+ return DDERR_INVALIDPARAMS;
+
+ if (pDDSD->dwSize != sizeof(LPDDSURFACEDESC2))
+ return DDERR_INVALIDPARAMS;
+
+ pDDSD->dwFlags |= DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_PITCH |
DDSD_REFRESHRATE;
+ pDDSD->dwHeight = This->lpLcl->lpGbl->vmiData.dwDisplayWidth;
+ pDDSD->dwWidth = This->lpLcl->lpGbl->vmiData.dwDisplayHeight;
+ pDDSD->ddpfPixelFormat = This->lpLcl->lpGbl->vmiData.ddpfDisplay;
+ pDDSD->dwRefreshRate = This->lpLcl->lpGbl->dwMonitorFrequency;
+ pDDSD->lPitch = This->lpLcl->lpGbl->vmiData.lDisplayPitch;
+
+ return DD_OK;
+}
Propchange: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c Mon May 21 14:11:10 2007
@@ -11,8 +11,7 @@
#include "rosdraw.h"
-HRESULT
-WINAPI
+HRESULT WINAPI
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
REFIID id,
LPVOID *obj)
@@ -21,8 +20,8 @@
DX_WINDBG_trace();
- /* fixme
- the D3D object cab be optain from here
+ /* FIXME
+ the D3D object can be optained from here
Direct3D7
*/
if (IsEqualGUID(&IID_IDirectDraw7, id))
@@ -44,12 +43,7 @@
return DD_OK;
}
-/*
- * IMPLEMENT
- * Status ok
- */
-ULONG
-WINAPI
+ULONG WINAPI
Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
@@ -69,9 +63,7 @@
return This->dwIntRefCnt;
}
-
-ULONG
-WINAPI
+ULONG WINAPI
Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
@@ -103,70 +95,16 @@
return This->dwIntRefCnt;
}
-HRESULT
-WINAPI
+HRESULT WINAPI
+Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
+{
+ return DDERR_ALREADYINITIALIZED;
+}
+
+HRESULT WINAPI
Main_DirectDraw_Compact(LPDIRECTDRAW7 iface)
{
- return DD_OK; // not implemented in ms ddraw
-}
-
-HRESULT WINAPI
-Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
- DWORD dwBPP, DWORD
dwRefreshRate, DWORD dwFlags)
-{
- LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
- DX_WINDBG_trace();
-
- // FIXME: Check primary if surface is locked / busy etc.
-
- // Check Parameter
- if(dwFlags != 0)
- {
- return DDERR_INVALIDPARAMS;
- }
-
- if ((!dwHeight || This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight)
&&
- (!dwWidth || This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth)
&&
- (!dwBPP || This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount ==
dwBPP) &&
- (!dwRefreshRate || This->lpLcl->lpGbl->dwMonitorFrequency ==
dwRefreshRate))
- {
- return DD_OK; // nothing to do here for us
- }
-
- // Here we go
- DEVMODE DevMode;
- DevMode.dmFields = 0;
- if(dwHeight)
- DevMode.dmFields |= DM_PELSHEIGHT;
- if(dwWidth)
- DevMode.dmFields |= DM_PELSWIDTH;
- if(dwBPP)
- DevMode.dmFields |= DM_BITSPERPEL;
- if(dwRefreshRate)
- DevMode.dmFields |= DM_DISPLAYFREQUENCY;
-
- DevMode.dmPelsHeight = dwHeight;
- DevMode.dmPelsWidth = dwWidth;
- DevMode.dmBitsPerPel = dwBPP;
- DevMode.dmDisplayFrequency = dwRefreshRate;
-
- LONG retval = ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN); /* FIXME: Are we
supposed to set CDS_SET_PRIMARY as well ? */
-
- if(retval == DISP_CHANGE_BADMODE)
- {
- return DDERR_UNSUPPORTED;
- }
- else if(retval != DISP_CHANGE_SUCCESSFUL)
- {
- return DDERR_GENERIC;
- }
-
- // Update Interals
- BOOL ModeChanged;
- DdReenableDirectDrawObject(This->lpLcl->lpGbl, &ModeChanged);
- StartDirectDraw((LPDIRECTDRAW)iface, 0, TRUE);
-
- return DD_OK;
+ return DD_OK; // not implemented in ms ddraw either
}
HRESULT WINAPI
@@ -204,8 +142,9 @@
return memdata.ddRVal;
}
-HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2
pDDSD,
- LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown
*pUnkOuter)
+HRESULT WINAPI
+Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
+ LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter)
{
HRESULT ret;
DDSURFACEDESC2 dd_desc_v2;
@@ -258,7 +197,7 @@
return DDERR_INVALIDPARAMS;
}
- /* check if this process belong to this ddraw */
+ /* Check if this process belongs to this ddraw object */
if ( dd_int->lpLcl->dwProcessId != GetCurrentProcessId() )
{
/* FIXME send back right return code */
@@ -270,7 +209,6 @@
LeaveCriticalSection(&ddcs);
return ret;
}
-
IDirectDraw7Vtbl DirectDraw7_Vtable =
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_stubs.c Mon May 21 14:11:10 2007
@@ -78,15 +78,6 @@
DX_STUB;
}
-/*
- * Status: Implentation removed due to rewrite
- */
-HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2
pDDSD)
-{
- DX_WINDBG_trace();
- DX_STUB;
-}
-
HRESULT WINAPI
Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
{
@@ -103,13 +94,6 @@
}
HRESULT WINAPI
-Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
-{
- DX_WINDBG_trace();
- DX_STUB;
-}
-
-HRESULT WINAPI
Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
{
DX_WINDBG_trace();
@@ -118,17 +102,6 @@
HRESULT WINAPI
Main_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL lpbIsInVB)
-{
- DX_WINDBG_trace();
- DX_STUB;
-}
-
-/*
- * Status: Implentation removed due to rewrite
- */
-HRESULT
-WINAPI
-Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
{
DX_WINDBG_trace();
DX_STUB;
Modified: trunk/reactos/dll/directx/ddraw/ddraw.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/ddraw.rb…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/ddraw.rbuild (original)
+++ trunk/reactos/dll/directx/ddraw/ddraw.rbuild Mon May 21 14:11:10 2007
@@ -23,9 +23,10 @@
<file>cleanup.c</file>
<directory name="Ddraw">
+ <file>ddraw_main.c</file>
+ <file>ddraw_displaymode.c</file>
+ <file>ddraw_setcooperativelevel.c</file>
<file>ddraw_stubs.c</file>
- <file>ddraw_setcooperativelevel.c</file>
- <file>ddraw_main.c</file>
<file>callbacks_dd_hel.c</file>
</directory>
<directory name="Surface">