Author: greatlrd
Date: Tue Apr 11 19:06:54 2006
New Revision: 21549
URL:
http://svn.reactos.ru/svn/reactos?rev=21549&view=rev
Log:
First HEL support that is working for one dx apps I got in windows
Modified:
trunk/reactos/dll/directx/ddraw/hal/ddraw_hal.c
trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
Modified: trunk/reactos/dll/directx/ddraw/hal/ddraw_hal.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/hal/ddraw…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/hal/ddraw_hal.c (original)
+++ trunk/reactos/dll/directx/ddraw/hal/ddraw_hal.c Tue Apr 11 19:06:54 2006
@@ -16,104 +16,8 @@
IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
/* HAL Startup process */
- DEVMODE devmode;
- HBITMAP hbmp;
- const UINT bmiSize = sizeof(BITMAPINFOHEADER) + 0x10;
- UCHAR *pbmiData;
- BITMAPINFO *pbmi;
- DWORD *pMasks;
BOOL newmode = FALSE;
- /*
- Get Display mode res and caps
- We need fill the mDDrawGlobal
- vmidata struct right
-
- this code is from Steffen Schulze
- 1. Add the mpModeInfos to inisate
- */
- 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;
-
- /*
- Create HDC
- we need it for doing the Call to GdiEntry1
- */
- This->hdc = CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL);
-
- if (This->hdc == NULL)
- {
- return DD_FALSE;
- }
-
- /* Do not release HDC it is mapen in kernel mode
- we can only release it at exit of ddraw.dll
- */
-
- /*
- Dectect RGB bit mask
- this code is from Steffen Schulze
- why it need I do not know yet but it
- will allown us to create any type of
- surface later
- */
-
- hbmp = CreateCompatibleBitmap(This->hdc, 1, 1);
- if (hbmp==NULL)
- {
- DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- return DD_FALSE;
- }
-
- pbmiData = (UCHAR *) DxHeapMemAlloc(bmiSize);
- pbmi = (BITMAPINFO*)pbmiData;
-
- if (pbmiData==NULL)
- {
- DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
- return DDERR_UNSUPPORTED;
- }
-
- 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);
-
- /*
- prepare start up the DX Draw HAL interface now
- */
-
- memset(&This->mDDrawGlobal, 0, sizeof(DDRAWI_DIRECTDRAW_GBL));
- memset(&This->mHALInfo, 0, sizeof(DDHALINFO));
- memset(&This->mCallbacks, 0, sizeof(DDHAL_CALLBACKS));
/*
Startup DX HAL step one of three
@@ -121,8 +25,7 @@
if (!DdCreateDirectDrawObject(&This->mDDrawGlobal, This->hdc))
{
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
return DD_FALSE;
}
@@ -132,21 +35,10 @@
if (!DdReenableDirectDrawObject(&This->mDDrawGlobal, &newmode))
{
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
- return DD_FALSE;
- }
-
- /*
- Setup the DirectDraw Local
- */
-
- This->mDDrawLocal.lpDDCB = &This->mCallbacks;
- This->mDDrawLocal.lpGbl = &This->mDDrawGlobal;
- This->mDDrawLocal.dwProcessId = GetCurrentProcessId();
-
- This->mDDrawGlobal.lpDDCBtmp = &This->mCallbacks;
- This->mDDrawGlobal.lpExclusiveOwner = &This->mDDrawLocal;
+ DeleteDC(This->hdc);
+ return DD_FALSE;
+ }
+
/*
Startup DX HAL step two of three
@@ -165,8 +57,7 @@
NULL))
{
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
@@ -176,8 +67,7 @@
if (This->mpvmList == NULL)
{
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
@@ -188,8 +78,7 @@
{
DxHeapMemFree(This->mpvmList);
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
@@ -201,8 +90,7 @@
DxHeapMemFree( This->mpFourCC);
DxHeapMemFree( This->mpvmList);
DxHeapMemFree( This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
@@ -229,8 +117,7 @@
DxHeapMemFree(This->mpFourCC);
DxHeapMemFree(This->mpvmList);
DxHeapMemFree(This->mpModeInfos);
- DeleteDC(This->hdc);
- DeleteObject(hbmp);
+ DeleteDC(This->hdc);
// FIXME Close DX fristcall and second call
return DD_FALSE;
}
@@ -256,8 +143,7 @@
This->mDDrawGlobal.hInstance = This->mHALInfo.hInstance;
This->mDDrawGlobal.lp16DD = &This->mDDrawGlobal;
-
- DeleteObject(hbmp);
+
//DeleteDC(This->hdc);
DDHAL_GETDRIVERINFODATA DriverInfo;
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddra…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Tue Apr 11 19:06:54 2006
@@ -70,6 +70,16 @@
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;
@@ -95,15 +105,91 @@
/* cObsolete is undoc in msdn it being use in CreateDCA */
RtlCopyMemory(&This->mDDrawGlobal.cObsolete,&"DISPLAY",7);
RtlCopyMemory(&This->mDDrawGlobal.cDriverName,&"DISPLAY",7);
-
-
-
- // call software first
- Hal_DirectDraw_Initialize (iface);
-
- Hel_DirectDraw_Initialize (iface);
- This->mDdCanCreateSurface.lpDD = &This->mDDrawGlobal;
-
+
+ /* 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;
@@ -123,10 +209,11 @@
{
This->mDdCreateSurface.CreateSurface =
This->mCallbacks.HELDD.CreateSurface;
}
-
- This->mDdCreateSurface.lpDD = &This->mDDrawGlobal;
- This->mDdCreateSurface.CreateSurface = This->mCallbacks.HALDD.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;
}