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
110 lines
3.8 KiB
C++
110 lines
3.8 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.
|
|
*
|
|
*/
|
|
|
|
#include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
|
|
#include <AzToolsFramework/Thumbnails/Thumbnail.h>
|
|
AZ_PUSH_DISABLE_WARNING(4127 4251 4800 4244, "-Wunknown-warning-option") // 4127: conditional expression is constant
|
|
// 4251: 'QTextCodec::ConverterState::flags': class 'QFlags<QTextCodec::ConversionFlag>' needs to have dll-interface to be used by clients of struct 'QTextCodec::ConverterState'
|
|
// 4800: 'QTextBoundaryFinderPrivate *const ': forcing value to bool 'true' or 'false' (performance warning)
|
|
// 4244: conversion from 'int' to 'qint8', possible loss of data
|
|
#include <QtConcurrent/QtConcurrent>
|
|
#include <QThreadPool>
|
|
AZ_POP_DISABLE_WARNING
|
|
|
|
namespace AzToolsFramework
|
|
{
|
|
namespace Thumbnailer
|
|
{
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// ThumbnailKey
|
|
//////////////////////////////////////////////////////////////////////////
|
|
bool ThumbnailKey::IsReady() const { return m_ready; }
|
|
|
|
bool ThumbnailKey::UpdateThumbnail()
|
|
{
|
|
if (!IsReady())
|
|
{
|
|
return false;
|
|
}
|
|
emit UpdateThumbnailSignal();
|
|
return true;
|
|
}
|
|
|
|
size_t ThumbnailKey::GetHash() const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
bool ThumbnailKey::Equals(const ThumbnailKey* other) const
|
|
{
|
|
return RTTI_GetType() == other->RTTI_GetType();
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Thumbnail
|
|
//////////////////////////////////////////////////////////////////////////
|
|
Thumbnail::Thumbnail(SharedThumbnailKey key)
|
|
: QObject()
|
|
, m_state(State::Unloaded)
|
|
, m_key(key)
|
|
{
|
|
connect(&m_watcher, &QFutureWatcher<void>::finished, this, [this]()
|
|
{
|
|
if (m_state == State::Loading)
|
|
{
|
|
m_state = State::Ready;
|
|
}
|
|
Q_EMIT Updated();
|
|
});
|
|
}
|
|
|
|
Thumbnail::~Thumbnail() = default;
|
|
|
|
bool Thumbnail::operator==(const Thumbnail& other) const
|
|
{
|
|
return m_key == other.m_key;
|
|
}
|
|
|
|
void Thumbnail::Load()
|
|
{
|
|
if (m_state == State::Unloaded)
|
|
{
|
|
m_state = State::Loading;
|
|
QThreadPool* threadPool;
|
|
ThumbnailContextRequestBus::BroadcastResult(
|
|
threadPool,
|
|
&ThumbnailContextRequestBus::Handler::GetThreadPool);
|
|
QFuture<void> future = QtConcurrent::run(threadPool, [this](){ LoadThread(); });
|
|
m_watcher.setFuture(future);
|
|
}
|
|
}
|
|
|
|
const QPixmap& Thumbnail::GetPixmap() const
|
|
{
|
|
return m_pixmap;
|
|
}
|
|
|
|
SharedThumbnailKey Thumbnail::GetKey() const
|
|
{
|
|
return m_key;
|
|
}
|
|
|
|
Thumbnail::State Thumbnail::GetState() const
|
|
{
|
|
return m_state;
|
|
}
|
|
|
|
} // namespace Thumbnailer
|
|
} // namespace AzToolsFramework
|
|
|
|
#include "Thumbnails/moc_Thumbnail.cpp"
|