瀏覽代碼

squish: Move to a module and split thirdparty lib

Rémi Verschelde 9 年之前
父節點
當前提交
8311a78df5

+ 1 - 4
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'):

+ 0 - 2
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");
 

+ 0 - 13
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();
 }
 

+ 0 - 23
drivers/squish/SCsub

@@ -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')

+ 27 - 0
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")

+ 10 - 0
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")

+ 3 - 2
drivers/squish/image_compress_squish.cpp → 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 <squish.h>
+
 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);
 
 }
-

+ 0 - 3
drivers/squish/image_compress_squish.h → 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

+ 42 - 0
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

+ 32 - 0
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

+ 1 - 2
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'),
 	]

+ 3 - 0
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.)
 

+ 12 - 0
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

+ 2 - 1
drivers/squish/alpha.cpp → thirdparty/squish/alpha.cpp

@@ -24,6 +24,7 @@
    -------------------------------------------------------------------------- */
    
 #include "alpha.h"
+#include <climits>
 #include <algorithm>
 
 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 )
 		{

+ 1 - 1
drivers/squish/alpha.h → thirdparty/squish/alpha.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_ALPHA_H
 #define SQUISH_ALPHA_H
 
-#include "squish/squish.h"
+#include <squish.h>
 
 namespace squish {
 

+ 0 - 0
drivers/squish/clusterfit.cpp → thirdparty/squish/clusterfit.cpp


+ 1 - 1
drivers/squish/clusterfit.h → thirdparty/squish/clusterfit.h

@@ -27,7 +27,7 @@
 #ifndef SQUISH_CLUSTERFIT_H
 #define SQUISH_CLUSTERFIT_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "maths.h"
 #include "simd.h"
 #include "colourfit.h"

+ 0 - 0
drivers/squish/colourblock.cpp → thirdparty/squish/colourblock.cpp


+ 1 - 1
drivers/squish/colourblock.h → thirdparty/squish/colourblock.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_COLOURBLOCK_H
 #define SQUISH_COLOURBLOCK_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "maths.h"
 
 namespace squish {

+ 0 - 0
drivers/squish/colourfit.cpp → thirdparty/squish/colourfit.cpp


+ 1 - 1
drivers/squish/colourfit.h → thirdparty/squish/colourfit.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_COLOURFIT_H
 #define SQUISH_COLOURFIT_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "maths.h"
 
 namespace squish {

+ 0 - 0
drivers/squish/colourset.cpp → thirdparty/squish/colourset.cpp


+ 1 - 1
drivers/squish/colourset.h → thirdparty/squish/colourset.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_COLOURSET_H
 #define SQUISH_COLOURSET_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "maths.h"
 
 namespace squish {

+ 0 - 0
drivers/squish/config.h → thirdparty/squish/config.h


+ 0 - 0
drivers/squish/maths.cpp → thirdparty/squish/maths.cpp


+ 0 - 0
drivers/squish/maths.h → thirdparty/squish/maths.h


+ 0 - 0
drivers/squish/rangefit.cpp → thirdparty/squish/rangefit.cpp


+ 1 - 1
drivers/squish/rangefit.h → thirdparty/squish/rangefit.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_RANGEFIT_H
 #define SQUISH_RANGEFIT_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "colourfit.h"
 #include "maths.h"
 

+ 0 - 0
drivers/squish/simd.h → thirdparty/squish/simd.h


+ 0 - 0
drivers/squish/simd_float.h → thirdparty/squish/simd_float.h


+ 0 - 0
drivers/squish/simd_sse.h → thirdparty/squish/simd_sse.h


+ 0 - 0
drivers/squish/simd_ve.h → thirdparty/squish/simd_ve.h


+ 3 - 2
drivers/squish/singlecolourfit.cpp → thirdparty/squish/singlecolourfit.cpp

@@ -26,6 +26,7 @@
 #include "singlecolourfit.h"
 #include "colourset.h"
 #include "colourblock.h"
+#include <climits>
 
 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

+ 1 - 1
drivers/squish/singlecolourfit.h → thirdparty/squish/singlecolourfit.h

@@ -26,7 +26,7 @@
 #ifndef SQUISH_SINGLECOLOURFIT_H
 #define SQUISH_SINGLECOLOURFIT_H
 
-#include "squish/squish.h"
+#include <squish.h>
 #include "colourfit.h"
 
 namespace squish {

+ 0 - 0
drivers/squish/singlecolourlookup.inl → thirdparty/squish/singlecolourlookup.inl


+ 1 - 1
drivers/squish/squish.cpp → thirdparty/squish/squish.cpp

@@ -23,7 +23,7 @@
 	
    -------------------------------------------------------------------------- */
    
-#include "squish/squish.h"
+#include <squish.h>
 #include "colourset.h"
 #include "maths.h"
 #include "rangefit.h"

+ 0 - 0
drivers/squish/squish.h → thirdparty/squish/squish.h