Integrating up through commit 90f050496
This commit is contained in:
+10
-1
@@ -52,6 +52,15 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SourceControlThumbnailKey::Equals(const ThumbnailKey* other) const
|
||||
{
|
||||
if (!ThumbnailKey::Equals(other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_fileName == azrtti_cast<const SourceControlThumbnailKey*>(other)->GetFileName();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// SourceControlThumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -142,7 +151,7 @@ namespace AzToolsFramework
|
||||
// SourceControlThumbnailCache
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
SourceControlThumbnailCache::SourceControlThumbnailCache()
|
||||
: ThumbnailCache<SourceControlThumbnail, SourceControlKeyHash, SourceControlKeyEqual>()
|
||||
: ThumbnailCache<SourceControlThumbnail>()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -36,6 +36,8 @@ namespace AzToolsFramework
|
||||
|
||||
bool UpdateThumbnail() override;
|
||||
|
||||
bool Equals(const ThumbnailKey* other) const override;
|
||||
|
||||
protected:
|
||||
//! absolute path
|
||||
AZStd::string m_fileName;
|
||||
@@ -107,7 +109,7 @@ namespace AzToolsFramework
|
||||
|
||||
//! Stores products' thumbnails
|
||||
class SourceControlThumbnailCache
|
||||
: public ThumbnailCache<SourceControlThumbnail, SourceControlKeyHash, SourceControlKeyEqual>
|
||||
: public ThumbnailCache<SourceControlThumbnail>
|
||||
{
|
||||
public:
|
||||
SourceControlThumbnailCache();
|
||||
|
||||
@@ -39,6 +39,16 @@ namespace AzToolsFramework
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t ThumbnailKey::GetHash() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ThumbnailKey::Equals(const ThumbnailKey* other) const
|
||||
{
|
||||
return RTTI_GetType() == other->RTTI_GetType();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Thumbnail
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -49,19 +49,23 @@ namespace AzToolsFramework
|
||||
|
||||
virtual bool UpdateThumbnail();
|
||||
|
||||
Q_SIGNALS:
|
||||
virtual size_t GetHash() const;
|
||||
|
||||
virtual bool Equals(const ThumbnailKey* other) const;
|
||||
Q_SIGNALS:
|
||||
//! Updated signal is dispatched whenever thumbnail data was changed. Anyone using this thumbnail should listen to this.
|
||||
void ThumbnailUpdatedSignal() const;
|
||||
//! Force update mapped thumbnails
|
||||
void UpdateThumbnailSignal() const;
|
||||
|
||||
|
||||
private:
|
||||
bool m_ready = false;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<ThumbnailKey> SharedThumbnailKey;
|
||||
|
||||
#define MAKE_TKEY(type, ...) QSharedPointer<type>(new type(__VA_ARGS__))
|
||||
#define MAKE_TKEY(type, ...) QSharedPointer<type>(new type(__VA_ARGS__))
|
||||
|
||||
//! Thumbnail is the base class in thumbnailer system.
|
||||
/*
|
||||
@@ -92,7 +96,7 @@ Q_SIGNALS:
|
||||
SharedThumbnailKey GetKey() const;
|
||||
State GetState() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
Q_SIGNALS:
|
||||
void Updated() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
@@ -128,16 +132,44 @@ Q_SIGNALS:
|
||||
};
|
||||
|
||||
typedef QSharedPointer<ThumbnailProvider> SharedThumbnailProvider;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
// hash specialization
|
||||
template <>
|
||||
struct hash<AzToolsFramework::Thumbnailer::SharedThumbnailKey>
|
||||
{
|
||||
AZ_FORCE_INLINE size_t operator()(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const
|
||||
{
|
||||
return key->GetHash();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct AZStd::equal_to<AzToolsFramework::Thumbnailer::SharedThumbnailKey>
|
||||
{
|
||||
AZ_FORCE_INLINE bool operator()(const AzToolsFramework::Thumbnailer::SharedThumbnailKey& left, const AzToolsFramework::Thumbnailer::SharedThumbnailKey& right) const
|
||||
{
|
||||
return left->Equals(right.data());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
//! ThumbnailCache manages thumbnails of specific type, derive your custom provider from this
|
||||
/*
|
||||
ThumbnailType - type of thumbnails managed
|
||||
HasherType - hashing function for storing thumbnail keys in the hashtable
|
||||
Hasher - hashing function for storing thumbnail keys in the hashtable
|
||||
EqualKey - equality function for storing thumbnail keys in the hashtable
|
||||
HasherType and EqualKey need to be provided on individual basis depending on
|
||||
Hasher and EqualKey need to be provided on individual basis depending on
|
||||
what constitutes a unique key and how should the key collection be optimized
|
||||
*/
|
||||
template<typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
template<class ThumbnailType, class Hasher = AZStd::hash<SharedThumbnailKey>, class EqualKey = AZStd::equal_to<SharedThumbnailKey>>
|
||||
class ThumbnailCache
|
||||
: public ThumbnailProvider
|
||||
, public AZ::TickBus::Handler
|
||||
@@ -157,7 +189,7 @@ Q_SIGNALS:
|
||||
|
||||
protected:
|
||||
int m_thumbnailSize;
|
||||
AZStd::unordered_map<SharedThumbnailKey, SharedThumbnail, HasherType, EqualKey> m_cache;
|
||||
AZStd::unordered_map<SharedThumbnailKey, SharedThumbnail, Hasher, EqualKey> m_cache;
|
||||
|
||||
//! Check if thumbnail key is handled by this provider, overload in derived class
|
||||
virtual bool IsSupportedThumbnail(SharedThumbnailKey key) const = 0;
|
||||
@@ -169,4 +201,5 @@ Q_SIGNALS:
|
||||
|
||||
Q_DECLARE_METATYPE(AzToolsFramework::Thumbnailer::SharedThumbnailKey)
|
||||
|
||||
|
||||
#include <AzToolsFramework/Thumbnails/Thumbnail.inl>
|
||||
|
||||
@@ -16,21 +16,21 @@ namespace AzToolsFramework
|
||||
{
|
||||
namespace Thumbnailer
|
||||
{
|
||||
template <typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
ThumbnailCache<ThumbnailType, HasherType, EqualKey>::ThumbnailCache()
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
ThumbnailCache<ThumbnailType, Hasher, EqualKey>::ThumbnailCache()
|
||||
: m_thumbnailSize(0)
|
||||
{
|
||||
BusConnect();
|
||||
}
|
||||
|
||||
template <typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
ThumbnailCache<ThumbnailType, HasherType, EqualKey>::~ThumbnailCache()
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
ThumbnailCache<ThumbnailType, Hasher, EqualKey>::~ThumbnailCache()
|
||||
{
|
||||
BusDisconnect();
|
||||
}
|
||||
|
||||
template <typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
void ThumbnailCache<ThumbnailType, HasherType, EqualKey>::OnTick(float deltaTime, AZ::ScriptTimePoint /*time*/)
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
void ThumbnailCache<ThumbnailType, Hasher, EqualKey>::OnTick(float deltaTime, AZ::ScriptTimePoint /*time*/)
|
||||
{
|
||||
for (auto& kvp : m_cache)
|
||||
{
|
||||
@@ -38,9 +38,8 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
bool ThumbnailCache<ThumbnailType, HasherType, EqualKey>::GetThumbnail(
|
||||
SharedThumbnailKey key, SharedThumbnail& thumbnail)
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
bool ThumbnailCache<ThumbnailType, Hasher, EqualKey>::GetThumbnail(SharedThumbnailKey key, SharedThumbnail& thumbnail)
|
||||
{
|
||||
auto it = m_cache.find(key);
|
||||
if (it != m_cache.end())
|
||||
@@ -57,8 +56,8 @@ namespace AzToolsFramework
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename ThumbnailType, typename HasherType, typename EqualKey>
|
||||
void ThumbnailCache<ThumbnailType, HasherType, EqualKey>::SetThumbnailSize(int thumbnailSize)
|
||||
template <class ThumbnailType, class Hasher, class EqualKey>
|
||||
void ThumbnailCache<ThumbnailType, Hasher, EqualKey>::SetThumbnailSize(int thumbnailSize)
|
||||
{
|
||||
m_thumbnailSize = thumbnailSize;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace AzToolsFramework
|
||||
static const bool EnableEventQueue = true;
|
||||
typedef AZStd::recursive_mutex MutexType;
|
||||
|
||||
virtual void RenderThumbnail(AZ::Data::AssetId assetId, int thumbnailSize) = 0;
|
||||
virtual void RenderThumbnail(SharedThumbnailKey thumbnailKey, int thumbnailSize) = 0;
|
||||
|
||||
virtual bool Installed() const { return false; }
|
||||
};
|
||||
@@ -79,7 +79,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
public:
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
typedef AZ::Data::AssetId BusIdType;
|
||||
typedef SharedThumbnailKey BusIdType;
|
||||
|
||||
//! notify product thumbnail that the data is ready
|
||||
virtual void ThumbnailRendered(QPixmap& thumbnailImage) = 0;
|
||||
|
||||
Reference in New Issue
Block a user