diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-04-26 10:49:08 -0500 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-05-31 18:59:00 -0500 |
commit | 6a9c990da72a737fa95d9e97d53f835706aea7c3 (patch) | |
tree | 0f5c1d36279bef5d0d5c84fc1d3fb24256b65ba8 /core | |
parent | bd26fa7bf2bf02f9ef17ad4ef3a93ffed3ffcf56 (diff) |
Add ETC1/ETC2 compression support though etc2comp.
Remove rg-etc1 code. Also updated travis to use ubuntu 14.04.
Fixes #8457.
Diffstat (limited to 'core')
-rw-r--r-- | core/image.cpp | 22 | ||||
-rw-r--r-- | core/image.h | 8 | ||||
-rw-r--r-- | core/math/math_funcs.h | 17 |
3 files changed, 32 insertions, 15 deletions
diff --git a/core/image.cpp b/core/image.cpp index 2640c6be2a..8d38846a58 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1483,16 +1483,16 @@ Error Image::decompress() { _image_decompress_bc(this); else if (format >= FORMAT_PVRTC2 && format <= FORMAT_PVRTC4A && _image_decompress_pvrtc) _image_decompress_pvrtc(this); - else if (format == FORMAT_ETC && _image_decompress_etc) - _image_decompress_etc(this); - else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RGB8A1 && _image_decompress_etc) + else if (format == FORMAT_ETC && _image_decompress_etc1) + _image_decompress_etc1(this); + else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RGB8A1 && _image_decompress_etc1) _image_decompress_etc2(this); else return ERR_UNAVAILABLE; return OK; } -Error Image::compress(CompressMode p_mode, bool p_for_srgb) { +Error Image::compress(CompressMode p_mode, bool p_for_srgb, float p_lossy_quality) { switch (p_mode) { @@ -1513,13 +1513,13 @@ Error Image::compress(CompressMode p_mode, bool p_for_srgb) { } break; case COMPRESS_ETC: { - ERR_FAIL_COND_V(!_image_compress_etc_func, ERR_UNAVAILABLE); - _image_compress_etc_func(this); + ERR_FAIL_COND_V(!_image_compress_etc1_func, ERR_UNAVAILABLE); + _image_compress_etc1_func(this, p_lossy_quality); } break; case COMPRESS_ETC2: { - ERR_FAIL_COND_V(!_image_compress_etc_func, ERR_UNAVAILABLE); - _image_compress_etc_func(this); + ERR_FAIL_COND_V(!_image_compress_etc2_func, ERR_UNAVAILABLE); + _image_compress_etc2_func(this, p_lossy_quality); } break; } @@ -1652,11 +1652,11 @@ Ref<Image> (*Image::_jpg_mem_loader_func)(const uint8_t *, int) = NULL; void (*Image::_image_compress_bc_func)(Image *, bool) = NULL; void (*Image::_image_compress_pvrtc2_func)(Image *) = NULL; void (*Image::_image_compress_pvrtc4_func)(Image *) = NULL; -void (*Image::_image_compress_etc_func)(Image *) = NULL; -void (*Image::_image_compress_etc2_func)(Image *) = NULL; +void (*Image::_image_compress_etc1_func)(Image *, float) = NULL; +void (*Image::_image_compress_etc2_func)(Image *, float) = NULL; void (*Image::_image_decompress_pvrtc)(Image *) = NULL; void (*Image::_image_decompress_bc)(Image *) = NULL; -void (*Image::_image_decompress_etc)(Image *) = NULL; +void (*Image::_image_decompress_etc1)(Image *) = NULL; void (*Image::_image_decompress_etc2)(Image *) = NULL; PoolVector<uint8_t> (*Image::lossy_packer)(const Ref<Image> &, float) = NULL; diff --git a/core/image.h b/core/image.h index 2a78870f53..cd75dbfcfa 100644 --- a/core/image.h +++ b/core/image.h @@ -117,12 +117,12 @@ public: static void (*_image_compress_bc_func)(Image *, bool p_srgb); static void (*_image_compress_pvrtc2_func)(Image *); static void (*_image_compress_pvrtc4_func)(Image *); - static void (*_image_compress_etc_func)(Image *); - static void (*_image_compress_etc2_func)(Image *); + static void (*_image_compress_etc1_func)(Image *, float); + static void (*_image_compress_etc2_func)(Image *, float); static void (*_image_decompress_pvrtc)(Image *); static void (*_image_decompress_bc)(Image *); - static void (*_image_decompress_etc)(Image *); + static void (*_image_decompress_etc1)(Image *); static void (*_image_decompress_etc2)(Image *); static PoolVector<uint8_t> (*lossy_packer)(const Ref<Image> &p_image, float p_quality); @@ -267,7 +267,7 @@ public: COMPRESS_ETC2, }; - Error compress(CompressMode p_mode = COMPRESS_S3TC, bool p_for_srgb = false); + Error compress(CompressMode p_mode = COMPRESS_S3TC, bool p_for_srgb = false, float p_lossy_quality = 0.7); Error decompress(); bool is_compressed() const; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 6a5e12c3ce..440d989705 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -112,6 +112,15 @@ public: static _ALWAYS_INLINE_ bool is_inf(double p_val) { #ifdef _MSC_VER return !_finite(p_val); +// workaround for mingw builds on travis +#elif defined(__MINGW32__) || defined(__MINGW64__) + union { + uint64_t u; + double f; + } ieee754; + ieee754.f = p_val; + return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && + ((unsigned)ieee754.u == 0); #else return isinf(p_val); #endif @@ -120,6 +129,14 @@ public: static _ALWAYS_INLINE_ bool is_inf(float p_val) { #ifdef _MSC_VER return !_finite(p_val); +// workaround for mingw builds on travis +#elif defined(__MINGW32__) || defined(__MINGW64__) + union { + uint32_t u; + float f; + } ieee754; + ieee754.f = p_val; + return (ieee754.u & 0x7fffffff) == 0x7f800000; #else return isinf(p_val); #endif |