ATOM-15370 Fix thumbnail scaling and sizing issues
TLDR Thumbnails size will be removed from the system. Each thumbnail class is responsible for determining its stored size. Images and other thumbnail types can be scaled up or down within reason without blurring. The thumbnail system uses the concept of context and size organize thumbnails by size based on their intended use. However, most of the thumbnail classes do not respect or use the specified size, which is 16 by 16 pixels and really only usable for small icons. The thumbnails are currently being used in the asset browser tree control, the larger asset browser previews, the material component property asset controls, the material component inspector for the large preview, and other places. Each of these places use completely different sizes, some of which are large and change dynamically. Whenever the thumbnails are painted they are scaled to the desired size. Material and mesh thumbnails were always being captured at 512x512 regardless of what the rest of the thumbnail system said. Source, product, and folder thumbnails would be stored at the original asset size. The loading movie thumbnail was always drawn at 16 by 16 and scale up so it was always blurry. Image thumbnails were always scaled down to 16 by 16 and scale up for larger previews. Rather than worrying about the size of each context, each thumbnail class will store the image at whenever it deems to be a large enough size that can be scaled down when used. This may eliminate the need for multiple thumbnail contexts which are not being used anyway. https://jira.agscollab.com/browse/ATOM-15370
This commit is contained in:
+4
-3
@@ -53,8 +53,8 @@ namespace AzToolsFramework
|
||||
static constexpr const char* FolderIconPath = "Editor/Icons/AssetBrowser/Folder_16.svg";
|
||||
static constexpr const char* GemIconPath = "Editor/Icons/AssetBrowser/GemFolder_16.svg";
|
||||
|
||||
FolderThumbnail::FolderThumbnail(SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
FolderThumbnail::FolderThumbnail(SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{}
|
||||
|
||||
void FolderThumbnail::LoadThread()
|
||||
@@ -69,7 +69,8 @@ namespace AzToolsFramework
|
||||
AZStd::string absoluteIconPath;
|
||||
AZ::StringFunc::Path::Join(engineRoot, folderIcon, absoluteIconPath);
|
||||
|
||||
m_icon = QIcon(absoluteIconPath.c_str());
|
||||
m_pixmap.load(absoluteIconPath.c_str());
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FolderThumbnail(SharedThumbnailKey key, int thumbnailSize);
|
||||
FolderThumbnail(SharedThumbnailKey key);
|
||||
void LoadThread() override;
|
||||
};
|
||||
|
||||
|
||||
+4
-8
@@ -57,8 +57,8 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const char* DEFAULT_PRODUCT_ICON_PATH = "Editor/Icons/AssetBrowser/DefaultProduct_16.svg";
|
||||
|
||||
ProductThumbnail::ProductThumbnail(Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
ProductThumbnail::ProductThumbnail(Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{}
|
||||
|
||||
void ProductThumbnail::LoadThread()
|
||||
@@ -96,12 +96,8 @@ namespace AzToolsFramework
|
||||
iconPath = QString::fromUtf8(DEFAULT_PRODUCT_ICON_PATH);
|
||||
}
|
||||
|
||||
m_icon = QIcon(iconPath);
|
||||
|
||||
if (m_icon.isNull())
|
||||
{
|
||||
m_state = State::Failed;
|
||||
}
|
||||
m_pixmap.load(iconPath);
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProductThumbnail(Thumbnailer::SharedThumbnailKey key, int thumbnailSize);
|
||||
ProductThumbnail(Thumbnailer::SharedThumbnailKey key);
|
||||
|
||||
protected:
|
||||
void LoadThread() override;
|
||||
|
||||
+4
-3
@@ -58,8 +58,8 @@ namespace AzToolsFramework
|
||||
static constexpr const char* DefaultFileIconPath = "Editor/Icons/AssetBrowser/Default_16.svg";
|
||||
QMutex SourceThumbnail::m_mutex;
|
||||
|
||||
SourceThumbnail::SourceThumbnail(SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
SourceThumbnail::SourceThumbnail(SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -124,7 +124,8 @@ namespace AzToolsFramework
|
||||
iconPathToUse = iconPath.c_str();
|
||||
}
|
||||
|
||||
m_icon = QIcon(iconPathToUse);
|
||||
m_pixmap.load(iconPathToUse);
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SourceThumbnail(SharedThumbnailKey key, int thumbnailSize);
|
||||
SourceThumbnail(SharedThumbnailKey key);
|
||||
|
||||
protected:
|
||||
void LoadThread() override;
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ namespace AzToolsFramework
|
||||
else
|
||||
{
|
||||
// Scaling and centering pixmap within bounds to preserve aspect ratio
|
||||
const QPixmap pixmap = thumbnail->GetPixmap(size).scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
const QPixmap pixmap = thumbnail->GetPixmap().scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
const QSize sizeDelta = size - pixmap.size();
|
||||
const QPoint pointDelta = QPoint(sizeDelta.width() / 2, sizeDelta.height() / 2);
|
||||
painter->drawPixmap(point + pointDelta, pixmap);
|
||||
|
||||
+1
-2
@@ -36,8 +36,7 @@ namespace AzToolsFramework
|
||||
using namespace Thumbnailer;
|
||||
using namespace AssetBrowser;
|
||||
const char* contextName = "MaterialBrowser";
|
||||
int thumbnailSize = qApp->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterContext, contextName, thumbnailSize);
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterContext, contextName);
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(FolderThumbnailCache), contextName);
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(SourceThumbnailCache), contextName);
|
||||
ThumbnailerRequestsBus::Broadcast(&ThumbnailerRequests::RegisterThumbnailProvider, MAKE_TCACHE(MaterialThumbnailCache), contextName);
|
||||
|
||||
+4
-3
@@ -24,8 +24,8 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MaterialThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MaterialThumbnail::MaterialThumbnail(Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
MaterialThumbnail::MaterialThumbnail(Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
auto productKey = azrtti_cast<const AzToolsFramework::AssetBrowser::ProductThumbnailKey*>(m_key.data());
|
||||
AZ_Assert(productKey, "Incorrect key type, excpected ProductThumbnailKey");
|
||||
@@ -34,7 +34,8 @@ namespace AzToolsFramework
|
||||
MaterialBrowserRequestBus::BroadcastResult(multiMat, &MaterialBrowserRequests::IsMultiMaterial, productKey->GetAssetId());
|
||||
|
||||
QString iconPath = multiMat ? MultiMaterialIconPath : SimpleMaterialIconPath;
|
||||
m_pixmap = QPixmap(iconPath).scaled(m_thumbnailSize, m_thumbnailSize, Qt::KeepAspectRatio);
|
||||
m_pixmap.load(iconPath);
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialThumbnail(Thumbnailer::SharedThumbnailKey key, int thumbnailSize);
|
||||
MaterialThumbnail(Thumbnailer::SharedThumbnailKey key);
|
||||
};
|
||||
|
||||
namespace
|
||||
|
||||
@@ -18,13 +18,15 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
static constexpr const int LoadingThumbnailSize = 128;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// LoadingThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static const char* LoadingIconPath = "Editor/Icons/AssetBrowser/in_progress.gif";
|
||||
|
||||
LoadingThumbnail::LoadingThumbnail(int thumbnailSize)
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey), thumbnailSize)
|
||||
LoadingThumbnail::LoadingThumbnail()
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey))
|
||||
, m_angle(0)
|
||||
{
|
||||
const char* engineRoot = nullptr;
|
||||
@@ -34,7 +36,7 @@ namespace AzToolsFramework
|
||||
AZ::StringFunc::Path::Join(engineRoot, LoadingIconPath, iconPath);
|
||||
m_loadingMovie.setFileName(iconPath.c_str());
|
||||
m_loadingMovie.setCacheMode(QMovie::CacheMode::CacheAll);
|
||||
m_loadingMovie.setScaledSize(QSize(m_thumbnailSize, m_thumbnailSize));
|
||||
m_loadingMovie.setScaledSize(QSize(LoadingThumbnailSize, LoadingThumbnailSize));
|
||||
m_loadingMovie.start();
|
||||
m_pixmap = m_loadingMovie.currentPixmap();
|
||||
m_state = State::Ready;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadingThumbnail(int thumbnailSize);
|
||||
LoadingThumbnail();
|
||||
~LoadingThumbnail() override;
|
||||
|
||||
void UpdateTime(float /*deltaTime*/) override;
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace AzToolsFramework
|
||||
{
|
||||
static const char* MISSING_ICON_PATH = "Editor/Icons/AssetBrowser/Default_16.svg";
|
||||
|
||||
MissingThumbnail::MissingThumbnail(int thumbnailSize)
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey), thumbnailSize)
|
||||
MissingThumbnail::MissingThumbnail()
|
||||
: Thumbnail(MAKE_TKEY(ThumbnailKey))
|
||||
{
|
||||
m_icon = QIcon(MISSING_ICON_PATH);
|
||||
m_state = State::Ready;
|
||||
m_pixmap.load(MISSING_ICON_PATH);
|
||||
m_state = m_pixmap.isNull() ? State::Failed : State::Ready;
|
||||
}
|
||||
|
||||
} // namespace Thumbnailer
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MissingThumbnail(int thumbnailSize);
|
||||
MissingThumbnail();
|
||||
};
|
||||
} // namespace Thumbnailer
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
+5
-5
@@ -69,8 +69,8 @@ namespace AzToolsFramework
|
||||
|
||||
bool SourceControlThumbnail::m_readyForUpdate = true;
|
||||
|
||||
SourceControlThumbnail::SourceControlThumbnail(SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
SourceControlThumbnail::SourceControlThumbnail(SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
const char* engineRoot = nullptr;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(engineRoot, &AzFramework::ApplicationRequests::GetEngineRoot);
|
||||
@@ -122,16 +122,16 @@ namespace AzToolsFramework
|
||||
{
|
||||
if (fileInfo.HasFlag(AzToolsFramework::SCF_Writeable))
|
||||
{
|
||||
m_icon = QIcon(m_writableIconPath.c_str());
|
||||
m_pixmap.load(m_writableIconPath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_icon = QIcon(m_nonWritableIconPath.c_str());
|
||||
m_pixmap.load(m_nonWritableIconPath.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_icon = QIcon();
|
||||
m_pixmap = QPixmap();
|
||||
}
|
||||
m_readyForUpdate = true;
|
||||
emit Updated();
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SourceControlThumbnail(SharedThumbnailKey key, int thumbnailSize);
|
||||
SourceControlThumbnail(SharedThumbnailKey key);
|
||||
~SourceControlThumbnail() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -24,8 +24,6 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
static const int DefaultIconSize = 16;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ThumbnailKey
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -54,10 +52,9 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Thumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Thumbnail::Thumbnail(SharedThumbnailKey key, int thumbnailSize)
|
||||
Thumbnail::Thumbnail(SharedThumbnailKey key)
|
||||
: QObject()
|
||||
, m_state(State::Unloaded)
|
||||
, m_thumbnailSize(thumbnailSize)
|
||||
, m_key(key)
|
||||
{
|
||||
connect(&m_watcher, &QFutureWatcher<void>::finished, this, [this]()
|
||||
@@ -91,19 +88,9 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap Thumbnail::GetPixmap() const
|
||||
const QPixmap& Thumbnail::GetPixmap() const
|
||||
{
|
||||
return GetPixmap(QSize(DefaultIconSize, DefaultIconSize));
|
||||
}
|
||||
|
||||
QPixmap Thumbnail::GetPixmap(const QSize& size) const
|
||||
{
|
||||
if (m_icon.isNull())
|
||||
{
|
||||
return m_pixmap;
|
||||
}
|
||||
|
||||
return m_icon.pixmap(size);
|
||||
return m_pixmap;
|
||||
}
|
||||
|
||||
SharedThumbnailKey Thumbnail::GetKey() const
|
||||
|
||||
@@ -19,7 +19,6 @@ AZ_PUSH_DISABLE_WARNING(4127 4251 4800, "-Wunknown-warning-option") // 4127: con
|
||||
// 4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
#include <QFutureWatcher>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
#endif
|
||||
@@ -86,12 +85,11 @@ namespace AzToolsFramework
|
||||
Failed
|
||||
};
|
||||
|
||||
Thumbnail(SharedThumbnailKey key, int thumbnailSize);
|
||||
Thumbnail(SharedThumbnailKey key);
|
||||
~Thumbnail() override;
|
||||
bool operator == (const Thumbnail& other) const;
|
||||
void Load();
|
||||
virtual QPixmap GetPixmap() const;
|
||||
virtual QPixmap GetPixmap(const QSize& size) const;
|
||||
const QPixmap& GetPixmap() const;
|
||||
virtual void UpdateTime(float /*deltaTime*/) {}
|
||||
SharedThumbnailKey GetKey() const;
|
||||
State GetState() const;
|
||||
@@ -105,10 +103,8 @@ namespace AzToolsFramework
|
||||
protected:
|
||||
QFutureWatcher<void> m_watcher;
|
||||
State m_state;
|
||||
int m_thumbnailSize;
|
||||
SharedThumbnailKey m_key;
|
||||
QPixmap m_pixmap;
|
||||
QIcon m_icon;
|
||||
|
||||
virtual void LoadThread() {}
|
||||
};
|
||||
@@ -122,7 +118,6 @@ namespace AzToolsFramework
|
||||
ThumbnailProvider() = default;
|
||||
virtual ~ThumbnailProvider() = default;
|
||||
virtual bool GetThumbnail(SharedThumbnailKey key, SharedThumbnail& thumbnail) = 0;
|
||||
virtual void SetThumbnailSize(int thumbnailSize) = 0;
|
||||
//! Priority identifies ThumbnailProvider order in ThumbnailContext
|
||||
//! Higher priority means this ThumbnailProvider will take precedence in generating a thumbnail when
|
||||
//! a supplied ThumbnailKey is supported by multiple providers.
|
||||
@@ -185,10 +180,7 @@ namespace AzToolsFramework
|
||||
|
||||
bool GetThumbnail(SharedThumbnailKey key, SharedThumbnail& thumbnail) override;
|
||||
|
||||
void SetThumbnailSize(int thumbnailSize) override;
|
||||
|
||||
protected:
|
||||
int m_thumbnailSize;
|
||||
AZStd::unordered_map<SharedThumbnailKey, SharedThumbnail, Hasher, EqualKey> m_cache;
|
||||
|
||||
//! Check if thumbnail key is handled by this provider, overload in derived class
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace AzToolsFramework
|
||||
{
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
ThumbnailCache<ThumbnailType, Hasher, EqualKey>::ThumbnailCache()
|
||||
: m_thumbnailSize(0)
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
@@ -49,17 +48,11 @@ namespace AzToolsFramework
|
||||
}
|
||||
if (IsSupportedThumbnail(key))
|
||||
{
|
||||
thumbnail = QSharedPointer<ThumbnailType>(new ThumbnailType(key, m_thumbnailSize));
|
||||
thumbnail = QSharedPointer<ThumbnailType>(new ThumbnailType(key));
|
||||
m_cache[key] = thumbnail;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
void ThumbnailCache<ThumbnailType, Hasher, EqualKey>::SetThumbnailSize(int thumbnailSize)
|
||||
{
|
||||
m_thumbnailSize = thumbnailSize;
|
||||
}
|
||||
} // namespace Thumbnailer
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -24,10 +24,9 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
ThumbnailContext::ThumbnailContext(int thumbnailSize)
|
||||
: m_missingThumbnail(new MissingThumbnail(thumbnailSize))
|
||||
, m_loadingThumbnail(new LoadingThumbnail(thumbnailSize))
|
||||
, m_thumbnailSize(thumbnailSize)
|
||||
ThumbnailContext::ThumbnailContext()
|
||||
: m_missingThumbnail(new MissingThumbnail())
|
||||
, m_loadingThumbnail(new LoadingThumbnail())
|
||||
, m_threadPool(this)
|
||||
{
|
||||
ThumbnailContextRequestBus::Handler::BusConnect();
|
||||
@@ -120,7 +119,6 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
providerToAdd->SetThumbnailSize(m_thumbnailSize);
|
||||
m_providers.insert(providerToAdd);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(ThumbnailContext, AZ::SystemAllocator, 0)
|
||||
AZ_CLASS_ALLOCATOR(ThumbnailContext, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit ThumbnailContext(int thumbnailSize);
|
||||
ThumbnailContext();
|
||||
~ThumbnailContext() override;
|
||||
|
||||
//! Is the thumbnail currently loading or is about to load.
|
||||
@@ -82,8 +82,6 @@ namespace AzToolsFramework
|
||||
SharedThumbnail m_missingThumbnail;
|
||||
//! Default loading thumbnail used when thumbnail is found by is not yet generated
|
||||
SharedThumbnail m_loadingThumbnail;
|
||||
//! Thumbnail size (width and height in pixels)
|
||||
int m_thumbnailSize;
|
||||
//! There is only a limited number of threads on global threadPool, because there can be many thumbnails rendering at once
|
||||
//! an individual threadPool is needed to avoid deadlocks
|
||||
QThreadPool m_threadPool;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
public:
|
||||
//! Add thumbnail context
|
||||
virtual void RegisterContext(const char* contextName, int thumbnailSize) = 0;
|
||||
virtual void RegisterContext(const char* contextName) = 0;
|
||||
|
||||
//! Remove thumbnail context and all associated ThumbnailProviders
|
||||
virtual void UnregisterContext(const char* contextName) = 0;
|
||||
|
||||
+3
-4
@@ -32,8 +32,7 @@ namespace AzToolsFramework
|
||||
|
||||
void ThumbnailerComponent::Activate()
|
||||
{
|
||||
int thumbnailSize = qApp->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
RegisterContext(ThumbnailContext::DefaultContext, thumbnailSize);
|
||||
RegisterContext(ThumbnailContext::DefaultContext);
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
@@ -62,10 +61,10 @@ namespace AzToolsFramework
|
||||
provided.push_back(AZ_CRC("ThumbnailerService", 0x65422b97));
|
||||
}
|
||||
|
||||
void ThumbnailerComponent::RegisterContext(const char* contextName, int thumbnailSize)
|
||||
void ThumbnailerComponent::RegisterContext(const char* contextName)
|
||||
{
|
||||
AZ_Assert(m_thumbnails.find(contextName) == m_thumbnails.end(), "Context %s already registered", contextName);
|
||||
m_thumbnails[contextName] = AZStd::make_shared<ThumbnailContext>(thumbnailSize);
|
||||
m_thumbnails[contextName] = AZStd::make_shared<ThumbnailContext>();
|
||||
}
|
||||
|
||||
void ThumbnailerComponent::UnregisterContext(const char* contextName)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace AzToolsFramework
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ThumbnailerRequests
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RegisterContext(const char* contextName, int thumbnailSize) override;
|
||||
void RegisterContext(const char* contextName) override;
|
||||
void UnregisterContext(const char* contextName) override;
|
||||
bool HasContext(const char* contextName) const override;
|
||||
void RegisterThumbnailProvider(SharedThumbnailProvider provider, const char* contextName) override;
|
||||
|
||||
@@ -85,8 +85,6 @@ namespace UnitTest
|
||||
{
|
||||
constexpr const char* contextName1 = "Context1";
|
||||
constexpr const char* contextName2 = "Context2";
|
||||
constexpr int thumbnailSize1 = 128;
|
||||
constexpr int thumbnailSize2 = 256;
|
||||
|
||||
auto checkHasContext = [](const char* contextName)
|
||||
{
|
||||
@@ -98,12 +96,12 @@ namespace UnitTest
|
||||
EXPECT_FALSE(checkHasContext(contextName1));
|
||||
EXPECT_FALSE(checkHasContext(contextName2));
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1, thumbnailSize1);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1);
|
||||
|
||||
EXPECT_TRUE(checkHasContext(contextName1));
|
||||
EXPECT_FALSE(checkHasContext(contextName2));
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName2, thumbnailSize2);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName2);
|
||||
|
||||
EXPECT_TRUE(checkHasContext(contextName1));
|
||||
EXPECT_TRUE(checkHasContext(contextName2));
|
||||
@@ -123,8 +121,6 @@ namespace UnitTest
|
||||
{
|
||||
constexpr const char* contextName1 = "Context1";
|
||||
constexpr const char* contextName2 = "Context2";
|
||||
constexpr int thumbnailSize1 = 128;
|
||||
constexpr int thumbnailSize2 = 256;
|
||||
|
||||
auto checkHasContext = [](const char* contextName)
|
||||
{
|
||||
@@ -133,8 +129,8 @@ namespace UnitTest
|
||||
return hasContext;
|
||||
};
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1, thumbnailSize1);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName2, thumbnailSize2);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName2);
|
||||
|
||||
EXPECT_TRUE(checkHasContext(contextName1));
|
||||
EXPECT_TRUE(checkHasContext(contextName2));
|
||||
@@ -149,12 +145,11 @@ namespace UnitTest
|
||||
TEST_F(ThumbnailerTests, ThumbnailerComponent_RegisterContextTwice_Assert)
|
||||
{
|
||||
constexpr const char* contextName1 = "Context1";
|
||||
constexpr int thumbnailSize1 = 128;
|
||||
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1, thumbnailSize1);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1);
|
||||
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1, thumbnailSize1);
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRequestBus::Broadcast(&AzToolsFramework::Thumbnailer::ThumbnailerRequests::RegisterContext, contextName1);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace LUAEditor
|
||||
services.push_back(AZ_CRC("ThumbnailerService", 0x65422b97));
|
||||
}
|
||||
|
||||
void ThumbnailerNullComponent::RegisterContext(const char* /*contextName*/, int /*thumbnailSize*/)
|
||||
void ThumbnailerNullComponent::RegisterContext(const char* /*contextName*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace LUAEditor
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ThumbnailerRequests
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void RegisterContext(const char* contextName, int thumbnailSize) override;
|
||||
void RegisterContext(const char* contextName) override;
|
||||
void UnregisterContext(const char* contextName) override;
|
||||
bool HasContext(const char* contextName) const override;
|
||||
void RegisterThumbnailProvider(AzToolsFramework::Thumbnailer::SharedThumbnailProvider provider, const char* contextName) override;
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace ImageProcessingAtom
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
const int ImageThumbnailSize = 200;
|
||||
static constexpr const int ImageThumbnailSize = 256;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// ImageThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
ImageThumbnail::ImageThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
ImageThumbnail::ImageThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
auto sourceKey = azrtti_cast<const AzToolsFramework::AssetBrowser::SourceThumbnailKey*>(key.data());
|
||||
if (sourceKey)
|
||||
@@ -66,7 +66,7 @@ namespace ImageProcessingAtom
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
AZ::RPI::StreamingImageAsset::RTTI_Type(), &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail,
|
||||
m_key,
|
||||
m_thumbnailSize);
|
||||
ImageThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace ImageProcessingAtom
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ImageThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize);
|
||||
ImageThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~ImageThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
|
||||
@@ -21,13 +21,13 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
const int MaterialThumbnailSize = 200;
|
||||
static constexpr const int MaterialThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MaterialThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MaterialThumbnail::MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
MaterialThumbnail::MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::MaterialAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
@@ -47,7 +47,7 @@ namespace AZ
|
||||
RPI::MaterialAsset::RTTI_Type(),
|
||||
&AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail,
|
||||
m_key,
|
||||
m_thumbnailSize);
|
||||
MaterialThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace AZ
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize);
|
||||
MaterialThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~MaterialThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace AZ
|
||||
{
|
||||
namespace Thumbnails
|
||||
{
|
||||
const int MeshThumbnailSize = 200;
|
||||
static constexpr const int MeshThumbnailSize = 512; // 512 is the default size in render to texture pass
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// MeshThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
MeshThumbnail::MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize)
|
||||
: Thumbnail(key, thumbnailSize)
|
||||
MeshThumbnail::MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
m_assetId = GetAssetId(key, RPI::ModelAsset::RTTI_Type());
|
||||
if (!m_assetId.IsValid())
|
||||
@@ -48,7 +48,7 @@ namespace AZ
|
||||
RPI::ModelAsset::RTTI_Type(),
|
||||
&AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail,
|
||||
m_key,
|
||||
m_thumbnailSize);
|
||||
MeshThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace AZ
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key, int thumbnailSize);
|
||||
MeshThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
|
||||
~MeshThumbnail() override;
|
||||
|
||||
//! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
|
||||
|
||||
+2
-1
@@ -82,8 +82,9 @@ namespace AZ
|
||||
return m_data;
|
||||
}
|
||||
|
||||
void CommonThumbnailRenderer::RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, [[maybe_unused]] int thumbnailSize)
|
||||
void CommonThumbnailRenderer::RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize)
|
||||
{
|
||||
m_data->m_thumbnailSize = thumbnailSize;
|
||||
m_data->m_thumbnailQueue.push(thumbnailKey);
|
||||
if (m_currentStep == Step::None)
|
||||
{
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ namespace AZ
|
||||
|
||||
double m_simulateTime = 0.0f;
|
||||
float m_deltaTime = 0.0f;
|
||||
int m_thumbnailSize = 512;
|
||||
|
||||
//! Incoming thumbnail requests are appended to this queue and processed one at a time in OnTick function.
|
||||
AZStd::queue<AzToolsFramework::Thumbnailer::SharedThumbnailKey> m_thumbnailQueue;
|
||||
|
||||
Reference in New Issue
Block a user