summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-09-11 13:05:30 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-09-13 13:27:44 +0200
commit071129bf61dda7d23c6f305b0c42139bf20560cb (patch)
tree9315fb5421cf5a98a7a1a227a64f39e21e9e9e8e
parent6367fcb2a82c52c7f80e82941621be603373a57b (diff)
downloadqtlocation-mapboxgl-071129bf61dda7d23c6f305b0c42139bf20560cb.tar.gz
[linux,qt] Remove remainder of WebP support
-rw-r--r--cmake/mason-dependencies.cmake2
-rw-r--r--platform/default/image.cpp14
-rw-r--r--platform/default/webp_reader.cpp31
-rw-r--r--platform/linux/config.cmake2
-rw-r--r--platform/qt/config.cmake3
-rw-r--r--platform/qt/src/qt_image.cpp9
-rw-r--r--src/mbgl/util/mapbox.cpp14
-rw-r--r--test/fixtures/image/tile.webpbin8916 -> 0 bytes
-rw-r--r--test/util/image.test.cpp8
-rw-r--r--test/util/mapbox.test.cpp24
10 files changed, 4 insertions, 103 deletions
diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake
index 3c6a535fc8..160060a6fa 100644
--- a/cmake/mason-dependencies.cmake
+++ b/cmake/mason-dependencies.cmake
@@ -27,7 +27,6 @@ elseif(MBGL_PLATFORM STREQUAL "linux")
mason_use(libuv VERSION 1.9.1)
mason_use(libpng VERSION 1.6.25)
mason_use(libjpeg-turbo VERSION 1.5.0)
- mason_use(webp VERSION 0.5.1)
mason_use(benchmark VERSION 1.4.1${MASON_CXXABI_SUFFIX})
mason_use(args VERSION 6.2.0 HEADER_ONLY)
@@ -48,6 +47,5 @@ elseif(MBGL_PLATFORM STREQUAL "qt")
if(NOT WITH_QT_DECODERS)
mason_use(libjpeg-turbo VERSION 1.5.0)
mason_use(libpng VERSION 1.6.25)
- mason_use(webp VERSION 0.5.1)
endif()
endif()
diff --git a/platform/default/image.cpp b/platform/default/image.cpp
index 447c6bcd66..25063892b7 100644
--- a/platform/default/image.cpp
+++ b/platform/default/image.cpp
@@ -4,10 +4,6 @@
namespace mbgl {
-#if !defined(__ANDROID__) && !defined(__APPLE__)
-PremultipliedImage decodeWebP(const uint8_t*, size_t);
-#endif // !defined(__ANDROID__) && !defined(__APPLE__)
-
PremultipliedImage decodePNG(const uint8_t*, size_t);
PremultipliedImage decodeJPEG(const uint8_t*, size_t);
@@ -15,16 +11,6 @@ PremultipliedImage decodeImage(const std::string& string) {
const auto* data = reinterpret_cast<const uint8_t*>(string.data());
const size_t size = string.size();
-#if !defined(__ANDROID__) && !defined(__APPLE__)
- 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];
- if (riff_magic == 0x52494646 && webp_magic == 0x57454250) {
- return decodeWebP(data, size);
- }
- }
-#endif // !defined(__ANDROID__) && !defined(__APPLE__)
-
if (size >= 4) {
uint32_t magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
if (magic == 0x89504E47U) {
diff --git a/platform/default/webp_reader.cpp b/platform/default/webp_reader.cpp
deleted file mode 100644
index 2c01fb4479..0000000000
--- a/platform/default/webp_reader.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <mbgl/util/image.hpp>
-#include <mbgl/util/premultiply.hpp>
-#include <mbgl/util/logging.hpp>
-
-extern "C"
-{
-#include <webp/decode.h>
-}
-
-namespace mbgl {
-
-PremultipliedImage decodeWebP(const uint8_t* data, size_t size) {
- int width = 0, height = 0;
- if (WebPGetInfo(data, size, &width, &height) == 0) {
- throw std::runtime_error("failed to retrieve WebP basic header information");
- }
-
- int stride = width * 4;
- size_t webpSize = stride * height;
- auto webp = std::make_unique<uint8_t[]>(webpSize);
-
- if (!WebPDecodeRGBAInto(data, size, webp.get(), webpSize, stride)) {
- throw std::runtime_error("failed to decode WebP data");
- }
-
- UnassociatedImage image({ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
- std::move(webp));
- return util::premultiply(std::move(image));
-}
-
-} // namespace mbgl
diff --git a/platform/linux/config.cmake b/platform/linux/config.cmake
index be2b1cd9d9..1a2c4d850f 100644
--- a/platform/linux/config.cmake
+++ b/platform/linux/config.cmake
@@ -60,7 +60,6 @@ macro(mbgl_platform_core)
PRIVATE platform/default/jpeg_reader.cpp
PRIVATE platform/default/png_writer.cpp
PRIVATE platform/default/png_reader.cpp
- PRIVATE platform/default/webp_reader.cpp
# Headless view
PRIVATE platform/default/mbgl/gl/headless_frontend.cpp
@@ -81,7 +80,6 @@ macro(mbgl_platform_core)
target_add_mason_package(mbgl-core PUBLIC libpng)
target_add_mason_package(mbgl-core PUBLIC libjpeg-turbo)
- target_add_mason_package(mbgl-core PUBLIC webp)
target_add_mason_package(mbgl-core PUBLIC geojson)
target_link_libraries(mbgl-core
diff --git a/platform/qt/config.cmake b/platform/qt/config.cmake
index 5f639b3f78..9f7ee24cfb 100644
--- a/platform/qt/config.cmake
+++ b/platform/qt/config.cmake
@@ -25,12 +25,10 @@ macro(mbgl_platform_core)
target_sources(mbgl-core
PRIVATE platform/default/jpeg_reader.cpp
PRIVATE platform/default/png_reader.cpp
- PRIVATE platform/default/webp_reader.cpp
)
target_add_mason_package(mbgl-core PRIVATE libjpeg-turbo)
target_add_mason_package(mbgl-core PRIVATE libpng)
- target_add_mason_package(mbgl-core PRIVATE webp)
else()
add_definitions(-DQT_IMAGE_DECODERS)
endif()
@@ -84,6 +82,7 @@ if (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(mbgl-test
PRIVATE qmapboxgl
PRIVATE mbgl-filesource
+ PRIVATE -pthread
)
endmacro()
endif()
diff --git a/platform/qt/src/qt_image.cpp b/platform/qt/src/qt_image.cpp
index a5c92514c1..848a9b7f0a 100644
--- a/platform/qt/src/qt_image.cpp
+++ b/platform/qt/src/qt_image.cpp
@@ -21,7 +21,6 @@ std::string encodePNG(const PremultipliedImage& pre) {
#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) {
@@ -29,14 +28,6 @@ PremultipliedImage decodeImage(const std::string& string) {
const size_t size = string.size();
#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];
- if (riff_magic == 0x52494646 && webp_magic == 0x57454250) {
- return decodeWebP(data, size);
- }
- }
-
if (size >= 2) {
uint16_t magic = ((data[0] << 8) | data[1]) & 0xffff;
if (magic == 0xFFD8) {
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index cdd51a293d..b823b727a7 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -136,19 +136,7 @@ canonicalizeTileURL(const std::string& str, const style::SourceType type, const
if (type == style::SourceType::Raster || type == style::SourceType::RasterDEM) {
result += tileSize == util::tileSize ? "@2x" : "{ratio}";
}
-
-#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
- const bool forceWebP = str.compare(path.extension.first, path.extension.second, ".png") == 0;
-#else
- const bool forceWebP = false;
-#endif // !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
-
- // Replace PNG with WebP if necessary.
- if (forceWebP) {
- result += ".webp";
- } else {
- result.append(str, path.extension.first, path.extension.second);
- }
+ result.append(str, path.extension.first, path.extension.second);
// Append the query string, minus the access token parameter.
if (url.query.second > 1) {
diff --git a/test/fixtures/image/tile.webp b/test/fixtures/image/tile.webp
deleted file mode 100644
index 5dbad8f88d..0000000000
--- a/test/fixtures/image/tile.webp
+++ /dev/null
Binary files differ
diff --git a/test/util/image.test.cpp b/test/util/image.test.cpp
index f4a6473040..c2922415cb 100644
--- a/test/util/image.test.cpp
+++ b/test/util/image.test.cpp
@@ -78,14 +78,6 @@ TEST(Image, JPEGTile) {
EXPECT_EQ(256u, image.size.height);
}
-#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(256u, image.size.width);
- EXPECT_EQ(256u, image.size.height);
-}
-#endif // !defined(__ANDROID__) && !defined(__APPLE__) && !defined(QT_IMAGE_DECODERS)
-
TEST(Image, Resize) {
AlphaImage image({0, 0});
diff --git a/test/util/mapbox.test.cpp b/test/util/mapbox.test.cpp
index 301475dae4..33bd6e72ee 100644
--- a/test/util/mapbox.test.cpp
+++ b/test/util/mapbox.test.cpp
@@ -116,8 +116,8 @@ TEST(Mapbox, TileURL) {
"https://api.example.com/v4/a.b/0/0/0.png?access_token=key",
mbgl::util::mapbox::normalizeTileURL("https://api.example.com", "mapbox://tiles/a.b/0/0/0.png", "key"));
EXPECT_EQ(
- "https://api.mapbox.com/v4/a.b/0/0/0@2x.webp?access_token=key",
- mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0@2x.webp", "key"));
+ "https://api.mapbox.com/v4/a.b/0/0/0@2x.png?access_token=key",
+ mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b/0/0/0@2x.png", "key"));
EXPECT_EQ(
"https://api.mapbox.com/v4/a.b,c.d/0/0/0.pbf?access_token=key",
mbgl::util::mapbox::normalizeTileURL(util::API_BASE_URL, "mapbox://tiles/a.b,c.d/0/0/0.pbf", "key"));
@@ -166,8 +166,6 @@ TEST(Mapbox, CanonicalURL) {
EXPECT_EQ(
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.jpg70",
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.jpg70?access_token=key", SourceType::Raster, 512));
-
-#if defined(__ANDROID__) || defined(__APPLE__)
EXPECT_EQ(
"mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.png",
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 256));
@@ -180,20 +178,6 @@ TEST(Mapbox, CanonicalURL) {
EXPECT_EQ(
"mapbox://tiles/a.b/{z}/{x}/{y}@2x.png",
mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 512));
-#else
- EXPECT_EQ(
- "mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.webp",
- mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 256));
- EXPECT_EQ(
- "mapbox://tiles/a.b/{z}/{x}/{y}{ratio}.webp",
- mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 256));
- EXPECT_EQ(
- "mapbox://tiles/a.b/{z}/{x}/{y}@2x.webp",
- mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png", SourceType::Raster, 512));
- EXPECT_EQ(
- "mapbox://tiles/a.b/{z}/{x}/{y}@2x.webp",
- mbgl::util::mapbox::canonicalizeTileURL("http://api.mapbox.com/v4/a.b/{z}/{x}/{y}.png?access_token=key", SourceType::Raster, 512));
-#endif // defined(__ANDROID__) || defined(__APPLE__)
// We don't ever expect to see these inputs, but be safe anyway.
EXPECT_EQ(
@@ -221,11 +205,7 @@ TEST(Mapbox, CanonicalizeRasterTileset) {
mbgl::util::mapbox::canonicalizeTileset(tileset, "mapbox://mapbox.satellite", SourceType::Raster, 256);
-#if !defined(__ANDROID__) && !defined(__APPLE__)
- EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.webp", tileset.tiles[0]);
-#else
EXPECT_EQ("mapbox://tiles/mapbox.satellite/{z}/{x}/{y}{ratio}.png", tileset.tiles[0]);
-#endif
}
TEST(Mapbox, CanonicalizeVectorTileset) {