From 094ff361314756e13cc3c32f8cfead6260738024 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 17 Dec 2023 13:56:04 +0100 Subject: [PATCH] Moved png from drivers to a module. --- drivers/register_driver_types.cpp | 17 ------ modules/freetype/SCsub | 2 +- modules/freetype/config.py | 2 + {drivers => modules}/png/SCsub | 7 ++- modules/png/config.py | 6 ++ {drivers => modules}/png/image_loader_png.cpp | 2 +- {drivers => modules}/png/image_loader_png.h | 0 {drivers => modules}/png/libpng/LICENSE | 0 .../png/libpng/arm/arm_init.c | 0 .../png/libpng/arm/filter_neon.S | 0 .../png/libpng/arm/filter_neon_intrinsics.c | 0 .../png/libpng/arm/palette_neon_intrinsics.c | 0 {drivers => modules}/png/libpng/png.c | 0 {drivers => modules}/png/libpng/png.h | 0 {drivers => modules}/png/libpng/pngconf.h | 0 {drivers => modules}/png/libpng/pngdebug.h | 0 {drivers => modules}/png/libpng/pngerror.c | 0 {drivers => modules}/png/libpng/pngget.c | 0 {drivers => modules}/png/libpng/pnginfo.h | 0 {drivers => modules}/png/libpng/pnglibconf.h | 0 {drivers => modules}/png/libpng/pngmem.c | 0 {drivers => modules}/png/libpng/pngpread.c | 0 {drivers => modules}/png/libpng/pngpriv.h | 0 {drivers => modules}/png/libpng/pngread.c | 0 {drivers => modules}/png/libpng/pngrio.c | 0 {drivers => modules}/png/libpng/pngrtran.c | 0 {drivers => modules}/png/libpng/pngrutil.c | 0 {drivers => modules}/png/libpng/pngset.c | 0 {drivers => modules}/png/libpng/pngstruct.h | 0 {drivers => modules}/png/libpng/pngtrans.c | 0 {drivers => modules}/png/libpng/pngwio.c | 0 {drivers => modules}/png/libpng/pngwrite.c | 0 {drivers => modules}/png/libpng/pngwtran.c | 0 {drivers => modules}/png/libpng/pngwutil.c | 0 .../png/png_driver_common.cpp | 0 {drivers => modules}/png/png_driver_common.h | 0 modules/png/register_types.cpp | 58 +++++++++++++++++++ modules/png/register_types.h | 38 ++++++++++++ .../png/resource_saver_png.cpp | 2 +- {drivers => modules}/png/resource_saver_png.h | 0 40 files changed, 111 insertions(+), 23 deletions(-) rename {drivers => modules}/png/SCsub (93%) create mode 100644 modules/png/config.py rename {drivers => modules}/png/image_loader_png.cpp (99%) rename {drivers => modules}/png/image_loader_png.h (100%) rename {drivers => modules}/png/libpng/LICENSE (100%) rename {drivers => modules}/png/libpng/arm/arm_init.c (100%) rename {drivers => modules}/png/libpng/arm/filter_neon.S (100%) rename {drivers => modules}/png/libpng/arm/filter_neon_intrinsics.c (100%) rename {drivers => modules}/png/libpng/arm/palette_neon_intrinsics.c (100%) rename {drivers => modules}/png/libpng/png.c (100%) rename {drivers => modules}/png/libpng/png.h (100%) rename {drivers => modules}/png/libpng/pngconf.h (100%) rename {drivers => modules}/png/libpng/pngdebug.h (100%) rename {drivers => modules}/png/libpng/pngerror.c (100%) rename {drivers => modules}/png/libpng/pngget.c (100%) rename {drivers => modules}/png/libpng/pnginfo.h (100%) rename {drivers => modules}/png/libpng/pnglibconf.h (100%) rename {drivers => modules}/png/libpng/pngmem.c (100%) rename {drivers => modules}/png/libpng/pngpread.c (100%) rename {drivers => modules}/png/libpng/pngpriv.h (100%) rename {drivers => modules}/png/libpng/pngread.c (100%) rename {drivers => modules}/png/libpng/pngrio.c (100%) rename {drivers => modules}/png/libpng/pngrtran.c (100%) rename {drivers => modules}/png/libpng/pngrutil.c (100%) rename {drivers => modules}/png/libpng/pngset.c (100%) rename {drivers => modules}/png/libpng/pngstruct.h (100%) rename {drivers => modules}/png/libpng/pngtrans.c (100%) rename {drivers => modules}/png/libpng/pngwio.c (100%) rename {drivers => modules}/png/libpng/pngwrite.c (100%) rename {drivers => modules}/png/libpng/pngwtran.c (100%) rename {drivers => modules}/png/libpng/pngwutil.c (100%) rename {drivers => modules}/png/png_driver_common.cpp (100%) rename {drivers => modules}/png/png_driver_common.h (100%) create mode 100644 modules/png/register_types.cpp create mode 100644 modules/png/register_types.h rename {drivers => modules}/png/resource_saver_png.cpp (98%) rename {drivers => modules}/png/resource_saver_png.h (100%) diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index e1e6ed1..f795e0e 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -30,27 +30,10 @@ #include "register_driver_types.h" -#include "drivers/png/image_loader_png.h" -#include "drivers/png/resource_saver_png.h" - -static ImageLoaderPNG *image_loader_png; -static Ref resource_saver_png; - void register_core_driver_types() { - image_loader_png = memnew(ImageLoaderPNG); - ImageLoader::add_image_format_loader(image_loader_png); - - resource_saver_png.instance(); - ResourceSaver::add_resource_format_saver(resource_saver_png); } void unregister_core_driver_types() { - if (image_loader_png) { - memdelete(image_loader_png); - } - - ResourceSaver::remove_resource_format_saver(resource_saver_png); - resource_saver_png.unref(); } void register_driver_types() { diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 73d8bb0..ccdaaf2 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -93,7 +93,7 @@ if env["builtin_freetype"]: # Also requires libpng headers if env["builtin_libpng"]: - env_freetype.Prepend(CPPPATH=["#thirdparty/libpng"]) + env_freetype.Prepend(CPPPATH=["#modules/png/libpng"]) sfnt = thirdparty_dir + "src/sfnt/sfnt.c" # Must be done after all CPPDEFINES are being set so we can copy them. diff --git a/modules/freetype/config.py b/modules/freetype/config.py index c6f699c..3188dd4 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -1,5 +1,7 @@ def can_build(env, platform): + env.module_add_dependencies("freetype", ["png"], False) + return True diff --git a/drivers/png/SCsub b/modules/png/SCsub similarity index 93% rename from drivers/png/SCsub rename to modules/png/SCsub index fa5e4bc..bb658c3 100644 --- a/drivers/png/SCsub +++ b/modules/png/SCsub @@ -1,8 +1,9 @@ #!/usr/bin/env python Import("env") +Import("env_modules") -env_png = env.Clone() +env_png = env_modules.Clone() # Thirdparty source files @@ -57,7 +58,7 @@ if env["builtin_libpng"]: neon_sources.append(env_neon.Object(thirdparty_dir + "/arm/palette_neon_intrinsics.c")) thirdparty_obj += neon_sources - env.drivers_sources += thirdparty_obj + env.modules_sources += thirdparty_obj # Pandemonium source files @@ -65,7 +66,7 @@ if env["builtin_libpng"]: driver_obj = [] env_png.add_source_files(driver_obj, "*.cpp") -env.drivers_sources += driver_obj +env.modules_sources += driver_obj # Needed to force rebuilding the driver files when the thirdparty library is updated. env.Depends(driver_obj, thirdparty_obj) diff --git a/modules/png/config.py b/modules/png/config.py new file mode 100644 index 0000000..d22f945 --- /dev/null +++ b/modules/png/config.py @@ -0,0 +1,6 @@ +def can_build(env, platform): + return True + + +def configure(env): + pass diff --git a/drivers/png/image_loader_png.cpp b/modules/png/image_loader_png.cpp similarity index 99% rename from drivers/png/image_loader_png.cpp rename to modules/png/image_loader_png.cpp index 72c4dcc..4c9b75f 100644 --- a/drivers/png/image_loader_png.cpp +++ b/modules/png/image_loader_png.cpp @@ -32,7 +32,7 @@ #include "core/os/os.h" #include "core/string/print_string.h" -#include "drivers/png/png_driver_common.h" +#include "png_driver_common.h" #include diff --git a/drivers/png/image_loader_png.h b/modules/png/image_loader_png.h similarity index 100% rename from drivers/png/image_loader_png.h rename to modules/png/image_loader_png.h diff --git a/drivers/png/libpng/LICENSE b/modules/png/libpng/LICENSE similarity index 100% rename from drivers/png/libpng/LICENSE rename to modules/png/libpng/LICENSE diff --git a/drivers/png/libpng/arm/arm_init.c b/modules/png/libpng/arm/arm_init.c similarity index 100% rename from drivers/png/libpng/arm/arm_init.c rename to modules/png/libpng/arm/arm_init.c diff --git a/drivers/png/libpng/arm/filter_neon.S b/modules/png/libpng/arm/filter_neon.S similarity index 100% rename from drivers/png/libpng/arm/filter_neon.S rename to modules/png/libpng/arm/filter_neon.S diff --git a/drivers/png/libpng/arm/filter_neon_intrinsics.c b/modules/png/libpng/arm/filter_neon_intrinsics.c similarity index 100% rename from drivers/png/libpng/arm/filter_neon_intrinsics.c rename to modules/png/libpng/arm/filter_neon_intrinsics.c diff --git a/drivers/png/libpng/arm/palette_neon_intrinsics.c b/modules/png/libpng/arm/palette_neon_intrinsics.c similarity index 100% rename from drivers/png/libpng/arm/palette_neon_intrinsics.c rename to modules/png/libpng/arm/palette_neon_intrinsics.c diff --git a/drivers/png/libpng/png.c b/modules/png/libpng/png.c similarity index 100% rename from drivers/png/libpng/png.c rename to modules/png/libpng/png.c diff --git a/drivers/png/libpng/png.h b/modules/png/libpng/png.h similarity index 100% rename from drivers/png/libpng/png.h rename to modules/png/libpng/png.h diff --git a/drivers/png/libpng/pngconf.h b/modules/png/libpng/pngconf.h similarity index 100% rename from drivers/png/libpng/pngconf.h rename to modules/png/libpng/pngconf.h diff --git a/drivers/png/libpng/pngdebug.h b/modules/png/libpng/pngdebug.h similarity index 100% rename from drivers/png/libpng/pngdebug.h rename to modules/png/libpng/pngdebug.h diff --git a/drivers/png/libpng/pngerror.c b/modules/png/libpng/pngerror.c similarity index 100% rename from drivers/png/libpng/pngerror.c rename to modules/png/libpng/pngerror.c diff --git a/drivers/png/libpng/pngget.c b/modules/png/libpng/pngget.c similarity index 100% rename from drivers/png/libpng/pngget.c rename to modules/png/libpng/pngget.c diff --git a/drivers/png/libpng/pnginfo.h b/modules/png/libpng/pnginfo.h similarity index 100% rename from drivers/png/libpng/pnginfo.h rename to modules/png/libpng/pnginfo.h diff --git a/drivers/png/libpng/pnglibconf.h b/modules/png/libpng/pnglibconf.h similarity index 100% rename from drivers/png/libpng/pnglibconf.h rename to modules/png/libpng/pnglibconf.h diff --git a/drivers/png/libpng/pngmem.c b/modules/png/libpng/pngmem.c similarity index 100% rename from drivers/png/libpng/pngmem.c rename to modules/png/libpng/pngmem.c diff --git a/drivers/png/libpng/pngpread.c b/modules/png/libpng/pngpread.c similarity index 100% rename from drivers/png/libpng/pngpread.c rename to modules/png/libpng/pngpread.c diff --git a/drivers/png/libpng/pngpriv.h b/modules/png/libpng/pngpriv.h similarity index 100% rename from drivers/png/libpng/pngpriv.h rename to modules/png/libpng/pngpriv.h diff --git a/drivers/png/libpng/pngread.c b/modules/png/libpng/pngread.c similarity index 100% rename from drivers/png/libpng/pngread.c rename to modules/png/libpng/pngread.c diff --git a/drivers/png/libpng/pngrio.c b/modules/png/libpng/pngrio.c similarity index 100% rename from drivers/png/libpng/pngrio.c rename to modules/png/libpng/pngrio.c diff --git a/drivers/png/libpng/pngrtran.c b/modules/png/libpng/pngrtran.c similarity index 100% rename from drivers/png/libpng/pngrtran.c rename to modules/png/libpng/pngrtran.c diff --git a/drivers/png/libpng/pngrutil.c b/modules/png/libpng/pngrutil.c similarity index 100% rename from drivers/png/libpng/pngrutil.c rename to modules/png/libpng/pngrutil.c diff --git a/drivers/png/libpng/pngset.c b/modules/png/libpng/pngset.c similarity index 100% rename from drivers/png/libpng/pngset.c rename to modules/png/libpng/pngset.c diff --git a/drivers/png/libpng/pngstruct.h b/modules/png/libpng/pngstruct.h similarity index 100% rename from drivers/png/libpng/pngstruct.h rename to modules/png/libpng/pngstruct.h diff --git a/drivers/png/libpng/pngtrans.c b/modules/png/libpng/pngtrans.c similarity index 100% rename from drivers/png/libpng/pngtrans.c rename to modules/png/libpng/pngtrans.c diff --git a/drivers/png/libpng/pngwio.c b/modules/png/libpng/pngwio.c similarity index 100% rename from drivers/png/libpng/pngwio.c rename to modules/png/libpng/pngwio.c diff --git a/drivers/png/libpng/pngwrite.c b/modules/png/libpng/pngwrite.c similarity index 100% rename from drivers/png/libpng/pngwrite.c rename to modules/png/libpng/pngwrite.c diff --git a/drivers/png/libpng/pngwtran.c b/modules/png/libpng/pngwtran.c similarity index 100% rename from drivers/png/libpng/pngwtran.c rename to modules/png/libpng/pngwtran.c diff --git a/drivers/png/libpng/pngwutil.c b/modules/png/libpng/pngwutil.c similarity index 100% rename from drivers/png/libpng/pngwutil.c rename to modules/png/libpng/pngwutil.c diff --git a/drivers/png/png_driver_common.cpp b/modules/png/png_driver_common.cpp similarity index 100% rename from drivers/png/png_driver_common.cpp rename to modules/png/png_driver_common.cpp diff --git a/drivers/png/png_driver_common.h b/modules/png/png_driver_common.h similarity index 100% rename from drivers/png/png_driver_common.h rename to modules/png/png_driver_common.h diff --git a/modules/png/register_types.cpp b/modules/png/register_types.cpp new file mode 100644 index 0000000..1b40577 --- /dev/null +++ b/modules/png/register_types.cpp @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "register_types.h" + +#include "image_loader_png.h" +#include "resource_saver_png.h" + +static ImageLoaderPNG *image_loader_png = NULL; +static Ref resource_saver_png; + +void register_png_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_CORE) { + image_loader_png = memnew(ImageLoaderPNG); + ImageLoader::add_image_format_loader(image_loader_png); + + resource_saver_png.instance(); + ResourceSaver::add_resource_format_saver(resource_saver_png); + } +} + +void unregister_png_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_CORE) { + if (image_loader_png) { + memdelete(image_loader_png); + } + + ResourceSaver::remove_resource_format_saver(resource_saver_png); + resource_saver_png.unref(); + } +} diff --git a/modules/png/register_types.h b/modules/png/register_types.h new file mode 100644 index 0000000..08d21d9 --- /dev/null +++ b/modules/png/register_types.h @@ -0,0 +1,38 @@ +#ifndef PNG_REGISTER_TYPES_H +#define PNG_REGISTER_TYPES_H +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "modules/register_module_types.h" + +void register_png_types(ModuleRegistrationLevel p_level); +void unregister_png_types(ModuleRegistrationLevel p_level); + +#endif // BMP_REGISTER_TYPES_H diff --git a/drivers/png/resource_saver_png.cpp b/modules/png/resource_saver_png.cpp similarity index 98% rename from drivers/png/resource_saver_png.cpp rename to modules/png/resource_saver_png.cpp index e51a127..f4d5e63 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/modules/png/resource_saver_png.cpp @@ -32,7 +32,7 @@ #include "core/io/image.h" #include "core/os/file_access.h" -#include "drivers/png/png_driver_common.h" +#include "png_driver_common.h" #include "scene/resources/texture.h" Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { diff --git a/drivers/png/resource_saver_png.h b/modules/png/resource_saver_png.h similarity index 100% rename from drivers/png/resource_saver_png.h rename to modules/png/resource_saver_png.h