You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvertJob.h

79 lines
2.8 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <BuilderSettings/ImageProcessingDefines.h>
#include <BuilderSettings/PresetSettings.h>
#include <BuilderSettings/TextureSettings.h>
#include <Atom/ImageProcessing/ImageObject.h>
#include <AzCore/Jobs/Job.h>
namespace ImageProcessingAtom
{
class ImageConvertProcess;
class ImageConvertOutput
{
public:
enum OutputImageType
{
Base = 0, // Might contains alpha or not
Alpha, // Separate alpha image
Preview, // Combine base image with alpha if any, format RGBA8
Count
};
IImageObjectPtr GetOutputImage(OutputImageType type) const;
void SetOutputImage(IImageObjectPtr image, OutputImageType type);
void SetReady(bool ready);
bool IsReady() const;
float GetProgress() const;
void SetProgress(float progress);
void Reset();
private:
IImageObjectPtr m_outputImage[OutputImageType::Count];
bool m_outputReady = false;
float m_progress = 0.0f;
};
/**
* The ImagePreviewConvertJob is the multi-thread job to enable ImageConvertProcessing running on job thread for image process
* result preview window. This is used for generate preview result only.
* Note, we don't need this for image builder of asset processor since the job for image builder is managed by the builder system.
*/
class ImagePreviewConvertJob
: public AZ::Job
{
public:
AZ_CLASS_ALLOCATOR(ImagePreviewConvertJob, AZ::ThreadPoolAllocator, 0)
ImagePreviewConvertJob(IImageObjectPtr image, const TextureSettings* textureSetting, const PresetSettings* preset
, const AZStd::string& platformId, ImageConvertOutput* output, bool autoDelete = true
, AZ::JobContext* jobContext = nullptr);
void Process() override;
// Cancel the job itself
void Cancel();
// Whether the job is being canceled or the whole job group is being canceled
bool IsJobCancelled();
private:
static const int m_previewProcessStep = 2;
AZStd::unique_ptr<ImageConvertProcess> m_process;
AZStd::atomic_bool m_isCancelled;
ImageConvertOutput* m_output;
};
}// namespace ImageProcessingAtom