diff --git a/SConstruct b/SConstruct index 66c066b141f..c2fba48f919 100644 --- a/SConstruct +++ b/SConstruct @@ -124,7 +124,7 @@ opts.Add('libvorbis','Ogg Vorbis library for vorbis support (system/builtin)','b opts.Add('libtheora','Theora library for theora module (system/builtin)','builtin') opts.Add('opus','Opus and opusfile library for Opus format support: (system/builtin)','builtin') opts.Add('minizip','Build Minizip Archive Support: (yes/no)','yes') -opts.Add('squish','Squish BC Texture Compression in editor (yes/no)','yes') +opts.Add('squish','Squish library for BC Texture Compression in editor (system/builtin)','builtin') opts.Add('freetype','Freetype support in editor','builtin') opts.Add('xml','XML Save/Load support (yes/no)','yes') opts.Add('libpng','libpng library for image loader support (system/builtin)','builtin') @@ -324,9 +324,6 @@ if selected_platform in platform_list: # to test 64 bits compiltion # env.Append(CPPFLAGS=['-m64']) - if (env_base['squish']=='yes'): - env.Append(CPPFLAGS=['-DSQUISH_ENABLED']); - if (env['tools']=='yes'): env.Append(CPPFLAGS=['-DTOOLS_ENABLED']) if (env['disable_3d']=='yes'): diff --git a/drivers/SCsub b/drivers/SCsub index 8538f2745d2..bc0d948f41b 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -25,8 +25,6 @@ SConscript("chibi/SCsub"); if (env["tools"]=="yes"): SConscript("convex_decomp/SCsub"); -if (env["squish"]=="yes" and env["tools"]=="yes"): - SConscript("squish/SCsub"); if (env["freetype"]!="no"): SConscript("freetype/SCsub"); diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index 1999a9a7c9c..31d53e0185a 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -33,11 +33,6 @@ #include "png/resource_saver_png.h" #include "chibi/event_stream_chibi.h" - -#ifdef TOOLS_ENABLED -#include "squish/image_compress_squish.h" -#endif - #ifdef TOOLS_ENABLED #include "convex_decomp/b2d_decompose.h" #endif @@ -79,14 +74,6 @@ void register_driver_types() { Geometry::_decompose_func=b2d_decompose; #endif -#ifdef TOOLS_ENABLED -#ifdef SQUISH_ENABLED - - Image::set_compress_bc_func(image_compress_squish); - -#endif -#endif - initialize_chibi(); } diff --git a/drivers/squish/SCsub b/drivers/squish/SCsub deleted file mode 100644 index da39dc1ebc0..00000000000 --- a/drivers/squish/SCsub +++ /dev/null @@ -1,23 +0,0 @@ -Import('env') - - -squish_sources=[ -'squish/alpha.cpp', -'squish/clusterfit.cpp', -'squish/colourblock.cpp', -'squish/colourfit.cpp', -'squish/colourset.cpp', -'squish/maths.cpp', -'squish/rangefit.cpp', -'squish/singlecolourfit.cpp', -'squish/squish.cpp', -'squish/image_compress_squish.cpp', -] - - -if (env["tools"]=="yes"): - env.drivers_sources+=squish_sources - -#env.add_source_files(env.drivers_sources, squish_sources) - -Export('env') diff --git a/modules/squish/SCsub b/modules/squish/SCsub new file mode 100644 index 00000000000..072921ef641 --- /dev/null +++ b/modules/squish/SCsub @@ -0,0 +1,27 @@ +Import('env') +Import('env_modules') + +env_squish = env_modules.Clone() + +# Thirdparty source files +if (env["squish"] != "system"): # builtin + thirdparty_dir = "#thirdparty/squish/" + thirdparty_sources = [ + "alpha.cpp", + "clusterfit.cpp", + "colourblock.cpp", + "colourfit.cpp", + "colourset.cpp", + "maths.cpp", + "rangefit.cpp", + "singlecolourfit.cpp", + "squish.cpp", + ] + + thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + + env_squish.add_source_files(env.modules_sources, thirdparty_sources) + env_squish.Append(CPPPATH = [thirdparty_dir]) + +# Godot source files +env_squish.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/squish/config.py b/modules/squish/config.py new file mode 100644 index 00000000000..d28d9c702ef --- /dev/null +++ b/modules/squish/config.py @@ -0,0 +1,10 @@ + +def can_build(platform): + return True + +def configure(env): + # Tools only, disabled for non-tools + # TODO: Find a cleaner way to achieve that + if (env["tools"] == "no"): + env["module_squish_enabled"] = "no" + env.disabled_modules.append("squish") diff --git a/drivers/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp similarity index 99% rename from drivers/squish/image_compress_squish.cpp rename to modules/squish/image_compress_squish.cpp index 95de83d5a5f..ac7c935ceb5 100644 --- a/drivers/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "image_compress_squish.h" -#include "squish/squish.h" + #include "print_string.h" +#include + void image_compress_squish(Image *p_image) { int w=p_image->get_width(); @@ -88,4 +90,3 @@ void image_compress_squish(Image *p_image) { p_image->create(p_image->get_width(),p_image->get_height(),p_image->get_mipmaps(),target_format,data); } - diff --git a/drivers/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h similarity index 99% rename from drivers/squish/image_compress_squish.h rename to modules/squish/image_compress_squish.h index 8c37ac2caa6..19dd9006746 100644 --- a/drivers/squish/image_compress_squish.h +++ b/modules/squish/image_compress_squish.h @@ -29,11 +29,8 @@ #ifndef IMAGE_COMPRESS_SQUISH_H #define IMAGE_COMPRESS_SQUISH_H - #include "image.h" - void image_compress_squish(Image *p_image); - #endif // IMAGE_COMPRESS_SQUISH_H diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp new file mode 100644 index 00000000000..9e9621eb64a --- /dev/null +++ b/modules/squish/register_types.cpp @@ -0,0 +1,42 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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" + +#ifdef TOOLS_ENABLED + +#include "image_compress_squish.h" + +void register_squish_types() { + + Image::set_compress_bc_func(image_compress_squish); +} + +void unregister_squish_types() {} + +#endif diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h new file mode 100644 index 00000000000..bbde6a44bf8 --- /dev/null +++ b/modules/squish/register_types.h @@ -0,0 +1,32 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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. */ +/*************************************************************************/ +#ifdef TOOLS_ENABLED +void register_squish_types(); +void unregister_squish_types(); +#endif diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index fce57acc3be..19427eff148 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -26,8 +26,7 @@ def get_flags(): return [ ('tools', 'no'), - ('squish', 'no'), - ('etc1', 'no'), + ('module_etc1_enabled', 'no'), ('module_mpc_enabled', 'no'), ('module_theora_enabled', 'no'), ] diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 7c22bd97ffd..90122eef4af 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -154,6 +154,9 @@ def configure(env): if (env["enet"] == "system"): env.ParseConfig('pkg-config libenet --cflags --libs') + if (env["squish"] == "system" and env["tools"] == "yes"): + env.ParseConfig('pkg-config libsquish --cflags --libs') + # Sound and video libraries # Keep the order as it triggers chained dependencies (ogg needed by others, etc.) diff --git a/thirdparty/README.md b/thirdparty/README.md index f3a18df668c..a044e6dcdc5 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -158,6 +158,18 @@ Files extracted from upstream source: - RtAudio.{cpp,h} +## squish + +- Upstream: https://code.google.com/archive/p/libsquish + and patches from https://github.com/Cavewhere/squish +- Version: 1.11 +- License: MIT + +Files extracted from upstream source: + +- all .cpp, .h and .inl files + + ## theora - Upstream: https://www.theora.org diff --git a/drivers/squish/alpha.cpp b/thirdparty/squish/alpha.cpp similarity index 99% rename from drivers/squish/alpha.cpp rename to thirdparty/squish/alpha.cpp index 2ddb7dc28b7..2292081e7ad 100644 --- a/drivers/squish/alpha.cpp +++ b/thirdparty/squish/alpha.cpp @@ -24,6 +24,7 @@ -------------------------------------------------------------------------- */ #include "alpha.h" +#include #include namespace squish { @@ -114,7 +115,7 @@ static int FitCodes( u8 const* rgba, int mask, u8 const* codes, u8* indices ) // find the least error and corresponding index int value = rgba[4*i + 3]; - int least = 2147483647; //INT_MAX + int least = INT_MAX; int index = 0; for( int j = 0; j < 8; ++j ) { diff --git a/drivers/squish/alpha.h b/thirdparty/squish/alpha.h similarity index 98% rename from drivers/squish/alpha.h rename to thirdparty/squish/alpha.h index d56fe4d2c65..57360525516 100644 --- a/drivers/squish/alpha.h +++ b/thirdparty/squish/alpha.h @@ -26,7 +26,7 @@ #ifndef SQUISH_ALPHA_H #define SQUISH_ALPHA_H -#include "squish/squish.h" +#include namespace squish { diff --git a/drivers/squish/clusterfit.cpp b/thirdparty/squish/clusterfit.cpp similarity index 100% rename from drivers/squish/clusterfit.cpp rename to thirdparty/squish/clusterfit.cpp diff --git a/drivers/squish/clusterfit.h b/thirdparty/squish/clusterfit.h similarity index 98% rename from drivers/squish/clusterfit.h rename to thirdparty/squish/clusterfit.h index 2d2b67103b9..17db5d387c2 100644 --- a/drivers/squish/clusterfit.h +++ b/thirdparty/squish/clusterfit.h @@ -27,7 +27,7 @@ #ifndef SQUISH_CLUSTERFIT_H #define SQUISH_CLUSTERFIT_H -#include "squish/squish.h" +#include #include "maths.h" #include "simd.h" #include "colourfit.h" diff --git a/drivers/squish/colourblock.cpp b/thirdparty/squish/colourblock.cpp similarity index 100% rename from drivers/squish/colourblock.cpp rename to thirdparty/squish/colourblock.cpp diff --git a/drivers/squish/colourblock.h b/thirdparty/squish/colourblock.h similarity index 98% rename from drivers/squish/colourblock.h rename to thirdparty/squish/colourblock.h index 8a25b42a63c..df0a47217f4 100644 --- a/drivers/squish/colourblock.h +++ b/thirdparty/squish/colourblock.h @@ -26,7 +26,7 @@ #ifndef SQUISH_COLOURBLOCK_H #define SQUISH_COLOURBLOCK_H -#include "squish/squish.h" +#include #include "maths.h" namespace squish { diff --git a/drivers/squish/colourfit.cpp b/thirdparty/squish/colourfit.cpp similarity index 100% rename from drivers/squish/colourfit.cpp rename to thirdparty/squish/colourfit.cpp diff --git a/drivers/squish/colourfit.h b/thirdparty/squish/colourfit.h similarity index 98% rename from drivers/squish/colourfit.h rename to thirdparty/squish/colourfit.h index d048b487092..a2d0559a32c 100644 --- a/drivers/squish/colourfit.h +++ b/thirdparty/squish/colourfit.h @@ -26,7 +26,7 @@ #ifndef SQUISH_COLOURFIT_H #define SQUISH_COLOURFIT_H -#include "squish/squish.h" +#include #include "maths.h" namespace squish { diff --git a/drivers/squish/colourset.cpp b/thirdparty/squish/colourset.cpp similarity index 100% rename from drivers/squish/colourset.cpp rename to thirdparty/squish/colourset.cpp diff --git a/drivers/squish/colourset.h b/thirdparty/squish/colourset.h similarity index 98% rename from drivers/squish/colourset.h rename to thirdparty/squish/colourset.h index 803e787f5b4..dcf56ae28e8 100644 --- a/drivers/squish/colourset.h +++ b/thirdparty/squish/colourset.h @@ -26,7 +26,7 @@ #ifndef SQUISH_COLOURSET_H #define SQUISH_COLOURSET_H -#include "squish/squish.h" +#include #include "maths.h" namespace squish { diff --git a/drivers/squish/config.h b/thirdparty/squish/config.h similarity index 100% rename from drivers/squish/config.h rename to thirdparty/squish/config.h diff --git a/drivers/squish/maths.cpp b/thirdparty/squish/maths.cpp similarity index 100% rename from drivers/squish/maths.cpp rename to thirdparty/squish/maths.cpp diff --git a/drivers/squish/maths.h b/thirdparty/squish/maths.h similarity index 100% rename from drivers/squish/maths.h rename to thirdparty/squish/maths.h diff --git a/drivers/squish/rangefit.cpp b/thirdparty/squish/rangefit.cpp similarity index 100% rename from drivers/squish/rangefit.cpp rename to thirdparty/squish/rangefit.cpp diff --git a/drivers/squish/rangefit.h b/thirdparty/squish/rangefit.h similarity index 98% rename from drivers/squish/rangefit.h rename to thirdparty/squish/rangefit.h index 9d74f9c128d..795201993aa 100644 --- a/drivers/squish/rangefit.h +++ b/thirdparty/squish/rangefit.h @@ -26,7 +26,7 @@ #ifndef SQUISH_RANGEFIT_H #define SQUISH_RANGEFIT_H -#include "squish/squish.h" +#include #include "colourfit.h" #include "maths.h" diff --git a/drivers/squish/simd.h b/thirdparty/squish/simd.h similarity index 100% rename from drivers/squish/simd.h rename to thirdparty/squish/simd.h diff --git a/drivers/squish/simd_float.h b/thirdparty/squish/simd_float.h similarity index 100% rename from drivers/squish/simd_float.h rename to thirdparty/squish/simd_float.h diff --git a/drivers/squish/simd_sse.h b/thirdparty/squish/simd_sse.h similarity index 100% rename from drivers/squish/simd_sse.h rename to thirdparty/squish/simd_sse.h diff --git a/drivers/squish/simd_ve.h b/thirdparty/squish/simd_ve.h similarity index 100% rename from drivers/squish/simd_ve.h rename to thirdparty/squish/simd_ve.h diff --git a/drivers/squish/singlecolourfit.cpp b/thirdparty/squish/singlecolourfit.cpp similarity index 98% rename from drivers/squish/singlecolourfit.cpp rename to thirdparty/squish/singlecolourfit.cpp index ac8be1ad722..bd02cc41abe 100644 --- a/drivers/squish/singlecolourfit.cpp +++ b/thirdparty/squish/singlecolourfit.cpp @@ -26,6 +26,7 @@ #include "singlecolourfit.h" #include "colourset.h" #include "colourblock.h" +#include namespace squish { @@ -68,7 +69,7 @@ SingleColourFit::SingleColourFit( ColourSet const* colours, int flags ) m_colour[2] = ( u8 )FloatToInt( 255.0f*values->Z(), 255 ); // initialise the best error - m_besterror = 2147483647; //INT_MAX + m_besterror = INT_MAX; } void SingleColourFit::Compress3( void* block ) @@ -130,7 +131,7 @@ void SingleColourFit::Compress4( void* block ) void SingleColourFit::ComputeEndPoints( SingleColourLookup const* const* lookups ) { // check each index combination (endpoint or intermediate) - m_error = 2147483647; //INT_MAX + m_error = INT_MAX; for( int index = 0; index < 2; ++index ) { // check the error for this codebook index diff --git a/drivers/squish/singlecolourfit.h b/thirdparty/squish/singlecolourfit.h similarity index 98% rename from drivers/squish/singlecolourfit.h rename to thirdparty/squish/singlecolourfit.h index c8dce2a5a06..0388fda0287 100644 --- a/drivers/squish/singlecolourfit.h +++ b/thirdparty/squish/singlecolourfit.h @@ -26,7 +26,7 @@ #ifndef SQUISH_SINGLECOLOURFIT_H #define SQUISH_SINGLECOLOURFIT_H -#include "squish/squish.h" +#include #include "colourfit.h" namespace squish { diff --git a/drivers/squish/singlecolourlookup.inl b/thirdparty/squish/singlecolourlookup.inl similarity index 100% rename from drivers/squish/singlecolourlookup.inl rename to thirdparty/squish/singlecolourlookup.inl diff --git a/drivers/squish/squish.cpp b/thirdparty/squish/squish.cpp similarity index 99% rename from drivers/squish/squish.cpp rename to thirdparty/squish/squish.cpp index 400a3b0c46e..bbe89bfcfe5 100644 --- a/drivers/squish/squish.cpp +++ b/thirdparty/squish/squish.cpp @@ -23,7 +23,7 @@ -------------------------------------------------------------------------- */ -#include "squish/squish.h" +#include #include "colourset.h" #include "maths.h" #include "rangefit.h" diff --git a/drivers/squish/squish.h b/thirdparty/squish/squish.h similarity index 100% rename from drivers/squish/squish.h rename to thirdparty/squish/squish.h