eeafb5eaa3
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
127 lines
4.5 KiB
C++
127 lines
4.5 KiB
C++
/*
|
|
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
|
* its licensors.
|
|
*
|
|
* For complete copyright and license terms please see the LICENSE at the root of this
|
|
* distribution (the "License"). All use of this software is governed by the License,
|
|
* or, if provided, by the license below or the license accompanying this file. Do not
|
|
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#if !defined(Q_MOC_RUN)
|
|
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
|
#include <AzToolsFramework/Thumbnails/SourceControlThumbnailBus.h>
|
|
#endif
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
struct SourceControlFileInfo;
|
|
|
|
namespace Thumbnailer
|
|
{
|
|
class SourceControlThumbnailKey
|
|
: public ThumbnailKey
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
AZ_RTTI(SourceControlFileInfo, "{F6772100-A178-45A7-8F75-41426B07D829}", ThumbnailKey);
|
|
|
|
explicit SourceControlThumbnailKey(const char* fileName);
|
|
|
|
const AZStd::string& GetFileName() const;
|
|
|
|
bool UpdateThumbnail() override;
|
|
|
|
bool Equals(const ThumbnailKey* other) const override;
|
|
|
|
protected:
|
|
//! absolute path
|
|
AZStd::string m_fileName;
|
|
//! how often should sc thumbnails auto update
|
|
const AZStd::chrono::minutes m_updateInterval;
|
|
//! time since this sc thumbnail updated
|
|
AZStd::chrono::system_clock::time_point m_nextUpdate;
|
|
};
|
|
|
|
//! SourceControlThumbnail currently replicates the source control functionality within Material Browser
|
|
//! Additionally source control status is refreshed whenever an operation is performed through context menu
|
|
class SourceControlThumbnail
|
|
: public Thumbnail
|
|
, public SourceControlThumbnailRequestBus::Handler
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
SourceControlThumbnail(SharedThumbnailKey key);
|
|
~SourceControlThumbnail() override;
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// SourceControlNotificationBus
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void FileStatusChanged(const char* filename) override;
|
|
|
|
static bool ReadyForUpdate();
|
|
|
|
public Q_SLOTS:
|
|
void Update() override;
|
|
|
|
private:
|
|
// To avoid overpopulating sc update stack with status requests, sc thumbnail does not load until this function is called
|
|
void RequestSourceControlStatus();
|
|
void SourceControlFileInfoUpdated(bool succeeded, const SourceControlFileInfo& fileInfo);
|
|
|
|
//! If another sc thumbnail is currently requesting sc status this will return false
|
|
static bool m_readyForUpdate;
|
|
|
|
AZStd::string m_writableIconPath;
|
|
AZStd::string m_nonWritableIconPath;
|
|
};
|
|
|
|
namespace
|
|
{
|
|
class SourceControlKeyHash
|
|
{
|
|
public:
|
|
size_t operator() (const SharedThumbnailKey& /*val*/) const
|
|
{
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
class SourceControlKeyEqual
|
|
{
|
|
public:
|
|
bool operator()(const SharedThumbnailKey& val1, const SharedThumbnailKey& val2) const
|
|
{
|
|
auto sourceThumbnailKey1 = azrtti_cast<const SourceControlThumbnailKey*>(val1.data());
|
|
auto sourceThumbnailKey2 = azrtti_cast<const SourceControlThumbnailKey*>(val2.data());
|
|
if (!sourceThumbnailKey1 || !sourceThumbnailKey2)
|
|
{
|
|
return false;
|
|
}
|
|
return sourceThumbnailKey1->GetFileName() == sourceThumbnailKey2->GetFileName();
|
|
}
|
|
};
|
|
}
|
|
|
|
//! Stores products' thumbnails
|
|
class SourceControlThumbnailCache
|
|
: public ThumbnailCache<SourceControlThumbnail>
|
|
{
|
|
public:
|
|
SourceControlThumbnailCache();
|
|
~SourceControlThumbnailCache() override;
|
|
|
|
const char* GetProviderName() const override;
|
|
|
|
static constexpr const char* ProviderName = "SourceControl Thumbnails";
|
|
|
|
protected:
|
|
bool IsSupportedThumbnail(SharedThumbnailKey key) const override;
|
|
};
|
|
} // namespace Thumbnailer
|
|
} // namespace AzToolsFramework
|