Add image builder processing bus
This commit is contained in:
@@ -88,11 +88,13 @@ namespace ImageProcessingAtom
|
||||
m_assetHandlers.emplace_back(AZ::RPI::MakeAssetHandler<AZ::RPI::StreamingImageAssetHandler>());
|
||||
|
||||
ImageProcessingRequestBus::Handler::BusConnect();
|
||||
ImageBuilderRequestBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
void BuilderPluginComponent::Deactivate()
|
||||
{
|
||||
ImageProcessingRequestBus::Handler::BusDisconnect();
|
||||
ImageBuilderRequestBus::Handler::BusDisconnect();
|
||||
m_imageBuilder.BusDisconnect();
|
||||
BuilderSettingManager::DestroyInstance();
|
||||
CPixelFormats::DestroyInstance();
|
||||
@@ -146,6 +148,82 @@ namespace ImageProcessingAtom
|
||||
return image;
|
||||
}
|
||||
|
||||
IImageObjectPtr BuilderPluginComponent::CreateImage(
|
||||
AZ::u32 width,
|
||||
AZ::u32 height,
|
||||
AZ::u32 maxMipCount,
|
||||
EPixelFormat pixelFormat)
|
||||
{
|
||||
IImageObjectPtr image(IImageObject::CreateImage(width, height, maxMipCount, pixelFormat));
|
||||
return image;
|
||||
}
|
||||
|
||||
AZStd::vector<AssetBuilderSDK::JobProduct> BuilderPluginComponent::ConvertImageObject(
|
||||
IImageObjectPtr imageObject,
|
||||
const AZStd::string& presetName,
|
||||
const AZStd::string& platformName,
|
||||
const AZStd::string& outputDir,
|
||||
const AZ::Data::AssetId& sourceAssetId,
|
||||
const AZStd::string& sourceAssetName)
|
||||
{
|
||||
AZStd::vector<AssetBuilderSDK::JobProduct> outProducts;
|
||||
|
||||
AZStd::string_view presetFilePath;
|
||||
const PresetSettings* preset = BuilderSettingManager::Instance()->GetPreset(presetName, platformName, &presetFilePath);
|
||||
if (preset == nullptr)
|
||||
{
|
||||
AZ_Assert(false, "Cannot find preset with name %s.", presetName.c_str());
|
||||
return outProducts;
|
||||
}
|
||||
|
||||
AZStd::unique_ptr<ImageConvertProcessDescriptor> desc = AZStd::make_unique<ImageConvertProcessDescriptor>();
|
||||
TextureSettings& textureSettings = desc->m_textureSetting;
|
||||
textureSettings.m_preset = preset->m_uuid;
|
||||
desc->m_inputImage = imageObject;
|
||||
desc->m_presetSetting = *preset;
|
||||
desc->m_isPreview = false;
|
||||
desc->m_platform = platformName;
|
||||
desc->m_filePath = presetFilePath;
|
||||
desc->m_isStreaming = BuilderSettingManager::Instance()->GetBuilderSetting(platformName)->m_enableStreaming;
|
||||
desc->m_imageName = sourceAssetName;
|
||||
desc->m_outputFolder = outputDir;
|
||||
desc->m_sourceAssetId = sourceAssetId;
|
||||
|
||||
// Create an image convert process
|
||||
ImageConvertProcess* process = new ImageConvertProcess(AZStd::move(desc));
|
||||
if (process)
|
||||
{
|
||||
process->ProcessAll();
|
||||
bool result = process->IsSucceed();
|
||||
if (result)
|
||||
{
|
||||
process->GetAppendOutputProducts(outProducts);
|
||||
}
|
||||
delete process;
|
||||
}
|
||||
|
||||
return outProducts;
|
||||
}
|
||||
|
||||
bool BuilderPluginComponent::DoesSupportPlatform(const AZStd::string& platformId)
|
||||
{
|
||||
return ImageProcessingAtom::BuilderSettingManager::Instance()->DoesSupportPlatform(platformId);
|
||||
}
|
||||
|
||||
bool BuilderPluginComponent::IsPresetFormatSquarePow2(const AZStd::string& presetName, const AZStd::string& platformName)
|
||||
{
|
||||
AZStd::string_view filePath;
|
||||
const PresetSettings* preset = BuilderSettingManager::Instance()->GetPreset(presetName, platformName, &filePath);
|
||||
if (preset == nullptr)
|
||||
{
|
||||
AZ_Assert(false, "Cannot find preset with name %s.", presetName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
const PixelFormatInfo* info = CPixelFormats::GetInstance().GetPixelFormatInfo(preset->m_pixelFormat);
|
||||
return info->bSquarePow2;
|
||||
}
|
||||
|
||||
void ImageBuilderWorker::ShutDown()
|
||||
{
|
||||
// it is important to note that this will be called on a different thread than your process job thread
|
||||
|
||||
Reference in New Issue
Block a user