////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateDxFont
//
// TODO: Make underlying data for fonts shared
//
////////////////////////////////////////////////////////////////
CDxFontItem* CRenderItemManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality )
{
    if ( !CanCreateRenderItem ( CDxFontItem::GetClassId () ) )
        return NULL;

    CDxFontItem* pDxFontItem = new CDxFontItem ();
    pDxFontItem->PostConstruct ( this, strFullFilePath, uiSize, bBold, ulQuality );

    if ( !pDxFontItem->IsValid () )
    {
        SAFE_RELEASE ( pDxFontItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pDxFontItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateGuiFont
//
// TODO: Make underlying data for fonts shared
//
////////////////////////////////////////////////////////////////
CGuiFontItem* CRenderItemManager::CreateGuiFont ( const SString& strFullFilePath, const SString& strFontName, uint uiSize )
{
    if ( !CanCreateRenderItem ( CGuiFontItem::GetClassId () ) )
        return NULL;

    CGuiFontItem* pGuiFontItem = new CGuiFontItem ();
    pGuiFontItem->PostConstruct ( this, strFullFilePath, strFontName, uiSize );

    if ( !pGuiFontItem->IsValid () )
    {
        SAFE_RELEASE ( pGuiFontItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pGuiFontItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateShader
//
// Create a D3DX effect from .fx file
//
////////////////////////////////////////////////////////////////
CShaderItem* CRenderItemManager::CreateShader ( const SString& strFullFilePath, const SString& strRootPath, SString& strOutStatus, float fPriority, float fMaxDistance, bool bLayered, bool bDebug, int iTypeMask )
{
    if ( !CanCreateRenderItem ( CShaderItem::GetClassId () ) )
        return NULL;

    strOutStatus = "";

    CShaderItem* pShaderItem = new CShaderItem ();
    pShaderItem->PostConstruct ( this, strFullFilePath, strRootPath, strOutStatus, fPriority, fMaxDistance, bLayered, bDebug, iTypeMask );

    if ( !pShaderItem->IsValid () )
    {
        SAFE_RELEASE ( pShaderItem );
        return NULL;
    }

    return pShaderItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateWebBrowser
//
//
//
////////////////////////////////////////////////////////////////
CWebBrowserItem* CRenderItemManager::CreateWebBrowser ( uint uiSizeX, uint uiSizeY )
{
    if ( !CanCreateRenderItem ( CWebBrowserItem::GetClassId () ) )
        return NULL;

    CWebBrowserItem* pWebBrowserItem = new CWebBrowserItem;
    pWebBrowserItem->PostConstruct ( this, uiSizeX, uiSizeY );

    if ( !pWebBrowserItem->IsValid () )
    {
        SAFE_RELEASE ( pWebBrowserItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pWebBrowserItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateScreenSource
//
//
//
////////////////////////////////////////////////////////////////
CScreenSourceItem* CRenderItemManager::CreateScreenSource ( uint uiSizeX, uint uiSizeY )
{
    if ( !CanCreateRenderItem ( CScreenSourceItem::GetClassId () ) )
        return NULL;

    CScreenSourceItem* pScreenSourceItem = new CScreenSourceItem ();
    pScreenSourceItem->PostConstruct ( this, uiSizeX, uiSizeY );

    if ( !pScreenSourceItem->IsValid () )
    {
        SAFE_RELEASE ( pScreenSourceItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pScreenSourceItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateRenderTarget
//
//
//
////////////////////////////////////////////////////////////////
CRenderTargetItem* CRenderItemManager::CreateRenderTarget ( uint uiSizeX, uint uiSizeY, bool bWithAlphaChannel, bool bForce )
{
    if ( !bForce && !CanCreateRenderItem ( CRenderTargetItem::GetClassId () ) )
        return NULL;

    CRenderTargetItem* pRenderTargetItem = new CRenderTargetItem ();
    pRenderTargetItem->PostConstruct ( this, uiSizeX, uiSizeY, bWithAlphaChannel );

    if ( !pRenderTargetItem->IsValid () )
    {
        SAFE_RELEASE ( pRenderTargetItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pRenderTargetItem;
}
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::CreateRenderTarget
//
//
//
////////////////////////////////////////////////////////////////
CRenderTargetItem* CRenderItemManager::CreateRenderTarget ( uint uiSizeX, uint uiSizeY, bool bWithAlphaChannel, bool bForce )
{
    if ( !bForce && !CanCreateRenderItem ( CRenderTargetItem::GetClassId () ) )
        return NULL;

    // Include in memory stats only if render target is not for MTA internal use
    bool bIncludeInMemoryStats = (bForce == false);

    CRenderTargetItem* pRenderTargetItem = new CRenderTargetItem ();
    pRenderTargetItem->PostConstruct ( this, uiSizeX, uiSizeY, bWithAlphaChannel, bIncludeInMemoryStats );

    if ( !pRenderTargetItem->IsValid () )
    {
        SAFE_RELEASE ( pRenderTargetItem );
        return NULL;
    }

    UpdateMemoryUsage ();

    return pRenderTargetItem;
}