소스 검색

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

Yuriy Toporovskyy 4 년 전
부모
커밋
ad2ee47ea3
1개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 4
      Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp

+ 8 - 4
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;
         }