From 00bc99f7e8d9cc67c5db2052f15159f4b3709254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 4 Apr 2017 18:00:05 -0700 Subject: [PATCH] Cleanup. --- 3rdparty/maratis-tcl/LICENSE | 6 ++-- 3rdparty/stb/stb_image.h | 6 ++++ 3rdparty/tinyexr/tinyexr.h | 18 ++++++----- scripts/bimg.lua | 59 ------------------------------------ scripts/bimg_decode.lua | 26 ++++++++++++++++ scripts/bimg_encode.lua | 41 +++++++++++++++++++++++++ scripts/genie.lua | 2 ++ src/image_decode.cpp | 6 ++++ 8 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 scripts/bimg_decode.lua create mode 100644 scripts/bimg_encode.lua diff --git a/3rdparty/maratis-tcl/LICENSE b/3rdparty/maratis-tcl/LICENSE index 572d3ef..3126b7e 100644 --- a/3rdparty/maratis-tcl/LICENSE +++ b/3rdparty/maratis-tcl/LICENSE @@ -1,5 +1,5 @@ -Maratis Tiny C library - +Maratis Tiny C library + Copyright (c) 2015 Anael Seghezzi This software is provided 'as-is', without any express or implied @@ -19,4 +19,4 @@ Copyright (c) 2015 Anael Seghezzi be misrepresented as being the original software. 3. This notice may not be removed or altered from any source - distribution. + distribution. diff --git a/3rdparty/stb/stb_image.h b/3rdparty/stb/stb_image.h index ae2ada6..3ce6d8f 100644 --- a/3rdparty/stb/stb_image.h +++ b/3rdparty/stb/stb_image.h @@ -1,3 +1,9 @@ +#if defined(_MSC_VER) +# pragma warning(disable:4244) // warning C4244: '=': conversion from 'int' to 'stbi__uint16', possible loss of data +# pragma warning(disable:4245) // warning C4245: 'argument': conversion from 'int' to 'char', signed/unsigned mismatch +# pragma warning(disable:4456) // warning C4456: declaration of 'k' hides previous local declaration +#endif + /* stb_image - v2.15 - public domain image loader - http://nothings.org/stb_image.h no warranty implied; use at your own risk diff --git a/3rdparty/tinyexr/tinyexr.h b/3rdparty/tinyexr/tinyexr.h index 947941d..b0998b6 100644 --- a/3rdparty/tinyexr/tinyexr.h +++ b/3rdparty/tinyexr/tinyexr.h @@ -792,6 +792,8 @@ namespace miniz { defined(i386) || defined(__ia64__) || defined(__x86_64__) // MINIZ_X86_OR_X64_CPU is only used to help set the below macros. #define MINIZ_X86_OR_X64_CPU 1 +#else +#define MINIZ_X86_OR_X64_CPU 0 #endif #if defined(__sparcv9) @@ -803,7 +805,7 @@ namespace miniz { #endif #endif -#if MINIZ_X86_OR_X64_CPU +#if 1 // MINIZ_X86_OR_X64_CPU // Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient // integer loads and stores from unaligned addresses. //#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1 @@ -10452,7 +10454,7 @@ static void ReconstructLineOffsets(std::vector *offsets tinyexr::swap4(reinterpret_cast(&data_len)); (*offsets)[i] = offset; - + marker += data_len + 8; // 8 = 4 bytes(y) + 4 bytes(data_len) } } @@ -10797,7 +10799,7 @@ int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_ERROR_INVALID_ARGUMENT; } -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -11381,7 +11383,7 @@ int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, } #endif -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "wb"); #else @@ -11859,7 +11861,7 @@ int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, return TINYEXR_ERROR_INVALID_ARGUMENT; } -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -11983,7 +11985,7 @@ int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, return TINYEXR_ERROR_INVALID_ARGUMENT; } -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -12083,7 +12085,7 @@ int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) { return TINYEXR_ERROR_INVALID_ARGUMENT; } -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -12214,7 +12216,7 @@ int LoadEXRMultipartImageFromFile(EXRImage *exr_images, return TINYEXR_ERROR_INVALID_ARGUMENT; } -#ifdef _WIN32 +#if 0 //def _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else diff --git a/scripts/bimg.lua b/scripts/bimg.lua index 9f633e8..8bf6e3a 100644 --- a/scripts/bimg.lua +++ b/scripts/bimg.lua @@ -21,62 +21,3 @@ project "bimg" } configuration {} - -project "bimg_decode" - kind "StaticLib" - - includedirs { - path.join(BX_DIR, "include"), - path.join(BIMG_DIR, "include"), - path.join(BIMG_DIR, "3rdparty"), - path.join(BIMG_DIR, "3rdparty/nvtt"), - path.join(BIMG_DIR, "3rdparty/iqa/include"), - } - - files { - path.join(BIMG_DIR, "src/image_decode.*"), - } - - configuration { "linux-*" } - buildoptions { - "-fPIC", - } - - configuration {} - -project "bimg_encode" - kind "StaticLib" - - includedirs { - path.join(BX_DIR, "include"), - path.join(BIMG_DIR, "include"), - path.join(BIMG_DIR, "3rdparty"), - path.join(BIMG_DIR, "3rdparty/nvtt"), - path.join(BIMG_DIR, "3rdparty/iqa/include"), - } - - files { - path.join(BIMG_DIR, "src/image_encode.*"), - path.join(BIMG_DIR, "3rdparty/libsquish/**.cpp"), - path.join(BIMG_DIR, "3rdparty/libsquish/**.h"), - path.join(BIMG_DIR, "3rdparty/edtaa3/**.cpp"), - path.join(BIMG_DIR, "3rdparty/edtaa3/**.h"), - path.join(BIMG_DIR, "3rdparty/etc1/**.cpp"), - path.join(BIMG_DIR, "3rdparty/etc1/**.h"), - path.join(BIMG_DIR, "3rdparty/etc2/**.cpp"), - path.join(BIMG_DIR, "3rdparty/etc2/**.hpp"), - path.join(BIMG_DIR, "3rdparty/nvtt/**.cpp"), - path.join(BIMG_DIR, "3rdparty/nvtt/**.h"), - path.join(BIMG_DIR, "3rdparty/pvrtc/**.cpp"), - path.join(BIMG_DIR, "3rdparty/pvrtc/**.h"), - path.join(BIMG_DIR, "3rdparty/tinyexr/**.h"), - path.join(BIMG_DIR, "3rdparty/iqa/include/**.h"), - path.join(BIMG_DIR, "3rdparty/iqa/source/**.c"), - } - - configuration { "linux-*" } - buildoptions { - "-fPIC", - } - - configuration {} diff --git a/scripts/bimg_decode.lua b/scripts/bimg_decode.lua new file mode 100644 index 0000000..934cbec --- /dev/null +++ b/scripts/bimg_decode.lua @@ -0,0 +1,26 @@ +-- +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. +-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause +-- + +project "bimg_decode" + kind "StaticLib" + + includedirs { + path.join(BX_DIR, "include"), + path.join(BIMG_DIR, "include"), + path.join(BIMG_DIR, "3rdparty"), + path.join(BIMG_DIR, "3rdparty/nvtt"), + path.join(BIMG_DIR, "3rdparty/iqa/include"), + } + + files { + path.join(BIMG_DIR, "src/image_decode.*"), + } + + configuration { "linux-*" } + buildoptions { + "-fPIC", + } + + configuration {} diff --git a/scripts/bimg_encode.lua b/scripts/bimg_encode.lua new file mode 100644 index 0000000..1b853f6 --- /dev/null +++ b/scripts/bimg_encode.lua @@ -0,0 +1,41 @@ +-- +-- Copyright 2010-2017 Branimir Karadzic. All rights reserved. +-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause +-- + +project "bimg_encode" + kind "StaticLib" + + includedirs { + path.join(BX_DIR, "include"), + path.join(BIMG_DIR, "include"), + path.join(BIMG_DIR, "3rdparty"), + path.join(BIMG_DIR, "3rdparty/nvtt"), + path.join(BIMG_DIR, "3rdparty/iqa/include"), + } + + files { + path.join(BIMG_DIR, "src/image_encode.*"), + path.join(BIMG_DIR, "3rdparty/libsquish/**.cpp"), + path.join(BIMG_DIR, "3rdparty/libsquish/**.h"), + path.join(BIMG_DIR, "3rdparty/edtaa3/**.cpp"), + path.join(BIMG_DIR, "3rdparty/edtaa3/**.h"), + path.join(BIMG_DIR, "3rdparty/etc1/**.cpp"), + path.join(BIMG_DIR, "3rdparty/etc1/**.h"), + path.join(BIMG_DIR, "3rdparty/etc2/**.cpp"), + path.join(BIMG_DIR, "3rdparty/etc2/**.hpp"), + path.join(BIMG_DIR, "3rdparty/nvtt/**.cpp"), + path.join(BIMG_DIR, "3rdparty/nvtt/**.h"), + path.join(BIMG_DIR, "3rdparty/pvrtc/**.cpp"), + path.join(BIMG_DIR, "3rdparty/pvrtc/**.h"), + path.join(BIMG_DIR, "3rdparty/tinyexr/**.h"), + path.join(BIMG_DIR, "3rdparty/iqa/include/**.h"), + path.join(BIMG_DIR, "3rdparty/iqa/source/**.c"), + } + + configuration { "linux-*" } + buildoptions { + "-fPIC", + } + + configuration {} diff --git a/scripts/genie.lua b/scripts/genie.lua index 782e767..b22c4dd 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -65,6 +65,8 @@ end group "libs" dofile "bimg.lua" +dofile "bimg_decode.lua" +dofile "bimg_encode.lua" dofile(path.join(BX_DIR, "scripts/bx.lua")) diff --git a/src/image_decode.cpp b/src/image_decode.cpp index f73567c..3800a85 100644 --- a/src/image_decode.cpp +++ b/src/image_decode.cpp @@ -5,14 +5,19 @@ #include "bimg_p.h" +BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-function") + BX_PRAGMA_DIAGNOSTIC_PUSH() BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wtype-limits") BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-parameter") BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-value") +BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wdeprecated-declarations") BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // error C4100: '' : unreferenced formal parameter +BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4505) // warning C4505: 'tinyexr::miniz::def_realloc_func': unreferenced local function has been removed #if BX_PLATFORM_EMSCRIPTEN # include #endif // BX_PLATFORM_EMSCRIPTEN +#define MINIZ_NO_ARCHIVE_APIS #define MINIZ_NO_STDIO #define TINYEXR_IMPLEMENTATION #include @@ -48,6 +53,7 @@ BX_PRAGMA_DIAGNOSTIC_PUSH(); BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wmissing-field-initializers"); BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow"); BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wint-to-pointer-cast") +BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Warray-bounds"); #if BX_COMPILER_GCC >= 60000 BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wmisleading-indentation"); BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wshift-negative-value");