浏览代码

Avoid a somewhat costly call to ThumbnailerRequestsBus::IsLoading when the information is already manifest

Yuriy Toporovskyy 4 年之前
父节点
当前提交
ad2ee47ea3

+ 8 - 4
Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp

@@ -126,9 +126,9 @@ namespace AzToolsFramework
             {
             {
                 return 0;
                 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;
                 AzQtComponents::StyledBusyLabel* busyLabel;
                 AssetBrowserComponentRequestBus::BroadcastResult(busyLabel , &AssetBrowserComponentRequests::GetStyledBusyLabel);
                 AssetBrowserComponentRequestBus::BroadcastResult(busyLabel , &AssetBrowserComponentRequests::GetStyledBusyLabel);
@@ -137,7 +137,7 @@ namespace AzToolsFramework
                     busyLabel->DrawTo(painter, QRectF(point.x(), point.y(), size.width(), size.height()));
                     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
                 // Scaling and centering pixmap within bounds to preserve aspect ratio
                 const QPixmap pixmap = thumbnail->GetPixmap().scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
                 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);
                 const QPoint pointDelta = QPoint(sizeDelta.width() / 2, sizeDelta.height() / 2);
                 painter->drawPixmap(point + pointDelta, pixmap);
                 painter->drawPixmap(point + pointDelta, pixmap);
             }
             }
+            else
+            {
+                AZ_Assert(false, "Thumbnail state %d unexpected here", int(thumbnailState));
+            }
             return m_iconSize;
             return m_iconSize;
         }
         }