[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / guilib / imagefactory.cpp
blob81567825f8dfda25af706960a62e7d097890a287
1 /*
2 * Copyright (C) 2012-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 "imagefactory.h"
11 #include "ServiceBroker.h"
12 #include "addons/ExtsMimeSupportList.h"
13 #include "addons/ImageDecoder.h"
14 #include "addons/addoninfo/AddonType.h"
15 #include "guilib/FFmpegImage.h"
16 #include "utils/Mime.h"
18 #include <mutex>
20 CCriticalSection ImageFactory::m_createSec;
22 using namespace KODI::ADDONS;
24 IImage* ImageFactory::CreateLoader(const std::string& strFileName)
26 CURL url(strFileName);
27 return CreateLoader(url);
30 IImage* ImageFactory::CreateLoader(const CURL& url)
32 if(!url.GetFileType().empty())
33 return CreateLoaderFromMimeType("image/"+url.GetFileType());
35 return CreateLoaderFromMimeType(CMime::GetMimeType(url));
38 IImage* ImageFactory::CreateLoaderFromMimeType(const std::string& strMimeType)
40 auto addonInfos = CServiceBroker::GetExtsMimeSupportList().GetMimetypeSupportedAddonInfos(
41 strMimeType, CExtsMimeSupportList::FilterSelect::all);
42 for (const auto& addonInfo : addonInfos)
44 // Check asked and given mime type is supported by only for here allowed imagedecoder addons.
45 if (addonInfo.first != ADDON::AddonType::IMAGEDECODER)
46 continue;
48 std::unique_lock<CCriticalSection> lock(m_createSec);
49 std::unique_ptr<CImageDecoder> result =
50 std::make_unique<CImageDecoder>(addonInfo.second, strMimeType);
51 if (!result->IsCreated())
53 continue;
55 return result.release();
58 return new CFFmpegImage(strMimeType);