[linux,qt] Remove remainder of WebP support
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
BIN
test/fixtures/image/tile.webp
vendored
BIN
test/fixtures/image/tile.webp
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 8.7 KiB |
@@ -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});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user