diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-03-16 19:30:08 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-03-17 12:30:40 +0100 |
commit | 48c55af5c1d39e9a29cdb2e0c8203e6767f76c57 (patch) | |
tree | b81115238586a172be3acc487822cd27f12efe79 /platform | |
parent | 0b1faba36920be2c9343c912b4817448f5659f71 (diff) | |
download | qtlocation-mapboxgl-48c55af5c1d39e9a29cdb2e0c8203e6767f76c57.tar.gz |
fix sprites for pixel ratios that are not 1 and 2
- OpenGL ES 2 doesn't allow NPOT textures with wrap-around
- The Sprite object reported the map's pixelRatio, even though it loaded @2x assets
- Copying icons from the sprite into the atlas now uses bilinear scaling to scale up to the actual size
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/compression.cpp | 96 | ||||
-rw-r--r-- | platform/default/compression.hpp | 15 | ||||
-rw-r--r-- | platform/default/sqlite_cache.cpp | 2 |
3 files changed, 1 insertions, 112 deletions
diff --git a/platform/default/compression.cpp b/platform/default/compression.cpp deleted file mode 100644 index c8b38e742f..0000000000 --- a/platform/default/compression.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "compression.hpp" - -#include <zlib.h> - -#include <cstring> -#include <stdexcept> - - -// Check zlib library version. -const static bool zlibVersionCheck = []() { - const char *const version = zlibVersion(); - if (version[0] != ZLIB_VERSION[0]) { - char message[96]; - snprintf(message, 96, "zlib version mismatch: headers report %s, but library reports %s", - ZLIB_VERSION, version); - throw std::runtime_error(message); - } - - return true; -}(); - - -namespace mbgl { -namespace util { - -std::string compress(const std::string &raw) { - z_stream deflate_stream; - memset(&deflate_stream, 0, sizeof(deflate_stream)); - - // TODO: reuse z_streams - if (deflateInit(&deflate_stream, Z_DEFAULT_COMPRESSION) != Z_OK) { - throw std::runtime_error("failed to initialize deflate"); - } - - deflate_stream.next_in = (Bytef *)raw.data(); - deflate_stream.avail_in = uInt(raw.size()); - - std::string result; - char out[16384]; - - int code; - do { - deflate_stream.next_out = reinterpret_cast<Bytef *>(out); - deflate_stream.avail_out = sizeof(out); - code = deflate(&deflate_stream, Z_FINISH); - if (result.size() < deflate_stream.total_out) { - // append the block to the output string - result.append(out, deflate_stream.total_out - result.size()); - } - } while (code == Z_OK); - - deflateEnd(&deflate_stream); - - if (code != Z_STREAM_END) { - throw std::runtime_error(deflate_stream.msg); - } - - return result; -} - -std::string decompress(const std::string &raw) { - z_stream inflate_stream; - memset(&inflate_stream, 0, sizeof(inflate_stream)); - - // TODO: reuse z_streams - if (inflateInit(&inflate_stream) != Z_OK) { - throw std::runtime_error("failed to initialize inflate"); - } - - inflate_stream.next_in = (Bytef *)raw.data(); - inflate_stream.avail_in = uInt(raw.size()); - - std::string result; - char out[15384]; - - int code; - do { - inflate_stream.next_out = reinterpret_cast<Bytef *>(out); - inflate_stream.avail_out = sizeof(out); - code = inflate(&inflate_stream, 0); - // result.append(out, sizeof(out) - inflate_stream.avail_out); - if (result.size() < inflate_stream.total_out) { - result.append(out, inflate_stream.total_out - result.size()); - } - } while (code == Z_OK); - - inflateEnd(&inflate_stream); - - if (code != Z_STREAM_END) { - throw std::runtime_error(inflate_stream.msg); - } - - return result; -} -} -} diff --git a/platform/default/compression.hpp b/platform/default/compression.hpp deleted file mode 100644 index a33b2476a7..0000000000 --- a/platform/default/compression.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef MBGL_UTIL_COMPRESSION -#define MBGL_UTIL_COMPRESSION - -#include <string> - -namespace mbgl { -namespace util { - -std::string compress(const std::string &raw); -std::string decompress(const std::string &raw); - -} -} - -#endif diff --git a/platform/default/sqlite_cache.cpp b/platform/default/sqlite_cache.cpp index 522b23f22c..b8d47159ce 100644 --- a/platform/default/sqlite_cache.cpp +++ b/platform/default/sqlite_cache.cpp @@ -5,10 +5,10 @@ #include <mbgl/util/util.hpp> #include <mbgl/util/async_queue.hpp> #include <mbgl/util/variant.hpp> +#include <mbgl/util/compression.hpp> #include <mbgl/platform/log.hpp> #include "sqlite3.hpp" -#include "compression.hpp" #include <uv.h> |