Skip to content

Commit

Permalink
kill g_textureManager and g_largeTextureManager
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Apr 3, 2018
1 parent 4a687eb commit 8cb650b
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 70 deletions.
18 changes: 12 additions & 6 deletions xbmc/Application.cpp
Expand Up @@ -708,6 +708,10 @@ bool CApplication::CreateGUI()
if (sav_res)
CDisplaySettings::GetInstance().SetCurrentResolution(RES_DESKTOP, true);

m_pGUI.reset(new CGUIComponent());
m_pGUI->Init();

// Splash requires gui component!!
CServiceBroker::GetRenderSystem().ShowSplash("");

// The key mappings may already have been loaded by a peripheral
Expand All @@ -721,8 +725,6 @@ bool CApplication::CreateGUI()
info.iHeight,
info.strMode.c_str());

m_pGUI.reset(new CGUIComponent());

return true;
}

Expand Down Expand Up @@ -1632,6 +1634,7 @@ bool CApplication::LoadSkin(const std::string& skinID)
CServiceBroker::GetGUI()->GetWindowManager().AddMsgTarget(&g_fontManager);
CServiceBroker::GetGUI()->GetWindowManager().AddMsgTarget(&CStereoscopicsManager::GetInstance());
CServiceBroker::GetGUI()->GetWindowManager().SetCallback(*this);
//@todo should be done by GUIComponents
CServiceBroker::GetGUI()->GetWindowManager().Initialize();
CTextureCache::GetInstance().Initialize();
g_audioManager.Enable(true);
Expand Down Expand Up @@ -1699,8 +1702,8 @@ void CApplication::UnloadSkin(bool forReload /* = false */)
// remove the skin-dependent window
CServiceBroker::GetGUI()->GetWindowManager().Delete(WINDOW_DIALOG_FULLSCREEN_INFO);

g_TextureManager.Cleanup();
g_largeTextureManager.CleanupUnusedImages(true);
CServiceBroker::GetGUI()->GetTextureManager().Cleanup();
CServiceBroker::GetGUI()->GetLargeTextureManager().CleanupUnusedImages(true);

g_fontManager.Clear();

Expand Down Expand Up @@ -2785,6 +2788,9 @@ bool CApplication::Cleanup()
while(1); // execution ends
#endif

m_pGUI->Deinit();
m_pGUI.reset();

// Cleanup was called more than once on exit during my tests
if (m_ServiceManager)
{
Expand Down Expand Up @@ -4358,9 +4364,9 @@ void CApplication::ProcessSlow()
// check for any idle curl connections
g_curlInterface.CheckIdle();

g_largeTextureManager.CleanupUnusedImages();
CServiceBroker::GetGUI()->GetLargeTextureManager().CleanupUnusedImages();

g_TextureManager.FreeUnusedTextures(5000);
CServiceBroker::GetGUI()->GetTextureManager().FreeUnusedTextures(5000);

#ifdef HAS_DVD_DRIVE
// checks whats in the DVD drive and tries to autostart the content (xbox games, dvd, cdda, avi files...)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/GUILargeTextureManager.cpp
Expand Up @@ -48,7 +48,7 @@ bool CImageLoader::DoWork()
bool needsChecking = false;
std::string loadPath;

std::string texturePath = g_TextureManager.GetTexturePath(m_path);
std::string texturePath = CServiceBroker::GetGUI()->GetTextureManager().GetTexturePath(m_path);
if (texturePath.empty())
return false;

Expand Down
3 changes: 0 additions & 3 deletions xbmc/GUILargeTextureManager.h
Expand Up @@ -149,6 +149,3 @@ class CGUILargeTextureManager : public IJobCallback
CCriticalSection m_listSection;
};

extern CGUILargeTextureManager g_largeTextureManager;


5 changes: 0 additions & 5 deletions xbmc/SystemGlobals.cpp
Expand Up @@ -18,8 +18,6 @@
*
*/
#include "SectionLoader.h"
#include "GUILargeTextureManager.h"
#include "guilib/TextureManager.h"
#include "utils/AlarmClock.h"
#include "GUIInfoManager.h"
#include "filesystem/DllLibCurl.h"
Expand Down Expand Up @@ -48,9 +46,6 @@ std::map<std::string, std::string> CSpecialProtocol::m_pathMap;

