3
0

ImageThumbnailSystemComponent.h 2.4 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. #include <AzCore/Component/Component.h>
  10. #include <AzFramework/Application/Application.h>
  11. #include <AzToolsFramework/Thumbnails/Thumbnail.h>
  12. #include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
  13. namespace ImageProcessingAtom
  14. {
  15. namespace Utils
  16. {
  17. class AsyncImageAssetLoader;
  18. }
  19. namespace Thumbnails
  20. {
  21. //! System component for image thumbnails.
  22. class ImageThumbnailSystemComponent
  23. : public AZ::Component
  24. , public AzFramework::ApplicationLifecycleEvents::Bus::Handler
  25. , public AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::Handler
  26. {
  27. public:
  28. AZ_COMPONENT(ImageThumbnailSystemComponent, "{C45D69BB-4A3B-49CF-916B-580F05CAA755}");
  29. static void Reflect(AZ::ReflectContext* context);
  30. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  31. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  32. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  33. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  34. protected:
  35. // AZ::Component interface overrides...
  36. void Activate() override;
  37. void Deactivate() override;
  38. private:
  39. void SetupThumbnails();
  40. void TeardownThumbnails();
  41. // AzFramework::ApplicationLifecycleEvents overrides...
  42. void OnApplicationAboutToStop() override;
  43. // ThumbnailerRendererRequestBus::Handler interface overrides...
  44. bool Installed() const override;
  45. void RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize) override;
  46. template<class MkImageFn>
  47. void RenderThumbnailFromImage(
  48. AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize, MkImageFn mkPreviewImage) const;
  49. AZStd::shared_ptr<Utils::AsyncImageAssetLoader> m_imageAssetLoader;
  50. };
  51. } // namespace Thumbnails
  52. } // namespace ImageProcessingAtom