Author: khornicek
Date: Sat Oct 24 16:09:48 2009
New Revision: 43715
URL:
http://svn.reactos.org/svn/reactos?rev=43715&view=rev
Log:
- merge some of the more meaningful stuff from the reactx branch
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
trunk/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
trunk/reactos/dll/directx/ddraw/Surface/createsurface.c
trunk/reactos/dll/directx/ddraw/Surface/surface_main.c
trunk/reactos/dll/directx/ddraw/rosdraw.h
trunk/reactos/dll/directx/ddraw/startup.c
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 [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c [iso-8859-1] Sat Oct 24 16:09:48
2009
@@ -129,6 +129,19 @@
return retVal;
}
+/*++
+* @name DDraw->AddRef
+* @implemented
+*
+* The function DDraw->AddRef manages all ref counters in the COM object DDraw->
+
+* @return
+* Returns the local Ref counter value for the COM object
+*
+* @remarks.
+* none
+*
+*--*/
ULONG WINAPI
Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
{
@@ -136,13 +149,20 @@
DX_WINDBG_trace();
- _SEH2_TRY
- {
+ /* Lock the thread */
+ AcquireDDThreadLock();
+
+ _SEH2_TRY
+ {
+ /* Increment the internal ref counter */
This->dwIntRefCnt++;
+
+ /* Increment the local internal ref counter */
This->lpLcl->dwLocalRefCnt++;
if (This->lpLcl->lpGbl != NULL)
{
+ /* Increment the gobal internal ref counter */
This->lpLcl->lpGbl->dwRefCnt++;
}
}
@@ -161,6 +181,10 @@
}
_SEH2_END;
+ /* Release the thread lock */
+ ReleaseDDThreadLock();
+
+ /* Return the local Ref counter */
return retValue;
}
@@ -173,6 +197,10 @@
ULONG Counter = 0;
DX_WINDBG_trace();
+
+ /* Lock the thread */
+ AcquireDDThreadLock();
+
_SEH2_TRY
{
if (This!=NULL)
@@ -208,30 +236,47 @@
{
}
_SEH2_END;
+
+ /* Release the thread lock */
+ ReleaseDDThreadLock();
+
return Counter;
}
+
HRESULT WINAPI
Main_DirectDraw_Initialize (LPDDRAWI_DIRECTDRAW_INT This, LPGUID lpGUID)
{
return DDERR_ALREADYINITIALIZED;
}
-/*
- * Main_DirectDraw_Compact
- * ms say this one is not implement but it return DDERR_NOEXCLUSIVEMODE
- * when no exclusive owner are set in corpativelevel
- */
+
+/*++
+* @name DDraw->Compact
+* @implemented
+*
+* In exlusive mode the function DDraw->Compact returns DERR_NOEXCLUSIVEMODE, otherwise
it returns DD_OK
+*
+* @return
+* Returns only error code DD_OK or DERR_NOEXCLUSIVEMODE
+*
+* @remarks.
+* Microsoft says Compact is not implemented in ddraw.dll, but it returns
DDERR_NOEXCLUSIVEMODE or DD_OK
+*
+*--*/
HRESULT WINAPI
Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This)
{
HRESULT retVal = DD_OK;
DX_WINDBG_trace();
- // EnterCriticalSection(&ddcs);
-
- _SEH2_TRY
- {
+
+ /* Lock the thread */
+ AcquireDDThreadLock();
+
+ _SEH2_TRY
+ {
+ /* Check if Exclusive mode has been activated */
if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
{
retVal = DDERR_NOEXCLUSIVEMODE;
@@ -241,7 +286,10 @@
{
}
_SEH2_END;
- // LeaveCriticalSection(&ddcs);
+
+ /* Release the thread lock */
+ ReleaseDDThreadLock();
+
return retVal;
}
Modified: trunk/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Surface/…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/Surface/callbacks_surf_hel.c [iso-8859-1] Sat Oct 24
16:09:48 2009
@@ -17,7 +17,31 @@
DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
{
- DX_STUB;
+ DX_WINDBG_trace();
+
+ 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;
+ }
+ 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);
+ lpBltData->ddRVal = DD_OK;
+ }
+ return DDHAL_DRIVER_HANDLED;
}
DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
@@ -42,17 +66,105 @@
DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
{
- DX_STUB;
-}
-
+
+ HDC hDC;
+ HBITMAP hImage = NULL;
+
+ LONG cbBuffer = 0;
+ LPDWORD pixels = NULL;
+
+ HDC hMemDC = NULL;
+ HBITMAP hDCBmp = NULL;
+ BITMAP bm = {0};
+
+ DX_WINDBG_trace();
+
+ /* ToDo tell ddraw internal this surface is locked */
+ /* ToDo add support for dwFlags */
+
+
+ /* Get our hdc for the active window */
+ hDC = GetDC(lpLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
+
+ if (hDC != NULL)
+ {
+ /* Create a memory bitmap to store a copy of current hdc surface */
+
+ if (!lpLockData->bHasRect)
+ {
+ hImage = CreateCompatibleBitmap (hDC,
lpLockData->lpDDSurface->lpGbl->wWidth,
lpLockData->lpDDSurface->lpGbl->wHeight);
+ }
+ else
+ {
+ hImage = CreateCompatibleBitmap (hDC, lpLockData->rArea.right,
lpLockData->rArea.bottom);
+ }
+
+ /* Create a memory hdc so we can draw on our current memory bitmap */
+ hMemDC = CreateCompatibleDC(hDC);
+
+ if (hMemDC != NULL)
+ {
+ /* Select our memory bitmap to our memory hdc */
+ hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
+
+ /* Get our memory bitmap information */
+ GetObject(hImage, sizeof(BITMAP), &bm);
+
+ if (!lpLockData->bHasRect)
+ {
+ BitBlt (hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY);
+ }
+ else
+ {
+ BitBlt (hMemDC, lpLockData->rArea.top, lpLockData->rArea.left,
lpLockData->rArea.right, lpLockData->rArea.bottom, hDC, 0, 0, SRCCOPY);
+ }
+
+ SelectObject (hMemDC, hDCBmp);
+
+ /* Allocate memory buffer for the bitmap pixel data */
+ cbBuffer = bm.bmWidthBytes * bm.bmHeight ;
+ pixels = (PDWORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbBuffer );
+
+ if (pixels != NULL)
+ {
+ /* Get the bitmap bits */
+ GetBitmapBits(hImage,cbBuffer,pixels);
+
+ /* Fixme HACK - check which member stores the HEL bitmap buffer */
+ lpLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 = pixels;
+
+ /* Setup return value */
+ lpLockData->ddRVal = DD_OK;
+ lpLockData->lpSurfData = pixels;
+ }
+ }
+ }
+
+
+ /* Free the pixels buffer if we fail */
+ if ( (pixels != NULL) &&
+ (lpLockData->ddRVal != DD_OK) )
+ {
+ HeapFree(GetProcessHeap(), 0, pixels );
+ }
+
+ /* Cleanup after us */
+ if (hImage != NULL)
+ {
+ DeleteObject (hImage);
+ }
+
+ if (hMemDC != NULL)
+ {
+ DeleteDC (hMemDC);
+ }
+
+ return DDHAL_DRIVER_HANDLED;
+}
DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr)
{
- /*
- This api is not doucment by MS So I leave it
- as stub.
- */
-
+ /* This api is not doucmented by MS, keep it stubbed */
DX_STUB;
}
@@ -78,7 +190,64 @@
DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)
{
- DX_STUB;
+ HDC hDC;
+ HBITMAP hImage = NULL;
+
+ HDC hMemDC = NULL;
+ HBITMAP hDCBmp = NULL;
+ BITMAP bm = {0};
+
+ DX_WINDBG_trace();
+
+ /* Get our hdc for the active window */
+ hDC = GetDC(lpUnLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
+
+ if (hDC != NULL)
+ {
+ /* Create a memory bitmap to store a copy of current hdc surface */
+
+ /* fixme the rcarea are not store in the struct yet so the data will look
corupted */
+ hImage = CreateCompatibleBitmap (hDC,
lpUnLockData->lpDDSurface->lpGbl->wWidth,
lpUnLockData->lpDDSurface->lpGbl->wHeight);
+
+ /* Create a memory hdc so we can draw on our current memory bitmap */
+ hMemDC = CreateCompatibleDC(hDC);
+
+ if (hMemDC != NULL)
+ {
+ /* Select our memory bitmap to our memory hdc */
+ hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
+
+ /* Get our memory bitmap information */
+ GetObject(hImage, sizeof(BITMAP), &bm);
+
+ SetBitmapBits(hImage,bm.bmWidthBytes * bm.bmHeight,
lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2);
+
+ BitBlt (hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+
+ SelectObject (hMemDC, hDCBmp);
+
+ /* Setup return value */
+ lpUnLockData->ddRVal = DD_OK;
+ }
+ }
+
+ /* Cleanup after us */
+ if (hImage != NULL)
+ {
+ DeleteObject (hImage);
+ }
+
+ if (hMemDC != NULL)
+ {
+ DeleteDC (hMemDC);
+ }
+
+ if (lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 != NULL)
+ {
+ HeapFree(GetProcessHeap(), 0,
lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 );
+ }
+
+ return DDHAL_DRIVER_HANDLED;
}
DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOveryLayData)
Modified: trunk/reactos/dll/directx/ddraw/Surface/createsurface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Surface/…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Surface/createsurface.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/Surface/createsurface.c [iso-8859-1] Sat Oct 24
16:09:48 2009
@@ -35,7 +35,7 @@
DWORD count;
HRESULT ret;
- if(pDDraw->lpLcl->dwLocalFlags != DDRAWILCL_SETCOOPCALLED)
+ if((pDDraw->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED) !=
DDRAWILCL_SETCOOPCALLED)
{
return DDERR_NOCOOPERATIVELEVELSET;
}
@@ -45,7 +45,7 @@
return CLASS_E_NOAGGREGATION;
}
- if(!pDDSD->dwFlags & DDSD_CAPS)
+ if(!(pDDSD->dwFlags & DDSD_CAPS))
{
return DDERR_INVALIDPARAMS;
}
@@ -60,14 +60,14 @@
return DDERR_INVALIDCAPS;
}
- if(!(pDDSD->dwFlags & DDSD_HEIGHT) && !(pDDSD->dwFlags &
DDSD_HEIGHT)
- && !(pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
+ if((!(pDDSD->dwFlags & DDSD_HEIGHT) || !(pDDSD->dwFlags & DDSD_WIDTH))
+ && !(pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
{
return DDERR_INVALIDPARAMS;
}
- else if(pDDSD->dwFlags & DDSD_HEIGHT && pDDSD->dwFlags &
DDSD_HEIGHT
- && pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+ else if(((pDDSD->dwFlags & DDSD_HEIGHT) || (pDDSD->dwFlags &
DDSD_WIDTH))
+ && (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
{
return DDERR_INVALIDPARAMS;
}
Modified: trunk/reactos/dll/directx/ddraw/Surface/surface_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Surface/…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/Surface/surface_main.c [iso-8859-1] Sat Oct 24
16:09:48 2009
@@ -272,129 +272,166 @@
return This->dwIntRefCnt;
}
+
HRESULT WINAPI Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT rdst,
- LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
-{
-
- DDHAL_BLTDATA mDdBlt;
-
- DX_WINDBG_trace();
-
- if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
- & DDHAL_SURFCB32_BLT) != DDHAL_SURFCB32_BLT)
- {
- return DDERR_GENERIC;
- }
-
- ZeroMemory(&mDdBlt, sizeof(DDHAL_BLTDATA));
- ZeroMemory(&mDdBlt.bltFX, sizeof(DDBLTFX));
-
- if (!DdResetVisrgn( ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
- {
- DX_STUB_str("DdResetVisrgn failed");
+ LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc,
DWORD dwFlags, LPDDBLTFX lpbltfx)
+{
+ DDHAL_BLTDATA mDdBlt;
+
+ DX_WINDBG_trace();
+
+ if (ThisDest == NULL)
+ {
+ return DDERR_INVALIDPARAMS;
+ }
+
+ /* Zero out members in DDHAL_BLTDATA */
+ ZeroMemory(&mDdBlt, sizeof(DDHAL_BLTDATA));
+ ZeroMemory(&mDdBlt.bltFX, sizeof(DDBLTFX));
+
+ /* Check if we got HAL support for this api */
+ if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
&
+ DDHAL_SURFCB32_BLT) == DDHAL_SURFCB32_BLT)
+ {
+ mDdBlt.Blt =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Blt;
+ }
+ /* Check if we got HEL support for this api */
+ else if ((
ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
+ DDHAL_SURFCB32_BLT) == DDHAL_SURFCB32_BLT)
+ {
+ mDdBlt.Blt =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt;
+ }
+
+ if (mDdBlt.Blt == NULL)
+ {
+ /* This API is unsupported */
+ return DDERR_UNSUPPORTED;
+ }
+
+ /* Prepare for draw, if we do not reset the DdResetVisrgn some graphics card will not
draw on the screen */
+ if (!DdResetVisrgn( ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
+ {
+ DX_STUB_str("DdResetVisrgn failed");
+ }
+
+ mDdBlt.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
+ mDdBlt.lpDDDestSurface = ThisDest->lpLcl->lpSurfMore->slist[0];
+ ThisDest->lpLcl->lpSurfMore->slist[0]->hDC =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hDC;
+
+ /* Setup Src */
+ if (( ThisSrc != NULL ) )
+ {
+
+ mDdBlt.lpDDSrcSurface = ThisSrc->lpLcl->lpSurfMore->slist[0];
+ ThisSrc->lpLcl->lpSurfMore->slist[0]->hDC =
ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hDC;
+
+ if (rsrc != NULL)
+ {
+ memmove(&mDdBlt.rSrc, rsrc, sizeof (RECTL));
+ }
+ else
+ {
+
if(!GetWindowRect((HWND)ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
+ (RECT *)&mDdBlt.rSrc))
+ {
+ DX_STUB_str("GetWindowRect failed");
+ }
+ }
+
+ /* FIXME
+ * compare so we do not write too far
+ * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
+ * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
+ * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
+ */
+
+ }
+
+ /* Setup dest */
+ if (rdst != NULL)
+ {
+ memmove(&mDdBlt.rDest, rdst, sizeof (RECTL));
+ }
+ else
+ {
+ if
(!GetWindowRect((HWND)ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
+ (RECT *)&mDdBlt.rDest))
+ {
+ DX_STUB_str("GetWindowRect failed");
+ }
+ }
+
+ /* FIXME
+ * compare so we do not write too far
+ * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
+ * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
+ * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
+ */
+
+
+ /* setup bltFX */
+ if (lpbltfx != NULL)
+ {
+ memmove(&mDdBlt.bltFX, lpbltfx, sizeof (DDBLTFX));
+ }
+
+ /* setup value that are not config yet */
+ mDdBlt.dwFlags = dwFlags;
+ mDdBlt.IsClipped = FALSE;
+ mDdBlt.bltFX.dwSize = sizeof(DDBLTFX);
+
+
+ /* FIXME
+ BltData.dwRectCnt
+ BltData.dwROPFlags
+ BltData.IsClipped
+ BltData.prDestRects
+ BltData.rOrigDest
+ BltData.rOrigSrc
+ BltData.ddRVal
+ */
+
+ if (mDdBlt.Blt(&mDdBlt) != DDHAL_DRIVER_HANDLED)
+ {
+ DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
+ return DDERR_NOBLTHW;
}
- mDdBlt.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
- mDdBlt.Blt =
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Blt;
- mDdBlt.lpDDDestSurface = ThisDest->lpLcl->lpSurfMore->slist[0];
-
- ThisDest->lpLcl->lpSurfMore->slist[0]->hDC =
- ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hDC;
-
- /* Setup Src */
- if (ThisSrc != NULL)
- {
- mDdBlt.lpDDSrcSurface = ThisSrc->lpLcl->lpSurfMore->slist[0];
-
- ThisSrc->lpLcl->lpSurfMore->slist[0]->hDC =
- ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hDC;
-
- if (rsrc != NULL)
- {
- memmove(&mDdBlt.rSrc, rsrc, sizeof (RECTL));
- }
- else
- {
- if(!GetWindowRect((HWND)ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
- (RECT *)&mDdBlt.rSrc))
- {
- DX_STUB_str("GetWindowRect failed");
- }
- }
-
- /* FIXME
- * compare so we do not write to far
- * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
- * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
- * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
- */
-
- }
-
- /* Setup dest */
- if (rdst != NULL)
- {
- memmove(&mDdBlt.rDest, rdst, sizeof (RECTL));
- }
- else
- {
- if(!GetWindowRect((HWND)ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
- (RECT *)&mDdBlt.rDest))
- {
- DX_STUB_str("GetWindowRect failed");
- }
-
- }
-
- /* FIXME
- * compare so we do not write to far
- * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
- * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
- * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
- */
-
-
- /* setup bltFX */
- if (lpbltfx != NULL)
- {
- memmove(&mDdBlt.bltFX, lpbltfx, sizeof (DDBLTFX));
- }
-
- /* setup value that are not config yet */
- mDdBlt.dwFlags = dwFlags;
- mDdBlt.IsClipped = FALSE;
- mDdBlt.bltFX.dwSize = sizeof(DDBLTFX);
-
-
- /* FIXME
- BltData.dwRectCnt
- BltData.dwROPFlags
- BltData.IsClipped
- BltData.prDestRects
- BltData.rOrigDest
- BltData.rOrigSrc
- BltData.ddRVal
- */
-
- if (mDdBlt.Blt(&mDdBlt) != DDHAL_DRIVER_HANDLED)
- {
- DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
- return DDERR_NOBLTHW;
- }
-
- return mDdBlt.ddRVal;
-}
-
-
-HRESULT WINAPI
-Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect,
+ return mDdBlt.ddRVal;
+}
+
+
+HRESULT WINAPI
+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_LOCKDATA */
+ 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 (mdLock.Lock == NULL)
+ {
+ /* This api are unsupported */
+ return DDERR_UNSUPPORTED;
+ }
if (events != NULL)
{
@@ -415,20 +452,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;
- }
-
+ // return DDERR_UNSUPPORTED;
+ }
if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED)
{
@@ -460,11 +495,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;
}
@@ -474,30 +509,45 @@
HRESULT WINAPI Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT pRect)
{
- DDHAL_UNLOCKDATA mdUnLock;
-
- DX_WINDBG_trace();
-
- if
(!(This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags
& DDHAL_SURFCB32_UNLOCK))
- {
- DX_STUB_str("DDERR_UNSUPPORTED");
- return DDERR_UNSUPPORTED;
- }
+ DDHAL_UNLOCKDATA mdUnLock;
+
+ DX_WINDBG_trace();
+
+ /* Zero out members in DDHAL_UNLOCKDATA */
+ ZeroMemory(&mdUnLock, sizeof(DDHAL_UNLOCKDATA));
+
+ /* Check if we got HAL support for this api */
+ if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
+ DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
+ {
+ mdUnLock.Unlock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Unlock;
+ }
+ /* Check if we got HEL support for this api */
+ else if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags
&
+ DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
+ {
+ mdUnLock.Unlock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock;
+ }
+
+ if (mdUnLock.Unlock == NULL)
+ {
+ /* This api are unsupported */
+ return DDERR_UNSUPPORTED;
+ }
mdUnLock.ddRVal = DDERR_NOTPALETTIZED;
mdUnLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
- mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
- mdUnLock.Unlock =
This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->HALDDSurface.Unlock;
+ mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
if (!DdResetVisrgn( mdUnLock.lpDDSurface, NULL))
{
- DX_STUB_str("DDERR_UNSUPPORTED");
- return DDERR_UNSUPPORTED;
+ DX_STUB_str("DdResetVisrgn fail");
+ //return DDERR_UNSUPPORTED; /* this can fail */
}
if (mdUnLock.Unlock(&mdUnLock)!= DDHAL_DRIVER_HANDLED)
{
- DX_STUB_str("unLock fail");
+ DX_STUB_str("unLock fail");
return DDERR_UNSUPPORTED;
}
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 [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/rosdraw.h [iso-8859-1] Sat Oct 24 16:09:48 2009
@@ -8,6 +8,7 @@
#include <ddrawi.h>
#include <d3dhal.h>
#include <ddrawgdi.h>
+#include <pseh/pseh.h>
#include <pseh/pseh2.h>
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/dll/directx/ddraw/startup.c [iso-8859-1] Sat Oct 24 16:09:48 2009
@@ -33,8 +33,8 @@
This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
- /* fixme linking too second link when we shall not doing it */
- if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW)))
+ if ( (IsBadWritePtr(This,sizeof(LPDDRAWI_DIRECTDRAW_INT)) != 0) ||
+ (IsBadWritePtr(This->lpLcl,sizeof(LPDDRAWI_DIRECTDRAW_LCL)) != 0) )
{
/* We do not have a DirectDraw interface, we need alloc it*/
LPDDRAWI_DIRECTDRAW_INT memThis;
@@ -190,9 +190,6 @@
ddgbl.lpDriverHandle = &ddgbl;
ddgbl.hDDVxd = -1;
-
-
-
if (reenable == FALSE)
{
if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) &&
(This->lpLink == NULL))
@@ -236,8 +233,6 @@
RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
-
-
}
else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
{
@@ -289,7 +284,6 @@
/* Startup HEL and HAL */
This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
This->lpLcl->dwProcessId = GetCurrentProcessId();
-
switch (devicetypes)
{
case 2:
@@ -305,6 +299,7 @@
default:
hal_ret = StartDirectDrawHal(iface, reenable);
hel_ret = StartDirectDrawHel(iface, reenable);
+ break;
}
if (hal_ret!=DD_OK)
@@ -362,18 +357,30 @@
{
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface =
HelDdCanCreateSurface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface =
HelDdCreateSurface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette =
HelDdCreatePalette;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver =
HelDdDestroyDriver;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface =
HelDdFlipToGDISurface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.GetScanLine =
HelDdGetScanLine;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetColorKey =
HelDdSetColorKey;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetExclusiveMode =
HelDdSetExclusiveMode;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetMode =
HelDdSetMode;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.WaitForVerticalBlank =
HelDdWaitForVerticalBlank;
-
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwFlags =
DDHAL_CB32_CANCREATESURFACE |
+ if (reenable == FALSE)
+ {
+ if (ddgbl.lpDDCBtmp == NULL)
+ {
+ DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
+ if ( ddgbl.lpDDCBtmp == NULL)
+ {
+ return DD_FALSE;
+ }
+ }
+ }
+
+ ddgbl.lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface;
+ ddgbl.lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface;
+ ddgbl.lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette;
+ ddgbl.lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver;
+ ddgbl.lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface;
+ ddgbl.lpDDCBtmp->HELDD.GetScanLine = HelDdGetScanLine;
+ ddgbl.lpDDCBtmp->HELDD.SetColorKey = HelDdSetColorKey;
+ ddgbl.lpDDCBtmp->HELDD.SetExclusiveMode = HelDdSetExclusiveMode;
+ ddgbl.lpDDCBtmp->HELDD.SetMode = HelDdSetMode;
+ ddgbl.lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;
+
+ ddgbl.lpDDCBtmp->HELDD.dwFlags = DDHAL_CB32_CANCREATESURFACE |
DDHAL_CB32_CREATESURFACE |
DDHAL_CB32_CREATEPALETTE |
DDHAL_CB32_DESTROYDRIVER |
@@ -384,23 +391,23 @@
DDHAL_CB32_SETMODE |
DDHAL_CB32_WAITFORVERTICALBLANK ;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwSize =
sizeof(This->lpLcl->lpDDCB->HELDD);
-
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.AddAttachedSurface =
HelDdSurfAddAttachedSurface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.DestroySurface =
HelDdSurfDestroySurface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetBltStatus =
HelDdSurfGetBltStatus;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetFlipStatus =
HelDdSurfGetFlipStatus;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.reserved4 =
HelDdSurfreserved4;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetClipList =
HelDdSurfSetClipList;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetColorKey =
HelDdSurfSetColorKey;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetOverlayPosition =
HelDdSurfSetOverlayPosition;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetPalette =
HelDdSurfSetPalette;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.UpdateOverlay =
HelDdSurfUpdateOverlay;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwFlags =
DDHAL_SURFCB32_ADDATTACHEDSURFACE |
+ ddgbl.lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);
+
+ ddgbl.lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
+ ddgbl.lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
+ ddgbl.lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
+ ddgbl.lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
+ ddgbl.lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
+ ddgbl.lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
+ ddgbl.lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
+ ddgbl.lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
+ ddgbl.lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
+ ddgbl.lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
+ ddgbl.lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
+ ddgbl.lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
+ ddgbl.lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
+ ddgbl.lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
+ ddgbl.lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
DDHAL_SURFCB32_BLT |
DDHAL_SURFCB32_DESTROYSURFACE |
DDHAL_SURFCB32_FLIP |
@@ -415,7 +422,7 @@
DDHAL_SURFCB32_UNLOCK |
DDHAL_SURFCB32_UPDATEOVERLAY;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize =
sizeof(This->lpLcl->lpDDCB->HELDDSurface);
+ ddgbl.lpDDCBtmp->HELDDSurface.dwSize =
sizeof(This->lpLcl->lpDDCB->HELDDSurface);
/*
This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;