XFILE::CDirectoryCache g_directoryCache;

CGUITextureManager g_TextureManager;
CGUILargeTextureManager g_largeTextureManager;

CGUIPassword g_passwordManager;
CGUIInfoManager g_infoManager;

Expand Down
2 changes: 1 addition & 1 deletion xbmc/Util.cpp
Expand Up @@ -1549,7 +1549,7 @@ bool CUtil::SupportsReadFileOperations(const std::string& strPath)

std::string CUtil::GetDefaultFolderThumb(const std::string &folderThumb)
{
if (g_TextureManager.HasTexture(folderThumb))
if (CServiceBroker::GetGUI()->GetTextureManager().HasTexture(folderThumb))
return folderThumb;
return "";
}
Expand Down
8 changes: 4 additions & 4 deletions xbmc/addons/interfaces/GUI/AddonGUIWindow.cpp
Expand Up @@ -186,9 +186,9 @@ void CGUIAddonWindow::AllocResources(bool forceLoad /*= false */)
m_mediaDir = fallbackMediaPath;

//CLog::Log(LOGDEBUG, "CGUIPythonWindowXML::AllocResources called: %s", fallbackMediaPath.c_str());
g_TextureManager.AddTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().AddTexturePath(m_mediaDir);
CGUIMediaWindow::AllocResources(forceLoad);
g_TextureManager.RemoveTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().RemoveTexturePath(m_mediaDir);
}

void CGUIAddonWindow::FreeResources(bool forceUnLoad /*= false */)
Expand All @@ -198,9 +198,9 @@ void CGUIAddonWindow::FreeResources(bool forceUnLoad /*= false */)

void CGUIAddonWindow::Render()
{
g_TextureManager.AddTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().AddTexturePath(m_mediaDir);
CGUIMediaWindow::Render();
g_TextureManager.RemoveTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().RemoveTexturePath(m_mediaDir);
}

void CGUIAddonWindow::Update()
Expand Down
8 changes: 4 additions & 4 deletions xbmc/addons/interfaces/GUI/Window.cpp
Expand Up @@ -1147,16 +1147,16 @@ void CGUIAddonWindow::AllocResources(bool forceLoad /*= false */)
URIUtils::RemoveSlashAtEnd(fallbackMediaPath);
m_mediaDir = fallbackMediaPath;

g_TextureManager.AddTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().AddTexturePath(m_mediaDir);
CGUIMediaWindow::AllocResources(forceLoad);
g_TextureManager.RemoveTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().RemoveTexturePath(m_mediaDir);
}

void CGUIAddonWindow::Render()
{
g_TextureManager.AddTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().AddTexturePath(m_mediaDir);
CGUIMediaWindow::Render();
g_TextureManager.RemoveTexturePath(m_mediaDir);
CServiceBroker::GetGUI()->GetTextureManager().RemoveTexturePath(m_mediaDir);
}

