summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/qt/platform.gyp28
-rw-r--r--platform/qt/scripts/configure.sh1
-rw-r--r--platform/qt/src/image.cpp6
-rw-r--r--src/mbgl/util/mapbox.cpp4
-rw-r--r--test/util/image.cpp4
5 files changed, 29 insertions, 14 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)
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 91d9b80515..41959563f0 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -153,12 +153,12 @@ std::string canonicalizeTileURL(const std::string& url, SourceType type, uint16_
auto tileset = url.substr(tilesetStartIdx, tilesetEndIdx - tilesetStartIdx);
auto extension = url.substr(extensionIdx + 1, queryIdx - extensionIdx - 1);
-#if !defined(__ANDROID__) && !defined(__APPLE__)
+#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
// Replace PNG with WebP.
if (extension == "png") {
extension = "webp";
}
-#endif // !defined(__ANDROID__) && !defined(__APPLE__)
+#endif // !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
std::string result = "mapbox://tiles/" + tileset + "/{z}/{x}/{y}";
diff --git a/test/util/image.cpp b/test/util/image.cpp
index 445b32ce2a..67a79cf9dd 100644
--- a/test/util/image.cpp
+++ b/test/util/image.cpp
@@ -78,13 +78,13 @@ TEST(Image, JPEGTile) {
EXPECT_EQ(256, image.height);
}
-#if !defined(__ANDROID__) && !defined(__APPLE__)
+#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
TEST(Image, WebPTile) {
PremultipliedImage image = decodeImage(util::read_file("test/fixtures/image/tile.webp"));
EXPECT_EQ(256, image.width);
EXPECT_EQ(256, image.height);
}
-#endif // !defined(__ANDROID__) && !defined(__APPLE__)
+#endif // !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
TEST(Image, Premultiply) {
UnassociatedImage rgba { 1, 1 };