diff --git a/SConstruct b/SConstruct index 730af41545f..acc6c2e248a 100644 --- a/SConstruct +++ b/SConstruct @@ -127,7 +127,7 @@ opts.Add('theora','Theora Video (yes/no)','yes') opts.Add('theoralib','Theora Video (yes/no)','no') opts.Add('freetype','Freetype support in editor','builtin') opts.Add('xml','XML Save/Load support (yes/no)','yes') -opts.Add('png','PNG Image loader support (yes/no)','yes') +opts.Add('libpng','libpng library for image loader support (system/builtin)','builtin') opts.Add('jpg','JPG Image loader support (yes/no)','yes') opts.Add('webp','WEBP Image loader support (yes/no)','yes') opts.Add('dds','DDS Texture loader support (yes/no)','yes') @@ -350,8 +350,6 @@ if selected_platform in platform_list: if (env['theoralib']=='yes'): env.Append(CPPFLAGS=['-DTHEORALIB_ENABLED']); - if (env['png']=='yes'): - env.Append(CPPFLAGS=['-DPNG_ENABLED']); if (env['dds']=='yes'): env.Append(CPPFLAGS=['-DDDS_ENABLED']); if (env['pvr']=='yes'): diff --git a/drivers/SCsub b/drivers/SCsub index 5d3c0712965..3fd1bcd00df 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -26,8 +26,7 @@ if (env['openssl']!='no'): SConscript('openssl/SCsub') -if (env["png"]=="yes"): - SConscript("png/SCsub"); +SConscript("png/SCsub"); if (env["jpg"]=="yes"): #SConscript("jpg/SCsub"); SConscript("jpegd/SCsub"); diff --git a/drivers/png/SCsub b/drivers/png/SCsub index 96ef9fa5f87..ea2324c0cfd 100644 --- a/drivers/png/SCsub +++ b/drivers/png/SCsub @@ -1,42 +1,49 @@ Import('env') Import('env_drivers') +# Thirdparty source files -png_sources = [ - "png/png.c", - "png/pngerror.c", - "png/pngget.c", - "png/pngmem.c", - "png/pngpread.c", - "png/pngread.c", - "png/pngrio.c", - "png/pngrtran.c", - "png/pngrutil.c", - "png/pngset.c", - "png/pngtrans.c", - "png/pngwio.c", - "png/pngwrite.c", - "png/pngwtran.c", - "png/pngwutil.c", - "png/resource_saver_png.cpp", - "png/image_loader_png.cpp" -] +if (env["libpng"] == "builtin"): + thirdparty_dir = "#thirdparty/libpng/" + thirdparty_png_sources = [ + thirdparty_dir + "png.c", + thirdparty_dir + "pngerror.c", + thirdparty_dir + "pngget.c", + thirdparty_dir + "pngmem.c", + thirdparty_dir + "pngpread.c", + thirdparty_dir + "pngread.c", + thirdparty_dir + "pngrio.c", + thirdparty_dir + "pngrtran.c", + thirdparty_dir + "pngrutil.c", + thirdparty_dir + "pngset.c", + thirdparty_dir + "pngtrans.c", + thirdparty_dir + "pngwio.c", + thirdparty_dir + "pngwrite.c", + thirdparty_dir + "pngwtran.c", + thirdparty_dir + "pngwutil.c", + ] -# Currently .ASM filter_neon.S does not compile on NT. -import os -if ("neon_enabled" in env and env["neon_enabled"]) and os.name!="nt": - env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"]) - env_neon = env_drivers.Clone(); - if "S_compiler" in env: - env_neon['CC'] = env['S_compiler'] - #env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"]) - png_sources.append(env_neon.Object("#drivers/png/arm/arm_init.c")) - png_sources.append(env_neon.Object("#drivers/png/arm/filter_neon.S")) -else: - env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"]) + # Currently .ASM filter_neon.S does not compile on NT. + import os + if ("neon_enabled" in env and env["neon_enabled"]) and os.name!="nt": + env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=2"]) + env_neon = env_drivers.Clone(); + if "S_compiler" in env: + env_neon['CC'] = env['S_compiler'] + #env_neon.Append(CPPFLAGS=["-DPNG_ARM_NEON"]) + thirdparty_png_sources.append(env_neon.Object(thirdparty_dir + "/arm/arm_init.c")) + thirdparty_png_sources.append(env_neon.Object(thirdparty_dir + "/arm/filter_neon.S")) + else: + env_drivers.Append(CPPFLAGS=["-DPNG_ARM_NEON_OPT=0"]) -env.drivers_sources+=png_sources + #env_drivers.add_source_files(env.drivers_sources, thirdparty_png_sources) + env.drivers_sources += thirdparty_png_sources # Concatenation necessary for neon objects it seems? + env_drivers.Append(CPPPATH = [thirdparty_dir]) -#env.add_source_files(env.drivers_sources, png_sources) +# Godot's own source files + +env_drivers.add_source_files(env.drivers_sources, "*.cpp") + +Export('env_drivers') Export('env') diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 4967b0f9dfb..ab3f3e78fc0 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -30,6 +30,7 @@ #include "print_string.h" #include "os/os.h" + #include diff --git a/drivers/png/image_loader_png.h b/drivers/png/image_loader_png.h index d87d67d8985..c146e3f5a16 100644 --- a/drivers/png/image_loader_png.h +++ b/drivers/png/image_loader_png.h @@ -30,7 +30,8 @@ #define IMAGE_LOADER_PNG_H #include "io/image_loader.h" -#include "drivers/png/png.h" + +#include /** @author Juan Linietsky diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 2578fe9eb68..e7987f27bf4 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -27,11 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_saver_png.h" -#include "scene/resources/texture.h" -#include "drivers/png/png.h" -#include "os/file_access.h" -#include "globals.h" + #include "core/image.h" +#include "globals.h" +#include "os/file_access.h" +#include "scene/resources/texture.h" + +#include static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) { diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index ec02b7da8ed..89ec468442e 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -29,8 +29,8 @@ #include "register_driver_types.h" #include "png/image_loader_png.h" -#include "webp/image_loader_webp.h" #include "png/resource_saver_png.h" +#include "webp/image_loader_webp.h" #include "jpegd/image_loader_jpegd.h" #include "dds/texture_loader_dds.h" #include "etc1/texture_loader_pkm.h" @@ -75,14 +75,11 @@ #include "mpc/audio_stream_mpc.h" #endif -#ifdef PNG_ENABLED static ImageLoaderPNG *image_loader_png=NULL; static ResourceSaverPNG *resource_saver_png=NULL; -#endif #ifdef WEBP_ENABLED static ImageLoaderWEBP *image_loader_webp=NULL; -//static ResourceSaverPNG *resource_saver_png=NULL; #endif #ifdef JPG_ENABLED @@ -132,22 +129,15 @@ static ResourceFormatPBM * pbm_loader=NULL; void register_core_driver_types() { -#ifdef PNG_ENABLED image_loader_png = memnew( ImageLoaderPNG ); ImageLoader::add_image_format_loader( image_loader_png ); resource_saver_png = memnew( ResourceSaverPNG ); ResourceSaver::add_resource_format_saver(resource_saver_png); -#endif - #ifdef WEBP_ENABLED image_loader_webp = memnew( ImageLoaderWEBP ); ImageLoader::add_image_format_loader( image_loader_webp ); - -// resource_saver_png = memnew( ResourceSaverPNG ); -// ResourceSaver::add_resource_format_saver(resource_saver_png); - #endif #ifdef JPG_ENABLED @@ -165,18 +155,14 @@ void register_core_driver_types() { void unregister_core_driver_types() { -#ifdef PNG_ENABLED if (image_loader_png) memdelete( image_loader_png ); if (resource_saver_png) memdelete( resource_saver_png ); -#endif #ifdef WEBP_ENABLED if (image_loader_webp) memdelete( image_loader_webp ); -// if (resource_saver_png) -// memdelete( resource_saver_png ); #endif #ifdef JPG_ENABLED diff --git a/platform/x11/detect.py b/platform/x11/detect.py index ba232f6d4e7..98774e85554 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -71,10 +71,10 @@ def get_flags(): ('builtin_zlib', 'no'), ('glew', 'yes'), ("openssl", "yes"), - ('freetype','yes'), #use system freetype - + ('freetype','yes'), # use system freetype + ('libpng', 'system'), #("theora","no"), - ] + ] @@ -143,6 +143,8 @@ def configure(env): if (env["openssl"]=="yes"): env.ParseConfig('pkg-config openssl --cflags --libs') + if (env["libpng"] == "system"): + env.ParseConfig('pkg-config libpng --cflags --libs') if (env["freetype"]=="yes"): env.ParseConfig('pkg-config freetype2 --cflags --libs') diff --git a/thirdparty/README.md b/thirdparty/README.md new file mode 100644 index 00000000000..55d89810db9 --- /dev/null +++ b/thirdparty/README.md @@ -0,0 +1,16 @@ +# Third party libraries + + +## libpng + +- Upstream: http://libpng.org/pub/png/libpng.html +- Version: 1.6.23 +- License: libpng/zlib + +Files extracted from upstream source: + +- all .c and .h files of the main directory, except from: + * example.c + * pngtest.c +- the arm/ folder +- scripts/pnglibconf.h.prebuilt as pnglibconf.h diff --git a/thirdparty/libpng/LICENSE b/thirdparty/libpng/LICENSE new file mode 100644 index 00000000000..b7ad4b9eaf3 --- /dev/null +++ b/thirdparty/libpng/LICENSE @@ -0,0 +1,130 @@ + +This copy of the libpng notices is provided for your convenience. In case of +any discrepancy between this copy and the notices in the file png.h that is +included in the libpng distribution, the latter shall prevail. + +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + +If you modify libpng you may insert additional notices immediately following +this sentence. + +This code is released under the libpng license. + +libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are +Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of the + library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is with + the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners and +are released under other open source licenses. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the list +of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners +but are released under this license. + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing Authors +and Group 42, Inc. disclaim all warranties, expressed or implied, +including, without limitation, the warranties of merchantability and of +fitness for any purpose. The Contributing Authors and Group 42, Inc. +assume no liability for direct, indirect, incidental, special, exemplary, +or consequential damages, which may result from the use of the PNG +Reference Library, even if advised of the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + + 1. The origin of this source code must not be misrepresented. + + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, without +fee, and encourage the use of this source code as a component to +supporting the PNG file format in commercial products. If you use this +source code in a product, acknowledgment is not required but would be +appreciated. + +END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. + +TRADEMARK: + +The name "libpng" has not been registered by the Copyright owner +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owner claims "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. + +OSI CERTIFICATION: + +Libpng is OSI Certified Open Source Software. OSI Certified Open Source is +a certification mark of the Open Source Initiative. OSI has not addressed +the additional disclaimers inserted at version 1.0.7. + +EXPORT CONTROL: + +The Copyright owner believes that the Export Control Classification +Number (ECCN) for libpng is EAR99, which means not subject to export +controls or International Traffic in Arms Regulations (ITAR) because +it is open source, publicly available software, that does not contain +any encryption software. See the EAR, paragraphs 734.3(b)(3) and +734.7(b). + +Glenn Randers-Pehrson +glennrp at users.sourceforge.net +June 9, 2016 diff --git a/drivers/png/arm/arm_init.c b/thirdparty/libpng/arm/arm_init.c similarity index 100% rename from drivers/png/arm/arm_init.c rename to thirdparty/libpng/arm/arm_init.c diff --git a/drivers/png/arm/filter_neon.S b/thirdparty/libpng/arm/filter_neon.S similarity index 100% rename from drivers/png/arm/filter_neon.S rename to thirdparty/libpng/arm/filter_neon.S diff --git a/drivers/png/arm/filter_neon_intrinsics.c b/thirdparty/libpng/arm/filter_neon_intrinsics.c similarity index 100% rename from drivers/png/arm/filter_neon_intrinsics.c rename to thirdparty/libpng/arm/filter_neon_intrinsics.c diff --git a/drivers/png/png.c b/thirdparty/libpng/png.c similarity index 100% rename from drivers/png/png.c rename to thirdparty/libpng/png.c diff --git a/drivers/png/png.h b/thirdparty/libpng/png.h similarity index 100% rename from drivers/png/png.h rename to thirdparty/libpng/png.h diff --git a/drivers/png/pngconf.h b/thirdparty/libpng/pngconf.h similarity index 100% rename from drivers/png/pngconf.h rename to thirdparty/libpng/pngconf.h diff --git a/drivers/png/pngdebug.h b/thirdparty/libpng/pngdebug.h similarity index 100% rename from drivers/png/pngdebug.h rename to thirdparty/libpng/pngdebug.h diff --git a/drivers/png/pngerror.c b/thirdparty/libpng/pngerror.c similarity index 100% rename from drivers/png/pngerror.c rename to thirdparty/libpng/pngerror.c diff --git a/drivers/png/pngget.c b/thirdparty/libpng/pngget.c similarity index 100% rename from drivers/png/pngget.c rename to thirdparty/libpng/pngget.c diff --git a/drivers/png/pnginfo.h b/thirdparty/libpng/pnginfo.h similarity index 100% rename from drivers/png/pnginfo.h rename to thirdparty/libpng/pnginfo.h diff --git a/drivers/png/pnglibconf.h b/thirdparty/libpng/pnglibconf.h similarity index 100% rename from drivers/png/pnglibconf.h rename to thirdparty/libpng/pnglibconf.h diff --git a/drivers/png/pngmem.c b/thirdparty/libpng/pngmem.c similarity index 100% rename from drivers/png/pngmem.c rename to thirdparty/libpng/pngmem.c diff --git a/drivers/png/pngpread.c b/thirdparty/libpng/pngpread.c similarity index 100% rename from drivers/png/pngpread.c rename to thirdparty/libpng/pngpread.c diff --git a/drivers/png/pngpriv.h b/thirdparty/libpng/pngpriv.h similarity index 100% rename from drivers/png/pngpriv.h rename to thirdparty/libpng/pngpriv.h diff --git a/drivers/png/pngread.c b/thirdparty/libpng/pngread.c similarity index 100% rename from drivers/png/pngread.c rename to thirdparty/libpng/pngread.c diff --git a/drivers/png/pngrio.c b/thirdparty/libpng/pngrio.c similarity index 100% rename from drivers/png/pngrio.c rename to thirdparty/libpng/pngrio.c diff --git a/drivers/png/pngrtran.c b/thirdparty/libpng/pngrtran.c similarity index 100% rename from drivers/png/pngrtran.c rename to thirdparty/libpng/pngrtran.c diff --git a/drivers/png/pngrutil.c b/thirdparty/libpng/pngrutil.c similarity index 100% rename from drivers/png/pngrutil.c rename to thirdparty/libpng/pngrutil.c diff --git a/drivers/png/pngset.c b/thirdparty/libpng/pngset.c similarity index 100% rename from drivers/png/pngset.c rename to thirdparty/libpng/pngset.c diff --git a/drivers/png/pngstruct.h b/thirdparty/libpng/pngstruct.h similarity index 100% rename from drivers/png/pngstruct.h rename to thirdparty/libpng/pngstruct.h diff --git a/drivers/png/pngtrans.c b/thirdparty/libpng/pngtrans.c similarity index 100% rename from drivers/png/pngtrans.c rename to thirdparty/libpng/pngtrans.c diff --git a/drivers/png/pngwio.c b/thirdparty/libpng/pngwio.c similarity index 100% rename from drivers/png/pngwio.c rename to thirdparty/libpng/pngwio.c diff --git a/drivers/png/pngwrite.c b/thirdparty/libpng/pngwrite.c similarity index 100% rename from drivers/png/pngwrite.c rename to thirdparty/libpng/pngwrite.c diff --git a/drivers/png/pngwtran.c b/thirdparty/libpng/pngwtran.c similarity index 100% rename from drivers/png/pngwtran.c rename to thirdparty/libpng/pngwtran.c diff --git a/drivers/png/pngwutil.c b/thirdparty/libpng/pngwutil.c similarity index 100% rename from drivers/png/pngwutil.c rename to thirdparty/libpng/pngwutil.c