mirror of
https://github.com/reactos/reactos.git
synced 2025-05-30 06:28:34 +00:00
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. svn path=/trunk/; revision=23238
This commit is contained in:
parent
ca4d6063a2
commit
a3842a1f4e
5 changed files with 194 additions and 176 deletions
|
@ -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>
|
||||
|
|
|
@ -14,39 +14,6 @@
|
|||
#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
|
||||
* Status this api is finish and is 100% correct
|
||||
|
|
|
@ -69,17 +69,7 @@ const DWORD pixelformatsCount = sizeof(pixelformats) / sizeof(DDPIXELFORMAT);
|
|||
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;
|
||||
|
@ -89,7 +79,6 @@ Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
|
|||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
|
||||
if (This->InitializeDraw == TRUE)
|
||||
{
|
||||
return DDERR_ALREADYINITIALIZED;
|
||||
|
@ -99,121 +88,6 @@ Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,21 +10,10 @@
|
|||
#include <d3dhal.h>
|
||||
#include <ddrawgdi.h>
|
||||
|
||||
HRESULT WINAPI Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface, REFIID id, BOOL ex);
|
||||
|
||||
/* 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 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 @@ extern IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable;
|
|||
|
||||
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 );
|
||||
|
|
188
reactos/dll/directx/ddraw/startup.c
Normal file
188
reactos/dll/directx/ddraw/startup.c
Normal file
|
@ -0,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;
|
||||
}
|
||||
|
Loading…
Reference in a new issue