Compile again after renaming and moving files
Cleaned up namespaces Renamed a couple of functions and added comments Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+76
-80
@@ -10,104 +10,100 @@
|
||||
#include <Atom/RPI.Reflect/Model/ModelAsset.h>
|
||||
#include <Atom/RPI.Reflect/System/AnyAsset.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <Previewer/CommonThumbnail.h>
|
||||
#include <Previewer/CommonThumbnailUtils.h>
|
||||
#include <SharedPreview/SharedThumbnail.h>
|
||||
#include <SharedPreview/SharedThumbnailUtils.h>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
namespace LyIntegration
|
||||
{
|
||||
namespace Thumbnails
|
||||
static constexpr const int SharedThumbnailSize = 256;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SharedThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SharedThumbnail::SharedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
{
|
||||
static constexpr const int CommonThumbnailSize = 256;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CommonThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CommonThumbnail::CommonThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key)
|
||||
: Thumbnail(key)
|
||||
for (const AZ::Uuid& typeId : SharedPreviewUtils::GetSupportedAssetTypes())
|
||||
{
|
||||
for (const AZ::Uuid& typeId : GetSupportedThumbnailAssetTypes())
|
||||
const AZ::Data::AssetId& assetId = SharedPreviewUtils::GetAssetId(key, typeId);
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
const AZ::Data::AssetId& assetId = GetAssetId(key, typeId);
|
||||
if (assetId.IsValid())
|
||||
{
|
||||
m_assetId = assetId;
|
||||
m_typeId = typeId;
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AZ_Error("CommonThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
}
|
||||
|
||||
void CommonThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
m_typeId, &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key,
|
||||
CommonThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
CommonThumbnail::~CommonThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void CommonThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void CommonThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void CommonThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
m_assetId = assetId;
|
||||
m_typeId = typeId;
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusConnect(key);
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusConnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CommonThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
CommonThumbnailCache::CommonThumbnailCache()
|
||||
: ThumbnailCache<CommonThumbnail>()
|
||||
{
|
||||
}
|
||||
AZ_Error("SharedThumbnail", false, "Failed to find matching assetId for the thumbnailKey.");
|
||||
m_state = State::Failed;
|
||||
}
|
||||
|
||||
CommonThumbnailCache::~CommonThumbnailCache() = default;
|
||||
void SharedThumbnail::LoadThread()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::QueueEvent(
|
||||
m_typeId, &AzToolsFramework::Thumbnailer::ThumbnailerRendererRequests::RenderThumbnail, m_key, SharedThumbnailSize);
|
||||
// wait for response from thumbnail renderer
|
||||
m_renderWait.acquire();
|
||||
}
|
||||
|
||||
int CommonThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
SharedThumbnail::~SharedThumbnail()
|
||||
{
|
||||
AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler::BusDisconnect();
|
||||
AzFramework::AssetCatalogEventBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
const char* CommonThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
void SharedThumbnail::ThumbnailRendered(const QPixmap& thumbnailImage)
|
||||
{
|
||||
m_pixmap = thumbnailImage;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
bool CommonThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
void SharedThumbnail::ThumbnailFailedToRender()
|
||||
{
|
||||
m_state = State::Failed;
|
||||
m_renderWait.release();
|
||||
}
|
||||
|
||||
void SharedThumbnail::OnCatalogAssetChanged([[maybe_unused]] const AZ::Data::AssetId& assetId)
|
||||
{
|
||||
if (m_assetId == assetId && m_state == State::Ready)
|
||||
{
|
||||
return Thumbnails::IsSupportedThumbnail(key);
|
||||
m_state = State::Unloaded;
|
||||
Load();
|
||||
}
|
||||
} // namespace Thumbnails
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SharedThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SharedThumbnailCache::SharedThumbnailCache()
|
||||
: ThumbnailCache<SharedThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
SharedThumbnailCache::~SharedThumbnailCache() = default;
|
||||
|
||||
int SharedThumbnailCache::GetPriority() const
|
||||
{
|
||||
// Thumbnails override default source thumbnails, so carry higher priority
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* SharedThumbnailCache::GetProviderName() const
|
||||
{
|
||||
return ProviderName;
|
||||
}
|
||||
|
||||
bool SharedThumbnailCache::IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return SharedPreviewUtils::IsSupportedAssetType(key);
|
||||
}
|
||||
} // namespace LyIntegration
|
||||
} // namespace AZ
|
||||
|
||||
#include <Previewer/moc_CommonThumbnail.cpp>
|
||||
#include <SharedPreview/moc_SharedThumbnail.cpp>
|
||||
|
||||
Reference in New Issue
Block a user