From ad2ee47ea377a7e3999a976fa26f6d3002f8be3c Mon Sep 17 00:00:00 2001 From: Yuriy Toporovskyy Date: Fri, 25 Jun 2021 09:49:13 -0400 Subject: [PATCH] Avoid a somewhat costly call to ThumbnailerRequestsBus::IsLoading when the information is already manifest --- .../AssetBrowser/Views/EntryDelegate.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index d0ac05020d..bf9a68b6b2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -126,9 +126,9 @@ namespace AzToolsFramework { return 0; } - bool thumbnailLoading; - ThumbnailerRequestsBus::BroadcastResult(thumbnailLoading, &ThumbnailerRequests::IsLoading, thumbnailKey, m_thumbnailContext.c_str()); - if (thumbnailLoading) + + const Thumbnail::State thumbnailState = thumbnail->GetState(); + if (thumbnailState == Thumbnail::State::Loading) { AzQtComponents::StyledBusyLabel* busyLabel; AssetBrowserComponentRequestBus::BroadcastResult(busyLabel , &AssetBrowserComponentRequests::GetStyledBusyLabel); @@ -137,7 +137,7 @@ namespace AzToolsFramework busyLabel->DrawTo(painter, QRectF(point.x(), point.y(), size.width(), size.height())); } } - else + else if (thumbnailState == Thumbnail::State::Ready) { // Scaling and centering pixmap within bounds to preserve aspect ratio const QPixmap pixmap = thumbnail->GetPixmap().scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -145,6 +145,10 @@ namespace AzToolsFramework const QPoint pointDelta = QPoint(sizeDelta.width() / 2, sizeDelta.height() / 2); painter->drawPixmap(point + pointDelta, pixmap); } + else + { + AZ_Assert(false, "Thumbnail state %d unexpected here", int(thumbnailState)); + } return m_iconSize; }