From e8fc6bfeb53801447de25c12ba7536f574d121f4 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 8 Jul 2022 15:01:02 +0200 Subject: [Core] Make ImageFormatLoader extensible. --- modules/hdr/image_loader_hdr.cpp | 2 +- modules/hdr/image_loader_hdr.h | 2 +- modules/hdr/register_types.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/hdr') diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp index e7c6fe592d..6f0bc16a26 100644 --- a/modules/hdr/image_loader_hdr.cpp +++ b/modules/hdr/image_loader_hdr.cpp @@ -33,7 +33,7 @@ #include "core/os/os.h" #include "core/string/print_string.h" -Error ImageLoaderHDR::load_image(Ref p_image, Ref f, uint32_t p_flags, float p_scale) { +Error ImageLoaderHDR::load_image(Ref p_image, Ref f, BitField p_flags, float p_scale) { String header = f->get_token(); ERR_FAIL_COND_V_MSG(header != "#?RADIANCE" && header != "#?RGBE", ERR_FILE_UNRECOGNIZED, "Unsupported header information in HDR: " + header + "."); diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h index 1bff05129b..5f817f0ba8 100644 --- a/modules/hdr/image_loader_hdr.h +++ b/modules/hdr/image_loader_hdr.h @@ -35,7 +35,7 @@ class ImageLoaderHDR : public ImageFormatLoader { public: - virtual Error load_image(Ref p_image, Ref f, uint32_t p_flags, float p_scale); + virtual Error load_image(Ref p_image, Ref f, BitField p_flags, float p_scale); virtual void get_recognized_extensions(List *p_extensions) const; ImageLoaderHDR(); }; diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp index b988bf4587..18b1a73f1c 100644 --- a/modules/hdr/register_types.cpp +++ b/modules/hdr/register_types.cpp @@ -32,14 +32,14 @@ #include "image_loader_hdr.h" -static ImageLoaderHDR *image_loader_hdr = nullptr; +static Ref image_loader_hdr; void initialize_hdr_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } - image_loader_hdr = memnew(ImageLoaderHDR); + image_loader_hdr.instantiate(); ImageLoader::add_image_format_loader(image_loader_hdr); } @@ -48,5 +48,6 @@ void uninitialize_hdr_module(ModuleInitializationLevel p_level) { return; } - memdelete(image_loader_hdr); + ImageLoader::remove_image_format_loader(image_loader_hdr); + image_loader_hdr.unref(); } -- cgit v1.2.3