diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-05-05 18:10:03 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-05-05 18:47:14 +0300 |
commit | a81891771441dfc1c839b9d100368b6bbf1fc127 (patch) | |
tree | da242c7812532526a40fe7bb43083b3047c5fd1a /platform | |
parent | 10e522d10b33e5268b619296eae0ccad899809d9 (diff) | |
download | qtlocation-mapboxgl-a81891771441dfc1c839b9d100368b6bbf1fc127.tar.gz |
[Qt] Make it possible to disable libwebp and libjpeg-turbo at build time
Pull less dependencies.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/qt/platform.gyp | 28 | ||||
-rw-r--r-- | platform/qt/scripts/configure.sh | 1 | ||||
-rw-r--r-- | platform/qt/src/image.cpp | 6 |
3 files changed, 25 insertions, 10 deletions
diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp index dc43e0200f..8b6cdd5918 100644 --- a/platform/qt/platform.gyp +++ b/platform/qt/platform.gyp @@ -39,7 +39,6 @@ 'sources': [ '../default/asset_file_source.cpp', '../default/default_file_source.cpp', - '../default/jpeg_reader.cpp', '../default/log_stderr.cpp', '../default/mbgl/storage/offline.cpp', '../default/mbgl/storage/offline_database.cpp', @@ -48,7 +47,6 @@ '../default/sqlite3.cpp', '../default/string_stdlib.cpp', '../default/thread.cpp', - '../default/webp_reader.cpp', 'include/qmapbox.hpp', 'include/qmapboxgl.hpp', 'include/qquickmapboxgl.hpp', @@ -75,7 +73,6 @@ 'variables': { 'cflags': [ '<@(boost_cflags)', - '<@(libjpeg-turbo_cflags)', '<@(nunicode_cflags)', '<@(opengl_cflags)', '<@(qt_core_cflags)', @@ -83,25 +80,20 @@ '<@(qt_network_cflags)', '<@(rapidjson_cflags)', '<@(sqlite_cflags)', - '<@(webp_cflags)', '-fPIC', ], 'ldflags': [ - '<@(libjpeg-turbo_ldflags)', '<@(nunicode_ldflags)', '<@(opengl_ldflags)', '<@(qt_core_ldflags)', '<@(qt_gui_ldflags)', '<@(qt_network_ldflags)', '<@(sqlite_ldflags)', - '<@(webp_ldflags)', '<@(zlib_ldflags)', ], 'libraries': [ '<@(nunicode_static_libs)', '<@(sqlite_static_libs)', - '<@(libjpeg-turbo_static_libs)', - '<@(webp_static_libs)', '<@(zlib_static_libs)', ], }, @@ -114,6 +106,26 @@ ], 'conditions': [ + ['<(qt_image_decoders) == 0', { + 'sources': [ + '../default/jpeg_reader.cpp', + '../default/webp_reader.cpp', + ], + 'variables': { + 'cflags': [ + '<@(libjpeg-turbo_cflags)', + '<@(webp_cflags)', + ], + 'ldflags': [ + '<@(libjpeg-turbo_ldflags)', + '<@(webp_ldflags)', + ], + 'libraries': [ + '<@(libjpeg-turbo_static_libs)', + '<@(webp_static_libs)', + ], + }, + }], ['<(qt_version_major) == 4', { 'variables': { 'cflags': [ diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index b7807bd469..b1ff652f38 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -35,6 +35,7 @@ function print_qt_flags { QT_VERSION_MAJOR=$(qmake -query QT_VERSION | cut -d. -f1) CONFIG+=" 'qt_version_major%': ['${QT_VERSION_MAJOR}'],"$LN + CONFIG+=" 'qt_image_decoders%': [0],"$LN CONFIG+=" 'qt_core_cflags%': $(quote_flags $(mason cflags Qt system "QtCore")),"$LN CONFIG+=" 'qt_gui_cflags%': $(quote_flags $(mason cflags Qt system "QtGui")),"$LN diff --git a/platform/qt/src/image.cpp b/platform/qt/src/image.cpp index 816b3d7aee..f51f993d48 100644 --- a/platform/qt/src/image.cpp +++ b/platform/qt/src/image.cpp @@ -19,14 +19,16 @@ std::string encodePNG(const PremultipliedImage& pre) { return std::string(array.constData(), array.size()); } +#if !defined(QT_IMAGE_DECODERS) PremultipliedImage decodeJPEG(const uint8_t*, size_t); PremultipliedImage decodeWebP(const uint8_t*, size_t); +#endif PremultipliedImage decodeImage(const std::string& string) { const uint8_t* data = reinterpret_cast<const uint8_t*>(string.data()); const size_t size = string.size(); - // FIXME: Use Qt WebP decoder plugin. +#if !defined(QT_IMAGE_DECODERS) if (size >= 12) { uint32_t riff_magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; uint32_t webp_magic = (data[8] << 24) | (data[9] << 16) | (data[10] << 8) | data[11]; @@ -35,13 +37,13 @@ PremultipliedImage decodeImage(const std::string& string) { } } - // Use libjpeg-turbo rather than the built-in version of libjpeg. if (size >= 2) { uint16_t magic = ((data[0] << 8) | data[1]) & 0xffff; if (magic == 0xFFD8) { return decodeJPEG(data, size); } } +#endif QImage image = QImage::fromData(data, size) |