squish: Move to a module and split thirdparty lib

This commit is contained in:
Rémi Verschelde 2016-10-13 21:48:06 +02:00
parent 8981ff8a84
commit 8311a78df5
37 changed files with 144 additions and 60 deletions

View File

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

2
drivers/SCsub vendored
View File

@ -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");

View File

@ -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();
}

View File

@ -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
modules/squish/SCsub Normal file
View File

@ -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
modules/squish/config.py Normal file
View File

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

View File

@ -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);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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
thirdparty/README.md vendored
View File

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

View File

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

View File

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

View File

@ -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"

View File

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

View File

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

View File

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

View File

@ -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"

View File

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

View File

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

View File

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