png: Split library to thirdparty dir and allow unbundling
Uses the new structure agreed upon in #6157, but the thirdparty/ folder
does not behave following a logic similar to that of modules/ yet.
The png driver can't be moved to a module as discussed in #6157, as it's
required by core together with a few other ImageLoader implementations
(see drivers/register_driver_types.cpp:register_core_driver_types())
Dropped the possibility to disable PNG support, it's a core component
of Godot.
(cherry picked from commit 5fef84a135
)
This commit is contained in:
parent
846db09038
commit
575e986bde
35 changed files with 203 additions and 61 deletions
|
@ -129,7 +129,7 @@ opts.Add('theoralib','Theora Video (yes/no)','no')
|
|||
opts.Add('freetype','Freetype support in editor','builtin')
|
||||
opts.Add('speex','Speex Audio (yes/no)','yes')
|
||||
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')
|
||||
|
@ -352,8 +352,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'):
|
||||
|
|
3
drivers/SCsub
vendored
3
drivers/SCsub
vendored
|
@ -25,8 +25,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");
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "print_string.h"
|
||||
#include "os/os.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#define IMAGE_LOADER_PNG_H
|
||||
|
||||
#include "io/image_loader.h"
|
||||
#include "drivers/png/png.h"
|
||||
|
||||
#include <png.h>
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
|
|
|
@ -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 <png.h>
|
||||
|
||||
static void _write_png_data(png_structp png_ptr,png_bytep data, png_size_t p_length) {
|
||||
|
||||
|
|
16
drivers/register_driver_types.cpp
vendored
16
drivers/register_driver_types.cpp
vendored
|
@ -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"
|
||||
|
@ -79,14 +79,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
|
||||
|
@ -140,22 +137,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
|
||||
|
@ -173,18 +163,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
|
||||
|
|
|
@ -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')
|
||||
|
|
16
thirdparty/README.md
vendored
Normal file
16
thirdparty/README.md
vendored
Normal file
|
@ -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
|
130
thirdparty/libpng/LICENSE
vendored
Normal file
130
thirdparty/libpng/LICENSE
vendored
Normal file
|
@ -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
|
0
drivers/png/png.c → thirdparty/libpng/png.c
vendored
0
drivers/png/png.c → thirdparty/libpng/png.c
vendored
0
drivers/png/png.h → thirdparty/libpng/png.h
vendored
0
drivers/png/png.h → thirdparty/libpng/png.h
vendored
Loading…
Reference in a new issue