Beispiel #1
0
/*****************************************************************************
 * IDirectDrawPaletteImpl::Release
 *
 * Reduces the refcount. If the refcount falls to 0, the object is destroyed
 *
 * Returns:
 *  The new refcount
 *
 *****************************************************************************/
static ULONG WINAPI
DirectDrawPalette_Release(IDirectDrawPalette *iface)
{
    LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface;
    ULONG ref = 0;

    _SEH2_TRY
    {
        ref = --This->dwIntRefCnt;
        if(ref == 0)
        {
            AcquireDDThreadLock();
            if(((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw7_Vtable
                    || ((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1)->lpVtbl == &DirectDraw4_Vtable)
                Main_DirectDraw_Release((LPDDRAWI_DIRECTDRAW_INT)This->lpLcl->dwReserved1) ;
            DxHeapMemFree(This); //HUGE FIXME!!!
            ReleaseDDThreadLock();
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
    }
    _SEH2_END

    return ref;
}
Beispiel #2
0
/*++
* @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();

    /* Lock the thread */
    AcquireDDThreadLock();

    _SEH2_TRY
    {
        /* Check if Exclusive mode has been activated */
        if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
        {
            retVal = DDERR_NOEXCLUSIVEMODE;
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
    }
    _SEH2_END;

    /* Release the thread lock */
    ReleaseDDThreadLock();

    return retVal;
}
Beispiel #3
0
ULONG WINAPI
Main_DirectDraw_Release (LPDDRAWI_DIRECTDRAW_INT This)
{
    ULONG Counter = 0;

    DX_WINDBG_trace();

    /* Lock the thread */
    AcquireDDThreadLock();

    _SEH2_TRY
    {
        if (This!=NULL)
        {
            This->lpLcl->dwLocalRefCnt--;
            This->dwIntRefCnt--;

            if (This->lpLcl->lpGbl != NULL)
            {
                This->lpLcl->lpGbl->dwRefCnt--;
            }

            if ( This->lpLcl->lpGbl->dwRefCnt == 0)
            {
                // set resoltion back to the one in registry
                /*if(This->cooperative_level & DDSCL_EXCLUSIVE)
                {
                    ChangeDisplaySettings(NULL, 0);
                }*/

                Cleanup(This);
            }

            /* FIXME cleanup being not call why ?? */
            Counter = This->dwIntRefCnt;
        }
        else
        {
            Counter = This->dwIntRefCnt;
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
    }
    _SEH2_END;

    /* Release the thread lock */
    ReleaseDDThreadLock();

    return Counter;
}
Beispiel #4
0
ULONG WINAPI Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This)
{
    /* FIXME
       This is not right exiame how it should be done
     */
    ULONG ret = --This->dwIntRefCnt;
    if(!ret)
    {
        DX_STUB_str("Release is a bit simplistic right now\n");
        AcquireDDThreadLock();
        DxHeapMemFree(This);
        ReleaseDDThreadLock();
    }
    return ret;
}
Beispiel #5
0
/*++
* @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)
{
    ULONG retValue = 0;

    DX_WINDBG_trace();

    /* 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++;
        }
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
    }
    _SEH2_END;

    _SEH2_TRY
    {
        retValue = This->dwIntRefCnt;
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        retValue = 0;
    }
    _SEH2_END;

    /* Release the thread lock */
    ReleaseDDThreadLock();

    /* Return the local Ref counter */
    return retValue;
}