| 1 |
/* |
| 2 |
* Copyright (C) 2023 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "SpecialImageLoaderFactory.h" |
| 10 |
|
| 11 |
#include "guilib/Texture.h" |
| 12 |
#include "music/MusicEmbeddedImageFileLoader.h" |
| 13 |
#include "pictures/PictureFolderImageFileLoader.h" |
| 14 |
#include "pvr/PVRChannelGroupImageFileLoader.h" |
| 15 |
#include "video/VideoChapterImageFileLoader.h" |
| 16 |
#include "video/VideoEmbeddedImageFileLoader.h" |
| 17 |
#include "video/VideoGeneratedImageFileLoader.h" |
| 18 |
|
| 19 |
using namespace IMAGE_FILES; |
| 20 |
|
| 21 |
CSpecialImageLoaderFactory::CSpecialImageLoaderFactory() |
| 22 |
{ |
| 23 |
m_specialImageLoaders[0] = std::make_unique<VIDEO::CVideoEmbeddedImageFileLoader>(); |
| 24 |
m_specialImageLoaders[1] = std::make_unique<MUSIC_INFO::CMusicEmbeddedImageFileLoader>(); |
| 25 |
m_specialImageLoaders[2] = std::make_unique<VIDEO::CVideoGeneratedImageFileLoader>(); |
| 26 |
m_specialImageLoaders[3] = std::make_unique<CPictureFolderImageFileLoader>(); |
| 27 |
m_specialImageLoaders[4] = std::make_unique<VIDEO::CVideoChapterImageFileLoader>(); |
| 28 |
m_specialImageLoaders[5] = std::make_unique<PVR::CPVRChannelGroupImageFileLoader>(); |
| 29 |
} |
| 30 |
|
| 31 |
std::unique_ptr<CTexture> CSpecialImageLoaderFactory::Load(const std::string& specialType, |
| 32 |
const std::string& filePath, |
| 33 |
unsigned int preferredWidth, |
| 34 |
unsigned int preferredHeight) const |
| 35 |
{ |
| 36 |
if (specialType.empty()) |
| 37 |
return {}; |
| 38 |
for (auto& loader : m_specialImageLoaders) |
| 39 |
{ |
| 40 |
if (loader->CanLoad(specialType)) |
| 41 |
{ |
| 42 |
auto val = loader->Load(specialType, filePath, preferredWidth, preferredHeight); |
| 43 |
if (val) |
| 44 |
return val; |
| 45 |
} |
| 46 |
} |
| 47 |
return {}; |
| 48 |
} |