3
0

ImageConvertJob.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <BuilderSettings/PresetSettings.h>
  10. #include <BuilderSettings/TextureSettings.h>
  11. #include <Atom/ImageProcessing/ImageObject.h>
  12. #include <Atom/ImageProcessing/ImageProcessingDefines.h>
  13. #include <AzCore/Jobs/Job.h>
  14. namespace ImageProcessingAtom
  15. {
  16. class ImageConvertProcess;
  17. class ImageConvertOutput
  18. {
  19. public:
  20. IImageObjectPtr GetOutputImage() const;
  21. void SetOutputImage(IImageObjectPtr image);
  22. void SetReady(bool ready);
  23. bool IsReady() const;
  24. float GetProgress() const;
  25. void SetProgress(float progress);
  26. void Reset();
  27. private:
  28. IImageObjectPtr m_outputImage;
  29. bool m_outputReady = false;
  30. float m_progress = 0.0f;
  31. };
  32. /**
  33. * The ImagePreviewConvertJob is the multi-thread job to enable ImageConvertProcessing running on job thread for image process
  34. * result preview window. This is used for generate preview result only.
  35. * Note, we don't need this for image builder of asset processor since the job for image builder is managed by the builder system.
  36. */
  37. class ImagePreviewConvertJob
  38. : public AZ::Job
  39. {
  40. public:
  41. AZ_CLASS_ALLOCATOR(ImagePreviewConvertJob, AZ::ThreadPoolAllocator)
  42. ImagePreviewConvertJob(IImageObjectPtr image, const TextureSettings* textureSetting, const PresetSettings* preset
  43. , const AZStd::string& platformId, ImageConvertOutput* output, bool autoDelete = true
  44. , AZ::JobContext* jobContext = nullptr);
  45. void Process() override;
  46. // Cancel the job itself
  47. void Cancel();
  48. // Whether the job is being canceled or the whole job group is being canceled
  49. bool IsJobCancelled();
  50. private:
  51. static const int m_previewProcessStep = 2;
  52. AZStd::unique_ptr<ImageConvertProcess> m_process;
  53. AZStd::atomic_bool m_isCancelled;
  54. ImageConvertOutput* m_output;
  55. };
  56. }// namespace ImageProcessingAtom