Author: greatlrd
Date: Sun Jul 23 13:57:15 2006
New Revision: 23238
URL:
http://svn.reactos.org/svn/reactos?rev=23238&view=rev
Log:
Start cleaing up DDraw.dll I start moving all startup code for HAL and HEL to startup.c.
It will kill alot of files and code
and we can adodate our ddraw to wine ddraw design, at end.
Added:
trunk/reactos/dll/directx/ddraw/startup.c (with props)
Modified:
trunk/reactos/dll/directx/ddraw/ddraw.rbuild
trunk/reactos/dll/directx/ddraw/main.c
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
trunk/reactos/dll/directx/ddraw/rosdraw.h
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 Sun Jul 23 13:57:15 2006
@@ -17,6 +17,7 @@
<file>ddraw.rc</file>
<file>main.c</file>
<file>regsvr.c</file>
+ <file>startup.c</file>
<file>helinterface.c</file>
<file>clipper.c</file>
Modified: trunk/reactos/dll/directx/ddraw/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main.c?r…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main.c Sun Jul 23 13:57:15 2006
@@ -13,39 +13,6 @@
#include "rosdraw.h"
#include "d3dhal.h"
-
-
-/*
- * IMPLEMENT
- * Status this api is finish and is 100% correct
- */
-
-HRESULT
-WINAPI
-Create_DirectDraw (LPGUID pGUID,
- LPDIRECTDRAW* pIface,
- REFIID id,
- BOOL ex)
-{
- IDirectDrawImpl* This = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(IDirectDrawImpl));
-
- if (This == NULL)
- return E_OUTOFMEMORY;
-
- ZeroMemory(This,sizeof(IDirectDrawImpl));
-
- This->lpVtbl = &DirectDraw7_Vtable;
- This->lpVtbl_v1 = &DDRAW_IDirectDraw_VTable;
- This->lpVtbl_v2 = &DDRAW_IDirectDraw2_VTable;
- This->lpVtbl_v4 = &DDRAW_IDirectDraw4_VTable;
-
- *pIface = (LPDIRECTDRAW)This;
-
- if(This->lpVtbl->QueryInterface ((LPDIRECTDRAW7)This, id, (void**)&pIface) !=
S_OK)
- return DDERR_INVALIDPARAMS;
-
- return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID);
-}
/*
* IMPLEMENT
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddr…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Sun Jul 23 13:57:15 2006
@@ -69,17 +69,7 @@
HRESULT
WINAPI
Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
-{
- DWORD hal_ret;
- DWORD hel_ret;
- DEVMODE devmode;
- HBITMAP hbmp;
- const UINT bmiSize = sizeof(BITMAPINFOHEADER) + 0x10;
- UCHAR *pbmiData;
- BITMAPINFO *pbmi;
- DWORD *pMasks;
-
-
+{
DX_WINDBG_trace();
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
@@ -88,7 +78,6 @@
{
return DDERR_NOTINITIALIZED;
}
-
if (This->InitializeDraw == TRUE)
{
@@ -99,121 +88,6 @@
This->InitializeDraw = TRUE;
}
- RtlZeroMemory(&This->mDDrawGlobal, sizeof(DDRAWI_DIRECTDRAW_GBL));
-
-
- /* cObsolete is undoc in msdn it being use in CreateDCA */
- RtlCopyMemory(&This->mDDrawGlobal.cObsolete,&"DISPLAY",7);
- RtlCopyMemory(&This->mDDrawGlobal.cDriverName,&"DISPLAY",7);
-
- /* Same for HEL and HAL */
- This->mcModeInfos = 1;
- This->mpModeInfos = (DDHALMODEINFO*) DxHeapMemAlloc(This->mcModeInfos *
sizeof(DDHALMODEINFO));
-
- if (This->mpModeInfos == NULL)
- {
- return DD_FALSE;
- }
-
- EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
-
- This->mpModeInfos[0].dwWidth = devmode.dmPelsWidth;
- This->mpModeInfos[0].dwHeight = devmode.dmPelsHeight;
- This->mpModeInfos[0].dwBPP = devmode.dmBitsPerPel;
- This->mpModeInfos[0].lPitch = (devmode.dmPelsWidth*devmode.dmBitsPerPel)/8;
- This->mpModeInfos[0].wRefreshRate = (WORD)devmode.dmDisplayFrequency;
-
- This->hdc = CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
-
- if (This->hdc == NULL)
- {
- return DDERR_OUTOFMEMORY ;
- }
-
- hbmp = CreateCompatibleBitmap(This->hdc, 1, 1);
- if (hbmp==NULL)
- {
- DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- return DDERR_OUTOFMEMORY;
- }
-
- pbmiData = (UCHAR *) DxHeapMemAlloc(bmiSize);
- pbmi = (BITMAPINFO*)pbmiData;
-
- if (pbmiData==NULL)
- {
- DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
- return DDERR_OUTOFMEMORY;
- }
-
- pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pbmi->bmiHeader.biBitCount = (WORD)devmode.dmBitsPerPel;
- pbmi->bmiHeader.biCompression = BI_BITFIELDS;
- pbmi->bmiHeader.biWidth = 1;
- pbmi->bmiHeader.biHeight = 1;
-
- GetDIBits(This->hdc, hbmp, 0, 0, NULL, pbmi, 0);
- DeleteObject(hbmp);
-
- pMasks = (DWORD*)(pbmiData + sizeof(BITMAPINFOHEADER));
- This->mpModeInfos[0].dwRBitMask = pMasks[0];
- This->mpModeInfos[0].dwGBitMask = pMasks[1];
- This->mpModeInfos[0].dwBBitMask = pMasks[2];
- This->mpModeInfos[0].dwAlphaBitMask = pMasks[3];
-
- DxHeapMemFree(pbmiData);
-
- /* Startup HEL and HAL */
- RtlZeroMemory(&This->mDDrawGlobal, sizeof(DDRAWI_DIRECTDRAW_GBL));
- RtlZeroMemory(&This->mHALInfo, sizeof(DDHALINFO));
- RtlZeroMemory(&This->mCallbacks, sizeof(DDHAL_CALLBACKS));
-
- This->mDDrawLocal.lpDDCB = &This->mCallbacks;
- This->mDDrawLocal.lpGbl = &This->mDDrawGlobal;
- This->mDDrawLocal.dwProcessId = GetCurrentProcessId();
-
- This->mDDrawGlobal.lpDDCBtmp = &This->mCallbacks;
- This->mDDrawGlobal.lpExclusiveOwner = &This->mDDrawLocal;
-
- hal_ret = Hal_DirectDraw_Initialize (iface);
- hel_ret = Hel_DirectDraw_Initialize (iface);
- if ((hal_ret!=DD_OK) && (hel_ret!=DD_OK))
- {
- return DDERR_NODIRECTDRAWSUPPORT;
- }
-
- /*
- Try figout which api we shall use, first we try see if HAL exits
- if it does not we select HEL instead
- */
-
- if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags &
DDHAL_CB32_CANCREATESURFACE)
- {
- This->mDdCanCreateSurface.CanCreateSurface =
This->mCallbacks.HALDD.CanCreateSurface;
- }
- else
- {
- This->mDdCanCreateSurface.CanCreateSurface =
This->mCallbacks.HELDD.CanCreateSurface;
- }
-
- This->mDdCreateSurface.lpDD = &This->mDDrawGlobal;
-
- if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CREATESURFACE)
- {
- This->mDdCreateSurface.CreateSurface =
This->mCallbacks.HALDD.CreateSurface;
- }
- else
- {
- This->mDdCreateSurface.CreateSurface =
This->mCallbacks.HELDD.CreateSurface;
- }
-
- /* Setup calback struct so we do not need refill same info again */
- This->mDdCreateSurface.lpDD = &This->mDDrawGlobal;
- This->mDdCanCreateSurface.lpDD = &This->mDDrawGlobal;
-
return DD_OK;
}
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/rosdraw.h (original)
+++ trunk/reactos/dll/directx/ddraw/rosdraw.h Sun Jul 23 13:57:15 2006
@@ -10,21 +10,10 @@
#include <d3dhal.h>
#include <ddrawgdi.h>
-
-/* this sturct are not longer in DDK
- I did recrate it by looking diffent betwin DD_xx struct and _DDHAL strucrt
- only diffent I found was the global pointer have been change from
LPDDRAWI_DDRAWSURFACE_GBL
- to DD_DIRECTDRAW_GLOBAL
-*/
-
-typedef struct _DDHAL_MAPMEMORYDATA
-{
- LPDDRAWI_DDRAWSURFACE_GBL lpDD;
- BOOL bMap;
- HANDLE hProcess;
- FLATPTR fpProcess;
- HRESULT ddRVal;
-} DDHAL_MAPMEMORYDATA;
+HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL
ex);
+
+HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 );
+HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 );
/* own macro to alloc memmory */
#define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m)
@@ -228,8 +217,7 @@
HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2
ddscaps, LPDWORD total, LPDWORD free);
-HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 );
-HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 );
+
VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 );
HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7, LPDDSCAPS2, LPDWORD, LPDWORD
);
HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE );
Added: trunk/reactos/dll/directx/ddraw/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/startup.c (added)
+++ trunk/reactos/dll/directx/ddraw/startup.c Sun Jul 23 13:57:15 2006
@@ -1,0 +1,188 @@
+/* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $
+ *
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: lib/ddraw/ddraw.c
+ * PURPOSE: DirectDraw Library
+ * PROGRAMMER: Magnus Olsen (greatlrd)
+ *
+ */
+
+#include <windows.h>
+#include "rosdraw.h"
+#include "d3dhal.h"
+
+
+HRESULT WINAPI
+StartDirectDraw(LPDIRECTDRAW* iface)
+{
+ IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
+ DWORD hal_ret;
+ DWORD hel_ret;
+ DEVMODE devmode;
+ HBITMAP hbmp;
+ const UINT bmiSize = sizeof(BITMAPINFOHEADER) + 0x10;
+ UCHAR *pbmiData;
+ BITMAPINFO *pbmi;
+ DWORD *pMasks;
+
+ DX_WINDBG_trace();
+
+ RtlZeroMemory(&This->mDDrawGlobal, sizeof(DDRAWI_DIRECTDRAW_GBL));
+
+ /* cObsolete is undoc in msdn it being use in CreateDCA */
+ RtlCopyMemory(&This->mDDrawGlobal.cObsolete,&"DISPLAY",7);
+ RtlCopyMemory(&This->mDDrawGlobal.cDriverName,&"DISPLAY",7);
+
+ /* Same for HEL and HAL */
+ This->mcModeInfos = 1;
+ This->mpModeInfos = (DDHALMODEINFO*) DxHeapMemAlloc(This->mcModeInfos *
sizeof(DDHALMODEINFO));
+
+ if (This->mpModeInfos == NULL)
+ {
+ DX_STUB_str("DD_FALSE");
+ return DD_FALSE;
+ }
+
+ EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
+
+ This->mpModeInfos[0].dwWidth = devmode.dmPelsWidth;
+ This->mpModeInfos[0].dwHeight = devmode.dmPelsHeight;
+ This->mpModeInfos[0].dwBPP = devmode.dmBitsPerPel;
+ This->mpModeInfos[0].lPitch = (devmode.dmPelsWidth*devmode.dmBitsPerPel)/8;
+ This->mpModeInfos[0].wRefreshRate = (WORD)devmode.dmDisplayFrequency;
+
+ This->hdc = CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
+
+ if (This->hdc == NULL)
+ {
+ DX_STUB_str("DDERR_OUTOFMEMORY");
+ return DDERR_OUTOFMEMORY ;
+ }
+
+ hbmp = CreateCompatibleBitmap(This->hdc, 1, 1);
+ if (hbmp==NULL)
+ {
+ DxHeapMemFree(This->mpModeInfos);
+ DeleteDC(This->hdc);
+ DX_STUB_str("DDERR_OUTOFMEMORY");
+ return DDERR_OUTOFMEMORY;
+ }
+
+ pbmiData = (UCHAR *) DxHeapMemAlloc(bmiSize);
+ pbmi = (BITMAPINFO*)pbmiData;
+
+ if (pbmiData==NULL)
+ {
+ DxHeapMemFree(This->mpModeInfos);
+ DeleteDC(This->hdc);
+ DeleteObject(hbmp);
+ DX_STUB_str("DDERR_OUTOFMEMORY");
+ return DDERR_OUTOFMEMORY;
+ }
+
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biBitCount = (WORD)devmode.dmBitsPerPel;
+ pbmi->bmiHeader.biCompression = BI_BITFIELDS;
+ pbmi->bmiHeader.biWidth = 1;
+ pbmi->bmiHeader.biHeight = 1;
+
+ GetDIBits(This->hdc, hbmp, 0, 0, NULL, pbmi, 0);
+ DeleteObject(hbmp);
+
+ pMasks = (DWORD*)(pbmiData + sizeof(BITMAPINFOHEADER));
+ This->mpModeInfos[0].dwRBitMask = pMasks[0];
+ This->mpModeInfos[0].dwGBitMask = pMasks[1];
+ This->mpModeInfos[0].dwBBitMask = pMasks[2];
+ This->mpModeInfos[0].dwAlphaBitMask = pMasks[3];
+
+ DxHeapMemFree(pbmiData);
+
+ /* Startup HEL and HAL */
+ RtlZeroMemory(&This->mDDrawGlobal, sizeof(DDRAWI_DIRECTDRAW_GBL));
+ RtlZeroMemory(&This->mHALInfo, sizeof(DDHALINFO));
+ RtlZeroMemory(&This->mCallbacks, sizeof(DDHAL_CALLBACKS));
+
+ This->mDDrawLocal.lpDDCB = &This->mCallbacks;
+ This->mDDrawLocal.lpGbl = &This->mDDrawGlobal;
+ This->mDDrawLocal.dwProcessId = GetCurrentProcessId();
+
+ This->mDDrawGlobal.lpDDCBtmp = &This->mCallbacks;
+ This->mDDrawGlobal.lpExclusiveOwner = &This->mDDrawLocal;
+
+ hal_ret = Hal_DirectDraw_Initialize ((LPDIRECTDRAW7)iface);
+ hel_ret = Hel_DirectDraw_Initialize ((LPDIRECTDRAW7)iface);
+ if ((hal_ret!=DD_OK) && (hel_ret!=DD_OK))
+ {
+ DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT");
+ return DDERR_NODIRECTDRAWSUPPORT;
+ }
+
+ /*
+ Try figout which api we shall use, first we try see if HAL exits
+ if it does not we select HEL instead
+ */
+
+ if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags &
DDHAL_CB32_CANCREATESURFACE)
+ {
+ This->mDdCanCreateSurface.CanCreateSurface =
This->mCallbacks.HALDD.CanCreateSurface;
+ }
+ else
+ {
+ This->mDdCanCreateSurface.CanCreateSurface =
This->mCallbacks.HELDD.CanCreateSurface;
+ }
+
+ This->mDdCreateSurface.lpDD = &This->mDDrawGlobal;
+
+ if (This->mDDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_CREATESURFACE)
+ {
+ This->mDdCreateSurface.CreateSurface =
This->mCallbacks.HALDD.CreateSurface;
+ }
+ else
+ {
+ This->mDdCreateSurface.CreateSurface =
This->mCallbacks.HELDD.CreateSurface;
+ }
+
+ /* Setup calback struct so we do not need refill same info again */
+ This->mDdCreateSurface.lpDD = &This->mDDrawGlobal;
+ This->mDdCanCreateSurface.lpDD = &This->mDDrawGlobal;
+
+ return DD_OK;
+}
+
+HRESULT
+WINAPI
+Create_DirectDraw (LPGUID pGUID,
+ LPDIRECTDRAW* pIface,
+ REFIID id,
+ BOOL ex)
+{
+ IDirectDrawImpl* This = (IDirectDrawImpl*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(IDirectDrawImpl));
+
+ DX_WINDBG_trace();
+
+ if (This == NULL)
+ return E_OUTOFMEMORY;
+
+ ZeroMemory(This,sizeof(IDirectDrawImpl));
+
+ This->lpVtbl = &DirectDraw7_Vtable;
+ This->lpVtbl_v1 = &DDRAW_IDirectDraw_VTable;
+ This->lpVtbl_v2 = &DDRAW_IDirectDraw2_VTable;
+ This->lpVtbl_v4 = &DDRAW_IDirectDraw4_VTable;
+
+ *pIface = (LPDIRECTDRAW)This;
+
+ if(This->lpVtbl->QueryInterface ((LPDIRECTDRAW7)This, id, (void**)&pIface) !=
S_OK)
+ {
+ return DDERR_INVALIDPARAMS;
+ }
+
+ if (StartDirectDraw((LPDIRECTDRAW*)This) == DD_OK);
+ {
+ return This->lpVtbl->Initialize ((LPDIRECTDRAW7)This, pGUID);
+ }
+
+ return DDERR_INVALIDPARAMS;
+}
+
Propchange: trunk/reactos/dll/directx/ddraw/startup.c
------------------------------------------------------------------------------
svn:eol-style = native