Author: greatlrd
Date: Mon Nov 17 09:00:28 2008
New Revision: 37405
URL:
http://svn.reactos.org/svn/reactos?rev=37405&view=rev
Log:
ported old version of HEL lock surface for ddraw I wrote long time ago. It is not complete
and can contain bugs.
Modified:
branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c
Modified: branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddra…
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1]
(original)
+++ branches/reactx/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1]
Mon Nov 17 09:00:28 2008
@@ -1,119 +1,169 @@
/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS DirectX
- * FILE: ddraw/surface/callbacks_surf_hel.c
- * PURPOSE: HEL Callbacks For Surface APIs
- * PROGRAMMER: Magnus Olsen
- *
- */
-
+*
+* COPYRIGHT: See COPYING in the top level directory
+* PROJECT: ReactOS DirectX
+* FILE: ddraw/surface/callbacks_surf_hel.c
+* PURPOSE: HEL Callbacks For Surface APIs
+* PROGRAMMER: Magnus Olsen
+*
+*/
#include "rosdraw.h"
-
DWORD CALLBACK HelDdSurfAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA
lpDestroySurface)
{
- DX_STUB;
+DX_STUB;
+}
+DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
+{
+if (lpBltData->dwFlags & DDBLT_COLORFILL)
+{
+HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
+FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
+(CONST RECT *)&lpBltData->rDest,
+hbr);
+DeleteObject(hbr);
+lpBltData->ddRVal = DD_OK;
}
-DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
+else if (lpBltData->dwFlags & DDBLT_ROP)
{
- if (lpBltData->dwFlags & DDBLT_COLORFILL)
+BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
+lpBltData->rDest.top,
+lpBltData->rDest.left,
+lpBltData->rDest.right,
+lpBltData->rDest.bottom,
+(HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
+lpBltData->rSrc.top,
+lpBltData->rSrc.right,
+lpBltData->bltFX.dwROP);
+lpBltData->ddRVal = DD_OK;
+}
+return DDHAL_DRIVER_HANDLED;
+}
+DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
+{
+DX_STUB;
+}
+DWORD CALLBACK HelDdSurfFlip(LPDDHAL_FLIPDATA lpFlipData)
+{
+DX_STUB;
+}
+DWORD CALLBACK HelDdSurfGetBltStatus(LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData)
+{
+DX_STUB;
+}
+DWORD CALLBACK HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData)
+{
+DX_STUB;
+}
+DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
+{
+ HDC hDC;
+ BITMAP bm;
+ PDWORD pixels = NULL;
+ HGDIOBJ hBmp;
+ BITMAPINFO bmi;
+ int retvalue = 0;
+
+ /* ToDo tell ddraw internal this surface are locked */
+ /* ToDo add support for dwFlags */
+ /* ToDo fill in LPDDHALSURFCB_LOCK Lock ? */
+
+ /* Get our hdc for the surface */
+ hDC = (HDC)lpLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hDC;
+
+ /* Get our bitmap handle from hdc, we need it if we want extract the Bitmap pixel
data */
+ hBmp = GetCurrentObject(hDC, OBJ_BITMAP);
+
+ /* Get our bitmap information from hBmp, we need it if we want extract the Bitmap
pixel data */
+ if (GetObject(hBmp, sizeof(BITMAP), &bm) )
{
+ /* Alloc memory buffer at usermode for the bitmap pixel data */
+ pixels = (PDWORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bm.bmWidth *
bm.bmHeight * (bm.bmBitsPixel*bm.bmBitsPixel ) );
- HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
+ if (pixels != NULL)
+ {
+ /* Zero out all members in bmi so no junk data are left */
+ ZeroMemory(&bmi, sizeof(BITMAPINFO));
- FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
- (CONST RECT *)&lpBltData->rDest,
- hbr);
+ /* Setup BITMAPINFOHEADER for bmi header */
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = bm.bmWidth;
+ bmi.bmiHeader.biHeight = bm.bmHeight;
+ bmi.bmiHeader.biPlanes = bm.bmPlanes;
+ bmi.bmiHeader.biBitCount = bm.bmBitsPixel;
+ bmi.bmiHeader.biCompression = BI_RGB;
- DeleteObject(hbr);
+ /* Check if it the bitmap is palete or not */
+ if ( bm.bmBitsPixel <= 8)
+ {
+ /* Extract the bitmap bits data from palete bitmap */
+ retvalue = GetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi,
DIB_PAL_COLORS);
+ }
+ else
+ {
+ /* Extract the bitmap bits data from RGB bitmap */
+ retvalue = GetDIBits(hDC, hBmp, 0, bm.bmHeight, pixels, &bmi,
DIB_PAL_COLORS);
+ }
- lpBltData->ddRVal = DD_OK;
- }
-
- else if (lpBltData->dwFlags & DDBLT_ROP)
- {
-
- BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
- lpBltData->rDest.top,
- lpBltData->rDest.left,
- lpBltData->rDest.right,
- lpBltData->rDest.bottom,
- (HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
- lpBltData->rSrc.top,
- lpBltData->rSrc.right,
- lpBltData->bltFX.dwROP);
+ /* Check see if we susccess it to get the memory pointer and fill it for the
bitmap pixel data */
+ if (retvalue)
+ {
+ /* Check see if the are special area it should have been extracted or not
*/
+ if (!lpLockData->bHasRect)
+ {
+ /* The all bitmap pixel data must return */
+ lpLockData->lpSurfData = pixels;
+ lpLockData->ddRVal = DD_OK;
+ }
+ else
+ {
+ /* Only the lpLockData->rArea bitmap data should be return */
+ DX_STUB;
+ }
+ }
+ }
+ }
- lpBltData->ddRVal = DD_OK;
- }
+ /* Free the pixels buffer if we fail */
+ if ( (pixels != NULL) &&
+ (lpLockData->ddRVal != DD_OK) )
+ {
+ HeapFree(GetProcessHeap(), 0, pixels );
+ }
return DDHAL_DRIVER_HANDLED;
}
-DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
-{
- DX_STUB;
-}
-
-DWORD CALLBACK HelDdSurfFlip(LPDDHAL_FLIPDATA lpFlipData)
-{
- DX_STUB;
-}
-
-DWORD CALLBACK HelDdSurfGetBltStatus(LPDDHAL_GETBLTSTATUSDATA lpGetBltStatusData)
-{
- DX_STUB;
-}
-
-DWORD CALLBACK HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusData)
-{
- DX_STUB;
-}
-
-DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
-{
- DX_STUB;
-}
-
-
DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr)
{
- /*
- This api is not doucment by MS So I leave it
- as stub.
- */
-
- DX_STUB;
+/*
+This api is not doucment by MS So I leave it
+as stub.
+*/
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfSetClipList(LPDDHAL_SETCLIPLISTDATA lpSetClipListData)
{
- DX_STUB;
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKeyData)
{
- DX_STUB;
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfSetOverlayPosition(LPDDHAL_SETOVERLAYPOSITIONDATA
lpSetOverlayPositionData)
{
- DX_STUB;
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfSetPalette(LPDDHAL_SETPALETTEDATA lpSetPaletteData)
{
- DX_STUB;
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)
{
- DX_STUB;
+DX_STUB;
}
-
DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOveryLayData)
{
- DX_STUB;
+DX_STUB;
}
-
Modified: branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddra…
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1]
(original)
+++ branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1] Mon Nov
17 09:00:28 2008
@@ -403,14 +403,31 @@
HRESULT WINAPI
-Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect,
+Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT prect,
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE events)
{
DDHAL_LOCKDATA mdLock;
DX_WINDBG_trace();
- DX_WINDBG_trace_res( (DWORD)This->lpLcl->lpGbl->wWidth,
(DWORD)This->lpLcl->lpGbl->wHeight, (DWORD)This->lpLcl->lpGbl->lPitch,
(DWORD) 0);
+ DX_WINDBG_trace_res( (DWORD)ThisDest->lpLcl->lpGbl->wWidth,
(DWORD)ThisDest->lpLcl->lpGbl->wHeight,
(DWORD)ThisDest->lpLcl->lpGbl->lPitch, (DWORD) 0);
+
+
+ /* Zero out members in DDHAL_BLTDATA */
+ ZeroMemory(&mdLock, sizeof(DDHAL_LOCKDATA));
+
+ /* Check if we got HAL support for this api */
+ if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
&
+ DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
+ {
+ mdLock.Lock =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Lock;
+ }
+ /* Check if we got HEL support for this api */
+ else if ((
ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
+ DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
+ {
+ mdLock.Lock =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock;
+ }
if (events != NULL)
{
@@ -431,20 +448,18 @@
//FIXME check if it primary or not and use primary or pixelformat data, at moment it
is hardcode to primary
- mdLock.ddRVal = DDERR_NOTPALETTIZED;
- mdLock.Lock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->HALDDSurface.Lock;
+ mdLock.ddRVal = DDERR_CANTLOCKSURFACE;
mdLock.dwFlags = flags;
- mdLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
- mdLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
+ mdLock.lpDDSurface = ThisDest->lpLcl->lpSurfMore->slist[0];
+ mdLock.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
mdLock.lpSurfData = NULL;
- if (!DdResetVisrgn(This->lpLcl->lpSurfMore->slist[0], NULL))
+ if (!DdResetVisrgn(ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
{
DX_STUB_str("Here DdResetVisrgn lock");
return DDERR_UNSUPPORTED;
}
-
if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED)
{
@@ -476,11 +491,11 @@
pDDSD->lpSurface = (LPVOID) mdLock.lpSurfData;
- pDDSD->dwHeight = This->lpLcl->lpGbl->wHeight;
- pDDSD->dwWidth = This->lpLcl->lpGbl->wWidth;
-
- pDDSD->ddpfPixelFormat.dwRGBBitCount =
This->lpLcl->lpGbl->lpDD->lpModeInfo->dwBPP;// .lpModeInfo->dwBPP;
//This->lpLcl->lpGbl->lPitch/ 8;
- pDDSD->lPitch = This->lpLcl->lpGbl->lPitch;
+ pDDSD->dwHeight = ThisDest->lpLcl->lpGbl->wHeight;
+ pDDSD->dwWidth = ThisDest->lpLcl->lpGbl->wWidth;
+
+ pDDSD->ddpfPixelFormat.dwRGBBitCount =
ThisDest->lpLcl->lpGbl->lpDD->lpModeInfo->dwBPP;// .lpModeInfo->dwBPP;
//This->lpLcl->lpGbl->lPitch/ 8;
+ pDDSD->lPitch = ThisDest->lpLcl->lpGbl->lPitch;
pDDSD->dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
}