SharedThumbnail.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <AzCore/std/parallel/binary_semaphore.h>
  11. #include <AzFramework/Asset/AssetCatalogBus.h>
  12. #include <AzToolsFramework/Thumbnails/Thumbnail.h>
  13. #include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
  14. #endif
  15. namespace AZ
  16. {
  17. namespace LyIntegration
  18. {
  19. //! Custom thumbnail for most common Atom assets
  20. //! Detects asset changes and updates the thumbnail
  21. class SharedThumbnail final
  22. : public AzToolsFramework::Thumbnailer::Thumbnail
  23. , public AzToolsFramework::Thumbnailer::ThumbnailerRendererNotificationBus::Handler
  24. , private AzFramework::AssetCatalogEventBus::Handler
  25. {
  26. Q_OBJECT
  27. public:
  28. SharedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key);
  29. ~SharedThumbnail() override;
  30. //! AzToolsFramework::ThumbnailerRendererNotificationBus::Handler overrides...
  31. void ThumbnailRendered(const QPixmap& thumbnailImage) override;
  32. void ThumbnailFailedToRender() override;
  33. void Load() override;
  34. private:
  35. // AzFramework::AssetCatalogEventBus::Handler interface overrides...
  36. void OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) override;
  37. void OnCatalogAssetRemoved(const AZ::Data::AssetId& assetId, const AZ::Data::AssetInfo& assetInfo) override;
  38. Data::AssetInfo m_assetInfo;
  39. };
  40. //! Cache configuration for shared thumbnails
  41. class SharedThumbnailCache final : public AzToolsFramework::Thumbnailer::ThumbnailCache<SharedThumbnail>
  42. {
  43. public:
  44. SharedThumbnailCache();
  45. ~SharedThumbnailCache() override;
  46. int GetPriority() const override;
  47. const char* GetProviderName() const override;
  48. static constexpr const char* ProviderName = "Common Feature Shared Thumbnail Provider";
  49. protected:
  50. bool IsSupportedThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey key) const override;
  51. };
  52. } // namespace LyIntegration
  53. } // namespace AZ