void CGUIAddonWindow::AddItem(CFileItemPtr* fileItem, int itemPosition)
Expand Down
20 changes: 10 additions & 10 deletions xbmc/filesystem/AddonsDirectory.cpp
Expand Up @@ -198,7 +198,7 @@ static void GenerateTypeListing(const CURL& path, const std::set<TYPE>& types,
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(type);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -221,7 +221,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAME_CONTROLLER);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -238,7 +238,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAMEDLL);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -255,7 +255,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAMEDLL);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -272,7 +272,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAMEDLL);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -289,7 +289,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAMEDLL);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -306,7 +306,7 @@ static void GenerateGameListing(const CURL& path, const VECADDONS& addons, CFile
item->SetPath(itemPath.Get());
item->m_bIsFolder = true;
std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAMEDLL);
if (!thumb.empty() && g_TextureManager.HasTexture(thumb))
if (!thumb.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
break;
Expand All @@ -324,7 +324,7 @@ static void GenerateMainCategoryListing(const CURL& path, const VECADDONS& addon
item->SetPath(URIUtils::AddFileToFolder(path.Get(), CATEGORY_INFO_PROVIDERS));
item->m_bIsFolder = true;
const std::string thumb = "DefaultAddonInfoProvider.png";
if (g_TextureManager.HasTexture(thumb))
if (CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
}
Expand All @@ -334,7 +334,7 @@ static void GenerateMainCategoryListing(const CURL& path, const VECADDONS& addon
item->SetPath(URIUtils::AddFileToFolder(path.Get(), CATEGORY_LOOK_AND_FEEL));
item->m_bIsFolder = true;
const std::string thumb = "DefaultAddonLookAndFeel.png";
if (g_TextureManager.HasTexture(thumb))
if (CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
}
Expand All @@ -344,7 +344,7 @@ static void GenerateMainCategoryListing(const CURL& path, const VECADDONS& addon
item->SetPath(URIUtils::AddFileToFolder(path.Get(), CATEGORY_GAME_ADDONS));
item->m_bIsFolder = true;
const std::string thumb = CAddonInfo::TranslateIconType(ADDON_GAME);
if (g_TextureManager.HasTexture(thumb))
if (CServiceBroker::GetGUI()->GetTextureManager().HasTexture(thumb))
item->SetArt("thumb", thumb);
items.Add(item);
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/LibraryDirectory.cpp
Expand Up @@ -128,7 +128,7 @@ bool CLibraryDirectory::GetDirectory(const CURL& url, CFileItemList &items)
CFileItemPtr item(new CFileItem(URIUtils::AddFileToFolder(basePath, folder), true));

item->SetLabel(label);
if (!icon.empty() && g_TextureManager.HasTexture(icon))
if (!icon.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(icon))
item->SetIconImage(icon);
item->m_iprogramCount = order;
items.Add(item);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/MusicDatabaseDirectory.cpp
Expand Up @@ -55,7 +55,7 @@ bool CMusicDatabaseDirectory::GetDirectory(const CURL& url, CFileItemList &items
if (item->m_bIsFolder && !item->HasIcon() && !item->HasArt("thumb"))
{
std::string strImage = GetIcon(item->GetPath());
if (!strImage.empty() && g_TextureManager.HasTexture(strImage))
if (!strImage.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(strImage))
item->SetIconImage(strImage);
}
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/SourcesDirectory.cpp
Expand Up @@ -90,7 +90,7 @@ bool CSourcesDirectory::GetDirectory(const VECSOURCES &sources, CFileItemList &i
strIcon = "DefaultDVDFull.png";
else if (pItem->IsCDDA())
strIcon = "DefaultCDDA.png";
else if (pItem->IsRemovable() && g_TextureManager.HasTexture("DefaultRemovableDisk.png"))
else if (pItem->IsRemovable() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture("DefaultRemovableDisk.png"))
strIcon = "DefaultRemovableDisk.png";
else
strIcon = "DefaultHardDisk.png";
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/VideoDatabaseDirectory.cpp
Expand Up @@ -56,7 +56,7 @@ bool CVideoDatabaseDirectory::GetDirectory(const CURL& url, CFileItemList &items
if (item->m_bIsFolder && !item->HasIcon() && !item->HasArt("thumb"))
{
std::string strImage = GetIcon(item->GetPath());
if (!strImage.empty() && g_TextureManager.HasTexture(strImage))
if (!strImage.empty() && CServiceBroker::GetGUI()->GetTextureManager().HasTexture(strImage))
item->SetIconImage(strImage);
}
if (item->GetVideoInfoTag())
Expand Down
25 changes: 24 additions & 1 deletion xbmc/guilib/GUIComponent.cpp
Expand Up @@ -20,18 +20,31 @@

#include "GUIComponent.h"
#include "GUIWindowManager.h"
#include "TextureManager.h"
#include "dialogs/GUIDialogYesNo.h"
#include "GUILargeTextureManager.h"
#include "ServiceBroker.h"
#include "URL.h"

CGUIComponent::CGUIComponent()
{
m_pWindowManager.reset(new CGUIWindowManager());
m_pTextureManager.reset(new CGUITextureManager());
m_pLargeTextureManager.reset(new CGUILargeTextureManager());
}

CGUIComponent::~CGUIComponent()
{
Deinit();
}

void CGUIComponent::Init()
{
m_pWindowManager->Initialize();
CServiceBroker::RegisterGUI(this);
}

CGUIComponent::~CGUIComponent()
void CGUIComponent::Deinit()
{
CServiceBroker::UnregisterGUI();
m_pWindowManager->DeInitialize();
Expand All @@ -42,6 +55,16 @@ CGUIWindowManager& CGUIComponent::GetWindowManager()
return *m_pWindowManager;
}

CGUITextureManager& CGUIComponent::GetTextureManager()
{
return *m_pTextureManager;
}

CGUILargeTextureManager& CGUIComponent::GetLargeTextureManager()
{
return *m_pLargeTextureManager;
}

bool CGUIComponent::ConfirmDelete(std::string path)
{
CGUIDialogYesNo* pDialog = GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO);
Expand Down
9 changes: 9 additions & 0 deletions xbmc/guilib/GUIComponent.h
Expand Up @@ -24,17 +24,26 @@
#include <string>

class CGUIWindowManager;
class CGUITextureManager;
class CGUILargeTextureManager;

class CGUIComponent
{
public:
CGUIComponent();
virtual ~CGUIComponent();
void Init();
void Deinit();

CGUIWindowManager& GetWindowManager();
CGUITextureManager& GetTextureManager();
CGUILargeTextureManager& GetLargeTextureManager();

bool ConfirmDelete(std::string path);

protected:
// members are pointers in order to avoid includes
std::unique_ptr<CGUIWindowManager> m_pWindowManager;
std::unique_ptr<CGUITextureManager> m_pTextureManager;
std::unique_ptr<CGUILargeTextureManager> m_pLargeTextureManager;
};
4 changes: 2 additions & 2 deletions xbmc/guilib/GUIFontTTFGL.cpp
Expand Up @@ -72,7 +72,7 @@ bool CGUIFontTTFGL::FirstBegin()
if (m_textureStatus == TEXTURE_REALLOCATED)
{
if (glIsTexture(m_nTexture))
g_TextureManager.ReleaseHwTexture(m_nTexture);
CServiceBroker::GetGUI()->GetTextureManager().ReleaseHwTexture(m_nTexture);
m_textureStatus = TEXTURE_VOID;
}

Expand Down Expand Up @@ -401,7 +401,7 @@ void CGUIFontTTFGL::DeleteHardwareTexture()
if (m_textureStatus != TEXTURE_VOID)
{
if (glIsTexture(m_nTexture))
g_TextureManager.ReleaseHwTexture(m_nTexture);
CServiceBroker::GetGUI()->GetTextureManager().ReleaseHwTexture(m_nTexture);

m_textureStatus = TEXTURE_VOID;
m_updateY1 = m_updateY2 = 0;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/guilib/GUIMultiImage.cpp
Expand Up @@ -236,7 +236,7 @@ void CGUIMultiImage::LoadDirectory()
if (item.IsPicture() || CTextureCache::GetInstance().HasCachedImage(m_currentPath))
m_files.push_back(m_currentPath);
else // bundled folder?
g_TextureManager.GetBundledTexturesFromPath(m_currentPath, m_files);
CServiceBroker::GetGUI()->GetTextureManager().GetBundledTexturesFromPath(m_currentPath, m_files);
if (!m_files.empty())
{ // found - nothing more to do
OnDirectoryLoaded();
Expand Down Expand Up @@ -311,7 +311,7 @@ bool CGUIMultiImage::CMultiImageJob::DoWork()
{
// Load in images from the directory specified
// m_path is relative (as are all skin paths)
std::string realPath = g_TextureManager.GetTexturePath(m_path, true);
std::string realPath = CServiceBroker::GetGUI()->GetTextureManager().GetTexturePath(m_path, true);
if (realPath.empty())
return true;

Expand Down

0 comments on commit 8cb650b

Please sign in to comment.