[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / pvr / PVRThumbLoader.cpp
blob8f41a80b0c3fe2fccd9bd831c70d971739b45743
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "PVRThumbLoader.h"
11 #include "FileItem.h"
12 #include "FileItemList.h"
13 #include "ServiceBroker.h"
14 #include "TextureCache.h"
15 #include "pvr/PVRManager.h"
16 #include "pvr/filesystem/PVRGUIDirectory.h"
17 #include "settings/AdvancedSettings.h"
18 #include "settings/Settings.h"
19 #include "settings/SettingsComponent.h"
20 #include "utils/StringUtils.h"
21 #include "utils/log.h"
23 #include <ctime>
25 using namespace PVR;
27 bool CPVRThumbLoader::LoadItem(CFileItem* item)
29 bool result = LoadItemCached(item);
30 result |= LoadItemLookup(item);
31 return result;
34 bool CPVRThumbLoader::LoadItemCached(CFileItem* item)
36 return FillThumb(*item);
39 bool CPVRThumbLoader::LoadItemLookup(CFileItem* item)
41 return false;
44 void CPVRThumbLoader::OnLoaderFinish()
46 if (m_bInvalidated)
48 m_bInvalidated = false;
49 CServiceBroker::GetPVRManager().PublishEvent(PVREvent::ChannelGroupsInvalidated);
51 CThumbLoader::OnLoaderFinish();
54 void CPVRThumbLoader::ClearCachedImage(CFileItem& item)
56 const std::string thumb = item.GetArt("thumb");
57 if (!thumb.empty())
59 CServiceBroker::GetTextureCache()->ClearCachedImage(thumb);
60 if (m_textureDatabase->Open())
62 m_textureDatabase->ClearTextureForPath(item.GetPath(), "thumb");
63 m_textureDatabase->Close();
65 item.SetArt("thumb", "");
66 m_bInvalidated = true;
70 void CPVRThumbLoader::ClearCachedImages(const CFileItemList& items)
72 for (auto& item : items)
73 ClearCachedImage(*item);
76 bool CPVRThumbLoader::FillThumb(CFileItem& item)
78 // see whether we have a cached image for this item
79 std::string thumb = GetCachedImage(item, "thumb");
80 if (thumb.empty())
82 if (item.IsPVRChannelGroup())
83 thumb = CreateChannelGroupThumb(item);
84 else
85 CLog::LogF(LOGERROR, "Unsupported PVR item '{}'", item.GetPath());
87 if (!thumb.empty())
89 SetCachedImage(item, "thumb", thumb);
90 m_bInvalidated = true;
94 if (thumb.empty())
95 return false;
97 item.SetArt("thumb", thumb);
98 return true;
101 std::string CPVRThumbLoader::CreateChannelGroupThumb(const CFileItem& channelGroupItem)
103 return StringUtils::Format("{}?ts={}", // append timestamp to Thumb URL to enforce texture refresh
104 CTextureUtils::GetWrappedImageURL(channelGroupItem.GetPath(), "pvr"),
105 std::time(nullptr));