From 65451187f50de0ca5e76f0f10d7cfa51dac867c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 11 Nov 2014 18:05:24 +0100 Subject: [performance] remove use of snprintf in hot path; it's pretty slow on iOS --- src/map/tile_data.cpp | 4 ++-- src/renderer/painter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index c1354d490b..5eed22c47f 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -11,12 +11,12 @@ using namespace mbgl; TileData::TileData(Tile::ID const& id_, const SourceInfo& source_) : id(id_), + name(util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y)), state(State::initial), source(source_), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates - const std::string str = util::sprintf<32>("%d/%d/%d", id_.z, id_.x, id_.y); - debugFontBuffer.addText(str.c_str(), 50, 200, 5); + debugFontBuffer.addText(name.c_str(), 50, 200, 5); } TileData::~TileData() { diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 15bf9e3a0d..f350f2239b 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -370,7 +370,7 @@ void Painter::renderLayer(util::ptr layer_desc, const Tile::ID* id, void Painter::renderTileLayer(const Tile& tile, util::ptr layer_desc, const mat4 &matrix) { assert(tile.data); if (tile.data->hasData(*layer_desc) || layer_desc->type == StyleLayerType::Raster) { - gl::group group(util::sprintf<32>("render %d/%d/%d\n", tile.id.z, tile.id.y, tile.id.z)); + gl::group group(std::string { "render " } + tile.data->name); prepareTile(tile); tile.data->render(*this, layer_desc, matrix); } -- cgit v1.2.1 From b449b22abcceddab154e1694eb4f8ca8e392e35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 4 Dec 2014 12:59:09 +0100 Subject: remove use of std::to_string in favor of boost::lexical_cast std::to_string calls sprintf() internally, which is really slow --- src/geometry/vao.cpp | 5 +++-- src/map/source.cpp | 4 ++-- src/map/tile.cpp | 7 +++++++ src/map/tile_data.cpp | 10 +++++----- src/renderer/painter_debug.cpp | 2 +- src/style/value.cpp | 14 ++++---------- src/text/glyph_store.cpp | 4 ++-- src/util/stopwatch.cpp | 3 ++- 8 files changed, 26 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/geometry/vao.cpp b/src/geometry/vao.cpp index d2fd2727ef..66822ba5ce 100644 --- a/src/geometry/vao.cpp +++ b/src/geometry/vao.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { @@ -31,8 +32,8 @@ void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuin char *offset) { if (bound_shader != shader.getID()) { throw std::runtime_error(std::string("trying to rebind VAO to another shader from " + - std::to_string(bound_shader) + "(" + bound_shader_name + ") to " + - std::to_string(shader.getID()) + "(" + shader.name + ")" )); + util::toString(bound_shader) + "(" + bound_shader_name + ") to " + + util::toString(shader.getID()) + "(" + shader.name + ")" )); } else if (bound_offset != offset) { throw std::runtime_error("trying to bind VAO to another offset"); } else if (bound_vertex_buffer != vertexBuffer) { diff --git a/src/map/source.cpp b/src/map/source.cpp index 35f5072860..f4f5a1b811 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -88,13 +88,13 @@ size_t Source::getTileCount() const { void Source::drawClippingMasks(Painter &painter) { for (std::pair> &pair : tiles) { Tile &tile = *pair.second; - gl::group group(util::sprintf<32>("mask %d/%d/%d", tile.id.z, tile.id.y, tile.id.z)); + gl::group group(std::string { "mask: " } + std::string(tile.id)); painter.drawClippingMask(tile.matrix, tile.clip); } } void Source::render(Painter &painter, util::ptr layer_desc) { - gl::group group(std::string("layer: ") + layer_desc->id); + gl::group group(std::string { "layer: " } + layer_desc->id); for (const std::pair> &pair : tiles) { Tile &tile = *pair.second; if (tile.data && tile.data->state == TileData::State::parsed) { diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 3070d3fd96..52f3538417 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -1,5 +1,7 @@ #include #include +#include + #include @@ -52,6 +54,11 @@ bool Tile::ID::isChildOf(const Tile::ID &parent_id) const { } +Tile::ID::operator std::string() const { + return util::toString(z) + "/" + util::toString(x) + "/" + util::toString(y); +} + + // Taken from polymaps src/Layer.js // https://github.com/simplegeo/polymaps/blob/master/src/Layer.js#L333-L383 diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 5eed22c47f..f89ff15baf 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -11,7 +11,7 @@ using namespace mbgl; TileData::TileData(Tile::ID const& id_, const SourceInfo& source_) : id(id_), - name(util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y)), + name(id), state(State::initial), source(source_), debugBucket(debugFontBuffer) { @@ -24,7 +24,7 @@ TileData::~TileData() { } const std::string TileData::toString() const { - return util::sprintf<32>("[tile %d/%d/%d]", id.z, id.x, id.y); + return std::string { "[tile " } + name + "]"; } void TileData::request(uv::worker& worker, FileSource& fileSource, @@ -34,9 +34,9 @@ void TileData::request(uv::worker& worker, FileSource& fileSource, std::string url = source.tiles[(id.x + id.y) % source.tiles.size()]; url = util::replaceTokens(url, [&](const std::string &token) -> std::string { - if (token == "z") return std::to_string(id.z); - if (token == "x") return std::to_string(id.x); - if (token == "y") return std::to_string(id.y); + if (token == "z") return util::toString(id.z); + if (token == "x") return util::toString(id.x); + if (token == "y") return util::toString(id.y); if (token == "prefix") { std::string prefix { 2 }; prefix[0] = "0123456789abcdef"[id.x % 16]; diff --git a/src/renderer/painter_debug.cpp b/src/renderer/painter_debug.cpp index 5bc36a233c..c4d273aa47 100644 --- a/src/renderer/painter_debug.cpp +++ b/src/renderer/painter_debug.cpp @@ -6,7 +6,7 @@ using namespace mbgl; void Painter::renderTileDebug(const Tile& tile) { - gl::group group(util::sprintf<32>("debug %d/%d/%d", tile.id.z, tile.id.y, tile.id.z)); + gl::group group(std::string { "debug " } + std::string(tile.id)); assert(tile.data); if (debug) { prepareTile(tile); diff --git a/src/style/value.cpp b/src/style/value.cpp index bda9a089a8..ae51ce3783 100644 --- a/src/style/value.cpp +++ b/src/style/value.cpp @@ -1,11 +1,5 @@ #include - -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif -#include -#pragma GCC diagnostic pop +#include mbgl::Value mbgl::parseValue(pbf data) { while (data.next()) @@ -37,9 +31,9 @@ mbgl::Value mbgl::parseValue(pbf data) { std::string mbgl::toString(const mbgl::Value& value) { if (value.is()) return value.get(); else if (value.is()) return value.get() ? "true" : "false"; - else if (value.is()) return std::to_string(value.get()); - else if (value.is()) return std::to_string(value.get()); - else if (value.is()) return boost::lexical_cast(value.get()); + else if (value.is()) return util::toString(value.get()); + else if (value.is()) return util::toString(value.get()); + else if (value.is()) return util::toString(value.get()); else return "null"; } diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 8537ab5156..2f5db180fd 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -143,7 +143,7 @@ GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, Gl // Load the glyph set URL std::string url = util::replaceTokens(glyphURL, [&](const std::string &name) -> std::string { if (name == "fontstack") return util::percentEncode(fontStack); - if (name == "range") return std::to_string(glyphRange.first) + "-" + std::to_string(glyphRange.second); + if (name == "range") return util::toString(glyphRange.first) + "-" + util::toString(glyphRange.second); return ""; }); @@ -153,7 +153,7 @@ GlyphPBF::GlyphPBF(const std::string &glyphURL, const std::string &fontStack, Gl request->onload([&, url](const Response &res) { if (res.code != 200) { // Something went wrong with loading the glyph pbf. Pass on the error to the future listeners. - const std::string msg = util::sprintf<255>("[ERROR] failed to load glyphs (%d): %s\n", res.code, res.message.c_str()); + const std::string msg = std::string { "[ERROR] failed to load glyphs (" } + util::toString(res.code) + "): " + res.message; promise.set_exception(std::make_exception_ptr(std::runtime_error(msg))); } else { // Transfer the data to the GlyphSet and signal its availability. diff --git a/src/util/stopwatch.cpp b/src/util/stopwatch.cpp index c9b8756e3b..14b4f4018b 100644 --- a/src/util/stopwatch.cpp +++ b/src/util/stopwatch.cpp @@ -1,6 +1,7 @@ #ifndef DISABLE_STOPWATCH #include #include +#include #include #include @@ -23,7 +24,7 @@ stopwatch::stopwatch(const std::string &name_, EventSeverity severity_, Event ev void stopwatch::report(const std::string &name_) { timestamp duration = now() - start; - Log::Record(severity, event, name_ + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); + Log::Record(severity, event, name_ + ": " + util::toString(double(duration) / 1_millisecond) + "ms"); start += duration; } -- cgit v1.2.1 From abafb52f37beb5659efc2105ccd1568e1f754898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 4 Dec 2014 18:29:42 +0100 Subject: make most headers private --- src/clipper/clipper.cpp | 2 +- src/clipper/clipper.hpp | 398 ++++++++++++ src/csscolorparser/csscolorparser.cpp | 2 +- src/csscolorparser/csscolorparser.hpp | 44 ++ src/geometry/debug_font_buffer.cpp | 42 -- src/geometry/debug_font_data.hpp | 206 ------- src/geometry/elements_buffer.cpp | 21 - src/geometry/fill_buffer.cpp | 12 - src/geometry/glyph_atlas.cpp | 166 ----- src/geometry/icon_buffer.cpp | 35 -- src/geometry/line_buffer.cpp | 23 - src/geometry/resample.cpp | 62 -- src/geometry/sprite_atlas.cpp | 261 -------- src/geometry/static_vertex_buffer.cpp | 14 - src/geometry/text_buffer.cpp | 33 - src/geometry/vao.cpp | 55 -- src/libtess2/bucketalloc.c | 2 +- src/libtess2/bucketalloc.h | 2 +- src/libtess2/dict.c | 2 +- src/libtess2/mesh.h | 2 +- src/libtess2/priorityq.c | 2 +- src/libtess2/tess.h | 2 +- src/libtess2/tesselator.h | 209 +++++++ src/map/map.cpp | 647 -------------------- src/map/raster_tile_data.cpp | 34 -- src/map/source.cpp | 369 ----------- src/map/sprite.cpp | 152 ----- src/map/tile.cpp | 146 ----- src/map/tile_data.cpp | 104 ---- src/map/tile_parser.cpp | 175 ------ src/map/transform.cpp | 472 -------------- src/map/transform_state.cpp | 171 ------ src/map/vector_tile.cpp | 214 ------- src/map/vector_tile_data.cpp | 78 --- src/mbgl/geometry/anchor.hpp | 25 + src/mbgl/geometry/binpack.hpp | 100 +++ src/mbgl/geometry/buffer.hpp | 118 ++++ src/mbgl/geometry/debug_font_buffer.cpp | 42 ++ src/mbgl/geometry/debug_font_buffer.hpp | 17 + src/mbgl/geometry/debug_font_data.hpp | 206 +++++++ src/mbgl/geometry/elements_buffer.cpp | 21 + src/mbgl/geometry/elements_buffer.hpp | 64 ++ src/mbgl/geometry/fill_buffer.cpp | 13 + src/mbgl/geometry/fill_buffer.hpp | 21 + src/mbgl/geometry/geometry.hpp | 77 +++ src/mbgl/geometry/glyph_atlas.cpp | 167 +++++ src/mbgl/geometry/glyph_atlas.hpp | 54 ++ src/mbgl/geometry/icon_buffer.cpp | 35 ++ src/mbgl/geometry/icon_buffer.hpp | 22 + src/mbgl/geometry/line_buffer.cpp | 23 + src/mbgl/geometry/line_buffer.hpp | 39 ++ src/mbgl/geometry/resample.cpp | 62 ++ src/mbgl/geometry/resample.hpp | 13 + src/mbgl/geometry/sprite_atlas.cpp | 261 ++++++++ src/mbgl/geometry/sprite_atlas.hpp | 82 +++ src/mbgl/geometry/static_vertex_buffer.cpp | 14 + src/mbgl/geometry/static_vertex_buffer.hpp | 26 + src/mbgl/geometry/text_buffer.cpp | 33 + src/mbgl/geometry/text_buffer.hpp | 25 + src/mbgl/geometry/vao.cpp | 55 ++ src/mbgl/geometry/vao.hpp | 73 +++ src/mbgl/map/map.cpp | 654 ++++++++++++++++++++ src/mbgl/map/raster_tile_data.cpp | 34 ++ src/mbgl/map/raster_tile_data.hpp | 33 + src/mbgl/map/source.cpp | 370 +++++++++++ src/mbgl/map/source.hpp | 86 +++ src/mbgl/map/sprite.cpp | 152 +++++ src/mbgl/map/sprite.hpp | 79 +++ src/mbgl/map/tile.cpp | 147 +++++ src/mbgl/map/tile_data.cpp | 104 ++++ src/mbgl/map/tile_data.hpp | 88 +++ src/mbgl/map/tile_parser.cpp | 174 ++++++ src/mbgl/map/tile_parser.hpp | 77 +++ src/mbgl/map/transform.cpp | 472 ++++++++++++++ src/mbgl/map/transform_state.cpp | 172 ++++++ src/mbgl/map/vector_tile.cpp | 214 +++++++ src/mbgl/map/vector_tile.hpp | 118 ++++ src/mbgl/map/vector_tile_data.cpp | 78 +++ src/mbgl/map/vector_tile_data.hpp | 74 +++ src/mbgl/platform/gl.cpp | 95 +++ src/mbgl/platform/log.cpp | 7 + src/mbgl/renderer/bucket.hpp | 24 + src/mbgl/renderer/debug_bucket.cpp | 32 + src/mbgl/renderer/debug_bucket.hpp | 35 ++ src/mbgl/renderer/fill_bucket.cpp | 246 ++++++++ src/mbgl/renderer/fill_bucket.hpp | 88 +++ src/mbgl/renderer/frame_history.cpp | 85 +++ src/mbgl/renderer/frame_history.hpp | 40 ++ src/mbgl/renderer/line_bucket.cpp | 403 ++++++++++++ src/mbgl/renderer/line_bucket.hpp | 62 ++ src/mbgl/renderer/painter.cpp | 465 ++++++++++++++ src/mbgl/renderer/painter.hpp | 259 ++++++++ src/mbgl/renderer/painter_clipping.cpp | 39 ++ src/mbgl/renderer/painter_debug.cpp | 102 ++++ src/mbgl/renderer/painter_fill.cpp | 122 ++++ src/mbgl/renderer/painter_line.cpp | 101 +++ src/mbgl/renderer/painter_prerender.cpp | 45 ++ src/mbgl/renderer/painter_raster.cpp | 107 ++++ src/mbgl/renderer/painter_symbol.cpp | 208 +++++++ src/mbgl/renderer/prerendered_texture.cpp | 154 +++++ src/mbgl/renderer/prerendered_texture.hpp | 37 ++ src/mbgl/renderer/raster_bucket.cpp | 36 ++ src/mbgl/renderer/raster_bucket.hpp | 38 ++ src/mbgl/renderer/symbol_bucket.cpp | 427 +++++++++++++ src/mbgl/renderer/symbol_bucket.hpp | 114 ++++ src/mbgl/shader/dot.fragment.glsl | 9 + src/mbgl/shader/dot.vertex.glsl | 9 + src/mbgl/shader/dot_shader.cpp | 26 + src/mbgl/shader/dot_shader.hpp | 26 + src/mbgl/shader/gaussian.fragment.glsl | 11 + src/mbgl/shader/gaussian.vertex.glsl | 15 + src/mbgl/shader/gaussian_shader.cpp | 28 + src/mbgl/shader/gaussian_shader.hpp | 25 + src/mbgl/shader/icon.fragment.glsl | 8 + src/mbgl/shader/icon.vertex.glsl | 73 +++ src/mbgl/shader/icon_shader.cpp | 60 ++ src/mbgl/shader/icon_shader.hpp | 41 ++ src/mbgl/shader/line.fragment.glsl | 25 + src/mbgl/shader/line.vertex.glsl | 45 ++ src/mbgl/shader/line_shader.cpp | 34 ++ src/mbgl/shader/line_shader.hpp | 32 + src/mbgl/shader/linejoin.fragment.glsl | 14 + src/mbgl/shader/linejoin.vertex.glsl | 13 + src/mbgl/shader/linejoin_shader.cpp | 27 + src/mbgl/shader/linejoin_shader.hpp | 27 + src/mbgl/shader/linepattern.fragment.glsl | 37 ++ src/mbgl/shader/linepattern.vertex.glsl | 57 ++ src/mbgl/shader/linepattern_shader.cpp | 35 ++ src/mbgl/shader/linepattern_shader.hpp | 33 + src/mbgl/shader/outline.fragment.glsl | 9 + src/mbgl/shader/outline.vertex.glsl | 10 + src/mbgl/shader/outline_shader.cpp | 26 + src/mbgl/shader/outline_shader.hpp | 25 + src/mbgl/shader/pattern.fragment.glsl | 21 + src/mbgl/shader/pattern.vertex.glsl | 11 + src/mbgl/shader/pattern_shader.cpp | 26 + src/mbgl/shader/pattern_shader.hpp | 29 + src/mbgl/shader/plain.fragment.glsl | 5 + src/mbgl/shader/plain.vertex.glsl | 7 + src/mbgl/shader/plain_shader.cpp | 26 + src/mbgl/shader/plain_shader.hpp | 24 + src/mbgl/shader/raster.fragment.glsl | 36 ++ src/mbgl/shader/raster.vertex.glsl | 13 + src/mbgl/shader/raster_shader.cpp | 28 + src/mbgl/shader/raster_shader.hpp | 31 + src/mbgl/shader/sdf.fragment.glsl | 13 + src/mbgl/shader/sdf.vertex.glsl | 69 +++ src/mbgl/shader/sdf_shader.cpp | 91 +++ src/mbgl/shader/sdf_shader.hpp | 53 ++ src/mbgl/shader/shader.cpp | 133 ++++ src/mbgl/shader/shader.hpp | 28 + src/mbgl/shader/uniform.cpp | 47 ++ src/mbgl/shader/uniform.hpp | 53 ++ src/mbgl/storage/base_request.cpp | 87 +++ src/mbgl/storage/base_request.hpp | 62 ++ src/mbgl/storage/caching_http_file_source.cpp | 115 ++++ src/mbgl/storage/file_request.cpp | 37 ++ src/mbgl/storage/file_request.hpp | 27 + src/mbgl/storage/file_request_baton.cpp | 160 +++++ src/mbgl/storage/file_request_baton.hpp | 36 ++ src/mbgl/storage/http_request.cpp | 279 +++++++++ src/mbgl/storage/http_request.hpp | 58 ++ src/mbgl/storage/http_request_baton.cpp | 12 + src/mbgl/storage/request.cpp | 49 ++ src/mbgl/storage/response.cpp | 22 + src/mbgl/storage/sqlite_store.cpp | 228 +++++++ src/mbgl/storage/sqlite_store.hpp | 49 ++ src/mbgl/style/applied_class_properties.cpp | 52 ++ src/mbgl/style/applied_class_properties.hpp | 39 ++ src/mbgl/style/class_dictionary.cpp | 51 ++ src/mbgl/style/class_dictionary.hpp | 37 ++ src/mbgl/style/class_properties.cpp | 14 + src/mbgl/style/class_properties.hpp | 43 ++ src/mbgl/style/filter_expression.cpp | 123 ++++ src/mbgl/style/filter_expression.hpp | 125 ++++ src/mbgl/style/filter_expression_private.hpp | 118 ++++ src/mbgl/style/function_properties.cpp | 68 +++ src/mbgl/style/function_properties.hpp | 55 ++ src/mbgl/style/property_fallback.cpp | 61 ++ src/mbgl/style/property_fallback.hpp | 29 + src/mbgl/style/property_key.hpp | 70 +++ src/mbgl/style/property_transition.hpp | 15 + src/mbgl/style/property_value.hpp | 21 + src/mbgl/style/style.cpp | 107 ++++ src/mbgl/style/style.hpp | 68 +++ src/mbgl/style/style_bucket.cpp | 15 + src/mbgl/style/style_bucket.hpp | 112 ++++ src/mbgl/style/style_layer.cpp | 284 +++++++++ src/mbgl/style/style_layer.hpp | 89 +++ src/mbgl/style/style_layer_group.cpp | 34 ++ src/mbgl/style/style_layer_group.hpp | 23 + src/mbgl/style/style_parser.cpp | 845 ++++++++++++++++++++++++++ src/mbgl/style/style_parser.hpp | 113 ++++ src/mbgl/style/style_properties.cpp | 11 + src/mbgl/style/style_properties.hpp | 114 ++++ src/mbgl/style/style_source.cpp | 77 +++ src/mbgl/style/style_source.hpp | 41 ++ src/mbgl/style/types.cpp | 0 src/mbgl/style/types.hpp | 196 ++++++ src/mbgl/style/value.cpp | 60 ++ src/mbgl/style/value.hpp | 45 ++ src/mbgl/style/value_comparison.hpp | 109 ++++ src/mbgl/text/collision.cpp | 297 +++++++++ src/mbgl/text/collision.hpp | 58 ++ src/mbgl/text/glyph.cpp | 14 + src/mbgl/text/glyph.hpp | 60 ++ src/mbgl/text/glyph_store.cpp | 294 +++++++++ src/mbgl/text/glyph_store.hpp | 99 +++ src/mbgl/text/placement.cpp | 312 ++++++++++ src/mbgl/text/placement.hpp | 31 + src/mbgl/text/rotation_range.cpp | 263 ++++++++ src/mbgl/text/rotation_range.hpp | 54 ++ src/mbgl/text/types.hpp | 113 ++++ src/mbgl/util/box.hpp | 15 + src/mbgl/util/clip_ids.cpp | 96 +++ src/mbgl/util/clip_ids.hpp | 38 ++ src/mbgl/util/compression.cpp | 81 +++ src/mbgl/util/compression.hpp | 15 + src/mbgl/util/constants.cpp | 27 + src/mbgl/util/constants.hpp | 31 + src/mbgl/util/error.hpp | 20 + src/mbgl/util/interpolate.hpp | 27 + src/mbgl/util/io.cpp | 34 ++ src/mbgl/util/io.hpp | 15 + src/mbgl/util/mapbox.cpp | 44 ++ src/mbgl/util/mapbox.hpp | 17 + src/mbgl/util/mat3.cpp | 95 +++ src/mbgl/util/mat3.hpp | 42 ++ src/mbgl/util/mat4.cpp | 198 ++++++ src/mbgl/util/math.cpp | 25 + src/mbgl/util/optional.hpp | 69 +++ src/mbgl/util/parsedate.c | 689 +++++++++++++++++++++ src/mbgl/util/pbf.hpp | 184 ++++++ src/mbgl/util/queue.h | 92 +++ src/mbgl/util/raster.cpp | 106 ++++ src/mbgl/util/raster.hpp | 74 +++ src/mbgl/util/rect.hpp | 22 + src/mbgl/util/sqlite3.cpp | 165 +++++ src/mbgl/util/sqlite3.hpp | 74 +++ src/mbgl/util/stopwatch.cpp | 36 ++ src/mbgl/util/stopwatch.hpp | 40 ++ src/mbgl/util/texture_pool.cpp | 58 ++ src/mbgl/util/texture_pool.hpp | 25 + src/mbgl/util/time.cpp | 25 + src/mbgl/util/token.hpp | 50 ++ src/mbgl/util/transition.cpp | 26 + src/mbgl/util/transition.hpp | 77 +++ src/mbgl/util/unitbezier.hpp | 121 ++++ src/mbgl/util/url.cpp | 51 ++ src/mbgl/util/url.hpp | 15 + src/mbgl/util/utf.hpp | 24 + src/mbgl/util/uv-channel.c | 69 +++ src/mbgl/util/uv-channel.h | 29 + src/mbgl/util/uv-messenger.c | 86 +++ src/mbgl/util/uv-worker.c | 170 ++++++ src/mbgl/util/uv-worker.h | 41 ++ src/mbgl/util/uv.cpp | 25 + src/mbgl/util/uv_detail.hpp | 177 ++++++ src/mbgl/util/vec.hpp | 15 + src/platform/gl.cpp | 95 --- src/platform/log.cpp | 7 - src/rapidjson/document.h | 821 +++++++++++++++++++++++++ src/rapidjson/filestream.h | 46 ++ src/rapidjson/internal/pow10.h | 54 ++ src/rapidjson/internal/stack.h | 82 +++ src/rapidjson/internal/strfunc.h | 24 + src/rapidjson/prettywriter.h | 156 +++++ src/rapidjson/rapidjson.h | 525 ++++++++++++++++ src/rapidjson/reader.h | 692 +++++++++++++++++++++ src/rapidjson/stringbuffer.h | 49 ++ src/rapidjson/writer.h | 241 ++++++++ src/renderer/debug_bucket.cpp | 33 - src/renderer/fill_bucket.cpp | 246 -------- src/renderer/frame_history.cpp | 85 --- src/renderer/line_bucket.cpp | 403 ------------ src/renderer/painter.cpp | 465 -------------- src/renderer/painter_clipping.cpp | 39 -- src/renderer/painter_debug.cpp | 102 ---- src/renderer/painter_fill.cpp | 122 ---- src/renderer/painter_line.cpp | 101 --- src/renderer/painter_prerender.cpp | 45 -- src/renderer/painter_raster.cpp | 107 ---- src/renderer/painter_symbol.cpp | 208 ------- src/renderer/prerendered_texture.cpp | 154 ----- src/renderer/raster_bucket.cpp | 36 -- src/renderer/symbol_bucket.cpp | 427 ------------- src/shader/dot.fragment.glsl | 9 - src/shader/dot.vertex.glsl | 9 - src/shader/dot_shader.cpp | 26 - src/shader/gaussian.fragment.glsl | 11 - src/shader/gaussian.vertex.glsl | 15 - src/shader/gaussian_shader.cpp | 28 - src/shader/icon.fragment.glsl | 8 - src/shader/icon.vertex.glsl | 73 --- src/shader/icon_shader.cpp | 60 -- src/shader/line.fragment.glsl | 25 - src/shader/line.vertex.glsl | 45 -- src/shader/line_shader.cpp | 34 -- src/shader/linejoin.fragment.glsl | 14 - src/shader/linejoin.vertex.glsl | 13 - src/shader/linejoin_shader.cpp | 27 - src/shader/linepattern.fragment.glsl | 37 -- src/shader/linepattern.vertex.glsl | 57 -- src/shader/linepattern_shader.cpp | 35 -- src/shader/outline.fragment.glsl | 9 - src/shader/outline.vertex.glsl | 10 - src/shader/outline_shader.cpp | 26 - src/shader/pattern.fragment.glsl | 21 - src/shader/pattern.vertex.glsl | 11 - src/shader/pattern_shader.cpp | 26 - src/shader/plain.fragment.glsl | 5 - src/shader/plain.vertex.glsl | 7 - src/shader/plain_shader.cpp | 26 - src/shader/raster.fragment.glsl | 36 -- src/shader/raster.vertex.glsl | 13 - src/shader/raster_shader.cpp | 28 - src/shader/sdf.fragment.glsl | 13 - src/shader/sdf.vertex.glsl | 69 --- src/shader/sdf_shader.cpp | 91 --- src/shader/shader.cpp | 133 ---- src/shader/uniform.cpp | 47 -- src/storage/base_request.cpp | 87 --- src/storage/file_request.cpp | 37 -- src/storage/file_request_baton.cpp | 160 ----- src/storage/http_request.cpp | 279 --------- src/storage/http_request_baton.cpp | 12 - src/storage/request.cpp | 49 -- src/storage/response.cpp | 22 - src/storage/sqlite_store.cpp | 228 ------- src/style/applied_class_properties.cpp | 52 -- src/style/class_dictionary.cpp | 51 -- src/style/class_properties.cpp | 14 - src/style/filter_expression.cpp | 123 ---- src/style/function_properties.cpp | 68 --- src/style/property_fallback.cpp | 61 -- src/style/style.cpp | 107 ---- src/style/style_bucket.cpp | 15 - src/style/style_layer.cpp | 284 --------- src/style/style_layer_group.cpp | 35 -- src/style/style_parser.cpp | 845 -------------------------- src/style/style_properties.cpp | 11 - src/style/style_source.cpp | 77 --- src/style/types.cpp | 0 src/style/value.cpp | 60 -- src/text/collision.cpp | 297 --------- src/text/glyph.cpp | 14 - src/text/glyph_store.cpp | 294 --------- src/text/placement.cpp | 312 ---------- src/text/rotation_range.cpp | 263 -------- src/util/clip_ids.cpp | 96 --- src/util/compression.cpp | 81 --- src/util/io.cpp | 34 -- src/util/mapbox.cpp | 44 -- src/util/mat3.cpp | 95 --- src/util/mat4.cpp | 198 ------ src/util/math.cpp | 25 - src/util/parsedate.c | 689 --------------------- src/util/raster.cpp | 106 ---- src/util/sqlite3.cpp | 165 ----- src/util/stopwatch.cpp | 36 -- src/util/texture_pool.cpp | 58 -- src/util/time.cpp | 25 - src/util/transition.cpp | 26 - src/util/url.cpp | 51 -- src/util/uv-channel.c | 69 --- src/util/uv-messenger.c | 86 --- src/util/uv-worker.c | 170 ------ src/util/uv.cpp | 25 - 368 files changed, 22593 insertions(+), 13208 deletions(-) create mode 100755 src/clipper/clipper.hpp create mode 100644 src/csscolorparser/csscolorparser.hpp delete mode 100644 src/geometry/debug_font_buffer.cpp delete mode 100644 src/geometry/debug_font_data.hpp delete mode 100644 src/geometry/elements_buffer.cpp delete mode 100644 src/geometry/fill_buffer.cpp delete mode 100644 src/geometry/glyph_atlas.cpp delete mode 100644 src/geometry/icon_buffer.cpp delete mode 100644 src/geometry/line_buffer.cpp delete mode 100644 src/geometry/resample.cpp delete mode 100644 src/geometry/sprite_atlas.cpp delete mode 100644 src/geometry/static_vertex_buffer.cpp delete mode 100644 src/geometry/text_buffer.cpp delete mode 100644 src/geometry/vao.cpp create mode 100755 src/libtess2/tesselator.h delete mode 100644 src/map/map.cpp delete mode 100644 src/map/raster_tile_data.cpp delete mode 100644 src/map/source.cpp delete mode 100644 src/map/sprite.cpp delete mode 100644 src/map/tile.cpp delete mode 100644 src/map/tile_data.cpp delete mode 100644 src/map/tile_parser.cpp delete mode 100644 src/map/transform.cpp delete mode 100644 src/map/transform_state.cpp delete mode 100644 src/map/vector_tile.cpp delete mode 100644 src/map/vector_tile_data.cpp create mode 100644 src/mbgl/geometry/anchor.hpp create mode 100644 src/mbgl/geometry/binpack.hpp create mode 100644 src/mbgl/geometry/buffer.hpp create mode 100644 src/mbgl/geometry/debug_font_buffer.cpp create mode 100644 src/mbgl/geometry/debug_font_buffer.hpp create mode 100644 src/mbgl/geometry/debug_font_data.hpp create mode 100644 src/mbgl/geometry/elements_buffer.cpp create mode 100644 src/mbgl/geometry/elements_buffer.hpp create mode 100644 src/mbgl/geometry/fill_buffer.cpp create mode 100644 src/mbgl/geometry/fill_buffer.hpp create mode 100644 src/mbgl/geometry/geometry.hpp create mode 100644 src/mbgl/geometry/glyph_atlas.cpp create mode 100644 src/mbgl/geometry/glyph_atlas.hpp create mode 100644 src/mbgl/geometry/icon_buffer.cpp create mode 100644 src/mbgl/geometry/icon_buffer.hpp create mode 100644 src/mbgl/geometry/line_buffer.cpp create mode 100644 src/mbgl/geometry/line_buffer.hpp create mode 100644 src/mbgl/geometry/resample.cpp create mode 100644 src/mbgl/geometry/resample.hpp create mode 100644 src/mbgl/geometry/sprite_atlas.cpp create mode 100644 src/mbgl/geometry/sprite_atlas.hpp create mode 100644 src/mbgl/geometry/static_vertex_buffer.cpp create mode 100644 src/mbgl/geometry/static_vertex_buffer.hpp create mode 100644 src/mbgl/geometry/text_buffer.cpp create mode 100644 src/mbgl/geometry/text_buffer.hpp create mode 100644 src/mbgl/geometry/vao.cpp create mode 100644 src/mbgl/geometry/vao.hpp create mode 100644 src/mbgl/map/map.cpp create mode 100644 src/mbgl/map/raster_tile_data.cpp create mode 100644 src/mbgl/map/raster_tile_data.hpp create mode 100644 src/mbgl/map/source.cpp create mode 100644 src/mbgl/map/source.hpp create mode 100644 src/mbgl/map/sprite.cpp create mode 100644 src/mbgl/map/sprite.hpp create mode 100644 src/mbgl/map/tile.cpp create mode 100644 src/mbgl/map/tile_data.cpp create mode 100644 src/mbgl/map/tile_data.hpp create mode 100644 src/mbgl/map/tile_parser.cpp create mode 100644 src/mbgl/map/tile_parser.hpp create mode 100644 src/mbgl/map/transform.cpp create mode 100644 src/mbgl/map/transform_state.cpp create mode 100644 src/mbgl/map/vector_tile.cpp create mode 100644 src/mbgl/map/vector_tile.hpp create mode 100644 src/mbgl/map/vector_tile_data.cpp create mode 100644 src/mbgl/map/vector_tile_data.hpp create mode 100644 src/mbgl/platform/gl.cpp create mode 100644 src/mbgl/platform/log.cpp create mode 100644 src/mbgl/renderer/bucket.hpp create mode 100644 src/mbgl/renderer/debug_bucket.cpp create mode 100644 src/mbgl/renderer/debug_bucket.hpp create mode 100644 src/mbgl/renderer/fill_bucket.cpp create mode 100644 src/mbgl/renderer/fill_bucket.hpp create mode 100644 src/mbgl/renderer/frame_history.cpp create mode 100644 src/mbgl/renderer/frame_history.hpp create mode 100644 src/mbgl/renderer/line_bucket.cpp create mode 100644 src/mbgl/renderer/line_bucket.hpp create mode 100644 src/mbgl/renderer/painter.cpp create mode 100644 src/mbgl/renderer/painter.hpp create mode 100644 src/mbgl/renderer/painter_clipping.cpp create mode 100644 src/mbgl/renderer/painter_debug.cpp create mode 100644 src/mbgl/renderer/painter_fill.cpp create mode 100644 src/mbgl/renderer/painter_line.cpp create mode 100644 src/mbgl/renderer/painter_prerender.cpp create mode 100644 src/mbgl/renderer/painter_raster.cpp create mode 100644 src/mbgl/renderer/painter_symbol.cpp create mode 100644 src/mbgl/renderer/prerendered_texture.cpp create mode 100644 src/mbgl/renderer/prerendered_texture.hpp create mode 100644 src/mbgl/renderer/raster_bucket.cpp create mode 100644 src/mbgl/renderer/raster_bucket.hpp create mode 100644 src/mbgl/renderer/symbol_bucket.cpp create mode 100644 src/mbgl/renderer/symbol_bucket.hpp create mode 100644 src/mbgl/shader/dot.fragment.glsl create mode 100644 src/mbgl/shader/dot.vertex.glsl create mode 100644 src/mbgl/shader/dot_shader.cpp create mode 100644 src/mbgl/shader/dot_shader.hpp create mode 100644 src/mbgl/shader/gaussian.fragment.glsl create mode 100644 src/mbgl/shader/gaussian.vertex.glsl create mode 100644 src/mbgl/shader/gaussian_shader.cpp create mode 100644 src/mbgl/shader/gaussian_shader.hpp create mode 100644 src/mbgl/shader/icon.fragment.glsl create mode 100644 src/mbgl/shader/icon.vertex.glsl create mode 100644 src/mbgl/shader/icon_shader.cpp create mode 100644 src/mbgl/shader/icon_shader.hpp create mode 100644 src/mbgl/shader/line.fragment.glsl create mode 100644 src/mbgl/shader/line.vertex.glsl create mode 100644 src/mbgl/shader/line_shader.cpp create mode 100644 src/mbgl/shader/line_shader.hpp create mode 100644 src/mbgl/shader/linejoin.fragment.glsl create mode 100644 src/mbgl/shader/linejoin.vertex.glsl create mode 100644 src/mbgl/shader/linejoin_shader.cpp create mode 100644 src/mbgl/shader/linejoin_shader.hpp create mode 100644 src/mbgl/shader/linepattern.fragment.glsl create mode 100644 src/mbgl/shader/linepattern.vertex.glsl create mode 100644 src/mbgl/shader/linepattern_shader.cpp create mode 100644 src/mbgl/shader/linepattern_shader.hpp create mode 100644 src/mbgl/shader/outline.fragment.glsl create mode 100644 src/mbgl/shader/outline.vertex.glsl create mode 100644 src/mbgl/shader/outline_shader.cpp create mode 100644 src/mbgl/shader/outline_shader.hpp create mode 100644 src/mbgl/shader/pattern.fragment.glsl create mode 100644 src/mbgl/shader/pattern.vertex.glsl create mode 100644 src/mbgl/shader/pattern_shader.cpp create mode 100644 src/mbgl/shader/pattern_shader.hpp create mode 100644 src/mbgl/shader/plain.fragment.glsl create mode 100644 src/mbgl/shader/plain.vertex.glsl create mode 100644 src/mbgl/shader/plain_shader.cpp create mode 100644 src/mbgl/shader/plain_shader.hpp create mode 100644 src/mbgl/shader/raster.fragment.glsl create mode 100644 src/mbgl/shader/raster.vertex.glsl create mode 100644 src/mbgl/shader/raster_shader.cpp create mode 100644 src/mbgl/shader/raster_shader.hpp create mode 100644 src/mbgl/shader/sdf.fragment.glsl create mode 100644 src/mbgl/shader/sdf.vertex.glsl create mode 100644 src/mbgl/shader/sdf_shader.cpp create mode 100644 src/mbgl/shader/sdf_shader.hpp create mode 100644 src/mbgl/shader/shader.cpp create mode 100644 src/mbgl/shader/shader.hpp create mode 100644 src/mbgl/shader/uniform.cpp create mode 100644 src/mbgl/shader/uniform.hpp create mode 100644 src/mbgl/storage/base_request.cpp create mode 100644 src/mbgl/storage/base_request.hpp create mode 100644 src/mbgl/storage/caching_http_file_source.cpp create mode 100644 src/mbgl/storage/file_request.cpp create mode 100644 src/mbgl/storage/file_request.hpp create mode 100644 src/mbgl/storage/file_request_baton.cpp create mode 100644 src/mbgl/storage/file_request_baton.hpp create mode 100644 src/mbgl/storage/http_request.cpp create mode 100644 src/mbgl/storage/http_request.hpp create mode 100644 src/mbgl/storage/http_request_baton.cpp create mode 100644 src/mbgl/storage/request.cpp create mode 100644 src/mbgl/storage/response.cpp create mode 100644 src/mbgl/storage/sqlite_store.cpp create mode 100644 src/mbgl/storage/sqlite_store.hpp create mode 100644 src/mbgl/style/applied_class_properties.cpp create mode 100644 src/mbgl/style/applied_class_properties.hpp create mode 100644 src/mbgl/style/class_dictionary.cpp create mode 100644 src/mbgl/style/class_dictionary.hpp create mode 100644 src/mbgl/style/class_properties.cpp create mode 100644 src/mbgl/style/class_properties.hpp create mode 100644 src/mbgl/style/filter_expression.cpp create mode 100644 src/mbgl/style/filter_expression.hpp create mode 100644 src/mbgl/style/filter_expression_private.hpp create mode 100644 src/mbgl/style/function_properties.cpp create mode 100644 src/mbgl/style/function_properties.hpp create mode 100644 src/mbgl/style/property_fallback.cpp create mode 100644 src/mbgl/style/property_fallback.hpp create mode 100644 src/mbgl/style/property_key.hpp create mode 100644 src/mbgl/style/property_transition.hpp create mode 100644 src/mbgl/style/property_value.hpp create mode 100644 src/mbgl/style/style.cpp create mode 100644 src/mbgl/style/style.hpp create mode 100644 src/mbgl/style/style_bucket.cpp create mode 100644 src/mbgl/style/style_bucket.hpp create mode 100644 src/mbgl/style/style_layer.cpp create mode 100644 src/mbgl/style/style_layer.hpp create mode 100644 src/mbgl/style/style_layer_group.cpp create mode 100644 src/mbgl/style/style_layer_group.hpp create mode 100644 src/mbgl/style/style_parser.cpp create mode 100644 src/mbgl/style/style_parser.hpp create mode 100644 src/mbgl/style/style_properties.cpp create mode 100644 src/mbgl/style/style_properties.hpp create mode 100644 src/mbgl/style/style_source.cpp create mode 100644 src/mbgl/style/style_source.hpp create mode 100644 src/mbgl/style/types.cpp create mode 100644 src/mbgl/style/types.hpp create mode 100644 src/mbgl/style/value.cpp create mode 100644 src/mbgl/style/value.hpp create mode 100644 src/mbgl/style/value_comparison.hpp create mode 100644 src/mbgl/text/collision.cpp create mode 100644 src/mbgl/text/collision.hpp create mode 100644 src/mbgl/text/glyph.cpp create mode 100644 src/mbgl/text/glyph.hpp create mode 100644 src/mbgl/text/glyph_store.cpp create mode 100644 src/mbgl/text/glyph_store.hpp create mode 100644 src/mbgl/text/placement.cpp create mode 100644 src/mbgl/text/placement.hpp create mode 100644 src/mbgl/text/rotation_range.cpp create mode 100644 src/mbgl/text/rotation_range.hpp create mode 100644 src/mbgl/text/types.hpp create mode 100644 src/mbgl/util/box.hpp create mode 100644 src/mbgl/util/clip_ids.cpp create mode 100644 src/mbgl/util/clip_ids.hpp create mode 100644 src/mbgl/util/compression.cpp create mode 100644 src/mbgl/util/compression.hpp create mode 100644 src/mbgl/util/constants.cpp create mode 100644 src/mbgl/util/constants.hpp create mode 100644 src/mbgl/util/error.hpp create mode 100644 src/mbgl/util/interpolate.hpp create mode 100644 src/mbgl/util/io.cpp create mode 100644 src/mbgl/util/io.hpp create mode 100644 src/mbgl/util/mapbox.cpp create mode 100644 src/mbgl/util/mapbox.hpp create mode 100644 src/mbgl/util/mat3.cpp create mode 100644 src/mbgl/util/mat3.hpp create mode 100644 src/mbgl/util/mat4.cpp create mode 100644 src/mbgl/util/math.cpp create mode 100644 src/mbgl/util/optional.hpp create mode 100644 src/mbgl/util/parsedate.c create mode 100644 src/mbgl/util/pbf.hpp create mode 100644 src/mbgl/util/queue.h create mode 100644 src/mbgl/util/raster.cpp create mode 100644 src/mbgl/util/raster.hpp create mode 100644 src/mbgl/util/rect.hpp create mode 100644 src/mbgl/util/sqlite3.cpp create mode 100644 src/mbgl/util/sqlite3.hpp create mode 100644 src/mbgl/util/stopwatch.cpp create mode 100644 src/mbgl/util/stopwatch.hpp create mode 100644 src/mbgl/util/texture_pool.cpp create mode 100644 src/mbgl/util/texture_pool.hpp create mode 100644 src/mbgl/util/time.cpp create mode 100644 src/mbgl/util/token.hpp create mode 100644 src/mbgl/util/transition.cpp create mode 100644 src/mbgl/util/transition.hpp create mode 100644 src/mbgl/util/unitbezier.hpp create mode 100644 src/mbgl/util/url.cpp create mode 100644 src/mbgl/util/url.hpp create mode 100644 src/mbgl/util/utf.hpp create mode 100644 src/mbgl/util/uv-channel.c create mode 100644 src/mbgl/util/uv-channel.h create mode 100644 src/mbgl/util/uv-messenger.c create mode 100644 src/mbgl/util/uv-worker.c create mode 100644 src/mbgl/util/uv-worker.h create mode 100644 src/mbgl/util/uv.cpp create mode 100644 src/mbgl/util/uv_detail.hpp create mode 100644 src/mbgl/util/vec.hpp delete mode 100644 src/platform/gl.cpp delete mode 100644 src/platform/log.cpp create mode 100755 src/rapidjson/document.h create mode 100755 src/rapidjson/filestream.h create mode 100755 src/rapidjson/internal/pow10.h create mode 100755 src/rapidjson/internal/stack.h create mode 100755 src/rapidjson/internal/strfunc.h create mode 100755 src/rapidjson/prettywriter.h create mode 100755 src/rapidjson/rapidjson.h create mode 100755 src/rapidjson/reader.h create mode 100755 src/rapidjson/stringbuffer.h create mode 100755 src/rapidjson/writer.h delete mode 100644 src/renderer/debug_bucket.cpp delete mode 100644 src/renderer/fill_bucket.cpp delete mode 100644 src/renderer/frame_history.cpp delete mode 100644 src/renderer/line_bucket.cpp delete mode 100644 src/renderer/painter.cpp delete mode 100644 src/renderer/painter_clipping.cpp delete mode 100644 src/renderer/painter_debug.cpp delete mode 100644 src/renderer/painter_fill.cpp delete mode 100644 src/renderer/painter_line.cpp delete mode 100644 src/renderer/painter_prerender.cpp delete mode 100644 src/renderer/painter_raster.cpp delete mode 100644 src/renderer/painter_symbol.cpp delete mode 100644 src/renderer/prerendered_texture.cpp delete mode 100644 src/renderer/raster_bucket.cpp delete mode 100644 src/renderer/symbol_bucket.cpp delete mode 100644 src/shader/dot.fragment.glsl delete mode 100644 src/shader/dot.vertex.glsl delete mode 100644 src/shader/dot_shader.cpp delete mode 100644 src/shader/gaussian.fragment.glsl delete mode 100644 src/shader/gaussian.vertex.glsl delete mode 100644 src/shader/gaussian_shader.cpp delete mode 100644 src/shader/icon.fragment.glsl delete mode 100644 src/shader/icon.vertex.glsl delete mode 100644 src/shader/icon_shader.cpp delete mode 100644 src/shader/line.fragment.glsl delete mode 100644 src/shader/line.vertex.glsl delete mode 100644 src/shader/line_shader.cpp delete mode 100644 src/shader/linejoin.fragment.glsl delete mode 100644 src/shader/linejoin.vertex.glsl delete mode 100644 src/shader/linejoin_shader.cpp delete mode 100644 src/shader/linepattern.fragment.glsl delete mode 100644 src/shader/linepattern.vertex.glsl delete mode 100644 src/shader/linepattern_shader.cpp delete mode 100644 src/shader/outline.fragment.glsl delete mode 100644 src/shader/outline.vertex.glsl delete mode 100644 src/shader/outline_shader.cpp delete mode 100644 src/shader/pattern.fragment.glsl delete mode 100644 src/shader/pattern.vertex.glsl delete mode 100644 src/shader/pattern_shader.cpp delete mode 100644 src/shader/plain.fragment.glsl delete mode 100644 src/shader/plain.vertex.glsl delete mode 100644 src/shader/plain_shader.cpp delete mode 100644 src/shader/raster.fragment.glsl delete mode 100644 src/shader/raster.vertex.glsl delete mode 100644 src/shader/raster_shader.cpp delete mode 100644 src/shader/sdf.fragment.glsl delete mode 100644 src/shader/sdf.vertex.glsl delete mode 100644 src/shader/sdf_shader.cpp delete mode 100644 src/shader/shader.cpp delete mode 100644 src/shader/uniform.cpp delete mode 100644 src/storage/base_request.cpp delete mode 100644 src/storage/file_request.cpp delete mode 100644 src/storage/file_request_baton.cpp delete mode 100644 src/storage/http_request.cpp delete mode 100644 src/storage/http_request_baton.cpp delete mode 100644 src/storage/request.cpp delete mode 100644 src/storage/response.cpp delete mode 100644 src/storage/sqlite_store.cpp delete mode 100644 src/style/applied_class_properties.cpp delete mode 100644 src/style/class_dictionary.cpp delete mode 100644 src/style/class_properties.cpp delete mode 100644 src/style/filter_expression.cpp delete mode 100644 src/style/function_properties.cpp delete mode 100644 src/style/property_fallback.cpp delete mode 100644 src/style/style.cpp delete mode 100644 src/style/style_bucket.cpp delete mode 100644 src/style/style_layer.cpp delete mode 100644 src/style/style_layer_group.cpp delete mode 100644 src/style/style_parser.cpp delete mode 100644 src/style/style_properties.cpp delete mode 100644 src/style/style_source.cpp delete mode 100644 src/style/types.cpp delete mode 100644 src/style/value.cpp delete mode 100644 src/text/collision.cpp delete mode 100644 src/text/glyph.cpp delete mode 100644 src/text/glyph_store.cpp delete mode 100644 src/text/placement.cpp delete mode 100644 src/text/rotation_range.cpp delete mode 100644 src/util/clip_ids.cpp delete mode 100644 src/util/compression.cpp delete mode 100644 src/util/io.cpp delete mode 100644 src/util/mapbox.cpp delete mode 100644 src/util/mat3.cpp delete mode 100644 src/util/mat4.cpp delete mode 100644 src/util/math.cpp delete mode 100644 src/util/parsedate.c delete mode 100644 src/util/raster.cpp delete mode 100644 src/util/sqlite3.cpp delete mode 100644 src/util/stopwatch.cpp delete mode 100644 src/util/texture_pool.cpp delete mode 100644 src/util/time.cpp delete mode 100644 src/util/transition.cpp delete mode 100644 src/util/url.cpp delete mode 100644 src/util/uv-channel.c delete mode 100644 src/util/uv-messenger.c delete mode 100644 src/util/uv-worker.c delete mode 100644 src/util/uv.cpp (limited to 'src') diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index ea468d69e4..f5d8cd3c95 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -38,7 +38,7 @@ * * *******************************************************************************/ -#include +#include "clipper.hpp" #include #include #include diff --git a/src/clipper/clipper.hpp b/src/clipper/clipper.hpp new file mode 100755 index 0000000000..84870141e7 --- /dev/null +++ b/src/clipper/clipper.hpp @@ -0,0 +1,398 @@ +/******************************************************************************* +* * +* Author : Angus Johnson * +* Version : 6.1.3a * +* Date : 22 January 2014 * +* Website : http://www.angusj.com * +* Copyright : Angus Johnson 2010-2014 * +* * +* License: * +* Use, modification & distribution is subject to Boost Software License Ver 1. * +* http://www.boost.org/LICENSE_1_0.txt * +* * +* Attributions: * +* The code in this library is an extension of Bala Vatti's clipping algorithm: * +* "A generic solution to polygon clipping" * +* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. * +* http://portal.acm.org/citation.cfm?id=129906 * +* * +* Computer graphics and geometric modeling: implementation and algorithms * +* By Max K. Agoston * +* Springer; 1 edition (January 4, 2005) * +* http://books.google.com/books?q=vatti+clipping+agoston * +* * +* See also: * +* "Polygon Offsetting by Computing Winding Numbers" * +* Paper no. DETC2005-85513 pp. 565-575 * +* ASME 2005 International Design Engineering Technical Conferences * +* and Computers and Information in Engineering Conference (IDETC/CIE2005) * +* September 24-28, 2005 , Long Beach, California, USA * +* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * +* * +*******************************************************************************/ + +#ifndef clipper_hpp +#define clipper_hpp + +#define CLIPPER_VERSION "6.1.3" + +//use_int32: When enabled 32bit ints are used instead of 64bit ints. This +//improve performance but coordinate values are limited to the range +/- 46340 +//#define use_int32 + +//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance. +//#define use_xyz + +//use_lines: Enables line clipping. Adds a very minor cost to performance. +//#define use_lines + +//use_deprecated: Enables support for the obsolete OffsetPaths() function +//which has been replace with the ClipperOffset class. +#define use_deprecated + +#include +#include +#include +#include +#include +#include +#include + +namespace ClipperLib { + +enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; +enum PolyType { ptSubject, ptClip }; +//By far the most widely used winding rules for polygon filling are +//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32) +//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL) +//see http://glprogramming.com/red/chapter11.html +enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; + +#ifdef use_int32 +typedef int cInt; +typedef unsigned int cUInt; +#else +typedef signed long long cInt; +typedef unsigned long long cUInt; +#endif + +struct IntPoint { + cInt X; + cInt Y; +#ifdef use_xyz + cInt Z; + IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {}; +#else + IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {}; +#endif + + friend inline bool operator== (const IntPoint& a, const IntPoint& b) + { + return a.X == b.X && a.Y == b.Y; + } + friend inline bool operator!= (const IntPoint& a, const IntPoint& b) + { + return a.X != b.X || a.Y != b.Y; + } +}; +//------------------------------------------------------------------------------ + +typedef std::vector< IntPoint > Path; +typedef std::vector< Path > Paths; + +inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;} +inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;} + +std::ostream& operator <<(std::ostream &s, const IntPoint &p); +std::ostream& operator <<(std::ostream &s, const Path &p); +std::ostream& operator <<(std::ostream &s, const Paths &p); + +struct DoublePoint +{ + double X; + double Y; + DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {} + DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {} +}; +//------------------------------------------------------------------------------ + +#ifdef use_xyz +typedef void (*TZFillCallback)(IntPoint& z1, IntPoint& z2, IntPoint& pt); +#endif + +enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4}; +enum JoinType {jtSquare, jtRound, jtMiter}; +enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound}; +#ifdef use_deprecated + enum EndType_ {etClosed, etButt = 2, etSquare, etRound}; +#endif + +class PolyNode; +typedef std::vector< PolyNode* > PolyNodes; + +class PolyNode +{ +public: + PolyNode(); + Path Contour; + PolyNodes Childs; + PolyNode* Parent; + PolyNode* GetNext() const; + bool IsHole() const; + bool IsOpen() const; + int ChildCount() const; +private: + unsigned Index; //node index in Parent.Childs + bool m_IsOpen; + JoinType m_jointype; + EndType m_endtype; + PolyNode* GetNextSiblingUp() const; + void AddChild(PolyNode& child); + friend class Clipper; //to access Index + friend class ClipperOffset; +}; + +class PolyTree: public PolyNode +{ +public: + ~PolyTree(){Clear();}; + PolyNode* GetFirst() const; + void Clear(); + int Total() const; +private: + PolyNodes AllNodes; + friend class Clipper; //to access AllNodes +}; + +bool Orientation(const Path &poly); +double Area(const Path &poly); +int PointInPolygon(const IntPoint &pt, const Path &path); + +#ifdef use_deprecated + void OffsetPaths(const Paths &in_polys, Paths &out_polys, + double delta, JoinType jointype, EndType_ endtype, double limit = 0); +#endif + +void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd); +void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); +void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd); + +void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415); +void CleanPolygon(Path& poly, double distance = 1.415); +void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415); +void CleanPolygons(Paths& polys, double distance = 1.415); + +void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed); +void MinkowskiSum(const Path& pattern, const Paths& paths, + Paths& solution, PolyFillType pathFillType, bool pathIsClosed); +void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution); + +void PolyTreeToPaths(const PolyTree& polytree, Paths& paths); +void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths); +void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths); + +void ReversePath(Path& p); +void ReversePaths(Paths& p); + +struct IntRect { cInt left; cInt top; cInt right; cInt bottom; }; + +//enums that are used internally ... +enum EdgeSide { esLeft = 1, esRight = 2}; + +//forward declarations (for stuff used internally) ... +struct TEdge; +struct IntersectNode; +struct LocalMinima; +struct Scanbeam; +struct OutPt; +struct OutRec; +struct Join; + +typedef std::vector < OutRec* > PolyOutList; +typedef std::vector < TEdge* > EdgeList; +typedef std::vector < Join* > JoinList; +typedef std::vector < IntersectNode* > IntersectList; + + +//------------------------------------------------------------------------------ + +//ClipperBase is the ancestor to the Clipper class. It should not be +//instantiated directly. This class simply abstracts the conversion of sets of +//polygon coordinates into edge objects that are stored in a LocalMinima list. +class ClipperBase +{ +public: + ClipperBase(); + virtual ~ClipperBase(); + bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed); + bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed); + virtual void Clear(); + IntRect GetBounds(); + bool PreserveCollinear() {return m_PreserveCollinear;}; + void PreserveCollinear(bool value) {m_PreserveCollinear = value;}; +protected: + void DisposeLocalMinimaList(); + TEdge* AddBoundsToLML(TEdge *e, bool IsClosed); + void PopLocalMinima(); + virtual void Reset(); + TEdge* ProcessBound(TEdge* E, bool IsClockwise); + void InsertLocalMinima(LocalMinima *newLm); + void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed); + TEdge* DescendToMin(TEdge *&E); + void AscendToMax(TEdge *&E, bool Appending, bool IsClosed); + LocalMinima *m_CurrentLM; + LocalMinima *m_MinimaList; + bool m_UseFullRange; + EdgeList m_edges; + bool m_PreserveCollinear; + bool m_HasOpenPaths; +}; +//------------------------------------------------------------------------------ + +class Clipper : public virtual ClipperBase +{ +public: + Clipper(int initOptions = 0); + ~Clipper(); + bool Execute(ClipType clipType, + Paths &solution, + PolyFillType subjFillType = pftEvenOdd, + PolyFillType clipFillType = pftEvenOdd); + bool Execute(ClipType clipType, + PolyTree &polytree, + PolyFillType subjFillType = pftEvenOdd, + PolyFillType clipFillType = pftEvenOdd); + bool ReverseSolution() {return m_ReverseOutput;}; + void ReverseSolution(bool value) {m_ReverseOutput = value;}; + bool StrictlySimple() {return m_StrictSimple;}; + void StrictlySimple(bool value) {m_StrictSimple = value;}; + //set the callback function for z value filling on intersections (otherwise Z is 0) +#ifdef use_xyz + void ZFillFunction(TZFillCallback zFillFunc); +#endif +protected: + void Reset(); + virtual bool ExecuteInternal(); +private: + PolyOutList m_PolyOuts; + JoinList m_Joins; + JoinList m_GhostJoins; + IntersectList m_IntersectList; + ClipType m_ClipType; + std::set< cInt, std::greater > m_Scanbeam; + TEdge *m_ActiveEdges; + TEdge *m_SortedEdges; + bool m_ExecuteLocked; + PolyFillType m_ClipFillType; + PolyFillType m_SubjFillType; + bool m_ReverseOutput; + bool m_UsingPolyTree; + bool m_StrictSimple; +#ifdef use_xyz + TZFillCallback m_ZFill; //custom callback +#endif + void SetWindingCount(TEdge& edge); + bool IsEvenOddFillType(const TEdge& edge) const; + bool IsEvenOddAltFillType(const TEdge& edge) const; + void InsertScanbeam(const cInt Y); + cInt PopScanbeam(); + void InsertLocalMinimaIntoAEL(const cInt botY); + void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge); + void AddEdgeToSEL(TEdge *edge); + void CopyAELToSEL(); + void DeleteFromSEL(TEdge *e); + void DeleteFromAEL(TEdge *e); + void UpdateEdgeIntoAEL(TEdge *&e); + void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2); + bool IsContributing(const TEdge& edge) const; + bool IsTopHorz(const cInt XPos); + void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2); + void DoMaxima(TEdge *e); + void PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam); + void ProcessHorizontals(bool IsTopOfScanbeam); + void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam); + void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); + OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); + OutRec* GetOutRec(int idx); + void AppendPolygon(TEdge *e1, TEdge *e2); + void IntersectEdges(TEdge *e1, TEdge *e2, + const IntPoint &pt, bool protect = false); + OutRec* CreateOutRec(); + OutPt* AddOutPt(TEdge *e, const IntPoint &pt); + void DisposeAllOutRecs(); + void DisposeOutRec(PolyOutList::size_type index); + bool ProcessIntersections(const cInt botY, const cInt topY); + void BuildIntersectList(const cInt botY, const cInt topY); + void ProcessIntersectList(); + void ProcessEdgesAtTopOfScanbeam(const cInt topY); + void BuildResult(Paths& polys); + void BuildResult2(PolyTree& polytree); + void SetHoleState(TEdge *e, OutRec *outrec); + void DisposeIntersectNodes(); + bool FixupIntersectionOrder(); + void FixupOutPolygon(OutRec &outrec); + bool IsHole(TEdge *e); + bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl); + void FixHoleLinkage(OutRec &outrec); + void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt); + void ClearJoins(); + void ClearGhostJoins(); + void AddGhostJoin(OutPt *op, const IntPoint offPt); + bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2); + void JoinCommonEdges(); + void DoSimplePolygons(); + void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec); + void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec); +#ifdef use_xyz + void SetZ(IntPoint& pt, TEdge& e); +#endif +}; +//------------------------------------------------------------------------------ + +class ClipperOffset +{ +public: + ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25); + ~ClipperOffset(); + void AddPath(const Path& path, JoinType joinType, EndType endType); + void AddPaths(const Paths& paths, JoinType joinType, EndType endType); + void Execute(Paths& solution, double delta); + void Execute(PolyTree& solution, double delta); + void Clear(); + double MiterLimit; + double ArcTolerance; +private: + Paths m_destPolys; + Path m_srcPoly; + Path m_destPoly; + std::vector m_normals; + double m_delta, m_sinA, m_sin, m_cos; + double m_miterLim, m_StepsPerRad; + IntPoint m_lowest; + PolyNode m_polyNodes; + + void FixOrientations(); + void DoOffset(double delta); + void OffsetPoint(int j, int& k, JoinType jointype); + void DoSquare(int j, int k); + void DoMiter(int j, int k, double r); + void DoRound(int j, int k); +}; +//------------------------------------------------------------------------------ + +class clipperException : public std::exception +{ + public: + clipperException(const char* description): m_descr(description) {} + virtual ~clipperException() throw() {} + virtual const char* what() const throw() {return m_descr.c_str();} + private: + std::string m_descr; +}; +//------------------------------------------------------------------------------ + +} //ClipperLib namespace + +#endif //clipper_hpp + + diff --git a/src/csscolorparser/csscolorparser.cpp b/src/csscolorparser/csscolorparser.cpp index 938470f192..7ba989fde8 100644 --- a/src/csscolorparser/csscolorparser.cpp +++ b/src/csscolorparser/csscolorparser.cpp @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. -#include +#include "csscolorparser.hpp" #include #include diff --git a/src/csscolorparser/csscolorparser.hpp b/src/csscolorparser/csscolorparser.hpp new file mode 100644 index 0000000000..6caf796943 --- /dev/null +++ b/src/csscolorparser/csscolorparser.hpp @@ -0,0 +1,44 @@ +// (c) Dean McNamee , 2012. +// C++ port by Konstantin Käfer , 2014. +// +// https://github.com/deanm/css-color-parser-js +// https://github.com/kkaefer/css-color-parser-cpp +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +#ifndef CSS_COLOR_PARSER_CPP +#define CSS_COLOR_PARSER_CPP + +#include + +namespace CSSColorParser { + +struct Color { + inline Color() {} + inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_) + : r(r_), g(g_), b(b_), a(a_) {} + unsigned char r = 0, g = 0, b = 0; + float a = 1.0f; +}; + +Color parse(const std::string& css_str); + +} + +#endif diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp deleted file mode 100644 index 6c233f88df..0000000000 --- a/src/geometry/debug_font_buffer.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include - -#include "debug_font_data.hpp" - -using namespace mbgl; - -void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { - uint16_t *coords = nullptr; - - const size_t len = strlen(text); - for (size_t i = 0; i < len; ++i) { - if (text[i] < 32 || (unsigned char)(text[i]) >= 127) { - continue; - } - - const glyph& glyph = simplex[text[i] - 32]; - - int16_t prev_x = -1, prev_y = -1, prev = false; - for (int32_t j = 0; j < glyph.length; j += 2) { - if (glyph.data[j] == -1 && glyph.data[j + 1] == -1) { - prev = false; - } else { - int16_t x = std::round(left + glyph.data[j] * scale); - int16_t y = std::round(baseline - glyph.data[j + 1] * scale); - if (prev) { - coords = static_cast(addElement()); - coords[0] = prev_x; - coords[1] = prev_y; - - coords = static_cast(addElement()); - coords[0] = x; - coords[1] = y; - } - prev_x = x; prev_y = y; prev = true; - } - } - left += glyph.width * scale; - } -} diff --git a/src/geometry/debug_font_data.hpp b/src/geometry/debug_font_data.hpp deleted file mode 100644 index 26c54cb480..0000000000 --- a/src/geometry/debug_font_data.hpp +++ /dev/null @@ -1,206 +0,0 @@ -// This is an implementation file, so omit include guards. - -#include -#include - -const int8_t simplex_1[] = { 5, 21, 5, 7, -1, -1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2 }; -const int8_t simplex_2[] = { 4, 21, 4, 14, -1, -1, 12, 21, 12, 14 }; -const int8_t simplex_3[] = { 11, 25, 4, -7, -1, -1, 17, 25, 10, -7, -1, -1, 4, 12, 18, 12, -1, -1, 3, 6, 17, 6 }; -const int8_t simplex_4[] = { 8, 25, 8, -4, -1, -1, 12, 25, 12, -4, -1, -1, 17, 18, 15, 20, 12, 21, 8, 21, 5, 20, 3, 18, 3, 16, 4, 14, 5, 13, 7, 12, 13, 10, 15, 9, 16, 8, 17, 6, 17, 3, 15, 1, 12, 0, 8, 0, 5, 1, 3, 3 }; -const int8_t simplex_5[] = { 21, 21, 3, 0, -1, -1, 8, 21, 10, 19, 10, 17, 9, 15, 7, 14, 5, 14, 3, 16, 3, 18, 4, 20, 6, 21, 8, 21, 10, 20, 13, 19, 16, 19, 19, 20, 21, 21, -1, -1, 17, 7, 15, 6, 14, 4, 14, 2, 16, 0, 18, 0, 20, 1, 21, 3, 21, 5, 19, 7, 17, 7 }; -const int8_t simplex_6[] = { 23, 12, 23, 13, 22, 14, 21, 14, 20, 13, 19, 11, 17, 6, 15, 3, 13, 1, 11, 0, 7, 0, 5, 1, 4, 2, 3, 4, 3, 6, 4, 8, 5, 9, 12, 13, 13, 14, 14, 16, 14, 18, 13, 20, 11, 21, 9, 20, 8, 18, 8, 16, 9, 13, 11, 10, 16, 3, 18, 1, 20, 0, 22, 0, 23, 1, 23, 2 }; -const int8_t simplex_7[] = { 5, 19, 4, 20, 5, 21, 6, 20, 6, 18, 5, 16, 4, 15 }; -const int8_t simplex_8[] = { 11, 25, 9, 23, 7, 20, 5, 16, 4, 11, 4, 7, 5, 2, 7, -2, 9, -5, 11, -7 }; -const int8_t simplex_9[] = { 3, 25, 5, 23, 7, 20, 9, 16, 10, 11, 10, 7, 9, 2, 7, -2, 5, -5, 3, -7 }; -const int8_t simplex_10[] = { 8, 21, 8, 9, -1, -1, 3, 18, 13, 12, -1, -1, 13, 18, 3, 12 }; -const int8_t simplex_11[] = { 13, 18, 13, 0, -1, -1, 4, 9, 22, 9 }; -const int8_t simplex_12[] = { 6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6, -1, 5, -3, 4, -4 }; -const int8_t simplex_13[] = { 4, 9, 22, 9 }; -const int8_t simplex_14[] = { 5, 2, 4, 1, 5, 0, 6, 1, 5, 2 }; -const int8_t simplex_15[] = { 20, 25, 2, -7 }; -const int8_t simplex_16[] = { 9, 21, 6, 20, 4, 17, 3, 12, 3, 9, 4, 4, 6, 1, 9, 0, 11, 0, 14, 1, 16, 4, 17, 9, 17, 12, 16, 17, 14, 20, 11, 21, 9, 21 }; -const int8_t simplex_17[] = { 6, 17, 8, 18, 11, 21, 11, 0 }; -const int8_t simplex_18[] = { 4, 16, 4, 17, 5, 19, 6, 20, 8, 21, 12, 21, 14, 20, 15, 19, 16, 17, 16, 15, 15, 13, 13, 10, 3, 0, 17, 0 }; -const int8_t simplex_19[] = { 5, 21, 16, 21, 10, 13, 13, 13, 15, 12, 16, 11, 17, 8, 17, 6, 16, 3, 14, 1, 11, 0, 8, 0, 5, 1, 4, 2, 3, 4 }; -const int8_t simplex_20[] = { 13, 21, 3, 7, 18, 7, -1, -1, 13, 21, 13, 0 }; -const int8_t simplex_21[] = { 15, 21, 5, 21, 4, 12, 5, 13, 8, 14, 11, 14, 14, 13, 16, 11, 17, 8, 17, 6, 16, 3, 14, 1, 11, 0, 8, 0, 5, 1, 4, 2, 3, 4 }; -const int8_t simplex_22[] = { 16, 18, 15, 20, 12, 21, 10, 21, 7, 20, 5, 17, 4, 12, 4, 7, 5, 3, 7, 1, 10, 0, 11, 0, 14, 1, 16, 3, 17, 6, 17, 7, 16, 10, 14, 12, 11, 13, 10, 13, 7, 12, 5, 10, 4, 7 }; -const int8_t simplex_23[] = { 17, 21, 7, 0, -1, -1, 3, 21, 17, 21 }; -const int8_t simplex_24[] = { 8, 21, 5, 20, 4, 18, 4, 16, 5, 14, 7, 13, 11, 12, 14, 11, 16, 9, 17, 7, 17, 4, 16, 2, 15, 1, 12, 0, 8, 0, 5, 1, 4, 2, 3, 4, 3, 7, 4, 9, 6, 11, 9, 12, 13, 13, 15, 14, 16, 16, 16, 18, 15, 20, 12, 21, 8, 21 }; -const int8_t simplex_25[] = { 16, 14, 15, 11, 13, 9, 10, 8, 9, 8, 6, 9, 4, 11, 3, 14, 3, 15, 4, 18, 6, 20, 9, 21, 10, 21, 13, 20, 15, 18, 16, 14, 16, 9, 15, 4, 13, 1, 10, 0, 8, 0, 5, 1, 4, 3 }; -const int8_t simplex_26[] = { 5, 14, 4, 13, 5, 12, 6, 13, 5, 14, -1, -1, 5, 2, 4, 1, 5, 0, 6, 1, 5, 2 }; -const int8_t simplex_27[] = { 5, 14, 4, 13, 5, 12, 6, 13, 5, 14, -1, -1, 6, 1, 5, 0, 4, 1, 5, 2, 6, 1, 6, -1, 5, -3, 4, -4 }; -const int8_t simplex_28[] = { 20, 18, 4, 9, 20, 0 }; -const int8_t simplex_29[] = { 4, 12, 22, 12, -1, -1, 4, 6, 22, 6 }; -const int8_t simplex_30[] = { 4, 18, 20, 9, 4, 0 }; -const int8_t simplex_31[] = { 3, 16, 3, 17, 4, 19, 5, 20, 7, 21, 11, 21, 13, 20, 14, 19, 15, 17, 15, 15, 14, 13, 13, 12, 9, 10, 9, 7, -1, -1, 9, 2, 8, 1, 9, 0, 10, 1, 9, 2 }; -const int8_t simplex_32[] = { 18, 13, 17, 15, 15, 16, 12, 16, 10, 15, 9, 14, 8, 11, 8, 8, 9, 6, 11, 5, 14, 5, 16, 6, 17, 8, -1, -1, 12, 16, 10, 14, 9, 11, 9, 8, 10, 6, 11, 5, -1, -1, 18, 16, 17, 8, 17, 6, 19, 5, 21, 5, 23, 7, 24, 10, 24, 12, 23, 15, 22, 17, 20, 19, 18, 20, 15, 21, 12, 21, 9, 20, 7, 19, 5, 17, 4, 15, 3, 12, 3, 9, 4, 6, 5, 4, 7, 2, 9, 1, 12, 0, 15, 0, 18, 1, 20, 2, 21, 3, -1, -1, 19, 16, 18, 8, 18, 6, 19, 5 }; -const int8_t simplex_33[] = { 9, 21, 1, 0, -1, -1, 9, 21, 17, 0, -1, -1, 4, 7, 14, 7 }; -const int8_t simplex_34[] = { 4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 15, 17, 13, 16, 12, 13, 11, -1, -1, 4, 11, 13, 11, 16, 10, 17, 9, 18, 7, 18, 4, 17, 2, 16, 1, 13, 0, 4, 0 }; -const int8_t simplex_35[] = { 18, 16, 17, 18, 15, 20, 13, 21, 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5 }; -const int8_t simplex_36[] = { 4, 21, 4, 0, -1, -1, 4, 21, 11, 21, 14, 20, 16, 18, 17, 16, 18, 13, 18, 8, 17, 5, 16, 3, 14, 1, 11, 0, 4, 0 }; -const int8_t simplex_37[] = { 4, 21, 4, 0, -1, -1, 4, 21, 17, 21, -1, -1, 4, 11, 12, 11, -1, -1, 4, 0, 17, 0 }; -const int8_t simplex_38[] = { 4, 21, 4, 0, -1, -1, 4, 21, 17, 21, -1, -1, 4, 11, 12, 11 }; -const int8_t simplex_39[] = { 18, 16, 17, 18, 15, 20, 13, 21, 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5, 18, 8, -1, -1, 13, 8, 18, 8 }; -const int8_t simplex_40[] = { 4, 21, 4, 0, -1, -1, 18, 21, 18, 0, -1, -1, 4, 11, 18, 11 }; -const int8_t simplex_41[] = { 4, 21, 4, 0 }; -const int8_t simplex_42[] = { 12, 21, 12, 5, 11, 2, 10, 1, 8, 0, 6, 0, 4, 1, 3, 2, 2, 5, 2, 7 }; -const int8_t simplex_43[] = { 4, 21, 4, 0, -1, -1, 18, 21, 4, 7, -1, -1, 9, 12, 18, 0 }; -const int8_t simplex_44[] = { 4, 21, 4, 0, -1, -1, 4, 0, 16, 0 }; -const int8_t simplex_45[] = { 4, 21, 4, 0, -1, -1, 4, 21, 12, 0, -1, -1, 20, 21, 12, 0, -1, -1, 20, 21, 20, 0 }; -const int8_t simplex_46[] = { 4, 21, 4, 0, -1, -1, 4, 21, 18, 0, -1, -1, 18, 21, 18, 0 }; -const int8_t simplex_47[] = { 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5, 19, 8, 19, 13, 18, 16, 17, 18, 15, 20, 13, 21, 9, 21 }; -const int8_t simplex_48[] = { 4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 14, 17, 12, 16, 11, 13, 10, 4, 10 }; -const int8_t simplex_49[] = { 9, 21, 7, 20, 5, 18, 4, 16, 3, 13, 3, 8, 4, 5, 5, 3, 7, 1, 9, 0, 13, 0, 15, 1, 17, 3, 18, 5, 19, 8, 19, 13, 18, 16, 17, 18, 15, 20, 13, 21, 9, 21, -1, -1, 12, 4, 18, -2 }; -const int8_t simplex_50[] = { 4, 21, 4, 0, -1, -1, 4, 21, 13, 21, 16, 20, 17, 19, 18, 17, 18, 15, 17, 13, 16, 12, 13, 11, 4, 11, -1, -1, 11, 11, 18, 0 }; -const int8_t simplex_51[] = { 17, 18, 15, 20, 12, 21, 8, 21, 5, 20, 3, 18, 3, 16, 4, 14, 5, 13, 7, 12, 13, 10, 15, 9, 16, 8, 17, 6, 17, 3, 15, 1, 12, 0, 8, 0, 5, 1, 3, 3 }; -const int8_t simplex_52[] = { 8, 21, 8, 0, -1, -1, 1, 21, 15, 21 }; -const int8_t simplex_53[] = { 4, 21, 4, 6, 5, 3, 7, 1, 10, 0, 12, 0, 15, 1, 17, 3, 18, 6, 18, 21 }; -const int8_t simplex_54[] = { 1, 21, 9, 0, -1, -1, 17, 21, 9, 0 }; -const int8_t simplex_55[] = { 2, 21, 7, 0, -1, -1, 12, 21, 7, 0, -1, -1, 12, 21, 17, 0, -1, -1, 22, 21, 17, 0 }; -const int8_t simplex_56[] = { 3, 21, 17, 0, -1, -1, 17, 21, 3, 0 }; -const int8_t simplex_57[] = { 1, 21, 9, 11, 9, 0, -1, -1, 17, 21, 9, 11 }; -const int8_t simplex_58[] = { 17, 21, 3, 0, -1, -1, 3, 21, 17, 21, -1, -1, 3, 0, 17, 0 }; -const int8_t simplex_59[] = { 4, 25, 4, -7, -1, -1, 5, 25, 5, -7, -1, -1, 4, 25, 11, 25, -1, -1, 4, -7, 11, -7 }; -const int8_t simplex_60[] = { 0, 21, 14, -3 }; -const int8_t simplex_61[] = { 9, 25, 9, -7, -1, -1, 10, 25, 10, -7, -1, -1, 3, 25, 10, 25, -1, -1, 3, -7, 10, -7 }; -const int8_t simplex_62[] = { 6, 15, 8, 18, 10, 15, -1, -1, 3, 12, 8, 17, 13, 12, -1, -1, 8, 17, 8, 0 }; -const int8_t simplex_63[] = { 0, -2, 16, -2 }; -const int8_t simplex_64[] = { 6, 21, 5, 20, 4, 18, 4, 16, 5, 15, 6, 16, 5, 17 }; -const int8_t simplex_65[] = { 15, 14, 15, 0, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_66[] = { 4, 21, 4, 0, -1, -1, 4, 11, 6, 13, 8, 14, 11, 14, 13, 13, 15, 11, 16, 8, 16, 6, 15, 3, 13, 1, 11, 0, 8, 0, 6, 1, 4, 3 }; -const int8_t simplex_67[] = { 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_68[] = { 15, 21, 15, 0, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_69[] = { 3, 8, 15, 8, 15, 10, 14, 12, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_70[] = { 10, 21, 8, 21, 6, 20, 5, 17, 5, 0, -1, -1, 2, 14, 9, 14 }; -const int8_t simplex_71[] = { 15, 14, 15, -2, 14, -5, 13, -6, 11, -7, 8, -7, 6, -6, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_72[] = { 4, 21, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0 }; -const int8_t simplex_73[] = { 3, 21, 4, 20, 5, 21, 4, 22, 3, 21, -1, -1, 4, 14, 4, 0 }; -const int8_t simplex_74[] = { 5, 21, 6, 20, 7, 21, 6, 22, 5, 21, -1, -1, 6, 14, 6, -3, 5, -6, 3, -7, 1, -7 }; -const int8_t simplex_75[] = { 4, 21, 4, 0, -1, -1, 14, 14, 4, 4, -1, -1, 8, 8, 15, 0 }; -const int8_t simplex_76[] = { 4, 21, 4, 0 }; -const int8_t simplex_77[] = { 4, 14, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0, -1, -1, 15, 10, 18, 13, 20, 14, 23, 14, 25, 13, 26, 10, 26, 0 }; -const int8_t simplex_78[] = { 4, 14, 4, 0, -1, -1, 4, 10, 7, 13, 9, 14, 12, 14, 14, 13, 15, 10, 15, 0 }; -const int8_t simplex_79[] = { 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3, 16, 6, 16, 8, 15, 11, 13, 13, 11, 14, 8, 14 }; -const int8_t simplex_80[] = { 4, 14, 4, -7, -1, -1, 4, 11, 6, 13, 8, 14, 11, 14, 13, 13, 15, 11, 16, 8, 16, 6, 15, 3, 13, 1, 11, 0, 8, 0, 6, 1, 4, 3 }; -const int8_t simplex_81[] = { 15, 14, 15, -7, -1, -1, 15, 11, 13, 13, 11, 14, 8, 14, 6, 13, 4, 11, 3, 8, 3, 6, 4, 3, 6, 1, 8, 0, 11, 0, 13, 1, 15, 3 }; -const int8_t simplex_82[] = { 4, 14, 4, 0, -1, -1, 4, 8, 5, 11, 7, 13, 9, 14, 12, 14 }; -const int8_t simplex_83[] = { 14, 11, 13, 13, 10, 14, 7, 14, 4, 13, 3, 11, 4, 9, 6, 8, 11, 7, 13, 6, 14, 4, 14, 3, 13, 1, 10, 0, 7, 0, 4, 1, 3, 3 }; -const int8_t simplex_84[] = { 5, 21, 5, 4, 6, 1, 8, 0, 10, 0, -1, -1, 2, 14, 9, 14 }; -const int8_t simplex_85[] = { 4, 14, 4, 4, 5, 1, 7, 0, 10, 0, 12, 1, 15, 4, -1, -1, 15, 14, 15, 0 }; -const int8_t simplex_86[] = { 2, 14, 8, 0, -1, -1, 14, 14, 8, 0 }; -const int8_t simplex_87[] = { 3, 14, 7, 0, -1, -1, 11, 14, 7, 0, -1, -1, 11, 14, 15, 0, -1, -1, 19, 14, 15, 0 }; -const int8_t simplex_88[] = { 3, 14, 14, 0, -1, -1, 14, 14, 3, 0 }; -const int8_t simplex_89[] = { 2, 14, 8, 0, -1, -1, 14, 14, 8, 0, 6, -4, 4, -6, 2, -7, 1, -7 }; -const int8_t simplex_90[] = { 14, 14, 3, 0, -1, -1, 3, 14, 14, 14, -1, -1, 3, 0, 14, 0 }; -const int8_t simplex_91[] = { 9, 25, 7, 24, 6, 23, 5, 21, 5, 19, 6, 17, 7, 16, 8, 14, 8, 12, 6, 10, -1, -1, 7, 24, 6, 22, 6, 20, 7, 18, 8, 17, 9, 15, 9, 13, 8, 11, 4, 9, 8, 7, 9, 5, 9, 3, 8, 1, 7, 0, 6, -2, 6, -4, 7, -6, -1, -1, 6, 8, 8, 6, 8, 4, 7, 2, 6, 1, 5, -1, 5, -3, 6, -5, 7, -6, 9, -7 }; -const int8_t simplex_92[] = { 4, 25, 4, -7 }; -const int8_t simplex_93[] = { 5, 25, 7, 24, 8, 23, 9, 21, 9, 19, 8, 17, 7, 16, 6, 14, 6, 12, 8, 10, -1, -1, 7, 24, 8, 22, 8, 20, 7, 18, 6, 17, 5, 15, 5, 13, 6, 11, 10, 9, 6, 7, 5, 5, 5, 3, 6, 1, 7, 0, 8, -2, 8, -4, 7, -6, -1, -1, 8, 8, 6, 6, 6, 4, 7, 2, 8, 1, 9, -1, 9, -3, 8, -5, 7, -6, 5, -7 }; -const int8_t simplex_94[] = { 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16, 7, 18, 7, 20, 8, 21, 10, -1, -1, 3, 8, 4, 10, 6, 11, 8, 11, 10, 10, 14, 7, 16, 6, 18, 6, 20, 7, 21, 10, 21, 12 }; - -struct glyph { - uint8_t width; - uint8_t length; - const int8_t *data; -}; - -// Font data From Hershey Simplex Font -// http://paulbourke.net/dataformats/hershey/ - -const glyph simplex[] = { - /* 32 */ { 16, 0, nullptr }, - /* 33 ! */ { 10, sizeof(simplex_1), simplex_1 }, - /* 34 " */ { 16, sizeof(simplex_2), simplex_2 }, - /* 35 # */ { 21, sizeof(simplex_3), simplex_3 }, - /* 36 $ */ { 20, sizeof(simplex_4), simplex_4 }, - /* 37 % */ { 24, sizeof(simplex_5), simplex_5 }, - /* 38 & */ { 26, sizeof(simplex_6), simplex_6 }, - /* 39 ' */ { 10, sizeof(simplex_7), simplex_7 }, - /* 40 ( */ { 14, sizeof(simplex_8), simplex_8 }, - /* 41 ) */ { 14, sizeof(simplex_9), simplex_9 }, - /* 42 * */ { 16, sizeof(simplex_10), simplex_10 }, - /* 43 + */ { 26, sizeof(simplex_11), simplex_11 }, - /* 44 , */ { 10, sizeof(simplex_12), simplex_12 }, - /* 45 - */ { 26, sizeof(simplex_13), simplex_13 }, - /* 46 . */ { 10, sizeof(simplex_14), simplex_14 }, - /* 47 / */ { 22, sizeof(simplex_15), simplex_15 }, - /* 48 0 */ { 20, sizeof(simplex_16), simplex_16 }, - /* 49 1 */ { 20, sizeof(simplex_17), simplex_17 }, - /* 50 2 */ { 20, sizeof(simplex_18), simplex_18 }, - /* 51 3 */ { 20, sizeof(simplex_19), simplex_19 }, - /* 52 4 */ { 20, sizeof(simplex_20), simplex_20 }, - /* 53 5 */ { 20, sizeof(simplex_21), simplex_21 }, - /* 54 6 */ { 20, sizeof(simplex_22), simplex_22 }, - /* 55 7 */ { 20, sizeof(simplex_23), simplex_23 }, - /* 56 8 */ { 20, sizeof(simplex_24), simplex_24 }, - /* 57 9 */ { 20, sizeof(simplex_25), simplex_25 }, - /* 58 : */ { 10, sizeof(simplex_26), simplex_26 }, - /* 59 ; */ { 10, sizeof(simplex_27), simplex_27 }, - /* 60 < */ { 24, sizeof(simplex_28), simplex_28 }, - /* 61 = */ { 26, sizeof(simplex_29), simplex_29 }, - /* 62 > */ { 24, sizeof(simplex_30), simplex_30 }, - /* 63 ? */ { 18, sizeof(simplex_31), simplex_31 }, - /* 64 @ */ { 27, sizeof(simplex_32), simplex_32 }, - /* 65 A */ { 18, sizeof(simplex_33), simplex_33 }, - /* 66 B */ { 21, sizeof(simplex_34), simplex_34 }, - /* 67 C */ { 21, sizeof(simplex_35), simplex_35 }, - /* 68 D */ { 21, sizeof(simplex_36), simplex_36 }, - /* 69 E */ { 19, sizeof(simplex_37), simplex_37 }, - /* 70 F */ { 18, sizeof(simplex_38), simplex_38 }, - /* 71 G */ { 21, sizeof(simplex_39), simplex_39 }, - /* 72 H */ { 22, sizeof(simplex_40), simplex_40 }, - /* 73 I */ { 8, sizeof(simplex_41), simplex_41 }, - /* 74 J */ { 16, sizeof(simplex_42), simplex_42 }, - /* 75 K */ { 21, sizeof(simplex_43), simplex_43 }, - /* 76 L */ { 17, sizeof(simplex_44), simplex_44 }, - /* 77 M */ { 24, sizeof(simplex_45), simplex_45 }, - /* 78 N */ { 22, sizeof(simplex_46), simplex_46 }, - /* 79 O */ { 22, sizeof(simplex_47), simplex_47 }, - /* 80 P */ { 21, sizeof(simplex_48), simplex_48 }, - /* 81 Q */ { 22, sizeof(simplex_49), simplex_49 }, - /* 82 R */ { 21, sizeof(simplex_50), simplex_50 }, - /* 83 S */ { 20, sizeof(simplex_51), simplex_51 }, - /* 84 T */ { 16, sizeof(simplex_52), simplex_52 }, - /* 85 U */ { 22, sizeof(simplex_53), simplex_53 }, - /* 86 V */ { 18, sizeof(simplex_54), simplex_54 }, - /* 87 W */ { 24, sizeof(simplex_55), simplex_55 }, - /* 88 X */ { 20, sizeof(simplex_56), simplex_56 }, - /* 89 Y */ { 18, sizeof(simplex_57), simplex_57 }, - /* 90 Z */ { 20, sizeof(simplex_58), simplex_58 }, - /* 91 [ */ { 14, sizeof(simplex_59), simplex_59 }, - /* 92 \ */ { 14, sizeof(simplex_60), simplex_60 }, - /* 93 ] */ { 14, sizeof(simplex_61), simplex_61 }, - /* 94 ^ */ { 16, sizeof(simplex_62), simplex_62 }, - /* 95 _ */ { 16, sizeof(simplex_63), simplex_63 }, - /* 96 ` */ { 10, sizeof(simplex_64), simplex_64 }, - /* 97 a */ { 19, sizeof(simplex_65), simplex_65 }, - /* 98 b */ { 19, sizeof(simplex_66), simplex_66 }, - /* 99 c */ { 18, sizeof(simplex_67), simplex_67 }, - /* 100 d */ { 19, sizeof(simplex_68), simplex_68 }, - /* 101 e */ { 18, sizeof(simplex_69), simplex_69 }, - /* 102 f */ { 12, sizeof(simplex_70), simplex_70 }, - /* 103 g */ { 19, sizeof(simplex_71), simplex_71 }, - /* 104 h */ { 19, sizeof(simplex_72), simplex_72 }, - /* 105 i */ { 8, sizeof(simplex_73), simplex_73 }, - /* 106 j */ { 10, sizeof(simplex_74), simplex_74 }, - /* 107 k */ { 17, sizeof(simplex_75), simplex_75 }, - /* 108 l */ { 8, sizeof(simplex_76), simplex_76 }, - /* 109 m */ { 30, sizeof(simplex_77), simplex_77 }, - /* 110 n */ { 19, sizeof(simplex_78), simplex_78 }, - /* 111 o */ { 19, sizeof(simplex_79), simplex_79 }, - /* 112 p */ { 19, sizeof(simplex_80), simplex_80 }, - /* 113 q */ { 19, sizeof(simplex_81), simplex_81 }, - /* 114 r */ { 13, sizeof(simplex_82), simplex_82 }, - /* 115 s */ { 17, sizeof(simplex_83), simplex_83 }, - /* 116 t */ { 12, sizeof(simplex_84), simplex_84 }, - /* 117 u */ { 19, sizeof(simplex_85), simplex_85 }, - /* 118 v */ { 16, sizeof(simplex_86), simplex_86 }, - /* 119 w */ { 22, sizeof(simplex_87), simplex_87 }, - /* 120 x */ { 17, sizeof(simplex_88), simplex_88 }, - /* 121 y */ { 16, sizeof(simplex_89), simplex_89 }, - /* 122 z */ { 17, sizeof(simplex_90), simplex_90 }, - /* 123 { */ { 14, sizeof(simplex_91), simplex_91 }, - /* 124 | */ { 8, sizeof(simplex_92), simplex_92 }, - /* 125 } */ { 14, sizeof(simplex_93), simplex_93 }, - /* 126 ~ */ { 24, sizeof(simplex_94), simplex_94 }, -}; diff --git a/src/geometry/elements_buffer.cpp b/src/geometry/elements_buffer.cpp deleted file mode 100644 index 79af1b7e35..0000000000 --- a/src/geometry/elements_buffer.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include - -using namespace mbgl; - -void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) { - element_type *elements = static_cast(addElement()); - elements[0] = a; - elements[1] = b; - elements[2] = c; -} - -void LineElementsBuffer::add(element_type a, element_type b) { - element_type *elements = static_cast(addElement()); - elements[0] = a; - elements[1] = b; -} - -void PointElementsBuffer::add(element_type a) { - uint16_t *data = static_cast(addElement()); - data[0] = a; -} diff --git a/src/geometry/fill_buffer.cpp b/src/geometry/fill_buffer.cpp deleted file mode 100644 index c75ad3477d..0000000000 --- a/src/geometry/fill_buffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -#include - -using namespace mbgl; - -void FillVertexBuffer::add(vertex_type x, vertex_type y) { - vertex_type *vertices = static_cast(addElement()); - vertices[0] = x; - vertices[1] = y; -} diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp deleted file mode 100644 index 40459821fd..0000000000 --- a/src/geometry/glyph_atlas.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include - -#include -#include - - -using namespace mbgl; - -GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) - : width(width_), - height(height_), - bin(width_, height_), - data(new char[width_ *height_]), - dirty(true) { -} - -Rect GlyphAtlas::addGlyph(uint64_t tile_id, const std::string& face_name, - const SDFGlyph& glyph) -{ - std::lock_guard lock(mtx); - return addGlyph_impl(tile_id, face_name, glyph); -} - -Rect GlyphAtlas::addGlyph_impl(uint64_t tile_id, const std::string& face_name, - const SDFGlyph& glyph) -{ - // Use constant value for now. - const uint8_t buffer = 3; - - std::map& face = index[face_name]; - std::map::iterator it = face.find(glyph.id); - - // The glyph is already in this texture. - if (it != face.end()) { - GlyphValue& value = it->second; - value.ids.insert(tile_id); - return value.rect; - } - - // The glyph bitmap has zero width. - if (!glyph.bitmap.size()) { - return Rect{ 0, 0, 0, 0 }; - } - - uint16_t buffered_width = glyph.metrics.width + buffer * 2; - uint16_t buffered_height = glyph.metrics.height + buffer * 2; - - // Add a 1px border around every image. - uint16_t pack_width = buffered_width; - uint16_t pack_height = buffered_height; - - // Increase to next number divisible by 4, but at least 1. - // This is so we can scale down the texture coordinates and pack them - // into 2 bytes rather than 4 bytes. - pack_width += (4 - pack_width % 4); - pack_height += (4 - pack_height % 4); - - Rect rect = bin.allocate(pack_width, pack_height); - if (rect.w == 0) { - fprintf(stderr, "glyph bitmap overflow"); - return rect; - } - - assert(rect.x + rect.w <= width); - assert(rect.y + rect.h <= height); - - face.emplace(glyph.id, GlyphValue { rect, tile_id }); - - // Copy the bitmap - char *target = data.get(); - const char *source = glyph.bitmap.data(); - for (uint32_t y = 0; y < buffered_height; y++) { - uint32_t y1 = width * (rect.y + y) + rect.x; - uint32_t y2 = buffered_width * y; - for (uint32_t x = 0; x < buffered_width; x++) { - target[y1 + x] = source[y2 + x]; - } - } - - dirty = true; - - return rect; -} - -void GlyphAtlas::addGlyphs(uint64_t tileid, std::u32string const& text, std::string const& stackname, FontStack const& fontStack, GlyphPositions & face) -{ - std::lock_guard lock(mtx); - - std::map const& sdfs = fontStack.getSDFs(); - for (uint32_t chr : text) - { - auto sdf_it = sdfs.find(chr); - if (sdf_it != sdfs.end()) - { - SDFGlyph const& sdf = sdf_it->second; - Rect rect = addGlyph_impl(tileid, stackname, sdf); - face.emplace(chr, Glyph{rect, sdf.metrics}); - } - } -} - -void GlyphAtlas::removeGlyphs(uint64_t tile_id) { - std::lock_guard lock(mtx); - - for (auto& faces : index) { - std::map& face = faces.second; - for (auto it = face.begin(); it != face.end(); /* we advance in the body */) { - GlyphValue& value = it->second; - value.ids.erase(tile_id); - - if (!value.ids.size()) { - const Rect& rect = value.rect; - - // Clear out the bitmap. - char *target = data.get(); - for (uint32_t y = 0; y < rect.h; y++) { - uint32_t y1 = width * (rect.y + y) + rect.x; - for (uint32_t x = 0; x < rect.w; x++) { - target[y1 + x] = 0; - } - } - - dirty = true; - - bin.release(rect); - - // Make sure to post-increment the iterator: This will return the - // current iterator, but will go to the next position before we - // erase the element from the map. That way, the iterator stays - // valid. - face.erase(it++); - } else { - ++it; - } - } - } -} - -void GlyphAtlas::bind() { - if (!texture) { - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); -#ifndef GL_ES_VERSION_2_0 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); -#endif - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } else { - glBindTexture(GL_TEXTURE_2D, texture); - } - - if (dirty) { - std::lock_guard lock(mtx); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data.get()); - dirty = false; - -#if defined(DEBUG) - // platform::show_debug_image("Glyph Atlas", data, width, height); -#endif - } -}; diff --git a/src/geometry/icon_buffer.cpp b/src/geometry/icon_buffer.cpp deleted file mode 100644 index c571dfa69e..0000000000 --- a/src/geometry/icon_buffer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -#include - -namespace mbgl { - -const double IconVertexBuffer::angleFactor = 128.0 / M_PI; - -size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float angle, float minzoom, std::array range, float maxzoom, float labelminzoom) { - const size_t idx = index(); - void *data = addElement(); - - int16_t *shorts = static_cast(data); - shorts[0] /* pos */ = x; - shorts[1] /* pos */ = y; - shorts[2] /* offset */ = std::round(ox * 64); // use 1/64 pixels for placement - shorts[3] /* offset */ = std::round(oy * 64); - - uint8_t *ubytes = static_cast(data); - ubytes[8] /* labelminzoom */ = labelminzoom * 10; - ubytes[9] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160. - ubytes[10] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. - ubytes[11] /* angle */ = (int16_t)std::round(angle * angleFactor) % 256; - ubytes[12] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256; - ubytes[13] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256; - - shorts[8] /* tex */ = tx; - shorts[9] /* tex */ = ty; - - return idx; -} - -} diff --git a/src/geometry/line_buffer.cpp b/src/geometry/line_buffer.cpp deleted file mode 100644 index 50a6e66b93..0000000000 --- a/src/geometry/line_buffer.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -#include - -using namespace mbgl; - -size_t LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, int8_t tx, int8_t ty, int32_t linesofar) { - size_t idx = index(); - void *data = addElement(); - - int16_t *coords = static_cast(data); - coords[0] = (x * 2) | tx; - coords[1] = (y * 2) | ty; - - int8_t *extrude = static_cast(data); - extrude[4] = std::round(extrudeScale * ex); - extrude[5] = std::round(extrudeScale * ey); - - coords[3] = linesofar; - - return idx; -} diff --git a/src/geometry/resample.cpp b/src/geometry/resample.cpp deleted file mode 100644 index abb3ef1e3c..0000000000 --- a/src/geometry/resample.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include - -#include - -#include - -namespace mbgl { - -const float minScale = 0.5f; -const std::array, 4> minScaleArrays = {{ - /*1:*/ { minScale }, - /*2:*/ { minScale, 2 }, - /*4:*/ { minScale, 4, 2, 4 }, - /*8:*/ { minScale, 8, 4, 8, 2, 8, 4, 8 } -}}; - - -Anchors resample(const std::vector &vertices, float spacing, - const float /*minScale*/, float maxScale, const float tilePixelRatio, - const int start) { - - maxScale = std::round(std::fmax(std::fmin(8.0f, maxScale / 2.0f), 1.0f)); - spacing *= tilePixelRatio / maxScale; - const size_t index = util::clamp(std::floor(std::log(maxScale) / std::log(2)), 0, minScaleArrays.size() - 1); - const std::vector &minScales = minScaleArrays[index]; - const size_t len = minScales.size(); - - float distance = 0.0f; - float markedDistance = 0.0f; - int added = start; - - Anchors points; - - auto end = vertices.end() - 1; - int i = 0; - for (auto it = vertices.begin(); it != end; it++, i++) { - const Coordinate &a = *(it), b = *(it + 1); - - float segmentDist = util::dist(a, b); - float angle = util::angle_to(b, a); - - while (markedDistance + spacing < distance + segmentDist) { - markedDistance += spacing; - - float t = (markedDistance - distance) / segmentDist, - x = util::interpolate(a.x, b.x, t), - y = util::interpolate(a.y, b.y, t), - s = minScales[added % len]; - - if (x >= 0 && x < 4096 && y >= 0 && y < 4096) { - points.emplace_back(x, y, angle, s, i); - } - - added++; - } - - distance += segmentDist; - } - - return points; -} -} diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp deleted file mode 100644 index 7dc8f60ae6..0000000000 --- a/src/geometry/sprite_atlas.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - - -using namespace mbgl; - -SpriteAtlas::SpriteAtlas(dimension width_, dimension height_) - : width(width_), - height(height_), - bin(width_, height_), - dirty(true) { -} - -bool SpriteAtlas::resize(const float newRatio) { - if (pixelRatio == newRatio) return false; - - std::lock_guard lock(mtx); - - const float oldRatio = pixelRatio; - pixelRatio = newRatio; - - if (data) { - uint32_t *old_data = data; - - data = nullptr; - allocate(); - - const int old_w = width * oldRatio; - const int old_h = height * oldRatio; - const int new_w = width * newRatio; - const int new_h = height * newRatio; - - // Basic image scaling. TODO: Replace this with better image scaling. - uint32_t *img_new = reinterpret_cast(data); - const uint32_t *img_old = reinterpret_cast(old_data); - - for (int y = 0; y < new_h; y++) { - const int old_yoffset = ((y * old_h) / new_h) * old_w; - const int new_yoffset = y * new_w; - for (int x = 0; x < new_w; x++) { - const int old_x = (x * old_w) / new_w; - img_new[new_yoffset + x] = img_old[old_yoffset + old_x]; - } - } - - ::operator delete(old_data); - dirty = true; - - // Mark all sprite images as in need of update - for (const auto &pair : images) { - uninitialized.emplace(pair.first); - } - } - - return dirty; -} - -void copy_bitmap(const uint32_t *src, const int src_stride, const int src_x, const int src_y, - uint32_t *dst, const int dst_stride, const int dst_x, const int dst_y, - const int width, const int height) { - src += src_y * src_stride + src_x; - dst += dst_y * dst_stride + dst_x; - for (int y = 0; y < height; y++, src += src_stride, dst += dst_stride) { - for (int x = 0; x < width; x++) { - dst[x] = src[x]; - } - } -} - -Rect SpriteAtlas::allocateImage(size_t pixel_width, size_t pixel_height) { - // We have to allocate a new area in the bin, and store an empty image in it. - // Add a 1px border around every image. - Rect rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer); - if (rect.w == 0) { - return rect; - } - - rect.x += buffer; - rect.y += buffer; - rect.w -= 2 * buffer; - rect.h -= 2 * buffer; - - return rect; -} - -Rect SpriteAtlas::getImage(const std::string& name) { - std::lock_guard lock(mtx); - - auto rect_it = images.find(name); - if (rect_it != images.end()) { - return rect_it->second; - } - - const SpritePosition &pos = sprite->getSpritePosition(name); - if (!pos.width || !pos.height) { - return Rect { 0, 0, 0, 0 }; - } - - Rect rect = allocateImage(pos.width / pos.pixelRatio, pos.height / pos.pixelRatio); - if (rect.w == 0) { - if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite atlas bitmap overflow\n"); - } - return rect; - } - - images.emplace(name, rect); - - copy(rect, pos); - - return rect; -} - -SpriteAtlasPosition SpriteAtlas::getPosition(const std::string& name, bool repeating) { - std::lock_guard lock(mtx); - // `repeating` indicates that the image will be used in a repeating pattern - // repeating pattern images are assumed to have a 1px padding that mirrors the opposite edge - // positions for repeating images are adjusted to exclude the edge - Rect rect = getImage(name); - const int r = repeating ? 1 : 0; - return SpriteAtlasPosition { - {{ float(rect.w) / pixelRatio, float(rect.h) / pixelRatio }}, - {{ float(rect.x + r) / width, float(rect.y + r) / height }}, - {{ float(rect.x + rect.w - 2*r) / width, float(rect.y + rect.h - 2*r) / height }} - }; -} - -void SpriteAtlas::allocate() { - if (!data) { - dimension w = static_cast(width * pixelRatio); - dimension h = static_cast(height * pixelRatio); - data = static_cast(::operator new(w * h * sizeof(uint32_t))); - std::fill(data, data + w * h, 0); - } -} - -void SpriteAtlas::copy(const Rect& dst, const SpritePosition& src) { - if (!sprite->raster) return; - const uint32_t *src_img = reinterpret_cast(sprite->raster->getData()); - if (!src_img) return; - allocate(); - uint32_t *dst_img = reinterpret_cast(data); - - copy_bitmap( - /* source buffer */ src_img, - /* source stride */ sprite->raster->getWidth(), - /* source x */ src.x, - /* source y */ src.y, - /* dest buffer */ dst_img, - /* dest stride */ width * pixelRatio, - /* dest x */ dst.x * pixelRatio, - /* dest y */ dst.y * pixelRatio, - /* icon dimension */ src.width, - /* icon dimension */ src.height - ); - - dirty = true; -} - -void SpriteAtlas::setSprite(util::ptr sprite_) { - std::lock_guard lock(mtx); - - sprite = sprite_; - - if (!sprite->isLoaded()) return; - - util::erase_if(uninitialized, [this](const std::string &name) { - Rect dst = getImage(name); - const SpritePosition& src = sprite->getSpritePosition(name); - if (!src) { - if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite doesn't have image with name '%s'\n", name.c_str()); - } - return true; - } - - if (src.width == dst.w * pixelRatio && src.height == dst.h * pixelRatio && src.pixelRatio == pixelRatio) { - copy(dst, src); - return true; - } else { - if (debug::spriteWarnings) { - fprintf(stderr, "[WARNING] sprite icon dimension mismatch\n"); - } - return false; - } - }); -} - -void SpriteAtlas::bind(bool linear) { - bool first = false; - if (!texture) { - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); -#ifndef GL_ES_VERSION_2_0 - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); -#endif - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - first = true; - } else { - glBindTexture(GL_TEXTURE_2D, texture); - } - - GLuint filter_val = linear ? GL_LINEAR : GL_NEAREST; - if (filter_val != filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_val); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_val); - filter = filter_val; - } - - if (dirty) { - std::lock_guard lock(mtx); - allocate(); - - if (first) { - glTexImage2D( - GL_TEXTURE_2D, // GLenum target - 0, // GLint level - GL_RGBA, // GLint internalformat - width * pixelRatio, // GLsizei width - height * pixelRatio, // GLsizei height - 0, // GLint border - GL_RGBA, // GLenum format - GL_UNSIGNED_BYTE, // GLenum type - data // const GLvoid * data - ); - } else { - glTexSubImage2D( - GL_TEXTURE_2D, // GLenum target - 0, // GLint level - 0, // GLint xoffset - 0, // GLint yoffset - width * pixelRatio, // GLsizei width - height * pixelRatio, // GLsizei height - GL_RGBA, // GLenum format - GL_UNSIGNED_BYTE, // GLenum type - data // const GLvoid *pixels - ); - } - - dirty = false; - } -}; - -SpriteAtlas::~SpriteAtlas() { - std::lock_guard lock(mtx); - - glDeleteTextures(1, &texture); - texture = 0; - ::operator delete(data), data = nullptr; -} diff --git a/src/geometry/static_vertex_buffer.cpp b/src/geometry/static_vertex_buffer.cpp deleted file mode 100644 index c86211c50f..0000000000 --- a/src/geometry/static_vertex_buffer.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -namespace mbgl { - -StaticVertexBuffer::StaticVertexBuffer(std::initializer_list> init) { - for (const std::pair &vertex : init) { - vertex_type *vertices = static_cast(addElement()); - vertices[0] = vertex.first; - vertices[1] = vertex.second; - } -} - -} diff --git a/src/geometry/text_buffer.cpp b/src/geometry/text_buffer.cpp deleted file mode 100644 index 295ff02efa..0000000000 --- a/src/geometry/text_buffer.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include - -#include - -using namespace mbgl; - -const double TextVertexBuffer::angleFactor = 128.0 / M_PI; - -size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array range, float maxzoom, float labelminzoom) { - size_t idx = index(); - void *data = addElement(); - - int16_t *shorts = static_cast(data); - shorts[0] = x; - shorts[1] = y; - shorts[2] = std::round(ox * 64); // use 1/64 pixels for placement - shorts[3] = std::round(oy * 64); - - uint8_t *ubytes = static_cast(data); - ubytes[8] = labelminzoom * 10; - ubytes[9] = minzoom * 10; // 1/10 zoom levels: z16 == 160. - ubytes[10] = fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160. - ubytes[11] = (int16_t)round(angle * angleFactor) % 256; - ubytes[12] = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256; - ubytes[13] = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256; - - ubytes[14] = tx / 4; - ubytes[15] = ty / 4; - - return idx; -} diff --git a/src/geometry/vao.cpp b/src/geometry/vao.cpp deleted file mode 100644 index 66822ba5ce..0000000000 --- a/src/geometry/vao.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include - -namespace mbgl { - -VertexArrayObject::~VertexArrayObject() { - if (!gl::DeleteVertexArrays) return; - - if (vao) { - gl::DeleteVertexArrays(1, &vao); - } -} - -void VertexArrayObject::bindVertexArrayObject() { - if (!gl::GenVertexArrays || !gl::BindVertexArray) { - static bool reported = false; - if (!reported) { - Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); - reported = true; - } - return; - } - - if (!vao) { - gl::GenVertexArrays(1, &vao); - } - gl::BindVertexArray(vao); -} - -void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, - char *offset) { - if (bound_shader != shader.getID()) { - throw std::runtime_error(std::string("trying to rebind VAO to another shader from " + - util::toString(bound_shader) + "(" + bound_shader_name + ") to " + - util::toString(shader.getID()) + "(" + shader.name + ")" )); - } else if (bound_offset != offset) { - throw std::runtime_error("trying to bind VAO to another offset"); - } else if (bound_vertex_buffer != vertexBuffer) { - throw std::runtime_error("trying to bind VAO to another vertex buffer"); - } else if (bound_elements_buffer != elementsBuffer) { - throw std::runtime_error("trying to bind VAO to another elements buffer"); - } -} - -void VertexArrayObject::storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, - char *offset) { - bound_shader = shader.getID(); - bound_shader_name = shader.name; - bound_offset = offset; - bound_vertex_buffer = vertexBuffer; - bound_elements_buffer = elementsBuffer; -} - -} diff --git a/src/libtess2/bucketalloc.c b/src/libtess2/bucketalloc.c index df1a83c76c..efb2b9813b 100755 --- a/src/libtess2/bucketalloc.c +++ b/src/libtess2/bucketalloc.c @@ -35,7 +35,7 @@ extern "C" { #include #include -#include +#include "tesselator.h" //#define CHECK_BOUNDS diff --git a/src/libtess2/bucketalloc.h b/src/libtess2/bucketalloc.h index 7168cd7aa7..077d768136 100755 --- a/src/libtess2/bucketalloc.h +++ b/src/libtess2/bucketalloc.h @@ -36,7 +36,7 @@ extern "C" { #endif -#include +#include "tesselator.h" struct BucketAlloc *createBucketAlloc( TESSalloc* alloc, const char *name, unsigned int itemSize, unsigned int bucketSize ); diff --git a/src/libtess2/dict.c b/src/libtess2/dict.c index 53c66568d1..dd7bade2c8 100755 --- a/src/libtess2/dict.c +++ b/src/libtess2/dict.c @@ -30,7 +30,7 @@ */ #include -#include +#include "tesselator.h" #include "bucketalloc.h" #include "dict.h" diff --git a/src/libtess2/mesh.h b/src/libtess2/mesh.h index d6142716a9..1e16a194c1 100755 --- a/src/libtess2/mesh.h +++ b/src/libtess2/mesh.h @@ -32,7 +32,7 @@ #ifndef MESH_H #define MESH_H -#include +#include "tesselator.h" typedef struct TESSmesh TESSmesh; typedef struct TESSvertex TESSvertex; diff --git a/src/libtess2/priorityq.c b/src/libtess2/priorityq.c index 49e1c012f5..6229b6bfce 100755 --- a/src/libtess2/priorityq.c +++ b/src/libtess2/priorityq.c @@ -32,7 +32,7 @@ //#include "tesos.h" #include #include -#include +#include "tesselator.h" #include "priorityq.h" diff --git a/src/libtess2/tess.h b/src/libtess2/tess.h index e4673b34ff..8ed75600d2 100755 --- a/src/libtess2/tess.h +++ b/src/libtess2/tess.h @@ -37,7 +37,7 @@ #include "mesh.h" #include "dict.h" #include "priorityq.h" -#include +#include "tesselator.h" #ifdef __cplusplus extern "C" { diff --git a/src/libtess2/tesselator.h b/src/libtess2/tesselator.h new file mode 100755 index 0000000000..74ca18e27d --- /dev/null +++ b/src/libtess2/tesselator.h @@ -0,0 +1,209 @@ +/* +** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) +** Copyright (C) [dates of first publication] Silicon Graphics, Inc. +** All Rights Reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +** of the Software, and to permit persons to whom the Software is furnished to do so, +** subject to the following conditions: +** +** The above copyright notice including the dates of first publication and either this +** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. +** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +** OR OTHER DEALINGS IN THE SOFTWARE. +** +** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not +** be used in advertising or otherwise to promote the sale, use or other dealings in +** this Software without prior written authorization from Silicon Graphics, Inc. +*/ +/* +** Author: Mikko Mononen, July 2009. +*/ + +#ifndef TESSELATOR_H +#define TESSELATOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +// See OpenGL Red Book for description of the winding rules +// http://www.glprogramming.com/red/chapter11.html +enum TessWindingRule +{ + TESS_WINDING_ODD, + TESS_WINDING_NONZERO, + TESS_WINDING_POSITIVE, + TESS_WINDING_NEGATIVE, + TESS_WINDING_ABS_GEQ_TWO, +}; + +// The contents of the tessGetElements() depends on element type being passed to tessTesselate(). +// Tesselation result element types: +// TESS_POLYGONS +// Each element in the element array is polygon defined as 'polySize' number of vertex indices. +// If a polygon has than 'polySize' vertices, the remaining indices are stored as TESS_UNDEF. +// Example, drawing a polygon: +// const int nelems = tessGetElementCount(tess); +// const TESSindex* elems = tessGetElements(tess); +// for (int i = 0; i < nelems; i++) { +// const TESSindex* poly = &elems[i * polySize]; +// glBegin(GL_POLYGON); +// for (int j = 0; j < polySize; j++) { +// if (poly[j] == TESS_UNDEF) break; +// glVertex2fv(&verts[poly[j]*vertexSize]); +// } +// glEnd(); +// } +// +// TESS_CONNECTED_POLYGONS +// Each element in the element array is polygon defined as 'polySize' number of vertex indices, +// followed by 'polySize' indices to neighour polygons, that is each element is 'polySize' * 2 indices. +// If a polygon has than 'polySize' vertices, the remaining indices are stored as TESS_UNDEF. +// If a polygon edge is a boundary, that is, not connected to another polygon, the neighbour index is TESS_UNDEF. +// Example, flood fill based on seed polygon: +// const int nelems = tessGetElementCount(tess); +// const TESSindex* elems = tessGetElements(tess); +// unsigned char* visited = (unsigned char*)calloc(nelems); +// TESSindex stack[50]; +// int nstack = 0; +// stack[nstack++] = seedPoly; +// visited[startPoly] = 1; +// while (nstack > 0) { +// TESSindex idx = stack[--nstack]; +// const TESSindex* poly = &elems[idx * polySize * 2]; +// const TESSindex* nei = &poly[polySize]; +// for (int i = 0; i < polySize; i++) { +// if (poly[i] == TESS_UNDEF) break; +// if (nei[i] != TESS_UNDEF && !visited[nei[i]]) +// stack[nstack++] = nei[i]; +// visited[nei[i]] = 1; +// } +// } +// } +// +// TESS_BOUNDARY_CONTOURS +// Each element in the element array is [base index, count] pair defining a range of vertices for a contour. +// The first value is index to first vertex in contour and the second value is number of vertices in the contour. +// Example, drawing contours: +// const int nelems = tessGetElementCount(tess); +// const TESSindex* elems = tessGetElements(tess); +// for (int i = 0; i < nelems; i++) { +// const TESSindex base = elems[i * 2]; +// const TESSindex count = elems[i * 2 + 1]; +// glBegin(GL_LINE_LOOP); +// for (int j = 0; j < count; j++) { +// glVertex2fv(&verts[(base+count) * vertexSize]); +// } +// glEnd(); +// } +// +enum TessElementType +{ + TESS_POLYGONS, + TESS_CONNECTED_POLYGONS, + TESS_BOUNDARY_CONTOURS, +}; + +typedef float TESSreal; +typedef int TESSindex; +typedef struct TESStesselator TESStesselator; +typedef struct TESSalloc TESSalloc; + +#define TESS_UNDEF (~(TESSindex)0) + +// Custom memory allocator interface. +// The internal memory allocator allocates mesh edges, vertices and faces +// as well as dictionary nodes and active regions in buckets and uses simple +// freelist to speed up the allocation. The bucket size should roughly match your +// expected input data. For example if you process only hundreds of vertices, +// a bucket size of 128 might be ok, where as when processing thousands of vertices +// bucket size of 1024 might be approproate. The bucket size is a compromise between +// how often to allocate memory from the system versus how much extra space the system +// should allocate. Reasonable defaults are show in commects below, they will be used if +// the bucket sizes are zero. +// +// The use may left the memrealloc to be null. In that case, the tesselator will not try to +// dynamically grow int's internal arrays. The tesselator only needs the reallocation when it +// has found intersecting segments and needs to add new vertex. This defency can be cured by +// allocating some extra vertices beforehand. The 'extraVertices' variable allows to specify +// number of expected extra vertices. +struct TESSalloc +{ + void *(*memalloc)( void *userData, unsigned int size ); + void *(*memrealloc)( void *userData, void* ptr, unsigned int size ); + void (*memfree)( void *userData, void *ptr ); + void* userData; // User data passed to the allocator functions. + int meshEdgeBucketSize; // 512 + int meshVertexBucketSize; // 512 + int meshFaceBucketSize; // 256 + int dictNodeBucketSize; // 512 + int regionBucketSize; // 256 + int extraVertices; // Number of extra vertices allocated for the priority queue. +}; + +// tessNewTess() - Creates a new tesselator. +// Use tessDeleteTess() to delete the tesselator. +// Returns: +// new tesselator object. +TESStesselator* tessNewTess( TESSalloc* alloc ); + +// tessDeleteTess() - Deletes a tesselator. +// Parameters: +// tess - pointer to tesselator object to be deleted. +void tessDeleteTess( TESStesselator *tess ); + +// tessAddContour() - Adds a contour to be tesselated. +// The type of the vertex coordinates is assumed to be TESSreal. +// Parameters: +// tess - pointer to tesselator object. +// size - number of coordinates per vertex. Must be 2 or 3. +// pointer - pointer to the first coordinate of the first vertex in the array. +// stride - defines offset in bytes between consecutive vertices. +// count - number of vertices in contour. +void tessAddContour( TESStesselator *tess, int size, const void* pointer, int stride, int count ); + +// tessTesselate() - tesselate contours. +// Parameters: +// tess - pointer to tesselator object. +// windingRule - winding rules used for tesselation, must be one of TessWindingRule. +// elementType - defines the tesselation result element type, must be one of TessElementType. +// polySize - defines maximum vertices per polygons if output is polygons. +// vertexSize - defines the number of coordinates in tesselation result vertex, must be 2 or 3. +// normal - defines the normal of the input contours, of null the normal is calculated automatically. +// Returns: +// 1 if succeed, 0 if failed. +int tessTesselate( TESStesselator *tess, int windingRule, int elementType, int polySize, int vertexSize, const TESSreal* normal ); + +// tessGetVertexCount() - Returns number of vertices in the tesselated output. +int tessGetVertexCount( TESStesselator *tess ); + +// tessGetVertices() - Returns pointer to first coordinate of first vertex. +const TESSreal* tessGetVertices( TESStesselator *tess ); + +// tessGetVertexIndices() - Returns pointer to first vertex index. +// Vertex indices can be used to map the generated vertices to the original vertices. +// Every point added using tessAddContour() will get a new index starting at 0. +// New vertices generated at the intersections of segments are assigned value TESS_UNDEF. +const TESSindex* tessGetVertexIndices( TESStesselator *tess ); + +// tessGetElementCount() - Returns number of elements in the the tesselated output. +int tessGetElementCount( TESStesselator *tess ); + +// tessGetElements() - Returns pointer to the first element. +const TESSindex* tessGetElements( TESStesselator *tess ); + +#ifdef __cplusplus +} +#endif + +#endif // TESSELATOR_H diff --git a/src/map/map.cpp b/src/map/map.cpp deleted file mode 100644 index 822a98d63f..0000000000 --- a/src/map/map.cpp +++ /dev/null @@ -1,647 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define _USE_MATH_DEFINES -#include - -#include - -// Check libuv library version. -const static bool uv_version_check = []() { - const unsigned int version = uv_version(); - const unsigned int major = (version >> 16) & 0xFF; - const unsigned int minor = (version >> 8) & 0xFF; - const unsigned int patch = version & 0xFF; - -#ifndef UV_VERSION_PATCH - // 0.10 doesn't have UV_VERSION_PATCH defined, so we "fake" it by using the library patch level. - const unsigned int UV_VERSION_PATCH = version & 0xFF; -#endif - - if (major != UV_VERSION_MAJOR || minor != UV_VERSION_MINOR || patch != UV_VERSION_PATCH) { - throw std::runtime_error(mbgl::util::sprintf<96>( - "libuv version mismatch: headers report %d.%d.%d, but library reports %d.%d.%d", UV_VERSION_MAJOR, - UV_VERSION_MINOR, UV_VERSION_PATCH, major, minor, patch)); - } - return true; -}(); - - -#include -// Check zlib library version. -const static bool zlib_version_check = []() { - const char *const version = zlibVersion(); - if (version[0] != ZLIB_VERSION[0]) { - throw std::runtime_error(mbgl::util::sprintf<96>( - "zlib version mismatch: headers report %s, but library reports %s", ZLIB_VERSION, version)); - } - - return true; -}(); - - -#include -// Check sqlite3 library version. -const static bool sqlite_version_check = []() { - if (sqlite3_libversion_number() != SQLITE_VERSION_NUMBER) { - throw std::runtime_error(mbgl::util::sprintf<96>( - "sqlite3 libversion mismatch: headers report %d, but library reports %d", - SQLITE_VERSION_NUMBER, sqlite3_libversion_number())); - } - if (strcmp(sqlite3_sourceid(), SQLITE_SOURCE_ID) != 0) { - throw std::runtime_error(mbgl::util::sprintf<256>( - "sqlite3 sourceid mismatch: headers report \"%s\", but library reports \"%s\"", - SQLITE_SOURCE_ID, sqlite3_sourceid())); - } - - return true; -}(); - - -using namespace mbgl; - -Map::Map(View& view_, FileSource& fileSource_) - : loop(util::make_unique()), - view(view_), -#ifndef NDEBUG - mainThread(std::this_thread::get_id()), -#endif - transform(view_), - fileSource(fileSource_), - glyphAtlas(1024, 1024), - spriteAtlas(512, 512), - texturePool(std::make_shared()), - painter(spriteAtlas, glyphAtlas) -{ - view.initialize(this); - // Make sure that we're doing an initial drawing in all cases. - isClean.clear(); - isRendered.clear(); - isSwapped.test_and_set(); -} - -Map::~Map() { - if (async) { - stop(); - } - - // Explicitly reset all pointers. - activeSources.clear(); - sprite.reset(); - glyphStore.reset(); - style.reset(); - texturePool.reset(); - workers.reset(); - - uv_run(**loop, UV_RUN_DEFAULT); -} - -uv::worker &Map::getWorker() { - if (!workers) { - workers = util::make_unique(**loop, 4, "Tile Worker"); - } - return *workers; -} - -void Map::start() { - assert(std::this_thread::get_id() == mainThread); - assert(!async); - - // When starting map rendering in another thread, we perform async/continuously - // updated rendering. Only in these cases, we attach the async handlers. - async = true; - - // Reset the flag. - isStopped = false; - - // Setup async notifications - asyncTerminate = util::make_unique(**loop, [this]() { - assert(std::this_thread::get_id() == mapThread); - - // Remove all of these to make sure they are destructed in the correct thread. - glyphStore.reset(); - style.reset(); - workers.reset(); - activeSources.clear(); - - // Closes all open handles on the loop. This means that the loop will automatically terminate. - asyncCleanup.reset(); - asyncRender.reset(); - asyncTerminate.reset(); - }); - - asyncRender = util::make_unique(**loop, [this]() { - assert(std::this_thread::get_id() == mapThread); - - if (state.hasSize()) { - if (isRendered.test_and_set() == false) { - prepare(); - if (isClean.test_and_set() == false) { - render(); - isSwapped.clear(); - view.swap(); - } else { - // We set the rendered flag in the test above, so we have to reset it - // now that we're not actually rendering because the map is clean. - isRendered.clear(); - } - } - } - }); - - asyncCleanup = util::make_unique(**loop, [this]() { - painter.cleanup(); - }); - - thread = std::thread([this]() { -#ifndef NDEBUG - mapThread = std::this_thread::get_id(); -#endif - -#ifdef __APPLE__ - pthread_setname_np("Map"); -#endif - - run(); - -#ifndef NDEBUG - mapThread = std::thread::id(); -#endif - - // Make sure that the stop() function knows when to stop invoking the callback function. - isStopped = true; - view.notify(); - }); -} - -void Map::stop(stop_callback cb, void *data) { - assert(std::this_thread::get_id() == mainThread); - assert(mainThread != mapThread); - assert(async); - - asyncTerminate->send(); - - if (cb) { - // Wait until the render thread stopped. We are using this construct instead of plainly - // relying on the thread_join because the system might need to run things in the current - // thread that is required for the render thread to terminate correctly. This is for example - // the case with Cocoa's NSURLRequest. Otherwise, we will eventually deadlock because this - // thread (== main thread) is blocked. The callback function should use an efficient waiting - // function to avoid a busy waiting loop. - while (!isStopped) { - cb(data); - } - } - - // If a callback function was provided, this should return immediately because the thread has - // already finished executing. - thread.join(); - - async = false; -} - -void Map::run() { -#ifndef NDEBUG - if (!async) { - mapThread = mainThread; - } -#endif - assert(std::this_thread::get_id() == mapThread); - - setup(); - prepare(); - uv_run(**loop, UV_RUN_DEFAULT); - - // Run the event loop once more to make sure our async delete handlers are called. - uv_run(**loop, UV_RUN_ONCE); - - // If the map rendering wasn't started asynchronously, we perform one render - // *after* all events have been processed. - if (!async) { - render(); -#ifndef NDEBUG - mapThread = std::thread::id(); -#endif - } -} - -void Map::rerender() { - // We only send render events if we want to continuously update the map - // (== async rendering). - if (async) { - asyncRender->send(); - } -} - -void Map::update() { - isClean.clear(); - rerender(); -} - -bool Map::needsSwap() { - return isSwapped.test_and_set() == false; -} - -void Map::swapped() { - isRendered.clear(); - rerender(); -} - -void Map::cleanup() { - if (asyncCleanup != nullptr) { - asyncCleanup->send(); - } -} - -void Map::terminate() { - painter.terminate(); -} - -void Map::setReachability(bool reachable) { - // Note: This function may be called from *any* thread. - if (reachable) { - fileSource.prepare([&]() { - fileSource.retryAllPending(); - }); - } -} - -#pragma mark - Setup - -void Map::setup() { - assert(std::this_thread::get_id() == mapThread); - view.make_active(); - painter.setup(); - view.make_inactive(); -} - -void Map::setStyleURL(const std::string &url) { - // TODO: Make threadsafe. - styleURL = url; -} - - -void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) { - // TODO: Make threadsafe. - styleJSON.swap(newStyleJSON); - sprite.reset(); - if (!style) { - style = std::make_shared