Author: greatlrd
Date: Fri Nov 21 06:42:25 2008
New Revision: 37509
URL:
http://svn.reactos.org/svn/reactos?rev=37509&view=rev
Log:
Add Threadlock for DDraw_AddRef
Add Threadlock for DDraw_Release
Add Threadlock for DDraw->Compact
BugFix : Remove wrong zeromemory in StartDirectDrawHel discovery by Pigglesworth
Cleanup : reactivate hal support in DDrawSurface->Lock and DDrawSurface->UnLock
Modified:
branches/reactx/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
branches/reactx/reactos/dll/directx/ddraw/Surface/surface_main.c
branches/reactx/reactos/dll/directx/ddraw/startup.c
Modified: branches/reactx/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddra…
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c [iso-8859-1] Fri Nov 21
06:42:25 2008
@@ -134,6 +134,19 @@
return retVal;
}
+/*++
+* @name DDraw->AddRef
+* @implemented
+*
+* The function DDraw->AddRef count of all ref counter 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)
{
@@ -141,13 +154,20 @@
DX_WINDBG_trace();
- _SEH_TRY
- {
+ /* Lock the thread so nothing can change the COM while we updating it */
+ AcquireDDThreadLock();
+
+ _SEH_TRY
+ {
+ /* Count up the internal ref counter */
This->dwIntRefCnt++;
+
+ /* Count up the internal local ref counter */
This->lpLcl->dwLocalRefCnt++;
if (This->lpLcl->lpGbl != NULL)
{
+ /* Count up the internal gobal ref counter */
This->lpLcl->lpGbl->dwRefCnt++;
}
}
@@ -166,6 +186,10 @@
}
_SEH_END;
+ /* Release the thread lock */
+ ReleaseDDThreadLock();
+
+ /* Return the local Ref counter */
return retValue;
}
@@ -178,6 +202,10 @@
ULONG Counter = 0;
DX_WINDBG_trace();
+
+ /* Lock the thread so nothing can change the COM while we updating it */
+ AcquireDDThreadLock();
+
_SEH_TRY
{
if (This!=NULL)
@@ -213,30 +241,48 @@
{
}
_SEH_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
+*
+* The function DDraw->Compact only return two diffent return value, they are DD_OK and
DERR_NOEXCLUSIVEMODE
+* if we are in Exclusive mode we return DERR_NOEXCLUSIVEMODE, other wise we return DD_OK
+
+* @return
+* Returns only Error code DD_OK or DERR_NOEXCLUSIVEMODE
+*
+* @remarks.
+* Microsoft say Compact is not implement in ddraw.dll, but Compact return
DDERR_NOEXCLUSIVEMODE or DD_OK
+*
+*--*/
HRESULT WINAPI
Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This)
{
HRESULT retVal = DD_OK;
DX_WINDBG_trace();
- // EnterCriticalSection(&ddcs);
-
- _SEH_TRY
- {
+
+ /* Lock the thread so nothing can change the COM while we updating it */
+ AcquireDDThreadLock();
+
+ _SEH_TRY
+ {
+ /* Check see if Exclusive mode have been activate */
if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
{
retVal = DDERR_NOEXCLUSIVEMODE;
@@ -246,7 +292,10 @@
{
}
_SEH_END;
- // LeaveCriticalSection(&ddcs);
+
+ /* Release the thread lock */
+ ReleaseDDThreadLock();
+
return retVal;
}
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] Fri Nov
21 06:42:25 2008
@@ -415,12 +415,6 @@
/* Zero out members in DDHAL_LOCKDATA */
ZeroMemory(&mdLock, sizeof(DDHAL_LOCKDATA));
- if ( (ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
&
- DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
- {
- ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
-=DDHAL_SURFCB32_UNLOCK;
- ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
-=DDHAL_SURFCB32_LOCK;
- }
/* Check if we got HAL support for this api */
if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
&
DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
@@ -524,12 +518,6 @@
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)
- {
- This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
-=DDHAL_SURFCB32_UNLOCK;
- This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags
-=DDHAL_SURFCB32_LOCK;
- }
if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
{
Modified: branches/reactx/reactos/dll/directx/ddraw/startup.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactx/reactos/dll/directx/ddra…
==============================================================================
--- branches/reactx/reactos/dll/directx/ddraw/startup.c [iso-8859-1] (original)
+++ branches/reactx/reactos/dll/directx/ddraw/startup.c [iso-8859-1] Fri Nov 21 06:42:25
2008
@@ -301,7 +301,7 @@
hel_ret = StartDirectDrawHel(iface, reenable);
break;
}
-DX_STUB_str("here\n");
+
if (hal_ret!=DD_OK)
{
if (hel_ret!=DD_OK)
@@ -367,10 +367,6 @@
return DD_FALSE;
}
}
- }
- else
- {
- RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS));
}
ddgbl.lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface;