From b07f8a55d461d0282a4a1dfb174adaecf91cfec9 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 19 Dec 2015 19:49:45 +0100 Subject: [PATCH] libtxc_dxtn: stop depending on libstdc++. --- Makefile.am | 2 +- configure.ac | 4 ++++ s2tc_algorithm.cpp | 30 ++++++++++++------------------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Makefile.am b/Makefile.am index 14aacd2..e6853e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ endif if ENABLE_LIB lib_LTLIBRARIES = libtxc_dxtn.la libtxc_dxtn_la_SOURCES = s2tc_algorithm.cpp s2tc_libtxc_dxtn.cpp s2tc_common.h s2tc_algorithm.h txc_dxtn.h s2tc_license.h -libtxc_dxtn_la_LDFLAGS = -versioninfo 0:0:0 +libtxc_dxtn_la_LDFLAGS = -versioninfo 0:0:0 -nodefaultlibs libtxc_dxtn_la_LIBADD = -lm libtxc_dxtn_la_CFLAGS = -fvisibility=hidden -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement library_includedir = $(includedir) diff --git a/configure.ac b/configure.ac index 906eaca..ff27b6f 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AM_INIT_AUTOMAKE([-Wall foreign]) have_CXXFLAGS=${CXXFLAGS+set} AC_PROG_CXX +AM_PROG_AR # better default optimization flags for g++, please if test "$have_CXXFLAGS" != set; then if test "$GXX" = yes; then @@ -13,6 +14,9 @@ fi AC_PROG_LIBTOOL +# Disable dependency on libstdc++ for the .so library. +postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ , ,g'` + AC_ARG_ENABLE(runtime-linking, AS_HELP_STRING([--disable-runtime-linking], [Do not load the library at runtime (faster startup, more dependencies)]), [enable_runtime_linking=$enableval], [enable_runtime_linking=yes]) AC_ARG_ENABLE(tools, AS_HELP_STRING([--disable-tools], [Do not build the s2tc_compress and s2_decompress tools]), [enable_tools=$enableval], [enable_tools=yes]) AC_ARG_ENABLE(lib, AS_HELP_STRING([--disable-lib], [Do not build the included libtxc_dxtn library for S2TC]), [enable_lib=$enableval], [enable_lib=yes]) diff --git a/s2tc_algorithm.cpp b/s2tc_algorithm.cpp index e48977d..42238f2 100644 --- a/s2tc_algorithm.cpp +++ b/s2tc_algorithm.cpp @@ -26,14 +26,18 @@ #include #include #include -#include -#include #include "s2tc_algorithm.h" #include "s2tc_common.h" namespace { + template void swap(T& a, T& b) + { + T h = a; + a = b; + b = h; + } template struct color_type_info { }; @@ -204,16 +208,6 @@ namespace } }; - std::ostream &operator<<(std::ostream &ost, const color_t &c) - { - return ost << "make_color_t(" << int(c.r) << ", " << int(c.g) << ", " << int(c.b) << ")"; - } - - std::ostream &operator<<(std::ostream &ost, const bigcolor_t &c) - { - return ost << "bigcolor_t(" << c.r << ", " << c.g << ", " << c.b << ")"; - } - // 16 differences must fit in int // i.e. a difference must be lower than 2^27 @@ -692,7 +686,7 @@ namespace if(a1 < a0) { - std::swap(a0, a1); + swap(a0, a1); for(int i = 0; i < 16; ++i) switch(out.get(i)) { case 0: @@ -738,7 +732,7 @@ namespace if(a1 < a0) { - std::swap(a0, a1); + swap(a0, a1); for(int i = 0; i < 16; ++i) switch(out.get(i)) { case 0: @@ -761,7 +755,7 @@ namespace inline void s2tc_dxt5_encode_alpha_refine_never(bitarray &out, const unsigned char *in, int iw, int w, int h, unsigned char &a0, unsigned char &a1) { if(a1 < a0) - std::swap(a0, a1); + swap(a0, a1); unsigned char ramp[6] = { a0, a1 @@ -812,7 +806,7 @@ namespace if(have_trans ? c1 < c0 : c0 < c1) { - std::swap(c0, c1); + swap(c0, c1); for(int i = 0; i < 16; ++i) if(!(out.get(i) & 2)) out.do_xor(i, 1); @@ -844,7 +838,7 @@ namespace if(have_trans ? c1 < c0 : c0 < c1) { - std::swap(c0, c1); + swap(c0, c1); for(int i = 0; i < 16; ++i) if(!(out.get(i) & 2)) out.do_xor(i, 1); @@ -856,7 +850,7 @@ namespace inline void s2tc_dxt1_encode_color_refine_never(bitarray &out, const unsigned char *in, int iw, int w, int h, color_t &c0, color_t &c1) { if(have_trans ? c1 < c0 : c0 < c1) - std::swap(c0, c1); + swap(c0, c1); color_t ramp[2] = { c0, c1 -- 2.11.0