diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-07-17 12:44:45 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-07-17 12:44:45 -0400 |
commit | 4cb9972278c2121a87161e3b02b2071acc1ca8e1 (patch) | |
tree | b0f017fda1740503c1bd7d5e3a28e586648d2e77 | |
parent | 056f9e88d5214ae5752ec946666c756e2bf3d72b (diff) | |
parent | fa4133a094a084527633038d2de1982ed4898a08 (diff) | |
download | qtlocation-mapboxgl-4cb9972278c2121a87161e3b02b2071acc1ca8e1.tar.gz |
Merge branch 'master' into fuzz-pipe
Conflicts:
bin/package.json
src/style/style_parser.cpp
test/fixtures/fixture_log.cpp
test/test.gyp
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 40 | ||||
-rwxr-xr-x | bin/build-shaders.js | 17 | ||||
-rw-r--r-- | bin/package.json | 2 | ||||
-rw-r--r-- | common/curl_request.cpp | 20 | ||||
-rw-r--r-- | common/foundation_request.mm | 16 | ||||
-rw-r--r-- | common/glfw_view.cpp | 14 | ||||
-rw-r--r-- | common/glfw_view.hpp | 12 | ||||
-rw-r--r-- | common/headless_view.cpp | 37 | ||||
-rw-r--r-- | common/headless_view.hpp | 20 | ||||
-rw-r--r-- | common/nslog_log.hpp | 8 | ||||
-rw-r--r-- | common/nslog_log.mm | 2 | ||||
-rw-r--r-- | common/settings_json.cpp | 6 | ||||
-rw-r--r-- | common/settings_json.hpp | 6 | ||||
-rw-r--r-- | common/settings_nsuserdefaults.hpp | 6 | ||||
-rw-r--r-- | common/settings_nsuserdefaults.mm | 2 | ||||
-rw-r--r-- | common/stderr_log.cpp | 2 | ||||
-rw-r--r-- | common/stderr_log.hpp | 8 | ||||
-rw-r--r-- | config/constants.cpp | 44 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | include/llmr/geometry/interpolate.hpp | 13 | ||||
-rw-r--r-- | include/llmr/map/view.hpp | 34 | ||||
-rw-r--r-- | include/llmr/style/filter_expression.hpp | 117 | ||||
-rw-r--r-- | include/llmr/style/property_value.hpp | 21 | ||||
-rw-r--r-- | include/llmr/style/value.hpp | 147 | ||||
-rw-r--r-- | include/mbgl/geometry/anchor.hpp (renamed from include/llmr/geometry/anchor.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/binpack.hpp (renamed from include/llmr/geometry/binpack.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/geometry/buffer.hpp (renamed from include/llmr/geometry/buffer.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/geometry/debug_font_buffer.hpp (renamed from include/llmr/geometry/debug_font_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/elements_buffer.hpp (renamed from include/llmr/geometry/elements_buffer.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/geometry/fill_buffer.hpp (renamed from include/llmr/geometry/fill_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/geometry.hpp (renamed from include/llmr/geometry/geometry.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/geometry/glyph_atlas.hpp (renamed from include/llmr/geometry/glyph_atlas.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/geometry/icon_buffer.hpp (renamed from include/llmr/geometry/icon_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/interpolate.hpp | 13 | ||||
-rw-r--r-- | include/mbgl/geometry/line_buffer.hpp (renamed from include/llmr/geometry/line_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/sprite_atlas.hpp (renamed from include/llmr/geometry/sprite_atlas.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/geometry/text_buffer.hpp (renamed from include/llmr/geometry/text_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/geometry/vao.hpp (renamed from include/llmr/geometry/vao.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/geometry/vertex_buffer.hpp (renamed from include/llmr/geometry/vertex_buffer.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp (renamed from include/llmr/map/map.hpp) | 22 | ||||
-rw-r--r-- | include/mbgl/map/raster_tile_data.hpp (renamed from include/llmr/map/raster_tile_data.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/map/source.hpp (renamed from include/llmr/map/source.hpp) | 18 | ||||
-rw-r--r-- | include/mbgl/map/sprite.hpp (renamed from include/llmr/map/sprite.hpp) | 11 | ||||
-rw-r--r-- | include/mbgl/map/tile.hpp (renamed from include/llmr/map/tile.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/map/tile_data.hpp (renamed from include/llmr/map/tile_data.hpp) | 16 | ||||
-rw-r--r-- | include/mbgl/map/tile_parser.hpp (renamed from include/llmr/map/tile_parser.hpp) | 18 | ||||
-rw-r--r-- | include/mbgl/map/transform.hpp (renamed from include/llmr/map/transform.hpp) | 17 | ||||
-rw-r--r-- | include/mbgl/map/transform_state.hpp (renamed from include/llmr/map/transform_state.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile.hpp (renamed from include/llmr/map/vector_tile.hpp) | 20 | ||||
-rw-r--r-- | include/mbgl/map/vector_tile_data.hpp (renamed from include/llmr/map/vector_tile_data.hpp) | 24 | ||||
-rw-r--r-- | include/mbgl/map/view.hpp | 54 | ||||
-rw-r--r-- | include/mbgl/mbgl.hpp (renamed from include/llmr/llmr.hpp) | 4 | ||||
-rw-r--r-- | include/mbgl/platform/event.hpp (renamed from include/llmr/platform/event.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/platform/gl.hpp (renamed from include/llmr/platform/gl.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/platform/log.hpp (renamed from include/llmr/platform/log.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/platform/platform.hpp (renamed from include/llmr/platform/platform.hpp) | 22 | ||||
-rw-r--r-- | include/mbgl/platform/request.hpp (renamed from include/llmr/platform/request.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/renderer/bucket.hpp (renamed from include/llmr/renderer/bucket.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/renderer/debug_bucket.hpp (renamed from include/llmr/renderer/debug_bucket.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/renderer/fill_bucket.hpp (renamed from include/llmr/renderer/fill_bucket.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/renderer/frame_history.hpp (renamed from include/llmr/renderer/frame_history.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/renderer/icon_bucket.hpp (renamed from include/llmr/renderer/icon_bucket.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/renderer/line_bucket.hpp (renamed from include/llmr/renderer/line_bucket.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/renderer/painter.hpp (renamed from include/llmr/renderer/painter.hpp) | 50 | ||||
-rw-r--r-- | include/mbgl/renderer/prerendered_texture.hpp (renamed from include/llmr/renderer/prerendered_texture.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/renderer/raster_bucket.hpp (renamed from include/llmr/renderer/raster_bucket.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/renderer/text_bucket.hpp (renamed from include/llmr/renderer/text_bucket.hpp) | 18 | ||||
-rw-r--r-- | include/mbgl/shader/composite_shader.hpp (renamed from include/llmr/shader/composite_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/dot_shader.hpp (renamed from include/llmr/shader/dot_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/gaussian_shader.hpp (renamed from include/llmr/shader/gaussian_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/icon_shader.hpp (renamed from include/llmr/shader/icon_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/line_shader.hpp (renamed from include/llmr/shader/line_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/linejoin_shader.hpp (renamed from include/llmr/shader/linejoin_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/outline_shader.hpp (renamed from include/llmr/shader/outline_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/pattern_shader.hpp (renamed from include/llmr/shader/pattern_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/plain_shader.hpp (renamed from include/llmr/shader/plain_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/raster_shader.hpp (renamed from include/llmr/shader/raster_shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/shader.hpp (renamed from include/llmr/shader/shader.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/shader/text_shader.hpp (renamed from include/llmr/shader/text_shader.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/style/applied_class_properties.hpp (renamed from include/llmr/style/applied_class_properties.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/style/class_dictionary.hpp (renamed from include/llmr/style/class_dictionary.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/style/class_properties.hpp (renamed from include/llmr/style/class_properties.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/style/filter_comparison.hpp | 65 | ||||
-rw-r--r-- | include/mbgl/style/filter_comparison_private.hpp | 23 | ||||
-rw-r--r-- | include/mbgl/style/filter_expression.hpp | 54 | ||||
-rw-r--r-- | include/mbgl/style/filter_expression_private.hpp | 75 | ||||
-rw-r--r-- | include/mbgl/style/function_properties.hpp (renamed from include/llmr/style/function_properties.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/style/property_fallback.hpp (renamed from include/llmr/style/property_fallback.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/style/property_key.hpp (renamed from include/llmr/style/property_key.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/style/property_transition.hpp (renamed from include/llmr/style/property_transition.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/style/property_value.hpp | 21 | ||||
-rw-r--r-- | include/mbgl/style/rasterize_properties.hpp (renamed from include/llmr/style/rasterize_properties.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/style/style.hpp (renamed from include/llmr/style/style.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/style/style_bucket.hpp (renamed from include/llmr/style/style_bucket.hpp) | 16 | ||||
-rw-r--r-- | include/mbgl/style/style_layer.hpp (renamed from include/llmr/style/style_layer.hpp) | 16 | ||||
-rw-r--r-- | include/mbgl/style/style_layer_group.hpp (renamed from include/llmr/style/style_layer_group.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/style/style_parser.hpp (renamed from include/llmr/style/style_parser.hpp) | 20 | ||||
-rw-r--r-- | include/mbgl/style/style_properties.hpp (renamed from include/llmr/style/style_properties.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/style/style_source.hpp (renamed from include/llmr/style/style_source.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/style/types.hpp (renamed from include/llmr/style/types.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/style/value.hpp | 43 | ||||
-rw-r--r-- | include/mbgl/style/value_comparison.hpp | 109 | ||||
-rw-r--r-- | include/mbgl/text/collision.hpp (renamed from include/llmr/text/collision.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/text/glyph.hpp (renamed from include/llmr/text/glyph.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/text/glyph_store.hpp (renamed from include/llmr/text/glyph_store.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/text/placement.hpp (renamed from include/llmr/text/placement.hpp) | 14 | ||||
-rw-r--r-- | include/mbgl/text/rotation_range.hpp (renamed from include/llmr/text/rotation_range.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/text/types.hpp (renamed from include/llmr/text/types.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/util/clip_ids.hpp (renamed from include/llmr/util/clip_ids.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/util/constants.hpp (renamed from include/llmr/util/constants.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/enum.hpp (renamed from include/llmr/util/enum.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/util/error.hpp (renamed from include/llmr/util/error.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/image.hpp (renamed from include/llmr/util/image.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/io.hpp (renamed from include/llmr/util/io.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/mat4.hpp (renamed from include/llmr/util/mat4.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/math.hpp (renamed from include/llmr/util/math.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/noncopyable.hpp (renamed from include/llmr/util/noncopyable.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/util/pbf.hpp (renamed from include/llmr/util/pbf.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/util/raster.hpp (renamed from include/llmr/util/raster.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/util/rect.hpp (renamed from include/llmr/util/rect.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/recursive_wrapper.hpp (renamed from include/llmr/util/recursive_wrapper.hpp) | 2 | ||||
-rw-r--r-- | include/mbgl/util/std.hpp (renamed from include/llmr/util/std.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/string.hpp (renamed from include/llmr/util/string.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/texturepool.hpp (renamed from include/llmr/util/texturepool.hpp) | 10 | ||||
-rw-r--r-- | include/mbgl/util/threadpool.hpp (renamed from include/llmr/util/threadpool.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/time.hpp (renamed from include/llmr/util/time.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/timer.hpp (renamed from include/llmr/util/timer.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/util/token.hpp (renamed from include/llmr/util/token.hpp) | 8 | ||||
-rw-r--r-- | include/mbgl/util/transition.hpp (renamed from include/llmr/util/transition.hpp) | 12 | ||||
-rw-r--r-- | include/mbgl/util/unitbezier.hpp (renamed from include/llmr/util/unitbezier.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/utf.hpp (renamed from include/llmr/util/utf.hpp) | 6 | ||||
-rw-r--r-- | include/mbgl/util/uv.hpp (renamed from include/llmr/util/uv.hpp) | 4 | ||||
-rw-r--r-- | include/mbgl/util/variant.hpp (renamed from include/llmr/util/variant.hpp) | 2 | ||||
-rw-r--r-- | include/mbgl/util/vec.hpp (renamed from include/llmr/util/vec.hpp) | 6 | ||||
m--------- | ios/mapbox-gl-cocoa | 0 | ||||
-rw-r--r-- | linux/main.cpp | 12 | ||||
-rw-r--r-- | linux/mapboxgl-app.gyp (renamed from linux/llmr-app.gyp) | 6 | ||||
-rw-r--r-- | macosx/Info.plist | 2 | ||||
-rw-r--r-- | macosx/main.mm | 8 | ||||
-rw-r--r-- | macosx/mapboxgl-app.gyp (renamed from macosx/llmr-app.gyp) | 2 | ||||
-rw-r--r-- | mapboxgl.gyp (renamed from llmr.gyp) | 12 | ||||
-rw-r--r-- | proto/glyphs.proto | 2 | ||||
-rw-r--r-- | proto/vector_tile.proto | 2 | ||||
-rw-r--r-- | src/geometry/debug_font_buffer.cpp | 6 | ||||
-rw-r--r-- | src/geometry/elements_buffer.cpp | 4 | ||||
-rw-r--r-- | src/geometry/fill_buffer.cpp | 6 | ||||
-rw-r--r-- | src/geometry/glyph_atlas.cpp | 10 | ||||
-rw-r--r-- | src/geometry/icon_buffer.cpp | 6 | ||||
-rw-r--r-- | src/geometry/interpolate.cpp | 4 | ||||
-rw-r--r-- | src/geometry/line_buffer.cpp | 6 | ||||
-rw-r--r-- | src/geometry/sprite_atlas.cpp | 68 | ||||
-rw-r--r-- | src/geometry/text_buffer.cpp | 8 | ||||
-rw-r--r-- | src/geometry/vertex_buffer.cpp | 6 | ||||
-rw-r--r-- | src/map/map.cpp | 35 | ||||
-rw-r--r-- | src/map/raster_tile_data.cpp | 8 | ||||
-rw-r--r-- | src/map/source.cpp | 46 | ||||
-rw-r--r-- | src/map/sprite.cpp | 25 | ||||
-rw-r--r-- | src/map/tile.cpp | 4 | ||||
-rw-r--r-- | src/map/tile_data.cpp | 8 | ||||
-rw-r--r-- | src/map/tile_parser.cpp | 42 | ||||
-rw-r--r-- | src/map/transform.cpp | 63 | ||||
-rw-r--r-- | src/map/transform_state.cpp | 6 | ||||
-rw-r--r-- | src/map/vector_tile.cpp | 17 | ||||
-rw-r--r-- | src/map/vector_tile_data.cpp | 12 | ||||
-rw-r--r-- | src/platform/gl.cpp | 2 | ||||
-rw-r--r-- | src/platform/log.cpp | 4 | ||||
-rw-r--r-- | src/platform/request.cpp | 10 | ||||
-rw-r--r-- | src/renderer/debug_bucket.cpp | 8 | ||||
-rw-r--r-- | src/renderer/fill_bucket.cpp | 18 | ||||
-rw-r--r-- | src/renderer/frame_history.cpp | 4 | ||||
-rw-r--r-- | src/renderer/icon_bucket.cpp | 26 | ||||
-rw-r--r-- | src/renderer/line_bucket.cpp | 18 | ||||
-rw-r--r-- | src/renderer/painter.cpp | 20 | ||||
-rw-r--r-- | src/renderer/painter_clipping.cpp | 12 | ||||
-rw-r--r-- | src/renderer/painter_composite.cpp | 6 | ||||
-rw-r--r-- | src/renderer/painter_debug.cpp | 10 | ||||
-rw-r--r-- | src/renderer/painter_fill.cpp | 18 | ||||
-rw-r--r-- | src/renderer/painter_framebuffers.cpp | 10 | ||||
-rw-r--r-- | src/renderer/painter_icon.cpp | 18 | ||||
-rw-r--r-- | src/renderer/painter_line.cpp | 10 | ||||
-rw-r--r-- | src/renderer/painter_prerender.cpp | 6 | ||||
-rw-r--r-- | src/renderer/painter_raster.cpp | 10 | ||||
-rw-r--r-- | src/renderer/painter_text.cpp | 12 | ||||
-rw-r--r-- | src/renderer/prerendered_texture.cpp | 6 | ||||
-rw-r--r-- | src/renderer/raster_bucket.cpp | 6 | ||||
-rw-r--r-- | src/renderer/text_bucket.cpp | 26 | ||||
-rw-r--r-- | src/shader/composite_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/dot_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/gaussian_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/icon_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/line_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/linejoin_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/outline_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/pattern_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/plain_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/raster_shader.cpp | 8 | ||||
-rw-r--r-- | src/shader/shader.cpp | 10 | ||||
-rw-r--r-- | src/shader/text_shader.cpp | 8 | ||||
-rw-r--r-- | src/style/applied_class_properties.cpp | 4 | ||||
-rw-r--r-- | src/style/class_dictionary.cpp | 4 | ||||
-rw-r--r-- | src/style/class_properties.cpp | 4 | ||||
-rw-r--r-- | src/style/filter_comparison.cpp | 143 | ||||
-rw-r--r-- | src/style/filter_expression.cpp | 236 | ||||
-rw-r--r-- | src/style/function_properties.cpp | 6 | ||||
-rw-r--r-- | src/style/property_fallback.cpp | 4 | ||||
-rw-r--r-- | src/style/style.cpp | 16 | ||||
-rw-r--r-- | src/style/style_bucket.cpp | 4 | ||||
-rw-r--r-- | src/style/style_layer.cpp | 10 | ||||
-rw-r--r-- | src/style/style_layer_group.cpp | 4 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 23 | ||||
-rw-r--r-- | src/style/style_properties.cpp | 4 | ||||
-rw-r--r-- | src/style/value.cpp | 6 | ||||
-rw-r--r-- | src/text/collision.cpp | 10 | ||||
-rw-r--r-- | src/text/glyph.cpp | 4 | ||||
-rw-r--r-- | src/text/glyph_store.cpp | 20 | ||||
-rw-r--r-- | src/text/placement.cpp | 14 | ||||
-rw-r--r-- | src/text/rotation_range.cpp | 4 | ||||
-rw-r--r-- | src/util/clip_ids.cpp | 8 | ||||
-rw-r--r-- | src/util/image.cpp | 6 | ||||
-rw-r--r-- | src/util/io.cpp | 8 | ||||
-rw-r--r-- | src/util/mat4.cpp | 4 | ||||
-rw-r--r-- | src/util/raster.cpp | 14 | ||||
-rw-r--r-- | src/util/texturepool.cpp | 4 | ||||
-rw-r--r-- | src/util/threadpool.cpp | 8 | ||||
-rw-r--r-- | src/util/timer.cpp | 8 | ||||
-rw-r--r-- | src/util/transition.cpp | 12 | ||||
-rw-r--r-- | test/clip_ids.cpp | 6 | ||||
-rw-r--r-- | test/comparisons.cpp | 306 | ||||
-rw-r--r-- | test/enums.cpp | 4 | ||||
-rw-r--r-- | test/fixtures/fixture_log.cpp | 7 | ||||
-rw-r--r-- | test/fixtures/fixture_log.hpp | 10 | ||||
-rw-r--r-- | test/fixtures/fixture_request.cpp | 12 | ||||
-rw-r--r-- | test/fixtures/styles/icons.info.json | 18 | ||||
-rw-r--r-- | test/fixtures/styles/icons.style.json | 33 | ||||
-rw-r--r-- | test/fixtures/styles/icons/default.expected.png | bin | 0 -> 6538 bytes | |||
-rw-r--r-- | test/functions.cpp | 32 | ||||
-rw-r--r-- | test/headless.cpp | 10 | ||||
-rw-r--r-- | test/rotation_range.cpp | 4 | ||||
-rw-r--r-- | test/style.cpp | 4 | ||||
-rw-r--r-- | test/test.gyp | 35 | ||||
-rw-r--r-- | test/tile.cpp | 4 | ||||
-rw-r--r-- | test/variant.cpp | 209 |
243 files changed, 2343 insertions, 1810 deletions
diff --git a/.gitignore b/.gitignore index 5cf9666f55..c69b0331ef 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ /config/constants_local.cpp /build /bin/node_modules -/include/llmr/shader/shaders.hpp +/include/mbgl/shader/shaders.hpp /src/shader/shaders_gl.cpp /src/shader/shaders_gles2.cpp /bin/style.bin.js @@ -12,9 +12,9 @@ config.gypi: ./setup-libraries.sh # Builds the regular library -llmr: config.gypi llmr.gyp node - deps/run_gyp llmr.gyp --depth=. -Goutput_dir=.. --generator-output=./build/llmr -f make - $(MAKE) -C build/llmr BUILDTYPE=$(BUILDTYPE) V=$(V) llmr-x86 +mbgl: config.gypi mapboxgl.gyp node + deps/run_gyp mapboxgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl node: @if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi; @@ -40,8 +40,8 @@ xtest: config.gypi clear_xcode_cache node # Builds the linux app with make. This is also used by Travis CI -linux: config.gypi linux/llmr-app.gyp node - deps/run_gyp linux/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make +linux: config.gypi linux/mapboxgl-app.gyp node + deps/run_gyp linux/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -51,8 +51,8 @@ run-linux: linux # Builds the OS X app with make. -osx: config.gypi macosx/llmr-app.gyp node - deps/run_gyp macosx/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make +osx: config.gypi macosx/mapboxgl-app.gyp node + deps/run_gyp macosx/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -65,27 +65,27 @@ clear_xcode_cache: @CUSTOM_DD=`defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation 2>/dev/null`; \ if [[ $$CUSTOM_DD ]]; then \ echo clearing files in $$CUSTOM_DD older than one day; \ - find $$CUSTOM_DD/llmr-app-* -mtime +1 | xargs rm -rf; \ + find $$CUSTOM_DD/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ fi; \ if [[ -d ~/Library/Developer/Xcode/DerivedData/ ]] && [[ ! $$CUSTOM_DD ]]; then \ - echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/llmr-app-* older than one day'; \ - find ~/Library/Developer/Xcode/DerivedData/llmr-app-* -mtime +1 | xargs rm -rf; \ + echo 'clearing files in ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* older than one day'; \ + find ~/Library/Developer/Xcode/DerivedData/mapboxgl-app-* -mtime +1 | xargs rm -rf; \ fi # build Mac OS X project for Xcode -xproj: config.gypi macosx/llmr-app.gyp clear_xcode_cache node - deps/run_gyp macosx/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/macosx/llmr-app.xcodeproj +xproj: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode -iproj: config.gypi ios/mapbox-gl-cocoa/app/llmr-app.gyp clear_xcode_cache node - deps/run_gyp ios/mapbox-gl-cocoa/app/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/ios/mapbox-gl-cocoa/app/llmr-app.xcodeproj +iproj: config.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) -lproj: config.gypi linux/llmr-app.gyp clear_xcode_cache node - deps/run_gyp linux/llmr-app.gyp --depth=. --generator-output=./build -f xcode - open ./build/linux/llmr-app.xcodeproj +lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node + deps/run_gyp linux/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode + open ./build/linux/mapboxgl-app.xcodeproj ##### Maintenace operations #################################################### @@ -101,4 +101,4 @@ distclean: clean -rm -rf ./config.gypi -rm -rf ./mapnik-packaging/osx/out/ -.PHONY: llmr test linux +.PHONY: mbgl test linux diff --git a/bin/build-shaders.js b/bin/build-shaders.js index 61d182b03f..38aa753730 100755 --- a/bin/build-shaders.js +++ b/bin/build-shaders.js @@ -83,10 +83,10 @@ module.exports = function(shader_type, prefix, suffix) { } var header = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n\n'; - header += '#ifndef LLMR_SHADER_SHADERS\n'; - header += '#define LLMR_SHADER_SHADERS\n'; + header += '#ifndef MBGL_SHADER_SHADERS\n'; + header += '#define MBGL_SHADER_SHADERS\n'; header += '\n'; - header += 'namespace llmr {\n'; + header += 'namespace mbgl {\n'; header += '\n'; header += 'struct shader_source {\n'; header += ' const char *vertex;\n'; @@ -106,18 +106,19 @@ module.exports = function(shader_type, prefix, suffix) { var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n'; - code += '#include <llmr/platform/gl.hpp>\n'; + code += '#include <mbgl/platform/gl.hpp>\n'; code += prefix + '\n'; - code += '#include <llmr/shader/shaders.hpp>\n'; + code += '#include <mbgl/shader/shaders.hpp>\n'; code += '\n'; - code += 'using namespace llmr;\n'; + code += 'namespace mbgl {\n'; code += '\n'; - code += 'const shader_source llmr::shaders[SHADER_COUNT] = {\n'; + code += 'const shader_source shaders[SHADER_COUNT] = {\n'; code += lines.join(',\n'); code += '\n};\n'; + code += '\n}\n'; code += suffix + '\n'; - var header_path = path.join(process.argv[2], 'include/llmr/shader/shaders.hpp'); + var header_path = path.join(process.argv[2], 'include/mbgl/shader/shaders.hpp'); mkdirp.sync(path.dirname(header_path)); fs.writeFileSync(header_path, header); console.warn('wrote file ' + header_path); diff --git a/bin/package.json b/bin/package.json index 77edcb9bfa..50843fa4b8 100644 --- a/bin/package.json +++ b/bin/package.json @@ -1,5 +1,5 @@ { - "name": "llmr-native", + "name": "mbgl-native", "version": "0.0.1", "dependencies": { "brfs": "^1.1.2", diff --git a/common/curl_request.cpp b/common/curl_request.cpp index 66750e459e..b7e5e8b5cc 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -1,8 +1,8 @@ -#include <llmr/platform/platform.hpp> -#include <llmr/platform/request.hpp> -#include <llmr/util/uv.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/platform/request.hpp> +#include <mbgl/util/uv.hpp> +#include <mbgl/util/std.hpp> #include <queue> #include <boost/lockfree/queue.hpp> @@ -47,7 +47,7 @@ See http://nikhilm.github.com/uvbook/ for more information on libuv. */ -namespace llmr { +namespace mbgl { namespace platform { namespace request { @@ -66,8 +66,8 @@ static uv_async_t async_cancel; // Stores pointers (!) to shared_ptrs. We use shared_ptrs so that request objects don't get // auto-destructed while they're in progress. The TileData object retains a weak_ptr to this // request, so we have to use a shared_ptr here to ensure that this object stays alive. -static boost::lockfree::queue<std::shared_ptr<llmr::platform::Request> *> add_queue(8); -static boost::lockfree::queue<std::shared_ptr<llmr::platform::Request> *> cancel_queue(8); +static boost::lockfree::queue<std::shared_ptr<mbgl::platform::Request> *> add_queue(8); +static boost::lockfree::queue<std::shared_ptr<mbgl::platform::Request> *> cancel_queue(8); // Used as the CURL timer function to periodically check for socket updates. static uv_timer_t timeout; @@ -85,10 +85,10 @@ static CURLSH *curl_share = nullptr; static std::queue<CURL *> curl_handle_cache; -class CURLRequest : public llmr::platform::Request { +class CURLRequest : public mbgl::platform::Request { public: CURLRequest(const std::string &url, - std::function<void(llmr::platform::Response *)> callback, + std::function<void(mbgl::platform::Response *)> callback, std::shared_ptr<uv::loop> loop) : Request(url, callback, loop) {} @@ -380,4 +380,4 @@ void platform::cancel_request_http(const std::shared_ptr<Request> &req) { uv_async_send(&async_cancel); } } -} // end namespace llmr +} // end namespace mbgl diff --git a/common/foundation_request.mm b/common/foundation_request.mm index 4d6ca9c5fe..4684ff55fb 100644 --- a/common/foundation_request.mm +++ b/common/foundation_request.mm @@ -9,9 +9,9 @@ #include <memory> #include <string> #include <functional> -#include <llmr/platform/request.hpp> -#include <llmr/platform/platform.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/platform/request.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/util/std.hpp> #include <uv.h> uv_once_t request_initialize = UV_ONCE_INIT; @@ -37,10 +37,10 @@ void request_initialize_cb() { // We're using a child class to make sure ARC is working correctly, as well as to add activity // indicators on iOS. -class FoundationRequest : public llmr::platform::Request { +class FoundationRequest : public mbgl::platform::Request { public: FoundationRequest(const std::string &url, - std::function<void(llmr::platform::Response *)> callback, + std::function<void(mbgl::platform::Response *)> callback, std::shared_ptr<uv::loop> loop) : Request(url, callback, loop) { #if TARGET_OS_IPHONE @@ -65,8 +65,8 @@ public: NSURLSessionDataTask *task = nullptr; }; -std::shared_ptr<llmr::platform::Request> -llmr::platform::request_http(const std::string &url, +std::shared_ptr<mbgl::platform::Request> +mbgl::platform::request_http(const std::string &url, std::function<void(Response *)> callback, std::shared_ptr<uv::loop> loop) { uv_once(&request_initialize, request_initialize_cb); @@ -109,7 +109,7 @@ llmr::platform::request_http(const std::string &url, return req; } -void llmr::platform::cancel_request_http(const std::shared_ptr<Request> &req) { +void mbgl::platform::cancel_request_http(const std::shared_ptr<Request> &req) { if (req) { [((FoundationRequest *)(req.get()))->task cancel]; } diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index d4f8969143..60d95c8b81 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -8,7 +8,7 @@ GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) { GLFWView::~GLFWView() { glfwTerminate(); } -void GLFWView::initialize(llmr::Map *map) { +void GLFWView::initialize(mbgl::Map *map) { View::initialize(map); if (!glfwInit()) { @@ -34,7 +34,7 @@ void GLFWView::initialize(llmr::Map *map) { glfwWindowHint(GLFW_STENCIL_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwCreateWindow(1024, 768, "llmr", monitor, NULL); + window = glfwCreateWindow(1024, 768, "Mapbox GL", monitor, NULL); if (!window) { glfwTerminate(); fprintf(stderr, "Failed to initialize window\n"); @@ -194,6 +194,10 @@ void GLFWView::swap() { glfwPostEmptyEvent(); } +void GLFWView::notify_map_change(mbgl::MapChange change, mbgl::timestamp delay) { + // no-op +} + void GLFWView::fps() { static int frames = 0; static double time_elapsed = 0; @@ -208,7 +212,7 @@ void GLFWView::fps() { } } -namespace llmr { +namespace mbgl { namespace platform { double elapsed() { return glfwGetTime(); } @@ -281,9 +285,5 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w } #endif -void notify_map_change(MapChange change) { - // no-op -} - } } diff --git a/common/glfw_view.hpp b/common/glfw_view.hpp index 62da124caa..efef3431a9 100644 --- a/common/glfw_view.hpp +++ b/common/glfw_view.hpp @@ -1,7 +1,8 @@ -#ifndef LLMR_COMMON_GLFW_VIEW -#define LLMR_COMMON_GLFW_VIEW +#ifndef MBGL_COMMON_GLFW_VIEW +#define MBGL_COMMON_GLFW_VIEW -#include <llmr/llmr.hpp> +#include <mbgl/mbgl.hpp> +#include <mbgl/util/time.hpp> #ifdef NVIDIA #define GLFW_INCLUDE_ES2 @@ -10,14 +11,15 @@ #include <uv.h> -class GLFWView : public llmr::View { +class GLFWView : public mbgl::View { public: GLFWView(bool fullscreen = false); ~GLFWView(); - void initialize(llmr::Map *map); + void initialize(mbgl::Map *map); void swap(); void make_active(); + void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0); static void key(GLFWwindow *window, int key, int scancode, int action, int mods); static void scroll(GLFWwindow *window, double xoffset, double yoffset); diff --git a/common/headless_view.cpp b/common/headless_view.cpp index a44c6e6edb..6a7d75d754 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -1,19 +1,12 @@ #include "headless_view.hpp" -#include <llmr/util/timer.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/util/timer.hpp> -namespace llmr { +#include <stdexcept> -namespace platform { - -void notify_map_change(MapChange change) { - // no-op -} - -} +namespace mbgl { HeadlessView::HeadlessView() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension. CGLPixelFormatAttribute attributes[] = { @@ -39,7 +32,7 @@ HeadlessView::HeadlessView() { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX x_display = XOpenDisplay(0); if (x_display == nullptr) { @@ -75,7 +68,7 @@ HeadlessView::HeadlessView() { void HeadlessView::resize(int width, int height) { clear_buffers(); -#if LLMR_USE_CGL +#if MBGL_USE_CGL make_active(); // Create depth/stencil buffer @@ -110,7 +103,7 @@ void HeadlessView::resize(int width, int height) { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); @@ -120,7 +113,7 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); if (fbo) { @@ -139,7 +132,7 @@ void HeadlessView::clear_buffers() { } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX if (glx_pixmap) { glXDestroyGLXPixmap(x_display, glx_pixmap); glx_pixmap = 0; @@ -155,20 +148,24 @@ void HeadlessView::clear_buffers() { HeadlessView::~HeadlessView() { clear_buffers(); -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLDestroyContext(gl_context); #endif } +void HeadlessView::notify_map_change(mbgl::MapChange change, mbgl::timestamp delay) { + // no-op +} + void HeadlessView::make_active() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(gl_context); if (error) { fprintf(stderr, "Switching OpenGL context failed\n"); } #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { fprintf(stderr, "Switching OpenGL context failed\n"); } @@ -178,7 +175,7 @@ void HeadlessView::make_active() { void HeadlessView::swap() {} unsigned int HeadlessView::root_fbo() { -#if LLMR_USE_CGL +#if MBGL_USE_CGL return fbo; #endif diff --git a/common/headless_view.hpp b/common/headless_view.hpp index b3e1c11b9b..0b255b4a38 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -1,17 +1,18 @@ -#ifndef LLMR_COMMON_HEADLESS_CGL -#define LLMR_COMMON_HEADLESS_CGL +#ifndef MBGL_COMMON_HEADLESS_CGL +#define MBGL_COMMON_HEADLESS_CGL #ifdef __APPLE__ -#define LLMR_USE_CGL 1 +#define MBGL_USE_CGL 1 #else #include <GL/glx.h> -#define LLMR_USE_GLX 1 +#define MBGL_USE_GLX 1 #endif -#include <llmr/map/view.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/map/view.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/time.hpp> -namespace llmr { +namespace mbgl { class HeadlessView : public View { public: @@ -20,6 +21,7 @@ public: void resize(int width, int height); + void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); void swap(); unsigned int root_fbo(); @@ -29,14 +31,14 @@ private: private: -#if LLMR_USE_CGL +#if MBGL_USE_CGL CGLContextObj gl_context; GLuint fbo = 0; GLuint fbo_depth_stencil = 0; GLuint fbo_color = 0; #endif -#if LLMR_USE_GLX +#if MBGL_USE_GLX GLXContext gl_context = nullptr; XVisualInfo *x_info = nullptr; Display *x_display = nullptr; diff --git a/common/nslog_log.hpp b/common/nslog_log.hpp index 9f2f3aee7b..d40f963036 100644 --- a/common/nslog_log.hpp +++ b/common/nslog_log.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_COMMON_NSLOG_LOG -#define LLMR_COMMON_NSLOG_LOG +#ifndef MBGL_COMMON_NSLOG_LOG +#define MBGL_COMMON_NSLOG_LOG -#include <llmr/platform/log.hpp> +#include <mbgl/platform/log.hpp> -namespace llmr { +namespace mbgl { class NSLogBackend : public LogBackend { public: diff --git a/common/nslog_log.mm b/common/nslog_log.mm index c6ca65d0b7..12230143ac 100644 --- a/common/nslog_log.mm +++ b/common/nslog_log.mm @@ -4,7 +4,7 @@ #include <cstdarg> -namespace llmr { +namespace mbgl { void NSLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { NSLog(@"[%s] %s: %@", EventSeverityClass(severity).c_str(), EventClass(event).c_str(), diff --git a/common/settings_json.cpp b/common/settings_json.cpp index 771d89e1a2..bceab50da6 100644 --- a/common/settings_json.cpp +++ b/common/settings_json.cpp @@ -4,12 +4,12 @@ #include <rapidjson/document.h> #include <stdio.h> -using namespace llmr; +using namespace mbgl; Settings_JSON::Settings_JSON() { load(); } void Settings_JSON::load() { - FILE *settingsFile = fopen("/tmp/llmr-native.json", "r"); + FILE *settingsFile = fopen("/tmp/mbgl-native.json", "r"); if (settingsFile != NULL) { rapidjson::FileStream is(settingsFile); rapidjson::Document document; @@ -26,7 +26,7 @@ void Settings_JSON::load() { void Settings_JSON::save() { - rapidjson::FileStream s(fopen("/tmp/llmr-native.json", "w")); + rapidjson::FileStream s(fopen("/tmp/mbgl-native.json", "w")); rapidjson::PrettyWriter<rapidjson::FileStream> writer(s); writer.StartArray(); writer.Double(longitude); diff --git a/common/settings_json.hpp b/common/settings_json.hpp index fa95254656..09f7841c91 100644 --- a/common/settings_json.hpp +++ b/common/settings_json.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_JSON_SETTINGS -#define LLMR_JSON_SETTINGS +#ifndef MBGL_JSON_SETTINGS +#define MBGL_JSON_SETTINGS -namespace llmr { +namespace mbgl { class Settings_JSON { public: diff --git a/common/settings_nsuserdefaults.hpp b/common/settings_nsuserdefaults.hpp index 575cc4a75f..dcc6ab46b9 100644 --- a/common/settings_nsuserdefaults.hpp +++ b/common/settings_nsuserdefaults.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_COMMON_SETTINGS_NSUSERDEFAULTS -#define LLMR_COMMON_SETTINGS_NSUSERDEFAULTS +#ifndef MBGL_COMMON_SETTINGS_NSUSERDEFAULTS +#define MBGL_COMMON_SETTINGS_NSUSERDEFAULTS -namespace llmr { +namespace mbgl { class Settings_NSUserDefaults { public: diff --git a/common/settings_nsuserdefaults.mm b/common/settings_nsuserdefaults.mm index 783aa500d0..24571677f4 100644 --- a/common/settings_nsuserdefaults.mm +++ b/common/settings_nsuserdefaults.mm @@ -2,7 +2,7 @@ #include "settings_nsuserdefaults.hpp" -using namespace llmr; +using namespace mbgl; Settings_NSUserDefaults::Settings_NSUserDefaults() { diff --git a/common/stderr_log.cpp b/common/stderr_log.cpp index da5799d753..bcb84447bb 100644 --- a/common/stderr_log.cpp +++ b/common/stderr_log.cpp @@ -3,7 +3,7 @@ #include <iostream> #include <cstdarg> -namespace llmr { +namespace mbgl { void StderrLogBackend::record(EventSeverity severity, Event event, const std::string &msg) { std::cerr << "[" << severity << "] " << event << ": " << msg << std::endl; diff --git a/common/stderr_log.hpp b/common/stderr_log.hpp index e2492d3af5..45f76f0d1a 100644 --- a/common/stderr_log.hpp +++ b/common/stderr_log.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_COMMON_STDERR_LOG -#define LLMR_COMMON_STDERR_LOG +#ifndef MBGL_COMMON_STDERR_LOG +#define MBGL_COMMON_STDERR_LOG -#include <llmr/platform/log.hpp> +#include <mbgl/platform/log.hpp> -namespace llmr { +namespace mbgl { class StderrLogBackend : public LogBackend { public: diff --git a/config/constants.cpp b/config/constants.cpp index 36f51559e2..3d1422e6c7 100644 --- a/config/constants.cpp +++ b/config/constants.cpp @@ -1,27 +1,27 @@ -#include <llmr/util/constants.hpp> +#include <mbgl/util/constants.hpp> -const float llmr::util::tileSize = 512.0f; +const float mbgl::util::tileSize = 512.0f; #if defined(DEBUG) -const bool llmr::debug::tileParseWarnings = false; -const bool llmr::debug::styleParseWarnings = false; -const bool llmr::debug::spriteWarnings = false; -const bool llmr::debug::renderWarnings = false; -const bool llmr::debug::renderTree = false; -const bool llmr::debug::labelTextMissingWarning = true; -const bool llmr::debug::missingFontStackWarning = true; -const bool llmr::debug::missingFontFaceWarning = true; -const bool llmr::debug::glyphWarning = true; -const bool llmr::debug::shapingWarning = true; +const bool mbgl::debug::tileParseWarnings = false; +const bool mbgl::debug::styleParseWarnings = false; +const bool mbgl::debug::spriteWarnings = false; +const bool mbgl::debug::renderWarnings = false; +const bool mbgl::debug::renderTree = false; +const bool mbgl::debug::labelTextMissingWarning = true; +const bool mbgl::debug::missingFontStackWarning = true; +const bool mbgl::debug::missingFontFaceWarning = true; +const bool mbgl::debug::glyphWarning = true; +const bool mbgl::debug::shapingWarning = true; #else -const bool llmr::debug::tileParseWarnings = false; -const bool llmr::debug::styleParseWarnings = false; -const bool llmr::debug::spriteWarnings = false; -const bool llmr::debug::renderWarnings = false; -const bool llmr::debug::renderTree = false; -const bool llmr::debug::labelTextMissingWarning = false; -const bool llmr::debug::missingFontStackWarning = false; -const bool llmr::debug::missingFontFaceWarning = false; -const bool llmr::debug::glyphWarning = false; -const bool llmr::debug::shapingWarning = false; +const bool mbgl::debug::tileParseWarnings = false; +const bool mbgl::debug::styleParseWarnings = false; +const bool mbgl::debug::spriteWarnings = false; +const bool mbgl::debug::renderWarnings = false; +const bool mbgl::debug::renderTree = false; +const bool mbgl::debug::labelTextMissingWarning = false; +const bool mbgl::debug::missingFontStackWarning = false; +const bool mbgl::debug::missingFontFaceWarning = false; +const bool mbgl::debug::glyphWarning = false; +const bool mbgl::debug::shapingWarning = false; #endif @@ -50,7 +50,7 @@ def pkg_config(pkg, pkgconfig_root): return (libs, cflags) -def configure_llmr(o): +def configure_mbgl(o): if options.boost_root: o['variables']['boost_root'] = options.boost_root else: @@ -115,7 +115,7 @@ output = { } if __name__ == '__main__': - configure_llmr(output) + configure_mbgl(output) configure_glfw3(output) configure_uv(output) configure_png(output) diff --git a/include/llmr/geometry/interpolate.hpp b/include/llmr/geometry/interpolate.hpp deleted file mode 100644 index 0014d56aad..0000000000 --- a/include/llmr/geometry/interpolate.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef LLMR_GEOMETRY_INTERPOLATE -#define LLMR_GEOMETRY_INTERPOLATE - -#include <llmr/geometry/anchor.hpp> -#include <llmr/util/math.hpp> - -namespace llmr { - -Anchors interpolate(const std::vector<Coordinate> &vertices, float spacing, - float minScale = 0.0f, int start = 0); -} - -#endif diff --git a/include/llmr/map/view.hpp b/include/llmr/map/view.hpp deleted file mode 100644 index d032f783cb..0000000000 --- a/include/llmr/map/view.hpp +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef LLMR_MAP_VIEW -#define LLMR_MAP_VIEW - -namespace llmr { - -class Map; - -class View { -public: - virtual void initialize(Map *map) { - this->map = map; - } - - // Called from the render (=GL) thread. Signals that the context should - // swap the front and the back buffer. - virtual void swap() = 0; - - // Called from the render thread. Makes the GL context active in the current - // thread. This is typically just called once at the beginning of the - // renderer setup since the render thread doesn't switch the contexts. - virtual void make_active() = 0; - - // Returns the base framebuffer object, if any, and 0 if using the system - // provided framebuffer. - virtual unsigned int root_fbo() { - return 0; - } - -protected: - llmr::Map *map = nullptr; -}; -} - -#endif diff --git a/include/llmr/style/filter_expression.hpp b/include/llmr/style/filter_expression.hpp deleted file mode 100644 index 5c7a400d80..0000000000 --- a/include/llmr/style/filter_expression.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef LLMR_STYLE_FILTER_EXPRESSION -#define LLMR_STYLE_FILTER_EXPRESSION - -#include <llmr/style/value.hpp> -#include <llmr/util/recursive_wrapper.hpp> - -#include <forward_list> -#include <string> -#include <ostream> -#include <iostream> - -namespace llmr { - -class VectorTileTagExtractor; - -class FilterComparison { -public: - enum class Operator : uint8_t { - Equal, - NotEqual, - Greater, - GreaterEqual, - Less, - LessEqual, - In, - NotIn - }; - - class Instance { - public: - Instance(Operator op, std::forward_list<Value> &&values) - : op(op), values(values) {} - - bool compare(const Value &property_value) const; - bool compare(const std::forward_list<Value> &property_values) const; - - private: - template <typename Comparer> inline bool includes(const Value &property_value, const Comparer &comparer) const; - template <typename Comparer> inline bool compare(const Value &property_value, const Comparer &comparer) const; - template <typename Comparer> inline bool all(const std::forward_list<Value> &property_values, const Comparer &comparer) const; - - private: - Operator op = Operator::Equal; - std::forward_list<Value> values; - - friend std::ostream& operator <<(std::ostream &, const Instance &); - }; - -public: - FilterComparison(const std::string &field) : field(field) {}; - - const std::string &getField() const; - inline bool compare(const VectorTileTagExtractor &extractor) const; - - template <typename ...Args> - inline void add(Args&& ...args) { - instances.emplace_front(::std::forward<Args>(args)...); - } - -private: - std::string field; - std::forward_list<Instance> instances; - - friend std::ostream& operator <<(std::ostream &, const FilterComparison &); -}; - -std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison); -std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance); - - -FilterComparison::Operator parseFilterComparisonOperator(const std::string &op); - - -class FilterExpression { -public: - typedef util::recursive_wrapper<FilterExpression> Wrapper; - - enum class Operator : uint8_t { - And, - Or, - Xor, - Nor - }; - - enum class GeometryType : uint8_t { - Any, - Point, - LineString, - Polygon - }; - -public: - FilterExpression() = default; - FilterExpression(Operator op) : op(op) {}; - - bool empty() const; - - bool compare(const VectorTileTagExtractor &extractor) const; - void add(const FilterComparison &comparison); - void add(const FilterExpression &expression); - void setGeometryType(GeometryType g); - -private: - Operator op = Operator::And; - GeometryType type = GeometryType::Any; - std::forward_list<FilterComparison> comparisons; - std::forward_list<FilterExpression::Wrapper> expressions; - - friend std::ostream& operator <<(std::ostream &, const FilterExpression &); -}; - -std::ostream& operator <<(std::ostream &s, const FilterExpression &expression); - -FilterExpression::GeometryType parseGeometryType(const std::string &geometry); -} - -#endif diff --git a/include/llmr/style/property_value.hpp b/include/llmr/style/property_value.hpp deleted file mode 100644 index 3e2a675b53..0000000000 --- a/include/llmr/style/property_value.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LLMR_STYLE_PROPERTY_VALUE -#define LLMR_STYLE_PROPERTY_VALUE - -#include <llmr/util/variant.hpp> -#include <llmr/style/function_properties.hpp> -#include <llmr/style/types.hpp> - -namespace llmr { - -typedef util::variant< - std::string, - TranslateAnchorType, - RotateAnchorType, - Function<bool>, - Function<float>, - Function<Color> -> PropertyValue; - -} - -#endif diff --git a/include/llmr/style/value.hpp b/include/llmr/style/value.hpp deleted file mode 100644 index fac316d3d5..0000000000 --- a/include/llmr/style/value.hpp +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef LLMR_STYLE_VALUE -#define LLMR_STYLE_VALUE - -#include <llmr/util/variant.hpp> -#include <llmr/util/pbf.hpp> - -namespace llmr { - -typedef util::variant<bool, int64_t, uint64_t, double, std::string> Value; - -std::string toString(const Value &value); - -Value parseValue(pbf data); - -namespace util { - -namespace detail { - -inline int string_to_bool(std::string str) { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); - if (str == "0" || str == "0.0" || str == "false" || str == "null" || !str.length()) return 0; - else if (str == "true") return 1; - else return -1; -} - -template <typename T> -struct string_to_number {}; - -template <> struct string_to_number<bool> { - bool operator()(const std::string &str) const { - // Converts 0 => false, 1 => true and -1 => true. - return string_to_bool(str); - } -}; - -template <> struct string_to_number<double> { - double operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stod(str) : val; - } -}; - -template <> struct string_to_number<int64_t> { - int64_t operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stoll(str) : val; - } -}; - -template <> struct string_to_number<uint64_t> { - uint64_t operator()(std::string const &str) const { - int val = string_to_bool(str); - return val < 0 ? std::stoull(str) : val; - } -}; - -template <typename Operator> -struct relaxed_operator_visitor { - typedef bool result_type; - - bool operator()(bool lhs, bool rhs) const { return Operator()(lhs, rhs); } - - template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> - bool operator()(bool lhs, T rhs) const { return Operator()(lhs, bool(rhs)); } - - template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> - bool operator()(T lhs, bool rhs) const { return Operator()(bool(lhs), rhs); } - - bool operator()(int64_t lhs, uint64_t rhs) const { return lhs < 0 ? false : Operator()(uint64_t(lhs), rhs); } - bool operator()(uint64_t lhs, int64_t rhs) const { return rhs < 0 ? false : Operator()(lhs, uint64_t(rhs)); } - - template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> - bool operator()(const std::string &lhs, T rhs) const try { return Operator()(string_to_number<T>()(lhs), rhs); } - catch(...) { return false; } - - template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> - bool operator()(T lhs, const std::string &rhs) const try { return Operator()(lhs, string_to_number<T>()(rhs)); } - catch(...) { return false; } - - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return Operator()(lhs, rhs); } -}; - -struct relaxed_equal_operator { - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; } -}; - -struct relaxed_greater_operator { - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; } -}; - -struct relaxed_greater_equal_operator { - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return lhs >= rhs; } -}; - -struct relaxed_less_operator { - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return lhs < rhs; } -}; - -struct relaxed_less_equal_operator { - template <typename T0, typename T1> - bool operator()(T0 lhs, T1 rhs) const { return lhs <= rhs; } -}; - - -} // end namespace detail - -inline bool relaxed_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_equal_operator>(), lhs, rhs); -} - -inline bool relaxed_greater(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_operator>(), lhs, rhs); -} - -inline bool relaxed_greater_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_equal_operator>(), lhs, rhs); -} - -inline bool relaxed_less(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_operator>(), lhs, rhs); -} - -inline bool relaxed_less_equal(Value const &lhs, Value const &rhs) { - return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_equal_operator>(), lhs, rhs); -} - -} - - -template <typename T> -T toNumber(const Value &value) { - if (value.is<std::string>()) return util::detail::string_to_number<T>()(value.get<std::string>()); - else if (value.is<bool>()) return value.get<bool>(); - else if (value.is<int64_t>()) return value.get<int64_t>(); - else if (value.is<uint64_t>()) return value.get<uint64_t>(); - else if (value.is<double>()) return value.get<double>(); - else return 0; -} - -} - -#endif diff --git a/include/llmr/geometry/anchor.hpp b/include/mbgl/geometry/anchor.hpp index dd97c507f2..ab006530ff 100644 --- a/include/llmr/geometry/anchor.hpp +++ b/include/mbgl/geometry/anchor.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_ANCHOR -#define LLMR_GEOMETRY_ANCHOR +#ifndef MBGL_GEOMETRY_ANCHOR +#define MBGL_GEOMETRY_ANCHOR #include <vector> -namespace llmr { +namespace mbgl { struct Anchor { float x = 0.0f; diff --git a/include/llmr/geometry/binpack.hpp b/include/mbgl/geometry/binpack.hpp index 11536ee8b3..9aadaa202c 100644 --- a/include/llmr/geometry/binpack.hpp +++ b/include/mbgl/geometry/binpack.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_BINPACK -#define LLMR_GEOMETRY_BINPACK +#ifndef MBGL_GEOMETRY_BINPACK +#define MBGL_GEOMETRY_BINPACK -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/rect.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/rect.hpp> #include <cstdint> #include <list> -namespace llmr { +namespace mbgl { template <typename T> class BinPack : private util::noncopyable { diff --git a/include/llmr/geometry/buffer.hpp b/include/mbgl/geometry/buffer.hpp index 607f902bf1..20489cb33c 100644 --- a/include/llmr/geometry/buffer.hpp +++ b/include/mbgl/geometry/buffer.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_GEOMETRY_BUFFER -#define LLMR_GEOMETRY_BUFFER +#ifndef MBGL_GEOMETRY_BUFFER +#define MBGL_GEOMETRY_BUFFER -#include <llmr/platform/gl.hpp> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/noncopyable.hpp> #include <cstdlib> #include <cassert> #include <stdexcept> -namespace llmr { +namespace mbgl { template < size_t item_size, diff --git a/include/llmr/geometry/debug_font_buffer.hpp b/include/mbgl/geometry/debug_font_buffer.hpp index 15f6daf07f..7cceb0f576 100644 --- a/include/llmr/geometry/debug_font_buffer.hpp +++ b/include/mbgl/geometry/debug_font_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_DEBUG_FONT_BUFFER -#define LLMR_GEOMETRY_DEBUG_FONT_BUFFER +#ifndef MBGL_GEOMETRY_DEBUG_FONT_BUFFER +#define MBGL_GEOMETRY_DEBUG_FONT_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class DebugFontBuffer : public Buffer< 4 // 2 bytes per coordinate, 2 coordinates diff --git a/include/llmr/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp index a058312bda..ed60338e08 100644 --- a/include/llmr/geometry/elements_buffer.hpp +++ b/include/mbgl/geometry/elements_buffer.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER -#define LLMR_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER +#ifndef MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER +#define MBGL_GEOMETRY_TRIANGLE_ELEMENTS_BUFFER -#include <llmr/geometry/buffer.hpp> -#include <llmr/geometry/vao.hpp> +#include <mbgl/geometry/buffer.hpp> +#include <mbgl/geometry/vao.hpp> -namespace llmr { +namespace mbgl { struct ElementGroup { VertexArrayObject array; diff --git a/include/llmr/geometry/fill_buffer.hpp b/include/mbgl/geometry/fill_buffer.hpp index 9aebe35abf..4a3d5a5b38 100644 --- a/include/llmr/geometry/fill_buffer.hpp +++ b/include/mbgl/geometry/fill_buffer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_GEOMETRY_FILL_BUFFER -#define LLMR_GEOMETRY_FILL_BUFFER +#ifndef MBGL_GEOMETRY_FILL_BUFFER +#define MBGL_GEOMETRY_FILL_BUFFER #include "buffer.hpp" #include <vector> #include <cstdint> -namespace llmr { +namespace mbgl { class FillVertexBuffer : public Buffer< 4 // bytes per coordinates (2 * unsigned short == 4 bytes) diff --git a/include/llmr/geometry/geometry.hpp b/include/mbgl/geometry/geometry.hpp index 2f321934a7..47981ce83b 100644 --- a/include/llmr/geometry/geometry.hpp +++ b/include/mbgl/geometry/geometry.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_GEOMETRY -#define LLMR_GEOMETRY_GEOMETRY +#ifndef MBGL_GEOMETRY_GEOMETRY +#define MBGL_GEOMETRY_GEOMETRY -#include <llmr/util/pbf.hpp> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/util/pbf.hpp> +#include <mbgl/util/noncopyable.hpp> #include <cstdlib> -namespace llmr { +namespace mbgl { class Geometry : private util::noncopyable { diff --git a/include/llmr/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp index 0aada6a733..e05cbe3b90 100644 --- a/include/llmr/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_GEOMETRY_GLYPH_ATLAS -#define LLMR_GEOMETRY_GLYPH_ATLAS +#ifndef MBGL_GEOMETRY_GLYPH_ATLAS +#define MBGL_GEOMETRY_GLYPH_ATLAS -#include <llmr/geometry/binpack.hpp> -#include <llmr/text/glyph_store.hpp> +#include <mbgl/geometry/binpack.hpp> +#include <mbgl/text/glyph_store.hpp> #include <string> #include <set> @@ -10,7 +10,7 @@ #include <mutex> #include <atomic> -namespace llmr { +namespace mbgl { class GlyphAtlas { public: diff --git a/include/llmr/geometry/icon_buffer.hpp b/include/mbgl/geometry/icon_buffer.hpp index 6bb0ec30c1..346b3b5f06 100644 --- a/include/llmr/geometry/icon_buffer.hpp +++ b/include/mbgl/geometry/icon_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_ICON_BUFFER -#define LLMR_GEOMETRY_ICON_BUFFER +#ifndef MBGL_GEOMETRY_ICON_BUFFER +#define MBGL_GEOMETRY_ICON_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class IconVertexBuffer : public Buffer< 4 + // int16 x/y coordinates per vertex (== 4 bytes) diff --git a/include/mbgl/geometry/interpolate.hpp b/include/mbgl/geometry/interpolate.hpp new file mode 100644 index 0000000000..cebbcc7028 --- /dev/null +++ b/include/mbgl/geometry/interpolate.hpp @@ -0,0 +1,13 @@ +#ifndef MBGL_GEOMETRY_INTERPOLATE +#define MBGL_GEOMETRY_INTERPOLATE + +#include <mbgl/geometry/anchor.hpp> +#include <mbgl/util/math.hpp> + +namespace mbgl { + +Anchors interpolate(const std::vector<Coordinate> &vertices, float spacing, + float minScale = 0.0f, int start = 0); +} + +#endif diff --git a/include/llmr/geometry/line_buffer.hpp b/include/mbgl/geometry/line_buffer.hpp index 289f1bc6eb..5012bb12ac 100644 --- a/include/llmr/geometry/line_buffer.hpp +++ b/include/mbgl/geometry/line_buffer.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_GEOMETRY_LINE_BUFFER -#define LLMR_GEOMETRY_LINE_BUFFER +#ifndef MBGL_GEOMETRY_LINE_BUFFER +#define MBGL_GEOMETRY_LINE_BUFFER #include "buffer.hpp" -namespace llmr { +namespace mbgl { class LineVertexBuffer : public Buffer< 8 // 2 coordinates per vertex + 1 linesofar + 1 extrude coord pair == 4 (== 8 bytes) diff --git a/include/llmr/geometry/sprite_atlas.hpp b/include/mbgl/geometry/sprite_atlas.hpp index 13b85e5480..4b55540cc8 100644 --- a/include/llmr/geometry/sprite_atlas.hpp +++ b/include/mbgl/geometry/sprite_atlas.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_GEOMETRY_SPRITE_ATLAS -#define LLMR_GEOMETRY_SPRITE_ATLAS +#ifndef MBGL_GEOMETRY_SPRITE_ATLAS +#define MBGL_GEOMETRY_SPRITE_ATLAS -#include <llmr/geometry/binpack.hpp> +#include <mbgl/geometry/binpack.hpp> #include <string> #include <map> @@ -9,7 +9,7 @@ #include <atomic> #include <set> -namespace llmr { +namespace mbgl { class Sprite; class SpritePosition; diff --git a/include/llmr/geometry/text_buffer.hpp b/include/mbgl/geometry/text_buffer.hpp index 8d4cba2856..159f3207a8 100644 --- a/include/llmr/geometry/text_buffer.hpp +++ b/include/mbgl/geometry/text_buffer.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_GEOMETRY_TEXT_BUFFER -#define LLMR_GEOMETRY_TEXT_BUFFER +#ifndef MBGL_GEOMETRY_TEXT_BUFFER +#define MBGL_GEOMETRY_TEXT_BUFFER #include "buffer.hpp" #include <array> -namespace llmr { +namespace mbgl { class TextVertexBuffer : public Buffer < 16, diff --git a/include/llmr/geometry/vao.hpp b/include/mbgl/geometry/vao.hpp index 64b324372c..71d7ff89fe 100644 --- a/include/llmr/geometry/vao.hpp +++ b/include/mbgl/geometry/vao.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_GEOMETRY_VAO -#define LLMR_GEOMETRY_VAO +#ifndef MBGL_GEOMETRY_VAO +#define MBGL_GEOMETRY_VAO -#include <llmr/platform/gl.hpp> +#include <mbgl/platform/gl.hpp> #include <stdexcept> -namespace llmr { +namespace mbgl { class VertexArrayObject { public: diff --git a/include/llmr/geometry/vertex_buffer.hpp b/include/mbgl/geometry/vertex_buffer.hpp index 9478d7b15f..58fd4a9d03 100644 --- a/include/llmr/geometry/vertex_buffer.hpp +++ b/include/mbgl/geometry/vertex_buffer.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_GEOMETRY_VERTEX_BUFFER -#define LLMR_GEOMETRY_VERTEX_BUFFER +#ifndef MBGL_GEOMETRY_VERTEX_BUFFER +#define MBGL_GEOMETRY_VERTEX_BUFFER #include <vector> #include <cstddef> #include <cstdint> #include <cmath> -namespace llmr { +namespace mbgl { class VertexBuffer { public: diff --git a/include/llmr/map/map.hpp b/include/mbgl/map/map.hpp index af4250c357..774e5e1292 100644 --- a/include/llmr/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -1,23 +1,23 @@ -#ifndef LLMR_MAP_MAP -#define LLMR_MAP_MAP +#ifndef MBGL_MAP_MAP +#define MBGL_MAP_MAP #include <uv.h> -#include <llmr/map/view.hpp> -#include <llmr/map/transform.hpp> -#include <llmr/style/style.hpp> -#include <llmr/geometry/glyph_atlas.hpp> -#include <llmr/text/glyph_store.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/texturepool.hpp> +#include <mbgl/map/view.hpp> +#include <mbgl/map/transform.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/geometry/glyph_atlas.hpp> +#include <mbgl/text/glyph_store.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/texturepool.hpp> #include <cstdint> #include <string> #include <map> -namespace llmr { +namespace mbgl { class Source; class SpriteAtlas; diff --git a/include/llmr/map/raster_tile_data.hpp b/include/mbgl/map/raster_tile_data.hpp index f84b540d48..976faa91bc 100644 --- a/include/llmr/map/raster_tile_data.hpp +++ b/include/mbgl/map/raster_tile_data.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_RASTER_TILE_DATA -#define LLMR_MAP_RASTER_TILE_DATA +#ifndef MBGL_MAP_RASTER_TILE_DATA +#define MBGL_MAP_RASTER_TILE_DATA -#include <llmr/map/tile_data.hpp> +#include <mbgl/map/tile_data.hpp> -#include <llmr/renderer/raster_bucket.hpp> +#include <mbgl/renderer/raster_bucket.hpp> -namespace llmr { +namespace mbgl { class RasterTileData : public TileData { friend class TileParser; diff --git a/include/llmr/map/source.hpp b/include/mbgl/map/source.hpp index b8ffc27f52..be5fad3af8 100644 --- a/include/llmr/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_SOURCE -#define LLMR_MAP_SOURCE +#ifndef MBGL_MAP_SOURCE +#define MBGL_MAP_SOURCE -#include <llmr/map/tile.hpp> -#include <llmr/map/tile_data.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/time.hpp> -#include <llmr/style/style_source.hpp> -#include <llmr/style/types.hpp> +#include <mbgl/map/tile.hpp> +#include <mbgl/map/tile_data.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/style/style_source.hpp> +#include <mbgl/style/types.hpp> #include <list> #include <forward_list> @@ -16,7 +16,7 @@ #include <map> #include <set> -namespace llmr { +namespace mbgl { class TransformState; class Texturepool; diff --git a/include/llmr/map/sprite.hpp b/include/mbgl/map/sprite.hpp index 07f5903e51..22126eb6a1 100644 --- a/include/llmr/map/sprite.hpp +++ b/include/mbgl/map/sprite.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_STYLE_SPRITE -#define LLMR_STYLE_SPRITE +#ifndef MBGL_STYLE_SPRITE +#define MBGL_STYLE_SPRITE -#include <llmr/util/raster.hpp> -#include <llmr/util/vec.hpp> +#include <mbgl/util/raster.hpp> +#include <mbgl/util/vec.hpp> #include <string> #include <mutex> @@ -10,7 +10,7 @@ #include <atomic> #include <unordered_map> -namespace llmr { +namespace mbgl { class Map; @@ -52,6 +52,7 @@ private: private: Map ↦ + std::string url; std::string body; std::string image; std::atomic<bool> loaded; diff --git a/include/llmr/map/tile.hpp b/include/mbgl/map/tile.hpp index 9681c36374..7e868afad9 100644 --- a/include/llmr/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_MAP_TILE -#define LLMR_MAP_TILE +#ifndef MBGL_MAP_TILE +#define MBGL_MAP_TILE -#include <llmr/util/vec.hpp> -#include <llmr/util/mat4.hpp> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/noncopyable.hpp> #include <cstdint> #include <forward_list> @@ -11,7 +11,7 @@ #include <bitset> #include <memory> -namespace llmr { +namespace mbgl { class TileData; diff --git a/include/llmr/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 09f36d59b0..a4b73c339f 100644 --- a/include/llmr/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -1,18 +1,18 @@ -#ifndef LLMR_MAP_TILE_DATA -#define LLMR_MAP_TILE_DATA +#ifndef MBGL_MAP_TILE_DATA +#define MBGL_MAP_TILE_DATA -#include <llmr/map/tile.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/platform/platform.hpp> -#include <llmr/geometry/vao.hpp> -#include <llmr/renderer/debug_bucket.hpp> +#include <mbgl/map/tile.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/geometry/vao.hpp> +#include <mbgl/renderer/debug_bucket.hpp> #include <cstdint> #include <string> #include <memory> #include <atomic> -namespace llmr { +namespace mbgl { class Map; class Painter; diff --git a/include/llmr/map/tile_parser.hpp b/include/mbgl/map/tile_parser.hpp index e18c2746af..14e00946b8 100644 --- a/include/llmr/map/tile_parser.hpp +++ b/include/mbgl/map/tile_parser.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_MAP_TILE_PARSER -#define LLMR_MAP_TILE_PARSER +#ifndef MBGL_MAP_TILE_PARSER +#define MBGL_MAP_TILE_PARSER -#include <llmr/map/vector_tile.hpp> -#include <llmr/text/placement.hpp> -#include <llmr/text/glyph_store.hpp> -#include <llmr/text/glyph.hpp> -#include <llmr/util/utf.hpp> -#include <llmr/style/filter_expression.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/text/placement.hpp> +#include <mbgl/text/glyph_store.hpp> +#include <mbgl/text/glyph.hpp> +#include <mbgl/util/utf.hpp> +#include <mbgl/style/filter_expression.hpp> -namespace llmr { +namespace mbgl { class Style; class GlyphAtlas; diff --git a/include/llmr/map/transform.hpp b/include/mbgl/map/transform.hpp index c4474ff024..61bef76563 100644 --- a/include/llmr/map/transform.hpp +++ b/include/mbgl/map/transform.hpp @@ -1,21 +1,22 @@ -#ifndef LLMR_MAP_TRANSFORM -#define LLMR_MAP_TRANSFORM +#ifndef MBGL_MAP_TRANSFORM +#define MBGL_MAP_TRANSFORM -#include <llmr/util/transition.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/uv.hpp> +#include <mbgl/util/transition.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/uv.hpp> +#include "view.hpp" #include "transform_state.hpp" #include <forward_list> -namespace llmr { +namespace mbgl { struct box; class Transform : private util::noncopyable { public: - Transform(); + Transform(View &view); // Map view // Note: width * ratio does not necessarily equal fb_width @@ -74,6 +75,8 @@ private: void constrain(double& scale, double& y) const; private: + View &view; + mutable uv::rwlock mtx; // This reflects the current state of the transform, representing the actual position of the diff --git a/include/llmr/map/transform_state.hpp b/include/mbgl/map/transform_state.hpp index 29d0f59c46..85dd2eb87d 100644 --- a/include/llmr/map/transform_state.hpp +++ b/include/mbgl/map/transform_state.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_MAP_TRANSFORM_STATE -#define LLMR_MAP_TRANSFORM_STATE +#ifndef MBGL_MAP_TRANSFORM_STATE +#define MBGL_MAP_TRANSFORM_STATE -#include <llmr/util/mat4.hpp> -#include <llmr/map/tile.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/map/tile.hpp> #include <cstdint> -namespace llmr { +namespace mbgl { class Transform; diff --git a/include/llmr/map/vector_tile.hpp b/include/mbgl/map/vector_tile.hpp index ad7a0eea14..77e379865f 100644 --- a/include/llmr/map/vector_tile.hpp +++ b/include/mbgl/map/vector_tile.hpp @@ -1,18 +1,18 @@ -#ifndef LLMR_MAP_VECTOR_TILE -#define LLMR_MAP_VECTOR_TILE - -#include <llmr/util/pbf.hpp> -#include <llmr/util/vec.hpp> -#include <llmr/style/value.hpp> -#include <llmr/text/glyph.hpp> -#include <llmr/style/filter_expression.hpp> +#ifndef MBGL_MAP_VECTOR_TILE +#define MBGL_MAP_VECTOR_TILE + +#include <mbgl/util/pbf.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/style/value.hpp> +#include <mbgl/text/glyph.hpp> +#include <mbgl/style/filter_expression.hpp> #include <vector> #include <map> #include <unordered_map> #include <set> #include <limits> -namespace llmr { +namespace mbgl { class BucketDescription; class VectorTileLayer; @@ -46,7 +46,7 @@ public: VectorTileTagExtractor(const VectorTileLayer &layer); void setTags(const pbf &pbf); - std::forward_list<Value> getValues(const std::string &key) const; + std::vector<Value> getValues(const std::string &key) const; void setType(FilterExpression::GeometryType type); FilterExpression::GeometryType getType() const; diff --git a/include/llmr/map/vector_tile_data.hpp b/include/mbgl/map/vector_tile_data.hpp index d6f5391c22..dd55e8dae1 100644 --- a/include/llmr/map/vector_tile_data.hpp +++ b/include/mbgl/map/vector_tile_data.hpp @@ -1,22 +1,22 @@ -#ifndef LLMR_MAP_VECTOR_TILE_DATA -#define LLMR_MAP_VECTOR_TILE_DATA +#ifndef MBGL_MAP_VECTOR_TILE_DATA +#define MBGL_MAP_VECTOR_TILE_DATA -#include <llmr/map/tile_data.hpp> +#include <mbgl/map/tile_data.hpp> -#include <llmr/renderer/bucket.hpp> +#include <mbgl/renderer/bucket.hpp> -#include <llmr/geometry/vertex_buffer.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/fill_buffer.hpp> -#include <llmr/geometry/line_buffer.hpp> -#include <llmr/geometry/icon_buffer.hpp> -#include <llmr/geometry/text_buffer.hpp> -#include <llmr/map/tile_parser.hpp> +#include <mbgl/geometry/vertex_buffer.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/fill_buffer.hpp> +#include <mbgl/geometry/line_buffer.hpp> +#include <mbgl/geometry/icon_buffer.hpp> +#include <mbgl/geometry/text_buffer.hpp> +#include <mbgl/map/tile_parser.hpp> #include <unordered_map> -namespace llmr { +namespace mbgl { class VectorTileData : public TileData { diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp new file mode 100644 index 0000000000..92d60d4d02 --- /dev/null +++ b/include/mbgl/map/view.hpp @@ -0,0 +1,54 @@ +#ifndef MBGL_MAP_VIEW +#define MBGL_MAP_VIEW + +#include <mbgl/util/time.hpp> + +namespace mbgl { + +class Map; + +enum MapChange : uint8_t { + MapChangeRegionWillChange = 0, + MapChangeRegionWillChangeAnimated = 1, + MapChangeRegionDidChange = 2, + MapChangeRegionDidChangeAnimated = 3, + MapChangeWillStartLoadingMap = 4, + MapChangeDidFinishLoadingMap = 5, + MapChangeDidFailLoadingMap = 6, + MapChangeWillStartRenderingMap = 7, + MapChangeDidFinishRenderingMap = 8, + MapChangeDidFinishRenderingMapFullyRendered = 9 +}; + +class View { +public: + virtual void initialize(Map *map) { + this->map = map; + } + + // Called from the render (=GL) thread. Signals that the context should + // swap the front and the back buffer. + virtual void swap() = 0; + + // Called from the render thread. Makes the GL context active in the current + // thread. This is typically just called once at the beginning of the + // renderer setup since the render thread doesn't switch the contexts. + virtual void make_active() = 0; + + // Returns the base framebuffer object, if any, and 0 if using the system + // provided framebuffer. + virtual unsigned int root_fbo() { + return 0; + } + + // Notifies a watcher of map x/y/scale/rotation changes. + // Must only be called from the same thread that caused the change. + // Must not be called from the render thread. + virtual void notify_map_change(MapChange change, timestamp delay = 0) = 0; + +protected: + mbgl::Map *map = nullptr; +}; +} + +#endif diff --git a/include/llmr/llmr.hpp b/include/mbgl/mbgl.hpp index 349b15d8c9..90abd4e11e 100644 --- a/include/llmr/llmr.hpp +++ b/include/mbgl/mbgl.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_MAIN -#define LLMR_MAIN +#ifndef MBGL_MAIN +#define MBGL_MAIN #include "map/map.hpp" #include "map/view.hpp" diff --git a/include/llmr/platform/event.hpp b/include/mbgl/platform/event.hpp index 133cfc3c5a..b55c721c99 100644 --- a/include/llmr/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_PLATFORM_EVENT -#define LLMR_PLATFORM_EVENT +#ifndef MBGL_PLATFORM_EVENT +#define MBGL_PLATFORM_EVENT -#include <llmr/util/enum.hpp> +#include <mbgl/util/enum.hpp> #include <cstdint> -namespace llmr { +namespace mbgl { enum class EventSeverity : uint8_t { Debug, @@ -15,7 +15,7 @@ enum class EventSeverity : uint8_t { Error, }; -LLMR_DEFINE_ENUM_CLASS(EventSeverityClass, EventSeverity, { +MBGL_DEFINE_ENUM_CLASS(EventSeverityClass, EventSeverity, { { EventSeverity::Debug, "DEBUG" }, { EventSeverity::Info, "INFO" }, { EventSeverity::Test, "TEST" }, @@ -32,9 +32,10 @@ enum class Event : uint8_t { ParseTile, Render, HttpRequest, + Sprite, }; -LLMR_DEFINE_ENUM_CLASS(EventClass, Event, { +MBGL_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::General, "General" }, { Event::Setup, "Setup" }, { Event::Shader, "Shader" }, @@ -42,6 +43,7 @@ LLMR_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::ParseTile, "ParseTile" }, { Event::Render, "Render" }, { Event::HttpRequest, "HttpRequest" }, + { Event::Sprite, "Sprite" }, { Event(-1), "Unknown" }, }); diff --git a/include/llmr/platform/gl.hpp b/include/mbgl/platform/gl.hpp index b1e2d5d5a4..a29b230dbf 100644 --- a/include/llmr/platform/gl.hpp +++ b/include/mbgl/platform/gl.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_RENDERER_GL -#define LLMR_RENDERER_GL +#ifndef MBGL_RENDERER_GL +#define MBGL_RENDERER_GL #include <string> @@ -39,7 +39,7 @@ #include <GL/glext.h> #endif -namespace llmr { +namespace mbgl { namespace gl { // Debug group markers, useful for debuggin on iOS #if defined(__APPLE__) && defined(DEBUG) && defined(GL_EXT_debug_marker) diff --git a/include/llmr/platform/log.hpp b/include/mbgl/platform/log.hpp index 7b39370046..dc000b4d52 100644 --- a/include/llmr/platform/log.hpp +++ b/include/mbgl/platform/log.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_PLATFORM_LOG -#define LLMR_PLATFORM_LOG +#ifndef MBGL_PLATFORM_LOG +#define MBGL_PLATFORM_LOG #include "event.hpp" #include <memory> #include <string> -namespace llmr { +namespace mbgl { class LogBackend { public: diff --git a/include/llmr/platform/platform.hpp b/include/mbgl/platform/platform.hpp index 138843fee3..02aeb594b6 100644 --- a/include/llmr/platform/platform.hpp +++ b/include/mbgl/platform/platform.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_PLATFORM_PLATFORM -#define LLMR_PLATFORM_PLATFORM +#ifndef MBGL_PLATFORM_PLATFORM +#define MBGL_PLATFORM_PLATFORM #include <memory> #include <functional> @@ -11,7 +11,7 @@ namespace uv { class loop; } -namespace llmr { +namespace mbgl { namespace platform { class Request; @@ -24,19 +24,6 @@ struct Response { std::function<void(Response *)> callback; }; -enum MapChange : uint8_t { - MapChangeRegionWillChange = 0, - MapChangeRegionWillChangeAnimated = 1, - MapChangeRegionDidChange = 2, - MapChangeRegionDidChangeAnimated = 3, - MapChangeWillStartLoadingMap = 4, - MapChangeDidFinishLoadingMap = 5, - MapChangeDidFailLoadingMap = 6, - MapChangeWillStartRenderingMap = 7, - MapChangeDidFinishRenderingMap = 8, - MapChangeDidFinishRenderingMapFullyRendered = 9 -}; - // Makes an HTTP request of a URL, preferrably on a background thread, and calls a function with the // results in the original thread (which runs the libuv loop). // If the loop pointer is NULL, the callback function will be called on an arbitrary thread. @@ -48,9 +35,6 @@ std::shared_ptr<Request> request_http(const std::string &url, // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr<Request> &req); -// Notifies a watcher of map changes. -void notify_map_change(MapChange key); - // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/include/llmr/platform/request.hpp b/include/mbgl/platform/request.hpp index 5ba00830b8..7d2da8888c 100644 --- a/include/llmr/platform/request.hpp +++ b/include/mbgl/platform/request.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_PLATFORM_REQUEST -#define LLMR_PLATFORM_REQUEST +#ifndef MBGL_PLATFORM_REQUEST +#define MBGL_PLATFORM_REQUEST #include <string> #include <functional> #include <memory> #include <atomic> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/util/noncopyable.hpp> // Forward definition. typedef struct uv_loop_s uv_loop_t; @@ -16,7 +16,7 @@ namespace uv { class loop; } -namespace llmr { +namespace mbgl { namespace platform { struct Response; diff --git a/include/llmr/renderer/bucket.hpp b/include/mbgl/renderer/bucket.hpp index c135b8ee16..18f58ee464 100644 --- a/include/llmr/renderer/bucket.hpp +++ b/include/mbgl/renderer/bucket.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_RENDERER_BUCKET -#define LLMR_RENDERER_BUCKET +#ifndef MBGL_RENDERER_BUCKET +#define MBGL_RENDERER_BUCKET #include <string> #include <memory> -#include <llmr/map/tile.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/renderer/prerendered_texture.hpp> +#include <mbgl/map/tile.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/renderer/prerendered_texture.hpp> -namespace llmr { +namespace mbgl { class Painter; class StyleLayer; diff --git a/include/llmr/renderer/debug_bucket.hpp b/include/mbgl/renderer/debug_bucket.hpp index d72a645eee..ac4f18cc2c 100644 --- a/include/llmr/renderer/debug_bucket.hpp +++ b/include/mbgl/renderer/debug_bucket.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_DEBUGBUCKET -#define LLMR_RENDERER_DEBUGBUCKET +#ifndef MBGL_RENDERER_DEBUGBUCKET +#define MBGL_RENDERER_DEBUGBUCKET -#include <llmr/renderer/bucket.hpp> -#include <llmr/geometry/debug_font_buffer.hpp> -#include <llmr/geometry/vao.hpp> +#include <mbgl/renderer/bucket.hpp> +#include <mbgl/geometry/debug_font_buffer.hpp> +#include <mbgl/geometry/vao.hpp> #include <vector> #include <memory> @@ -12,7 +12,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class PlainShader; diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/mbgl/renderer/fill_bucket.hpp index db0e9c1042..9193b09149 100644 --- a/include/llmr/renderer/fill_bucket.hpp +++ b/include/mbgl/renderer/fill_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_FILLBUCKET -#define LLMR_RENDERER_FILLBUCKET +#ifndef MBGL_RENDERER_FILLBUCKET +#define MBGL_RENDERER_FILLBUCKET -#include <llmr/renderer/bucket.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/fill_buffer.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/renderer/bucket.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/fill_buffer.hpp> +#include <mbgl/style/style_bucket.hpp> #include <clipper/clipper.hpp> #include <libtess2/tesselator.h> @@ -16,7 +16,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class Style; class FillVertexBuffer; diff --git a/include/llmr/renderer/frame_history.hpp b/include/mbgl/renderer/frame_history.hpp index 35ef3cdf47..a5dbe21bca 100644 --- a/include/llmr/renderer/frame_history.hpp +++ b/include/mbgl/renderer/frame_history.hpp @@ -1,14 +1,14 @@ -#ifndef LLMR_RENDERER_FRAME_HISTORY -#define LLMR_RENDERER_FRAME_HISTORY +#ifndef MBGL_RENDERER_FRAME_HISTORY +#define MBGL_RENDERER_FRAME_HISTORY #include <deque> #include <cassert> #include <cmath> -#include <llmr/platform/platform.hpp> -#include <llmr/util/time.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/util/time.hpp> -namespace llmr { +namespace mbgl { struct FrameSnapshot { explicit inline FrameSnapshot(timestamp t, float z) : t(t), z(z) {} diff --git a/include/llmr/renderer/icon_bucket.hpp b/include/mbgl/renderer/icon_bucket.hpp index d13f53586b..e3b311332d 100644 --- a/include/llmr/renderer/icon_bucket.hpp +++ b/include/mbgl/renderer/icon_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_ICONBUCKET -#define LLMR_RENDERER_ICONBUCKET +#ifndef MBGL_RENDERER_ICONBUCKET +#define MBGL_RENDERER_ICONBUCKET -#include <llmr/renderer/bucket.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/icon_buffer.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/renderer/bucket.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/icon_buffer.hpp> +#include <mbgl/style/style_bucket.hpp> #include <vector> #include <memory> @@ -13,7 +13,7 @@ #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) #endif -namespace llmr { +namespace mbgl { class Style; class IconVertexBuffer; diff --git a/include/llmr/renderer/line_bucket.hpp b/include/mbgl/renderer/line_bucket.hpp index 881bd23ebb..d42b10bfb7 100644 --- a/include/llmr/renderer/line_bucket.hpp +++ b/include/mbgl/renderer/line_bucket.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_RENDERER_LINEBUCKET -#define LLMR_RENDERER_LINEBUCKET +#ifndef MBGL_RENDERER_LINEBUCKET +#define MBGL_RENDERER_LINEBUCKET #include "bucket.hpp" -#include <llmr/geometry/vao.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/line_buffer.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/geometry/vao.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/line_buffer.hpp> +#include <mbgl/style/style_bucket.hpp> #include <memory> #include <vector> -namespace llmr { +namespace mbgl { class Style; class LineVertexBuffer; diff --git a/include/llmr/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index ef160eddd2..9868b5d9da 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -1,33 +1,33 @@ -#ifndef LLMR_RENDERER_PAINTER -#define LLMR_RENDERER_PAINTER - -#include <llmr/map/tile_data.hpp> -#include <llmr/geometry/vao.hpp> -#include <llmr/geometry/vertex_buffer.hpp> -#include <llmr/util/mat4.hpp> -#include <llmr/util/noncopyable.hpp> -#include <llmr/renderer/frame_history.hpp> -#include <llmr/style/types.hpp> - -#include <llmr/shader/plain_shader.hpp> -#include <llmr/shader/outline_shader.hpp> -#include <llmr/shader/pattern_shader.hpp> -#include <llmr/shader/line_shader.hpp> -#include <llmr/shader/linejoin_shader.hpp> -#include <llmr/shader/icon_shader.hpp> -#include <llmr/shader/raster_shader.hpp> -#include <llmr/shader/text_shader.hpp> -#include <llmr/shader/dot_shader.hpp> -#include <llmr/shader/composite_shader.hpp> -#include <llmr/shader/gaussian_shader.hpp> - -#include <llmr/map/transform_state.hpp> +#ifndef MBGL_RENDERER_PAINTER +#define MBGL_RENDERER_PAINTER + +#include <mbgl/map/tile_data.hpp> +#include <mbgl/geometry/vao.hpp> +#include <mbgl/geometry/vertex_buffer.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/renderer/frame_history.hpp> +#include <mbgl/style/types.hpp> + +#include <mbgl/shader/plain_shader.hpp> +#include <mbgl/shader/outline_shader.hpp> +#include <mbgl/shader/pattern_shader.hpp> +#include <mbgl/shader/line_shader.hpp> +#include <mbgl/shader/linejoin_shader.hpp> +#include <mbgl/shader/icon_shader.hpp> +#include <mbgl/shader/raster_shader.hpp> +#include <mbgl/shader/text_shader.hpp> +#include <mbgl/shader/dot_shader.hpp> +#include <mbgl/shader/composite_shader.hpp> +#include <mbgl/shader/gaussian_shader.hpp> + +#include <mbgl/map/transform_state.hpp> #include <map> #include <unordered_map> #include <set> -namespace llmr { +namespace mbgl { class Transform; class Style; diff --git a/include/llmr/renderer/prerendered_texture.hpp b/include/mbgl/renderer/prerendered_texture.hpp index 168284e1de..9c72e14b88 100644 --- a/include/llmr/renderer/prerendered_texture.hpp +++ b/include/mbgl/renderer/prerendered_texture.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_RENDERER_PRERENDERED_TEXTURE -#define LLMR_RENDERER_PRERENDERED_TEXTURE +#ifndef MBGL_RENDERER_PRERENDERED_TEXTURE +#define MBGL_RENDERER_PRERENDERED_TEXTURE -#include <llmr/util/noncopyable.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/style/rasterize_properties.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/style/rasterize_properties.hpp> -namespace llmr { +namespace mbgl { class Painter; diff --git a/include/llmr/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp index 86bb1d925d..c111193126 100644 --- a/include/llmr/renderer/raster_bucket.hpp +++ b/include/mbgl/renderer/raster_bucket.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_RENDERER_RASTERBUCKET -#define LLMR_RENDERER_RASTERBUCKET +#ifndef MBGL_RENDERER_RASTERBUCKET +#define MBGL_RENDERER_RASTERBUCKET -#include <llmr/renderer/bucket.hpp> -#include <llmr/util/raster.hpp> +#include <mbgl/renderer/bucket.hpp> +#include <mbgl/util/raster.hpp> -namespace llmr { +namespace mbgl { class RasterShader; class VertexBuffer; diff --git a/include/llmr/renderer/text_bucket.hpp b/include/mbgl/renderer/text_bucket.hpp index 4d9bf382d6..cb4b8f2cda 100644 --- a/include/llmr/renderer/text_bucket.hpp +++ b/include/mbgl/renderer/text_bucket.hpp @@ -1,19 +1,19 @@ -#ifndef LLMR_RENDERER_TEXTBUCKET -#define LLMR_RENDERER_TEXTBUCKET +#ifndef MBGL_RENDERER_TEXTBUCKET +#define MBGL_RENDERER_TEXTBUCKET #include "bucket.hpp" -#include <llmr/geometry/vao.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/map/vector_tile.hpp> -#include <llmr/text/types.hpp> -#include <llmr/text/glyph.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/geometry/vao.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/text/types.hpp> +#include <mbgl/text/glyph.hpp> +#include <mbgl/style/style_bucket.hpp> #include <memory> #include <map> #include <vector> -namespace llmr { +namespace mbgl { class Style; class TextVertexBuffer; diff --git a/include/llmr/shader/composite_shader.hpp b/include/mbgl/shader/composite_shader.hpp index 31156485c4..c0c1704f3d 100644 --- a/include/llmr/shader/composite_shader.hpp +++ b/include/mbgl/shader/composite_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_COMPOSITE_SHADER -#define LLMR_SHADER_COMPOSITE_SHADER +#ifndef MBGL_SHADER_COMPOSITE_SHADER +#define MBGL_SHADER_COMPOSITE_SHADER -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class CompositeShader : public Shader { public: diff --git a/include/llmr/shader/dot_shader.hpp b/include/mbgl/shader/dot_shader.hpp index 5e817c09c1..d8d649db9c 100644 --- a/include/llmr/shader/dot_shader.hpp +++ b/include/mbgl/shader/dot_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_DOT -#define LLMR_SHADER_SHADER_DOT +#ifndef MBGL_SHADER_SHADER_DOT +#define MBGL_SHADER_SHADER_DOT -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class DotShader : public Shader { public: diff --git a/include/llmr/shader/gaussian_shader.hpp b/include/mbgl/shader/gaussian_shader.hpp index c3589c1534..a4b9d09f3a 100644 --- a/include/llmr/shader/gaussian_shader.hpp +++ b/include/mbgl/shader/gaussian_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_SHADER_GAUSSIAN -#define LLMR_RENDERER_SHADER_GAUSSIAN +#ifndef MBGL_RENDERER_SHADER_GAUSSIAN +#define MBGL_RENDERER_SHADER_GAUSSIAN -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class GaussianShader : public Shader { public: diff --git a/include/llmr/shader/icon_shader.hpp b/include/mbgl/shader/icon_shader.hpp index daf37b374a..b97b3c2be3 100644 --- a/include/llmr/shader/icon_shader.hpp +++ b/include/mbgl/shader/icon_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_ICON -#define LLMR_SHADER_SHADER_ICON +#ifndef MBGL_SHADER_SHADER_ICON +#define MBGL_SHADER_SHADER_ICON -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class IconShader : public Shader { public: diff --git a/include/llmr/shader/line_shader.hpp b/include/mbgl/shader/line_shader.hpp index 234c70a649..38efe0b71f 100644 --- a/include/llmr/shader/line_shader.hpp +++ b/include/mbgl/shader/line_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_LINE -#define LLMR_SHADER_SHADER_LINE +#ifndef MBGL_SHADER_SHADER_LINE +#define MBGL_SHADER_SHADER_LINE -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class LineShader : public Shader { public: diff --git a/include/llmr/shader/linejoin_shader.hpp b/include/mbgl/shader/linejoin_shader.hpp index 82ec3b59aa..5a5c97e921 100644 --- a/include/llmr/shader/linejoin_shader.hpp +++ b/include/mbgl/shader/linejoin_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_LINEJOIN -#define LLMR_SHADER_SHADER_LINEJOIN +#ifndef MBGL_SHADER_SHADER_LINEJOIN +#define MBGL_SHADER_SHADER_LINEJOIN -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class LinejoinShader : public Shader { public: diff --git a/include/llmr/shader/outline_shader.hpp b/include/mbgl/shader/outline_shader.hpp index 5b52b30054..551e31ca57 100644 --- a/include/llmr/shader/outline_shader.hpp +++ b/include/mbgl/shader/outline_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_OUTLINE -#define LLMR_SHADER_SHADER_OUTLINE +#ifndef MBGL_SHADER_SHADER_OUTLINE +#define MBGL_SHADER_SHADER_OUTLINE -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class OutlineShader : public Shader { public: diff --git a/include/llmr/shader/pattern_shader.hpp b/include/mbgl/shader/pattern_shader.hpp index d0142ebca4..b1b49b54df 100644 --- a/include/llmr/shader/pattern_shader.hpp +++ b/include/mbgl/shader/pattern_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_PATTERN -#define LLMR_SHADER_SHADER_PATTERN +#ifndef MBGL_SHADER_SHADER_PATTERN +#define MBGL_SHADER_SHADER_PATTERN -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class PatternShader : public Shader { public: diff --git a/include/llmr/shader/plain_shader.hpp b/include/mbgl/shader/plain_shader.hpp index bf768f8845..277788431f 100644 --- a/include/llmr/shader/plain_shader.hpp +++ b/include/mbgl/shader/plain_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_SHADER_PLAIN -#define LLMR_SHADER_SHADER_PLAIN +#ifndef MBGL_SHADER_SHADER_PLAIN +#define MBGL_SHADER_SHADER_PLAIN -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class PlainShader : public Shader { public: diff --git a/include/llmr/shader/raster_shader.hpp b/include/mbgl/shader/raster_shader.hpp index adc945e460..ec69fa7238 100644 --- a/include/llmr/shader/raster_shader.hpp +++ b/include/mbgl/shader/raster_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_RENDERER_SHADER_RASTER -#define LLMR_RENDERER_SHADER_RASTER +#ifndef MBGL_RENDERER_SHADER_RASTER +#define MBGL_RENDERER_SHADER_RASTER -#include <llmr/shader/shader.hpp> +#include <mbgl/shader/shader.hpp> -namespace llmr { +namespace mbgl { class RasterShader : public Shader { public: diff --git a/include/llmr/shader/shader.hpp b/include/mbgl/shader/shader.hpp index f4713c59f6..2398cb12e3 100644 --- a/include/llmr/shader/shader.hpp +++ b/include/mbgl/shader/shader.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_RENDERER_SHADER -#define LLMR_RENDERER_SHADER +#ifndef MBGL_RENDERER_SHADER +#define MBGL_RENDERER_SHADER #include <cstdint> #include <array> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/util/noncopyable.hpp> -namespace llmr { +namespace mbgl { class Shader : private util::noncopyable { public: diff --git a/include/llmr/shader/text_shader.hpp b/include/mbgl/shader/text_shader.hpp index d232ef9a0c..554b890fb0 100644 --- a/include/llmr/shader/text_shader.hpp +++ b/include/mbgl/shader/text_shader.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_SHADER_TEXT_SHADER -#define LLMR_SHADER_TEXT_SHADER +#ifndef MBGL_SHADER_TEXT_SHADER +#define MBGL_SHADER_TEXT_SHADER #include "shader.hpp" -namespace llmr { +namespace mbgl { class TextShader : public Shader { public: diff --git a/include/llmr/style/applied_class_properties.hpp b/include/mbgl/style/applied_class_properties.hpp index 20edadc0a7..827f15a2a1 100644 --- a/include/llmr/style/applied_class_properties.hpp +++ b/include/mbgl/style/applied_class_properties.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_STYLE_APPLIED_CLASS_PROPERTIES -#define LLMR_STYLE_APPLIED_CLASS_PROPERTIES +#ifndef MBGL_STYLE_APPLIED_CLASS_PROPERTIES +#define MBGL_STYLE_APPLIED_CLASS_PROPERTIES -#include <llmr/style/property_value.hpp> -#include <llmr/style/class_dictionary.hpp> -#include <llmr/util/time.hpp> +#include <mbgl/style/property_value.hpp> +#include <mbgl/style/class_dictionary.hpp> +#include <mbgl/util/time.hpp> #include <list> -namespace llmr { +namespace mbgl { class AppliedClassProperty { public: diff --git a/include/llmr/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp index 772eb9c70e..c7f9c6a284 100644 --- a/include/llmr/style/class_dictionary.hpp +++ b/include/mbgl/style/class_dictionary.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_CLASS_DICTIONARY -#define LLMR_STYLE_CLASS_DICTIONARY +#ifndef MBGL_STYLE_CLASS_DICTIONARY +#define MBGL_STYLE_CLASS_DICTIONARY #include <cstdint> #include <string> #include <unordered_map> -namespace llmr { +namespace mbgl { enum class ClassID : uint32_t { Fallback = 0, // These values are from the fallback properties diff --git a/include/llmr/style/class_properties.hpp b/include/mbgl/style/class_properties.hpp index 55d6aa2cc6..84b6f483bd 100644 --- a/include/llmr/style/class_properties.hpp +++ b/include/mbgl/style/class_properties.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_STYLE_CLASS_PROPERTIES -#define LLMR_STYLE_CLASS_PROPERTIES +#ifndef MBGL_STYLE_CLASS_PROPERTIES +#define MBGL_STYLE_CLASS_PROPERTIES -#include <llmr/style/property_key.hpp> -#include <llmr/style/property_value.hpp> -#include <llmr/style/property_transition.hpp> +#include <mbgl/style/property_key.hpp> +#include <mbgl/style/property_value.hpp> +#include <mbgl/style/property_transition.hpp> #include <map> -namespace llmr { +namespace mbgl { class ClassProperties { public: diff --git a/include/mbgl/style/filter_comparison.hpp b/include/mbgl/style/filter_comparison.hpp new file mode 100644 index 0000000000..bf48744f1e --- /dev/null +++ b/include/mbgl/style/filter_comparison.hpp @@ -0,0 +1,65 @@ +#ifndef MBGL_STYLE_FILTER_COMPARISON +#define MBGL_STYLE_FILTER_COMPARISON + +#include <mbgl/style/value.hpp> + +#include <vector> +#include <string> +#include <iosfwd> + +namespace mbgl { + +class FilterComparison { +public: + enum class Operator : uint8_t { + Equal, + NotEqual, + Greater, + GreaterEqual, + Less, + LessEqual, + In, + NotIn + }; + + class Instance { + public: + Instance(Operator op, std::vector<Value> &&values) + : op(op), values(values) {} + + bool compare(const std::vector<Value> &property_values) const; + + private: + Operator op = Operator::Equal; + std::vector<Value> values; + + friend std::ostream& operator <<(std::ostream &, const Instance &); + }; + +public: + FilterComparison(const std::string &field) : field(field) {}; + + const std::string &getField() const; + template <typename Extractor> inline bool compare(const Extractor &extractor) const; + + template <typename ...Args> + inline void add(Args&& ...args) { + instances.emplace_back(::std::forward<Args>(args)...); + } + +private: + std::string field; + std::vector<Instance> instances; + + friend std::ostream& operator <<(std::ostream &, const FilterComparison &); +}; + +std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison); +std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance); + + +FilterComparison::Operator parseFilterComparisonOperator(const std::string &op); + +} + +#endif diff --git a/include/mbgl/style/filter_comparison_private.hpp b/include/mbgl/style/filter_comparison_private.hpp new file mode 100644 index 0000000000..6486832424 --- /dev/null +++ b/include/mbgl/style/filter_comparison_private.hpp @@ -0,0 +1,23 @@ +#ifndef MBGL_STYLE_FILTER_COMPARISON_PRIVATE +#define MBGL_STYLE_FILTER_COMPARISON_PRIVATE + +#include "filter_comparison.hpp" + +namespace mbgl { + +template <typename Extractor> +inline bool FilterComparison::compare(const Extractor &extractor) const { + const std::vector<Value> values = extractor.getValues(field); + + // All instances are ANDed together. + for (const Instance &instance : instances) { + if (!instance.compare(values)) { + return false; + } + } + return true; +} + +} + +#endif diff --git a/include/mbgl/style/filter_expression.hpp b/include/mbgl/style/filter_expression.hpp new file mode 100644 index 0000000000..2a6a2927e7 --- /dev/null +++ b/include/mbgl/style/filter_expression.hpp @@ -0,0 +1,54 @@ +#ifndef MBGL_STYLE_FILTER_EXPRESSION +#define MBGL_STYLE_FILTER_EXPRESSION + +#include <mbgl/style/filter_comparison.hpp> +#include <mbgl/util/recursive_wrapper.hpp> + +#include <iosfwd> + +namespace mbgl { + +class FilterExpression { +public: + typedef util::recursive_wrapper<FilterExpression> Wrapper; + + enum class Operator : uint8_t { + And, + Or, + Xor, + Nor + }; + + enum class GeometryType : uint8_t { + Any, + Point, + LineString, + Polygon + }; + +public: + FilterExpression() = default; + FilterExpression(Operator op) : op(op) {}; + + bool empty() const; + + template <typename Extractor> bool compare(const Extractor &extractor) const; + void add(const FilterComparison &comparison); + void add(const FilterExpression &expression); + void setGeometryType(GeometryType g); + +private: + Operator op = Operator::And; + GeometryType type = GeometryType::Any; + std::vector<FilterComparison> comparisons; + std::vector<FilterExpression::Wrapper> expressions; + + friend std::ostream& operator <<(std::ostream &, const FilterExpression &); +}; + +std::ostream& operator <<(std::ostream &s, const FilterExpression &expression); + +FilterExpression::GeometryType parseGeometryType(const std::string &geometry); +} + +#endif diff --git a/include/mbgl/style/filter_expression_private.hpp b/include/mbgl/style/filter_expression_private.hpp new file mode 100644 index 0000000000..9379d250ba --- /dev/null +++ b/include/mbgl/style/filter_expression_private.hpp @@ -0,0 +1,75 @@ +#ifndef MBGL_STYLE_FILTER_EXPRESSION_PRIVATE +#define MBGL_STYLE_FILTER_EXPRESSION_PRIVATE + +#include "filter_expression.hpp" +#include "filter_comparison_private.hpp" + +namespace mbgl { + +template <typename Extractor> +bool FilterExpression::compare(const Extractor &extractor) const { + if (type != GeometryType::Any && extractor.getType() != type && extractor.getType() != GeometryType::Any) { + return false; + } + + switch (op) { + case Operator::And: + for (const FilterComparison &comparison : comparisons) { + if (!comparison.compare(extractor)) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + if (!expression.compare(extractor)) { + return false; + } + } + return true; + case Operator::Or: + for (const FilterComparison &comparison : comparisons) { + if (comparison.compare(extractor)) { + return true; + } + } + for (const FilterExpression &expression: expressions) { + if (expression.compare(extractor)) { + return true; + } + } + return false; + case Operator::Xor: { + int count = 0; + for (const FilterComparison &comparison : comparisons) { + count += comparison.compare(extractor); + if (count > 1) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + count += expression.compare(extractor); + if (count > 1) { + return false; + } + } + return count == 1; + } + case Operator::Nor: + for (const FilterComparison &comparison : comparisons) { + if (comparison.compare(extractor)) { + return false; + } + } + for (const FilterExpression &expression: expressions) { + if (expression.compare(extractor)) { + return false; + } + } + return true; + default: + return true; + } +} + +} + +#endif diff --git a/include/llmr/style/function_properties.hpp b/include/mbgl/style/function_properties.hpp index e72ced0b02..74ac80f83c 100644 --- a/include/llmr/style/function_properties.hpp +++ b/include/mbgl/style/function_properties.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_FUNCTION_PROPERTIES -#define LLMR_STYLE_FUNCTION_PROPERTIES +#ifndef MBGL_STYLE_FUNCTION_PROPERTIES +#define MBGL_STYLE_FUNCTION_PROPERTIES -#include <llmr/util/variant.hpp> +#include <mbgl/util/variant.hpp> #include <vector> -namespace llmr { +namespace mbgl { template <typename T> struct ConstantFunction { diff --git a/include/llmr/style/property_fallback.hpp b/include/mbgl/style/property_fallback.hpp index eb6bb15c9c..5c5eae0cd6 100644 --- a/include/llmr/style/property_fallback.hpp +++ b/include/mbgl/style/property_fallback.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_STYLE_PROPERTY_FALLBACK -#define LLMR_STYLE_PROPERTY_FALLBACK +#ifndef MBGL_STYLE_PROPERTY_FALLBACK +#define MBGL_STYLE_PROPERTY_FALLBACK -#include <llmr/style/property_key.hpp> -#include <llmr/style/property_value.hpp> +#include <mbgl/style/property_key.hpp> +#include <mbgl/style/property_value.hpp> #include <map> -namespace llmr { +namespace mbgl { class PropertyFallbackValue { public: diff --git a/include/llmr/style/property_key.hpp b/include/mbgl/style/property_key.hpp index e52c33ad17..d9005f2f4a 100644 --- a/include/llmr/style/property_key.hpp +++ b/include/mbgl/style/property_key.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_STYLE_PROPERTY_KEY -#define LLMR_STYLE_PROPERTY_KEY +#ifndef MBGL_STYLE_PROPERTY_KEY +#define MBGL_STYLE_PROPERTY_KEY -namespace llmr { +namespace mbgl { enum class PropertyKey { FillAntialias, diff --git a/include/llmr/style/property_transition.hpp b/include/mbgl/style/property_transition.hpp index 0175274436..07b7cfe288 100644 --- a/include/llmr/style/property_transition.hpp +++ b/include/mbgl/style/property_transition.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_STYLE_PROPERTY_TRANSITION -#define LLMR_STYLE_PROPERTY_TRANSITION +#ifndef MBGL_STYLE_PROPERTY_TRANSITION +#define MBGL_STYLE_PROPERTY_TRANSITION #include <cstdint> -namespace llmr { +namespace mbgl { struct PropertyTransition { uint16_t duration = 0; diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp new file mode 100644 index 0000000000..4d148dc029 --- /dev/null +++ b/include/mbgl/style/property_value.hpp @@ -0,0 +1,21 @@ +#ifndef MBGL_STYLE_PROPERTY_VALUE +#define MBGL_STYLE_PROPERTY_VALUE + +#include <mbgl/util/variant.hpp> +#include <mbgl/style/function_properties.hpp> +#include <mbgl/style/types.hpp> + +namespace mbgl { + +typedef util::variant< + std::string, + TranslateAnchorType, + RotateAnchorType, + Function<bool>, + Function<float>, + Function<Color> +> PropertyValue; + +} + +#endif diff --git a/include/llmr/style/rasterize_properties.hpp b/include/mbgl/style/rasterize_properties.hpp index 440f3e530f..aea90dfbdd 100644 --- a/include/llmr/style/rasterize_properties.hpp +++ b/include/mbgl/style/rasterize_properties.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_STYLE_RASTERIZE_PROPERTIES -#define LLMR_STYLE_RASTERIZE_PROPERTIES +#ifndef MBGL_STYLE_RASTERIZE_PROPERTIES +#define MBGL_STYLE_RASTERIZE_PROPERTIES -#include <llmr/style/function_properties.hpp> +#include <mbgl/style/function_properties.hpp> -namespace llmr { +namespace mbgl { // The calculated properties for a layer in a tile. class RasterizedProperties { diff --git a/include/llmr/style/style.hpp b/include/mbgl/style/style.hpp index cf091ad814..6aab71a4c6 100644 --- a/include/llmr/style/style.hpp +++ b/include/mbgl/style/style.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE -#define LLMR_STYLE_STYLE +#ifndef MBGL_STYLE_STYLE +#define MBGL_STYLE_STYLE -#include <llmr/style/property_transition.hpp> -#include <llmr/style/style_source.hpp> +#include <mbgl/style/property_transition.hpp> +#include <mbgl/style/style_source.hpp> -#include <llmr/util/time.hpp> -#include <llmr/util/uv.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/uv.hpp> #include <cstdint> #include <map> @@ -15,7 +15,7 @@ #include <set> #include <memory> -namespace llmr { +namespace mbgl { class Sprite; class StyleLayer; diff --git a/include/llmr/style/style_bucket.hpp b/include/mbgl/style/style_bucket.hpp index 5d8c9d6bb9..62f072d9cd 100644 --- a/include/llmr/style/style_bucket.hpp +++ b/include/mbgl/style/style_bucket.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_STYLE_STYLE_BUCKET -#define LLMR_STYLE_STYLE_BUCKET +#ifndef MBGL_STYLE_STYLE_BUCKET +#define MBGL_STYLE_STYLE_BUCKET -#include <llmr/style/types.hpp> -#include <llmr/style/filter_expression.hpp> -#include <llmr/style/style_source.hpp> -#include <llmr/util/vec.hpp> -#include <llmr/util/variant.hpp> +#include <mbgl/style/types.hpp> +#include <mbgl/style/filter_expression.hpp> +#include <mbgl/style/style_source.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/util/variant.hpp> #include <memory> #include <forward_list> -namespace llmr { +namespace mbgl { class Source; diff --git a/include/llmr/style/style_layer.hpp b/include/mbgl/style/style_layer.hpp index 4d6b8d1fa8..14d60ed9b6 100644 --- a/include/llmr/style/style_layer.hpp +++ b/include/mbgl/style/style_layer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_LAYER -#define LLMR_STYLE_STYLE_LAYER +#ifndef MBGL_STYLE_STYLE_LAYER +#define MBGL_STYLE_STYLE_LAYER -#include <llmr/style/class_dictionary.hpp> -#include <llmr/style/class_properties.hpp> -#include <llmr/style/style_properties.hpp> -#include <llmr/style/rasterize_properties.hpp> -#include <llmr/style/applied_class_properties.hpp> +#include <mbgl/style/class_dictionary.hpp> +#include <mbgl/style/class_properties.hpp> +#include <mbgl/style/style_properties.hpp> +#include <mbgl/style/rasterize_properties.hpp> +#include <mbgl/style/applied_class_properties.hpp> #include <vector> #include <memory> @@ -13,7 +13,7 @@ #include <map> #include <set> -namespace llmr { +namespace mbgl { class StyleBucket; class StyleLayerGroup; diff --git a/include/llmr/style/style_layer_group.hpp b/include/mbgl/style/style_layer_group.hpp index 90c02bc1f2..983dd136f0 100644 --- a/include/llmr/style/style_layer_group.hpp +++ b/include/mbgl/style/style_layer_group.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_LAYER_GROUP -#define LLMR_STYLE_STYLE_LAYER_GROUP +#ifndef MBGL_STYLE_STYLE_LAYER_GROUP +#define MBGL_STYLE_STYLE_LAYER_GROUP -#include <llmr/style/style_layer.hpp> +#include <mbgl/style/style_layer.hpp> #include <vector> -namespace llmr { +namespace mbgl { class StyleLayerGroup { public: diff --git a/include/llmr/style/style_parser.hpp b/include/mbgl/style/style_parser.hpp index 38ef343e53..431e3af8db 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/mbgl/style/style_parser.hpp @@ -1,19 +1,19 @@ -#ifndef LLMR_STYLE_STYLE_PARSER -#define LLMR_STYLE_STYLE_PARSER +#ifndef MBGL_STYLE_STYLE_PARSER +#define MBGL_STYLE_STYLE_PARSER #include <rapidjson/document.h> -#include <llmr/style/style.hpp> -#include <llmr/style/style_source.hpp> -#include <llmr/style/filter_expression.hpp> -#include <llmr/style/class_properties.hpp> -#include <llmr/style/rasterize_properties.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/style/style_source.hpp> +#include <mbgl/style/filter_expression.hpp> +#include <mbgl/style/class_properties.hpp> +#include <mbgl/style/rasterize_properties.hpp> +#include <mbgl/style/style_bucket.hpp> #include <unordered_map> #include <forward_list> #include <tuple> -namespace llmr { +namespace mbgl { enum class ClassID : uint32_t; @@ -91,7 +91,7 @@ private: FilterExpression parseFilter(JSVal, FilterExpression::Operator op); FilterExpression parseFilter(JSVal); Value parseValue(JSVal value); - std::forward_list<Value> parseValues(JSVal values); + std::vector<Value> parseValues(JSVal values); private: std::unordered_map<std::string, const rapidjson::Value *> constants; diff --git a/include/llmr/style/style_properties.hpp b/include/mbgl/style/style_properties.hpp index bc46e2d854..c7606be254 100644 --- a/include/llmr/style/style_properties.hpp +++ b/include/mbgl/style/style_properties.hpp @@ -1,16 +1,16 @@ -#ifndef LLMR_STYLE_STYLE_PROPERTIES -#define LLMR_STYLE_STYLE_PROPERTIES +#ifndef MBGL_STYLE_STYLE_PROPERTIES +#define MBGL_STYLE_STYLE_PROPERTIES -#include <llmr/util/variant.hpp> -#include <llmr/style/types.hpp> -#include <llmr/style/function_properties.hpp> +#include <mbgl/util/variant.hpp> +#include <mbgl/style/types.hpp> +#include <mbgl/style/function_properties.hpp> #include <array> #include <string> #include <type_traits> #include <memory> -namespace llmr { +namespace mbgl { struct FillProperties { FillProperties() {} diff --git a/include/llmr/style/style_source.hpp b/include/mbgl/style/style_source.hpp index 25a8218df9..6b86c30907 100644 --- a/include/llmr/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_STYLE_STYLE_SOURCE -#define LLMR_STYLE_STYLE_SOURCE +#ifndef MBGL_STYLE_STYLE_SOURCE +#define MBGL_STYLE_STYLE_SOURCE -#include <llmr/style/types.hpp> +#include <mbgl/style/types.hpp> #include <memory> -namespace llmr { +namespace mbgl { class Source; diff --git a/include/llmr/style/types.hpp b/include/mbgl/style/types.hpp index 82632849ac..ca2061fa91 100644 --- a/include/llmr/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_STYLE_TYPES -#define LLMR_STYLE_TYPES +#ifndef MBGL_STYLE_TYPES +#define MBGL_STYLE_TYPES -#include <llmr/util/enum.hpp> +#include <mbgl/util/enum.hpp> #include <string> #include <array> -namespace llmr { +namespace mbgl { // Stores a premultiplied color, with all four channels ranging from 0..1 typedef std::array<float, 4> Color; @@ -22,7 +22,7 @@ enum class StyleLayerType : uint8_t { Background }; -LLMR_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, { +MBGL_DEFINE_ENUM_CLASS(StyleLayerTypeClass, StyleLayerType, { { StyleLayerType::Unknown, "unknown" }, { StyleLayerType::Fill, "fill" }, { StyleLayerType::Line, "line" }, diff --git a/include/mbgl/style/value.hpp b/include/mbgl/style/value.hpp new file mode 100644 index 0000000000..5e6260e5a6 --- /dev/null +++ b/include/mbgl/style/value.hpp @@ -0,0 +1,43 @@ +#ifndef MBGL_STYLE_VALUE +#define MBGL_STYLE_VALUE + +#include <mbgl/util/variant.hpp> +#include <mbgl/util/pbf.hpp> + +#include <cstdlib> +#include <cerrno> + +namespace mbgl { + +typedef util::variant<bool, int64_t, uint64_t, double, std::string> Value; + +std::string toString(const Value &value); + +Value parseValue(pbf data); + +namespace util { +inline bool parseNumericString(const std::string &str, double &result) { + char *end = nullptr; + const char *begin = str.c_str(); + result = std::strtod(begin, &end); + while (*end != '\0' && isspace(*end)) end++; // eat whitespace after the end + return errno == 0 && end - begin == long(str.size()); +} +} + +template <typename T> +T toNumber(const Value &value) { + if (value.is<std::string>()) { + double val; + return util::parseNumericString(value.get<std::string>(), val) ? val : 0; + } + else if (value.is<bool>()) return value.get<bool>(); + else if (value.is<int64_t>()) return value.get<int64_t>(); + else if (value.is<uint64_t>()) return value.get<uint64_t>(); + else if (value.is<double>()) return value.get<double>(); + else return 0; +} + +} + +#endif diff --git a/include/mbgl/style/value_comparison.hpp b/include/mbgl/style/value_comparison.hpp new file mode 100644 index 0000000000..41c1d44123 --- /dev/null +++ b/include/mbgl/style/value_comparison.hpp @@ -0,0 +1,109 @@ +#ifndef MBGL_STYLE_VALUE_COMPARISON +#define MBGL_STYLE_VALUE_COMPARISON + +#include "value.hpp" +#include <cstdlib> +#include <cerrno> + +namespace mbgl { + +namespace util { + +namespace detail { + +template <typename Operator> +struct relaxed_operator_visitor { + typedef bool result_type; + + inline bool operator()(bool lhs, bool rhs) const { return Operator()(lhs, rhs); } + + template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> + inline bool operator()(bool lhs, T rhs) const { return Operator()(T(lhs), rhs); } + + template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> + inline bool operator()(T lhs, bool rhs) const { return Operator()(lhs, T(rhs)); } + + inline bool operator()(int64_t lhs, uint64_t rhs) const { + return lhs < 0 ? false : Operator()(uint64_t(lhs), rhs); + } + inline bool operator()(uint64_t lhs, int64_t rhs) const { + return rhs < 0 ? false : Operator()(lhs, uint64_t(rhs)); + } + + template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> + inline bool operator()(const std::string &lhs, T rhs) const { + double value; + return parseNumericString(lhs, value) ? Operator()(value, double(rhs)) : false; + } + + template <typename T, class = typename std::enable_if<std::is_arithmetic<T>::value>::type> + inline bool operator()(T lhs, const std::string &rhs) const { + double value; + return parseNumericString(rhs, value) ? Operator()(double(lhs), value) : false; + } + + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return Operator()(lhs, rhs); } +}; + +struct relaxed_equal_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs == rhs; } +}; + +struct relaxed_not_equal_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs != rhs; } +}; + +struct relaxed_greater_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs > rhs; } +}; + +struct relaxed_greater_equal_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs >= rhs; } +}; + +struct relaxed_less_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs < rhs; } +}; + +struct relaxed_less_equal_operator { + template <typename T0, typename T1> + inline bool operator()(T0 lhs, T1 rhs) const { return lhs <= rhs; } +}; + +} // end namespace detail + +inline bool relaxed_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_equal_operator>(), lhs, rhs); +} + +inline bool relaxed_not_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_not_equal_operator>(), lhs, rhs); +} + +inline bool relaxed_greater(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_operator>(), lhs, rhs); +} + +inline bool relaxed_greater_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_greater_equal_operator>(), lhs, rhs); +} + +inline bool relaxed_less(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_operator>(), lhs, rhs); +} + +inline bool relaxed_less_equal(Value const &lhs, Value const &rhs) { + return apply_visitor(detail::relaxed_operator_visitor<detail::relaxed_less_equal_operator>(), lhs, rhs); +} + +} + +} + +#endif diff --git a/include/llmr/text/collision.hpp b/include/mbgl/text/collision.hpp index c9dafdd386..31103a7439 100644 --- a/include/llmr/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_TEXT_COLLISION -#define LLMR_TEXT_COLLISION +#ifndef MBGL_TEXT_COLLISION +#define MBGL_TEXT_COLLISION -#include <llmr/text/types.hpp> +#include <mbgl/text/types.hpp> -namespace llmr { +namespace mbgl { class Collision { diff --git a/include/llmr/text/glyph.hpp b/include/mbgl/text/glyph.hpp index 99c8964701..899c8fffee 100644 --- a/include/llmr/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_GLYPH -#define LLMR_TEXT_GLYPH +#ifndef MBGL_TEXT_GLYPH +#define MBGL_TEXT_GLYPH -#include <llmr/util/rect.hpp> +#include <mbgl/util/rect.hpp> #include <cstdint> #include <vector> #include <map> -namespace llmr { +namespace mbgl { typedef std::pair<uint16_t, uint16_t> GlyphRange; diff --git a/include/llmr/text/glyph_store.hpp b/include/mbgl/text/glyph_store.hpp index a1d1046b7f..9c874b31b0 100644 --- a/include/llmr/text/glyph_store.hpp +++ b/include/mbgl/text/glyph_store.hpp @@ -1,8 +1,8 @@ -#ifndef LLMR_TEXT_GLYPH_STORE -#define LLMR_TEXT_GLYPH_STORE +#ifndef MBGL_TEXT_GLYPH_STORE +#define MBGL_TEXT_GLYPH_STORE -#include <llmr/text/glyph.hpp> -#include <llmr/util/pbf.hpp> +#include <mbgl/text/glyph.hpp> +#include <mbgl/util/pbf.hpp> #include <cstdint> #include <vector> @@ -11,7 +11,7 @@ #include <set> #include <unordered_map> -namespace llmr { +namespace mbgl { class SDFGlyph { diff --git a/include/llmr/text/placement.hpp b/include/mbgl/text/placement.hpp index c245e260f0..69a1a10b72 100644 --- a/include/llmr/text/placement.hpp +++ b/include/mbgl/text/placement.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_PLACEMENT -#define LLMR_TEXT_PLACEMENT +#ifndef MBGL_TEXT_PLACEMENT +#define MBGL_TEXT_PLACEMENT -#include <llmr/text/collision.hpp> -#include <llmr/geometry/geometry.hpp> -#include <llmr/util/vec.hpp> -#include <llmr/text/glyph.hpp> +#include <mbgl/text/collision.hpp> +#include <mbgl/geometry/geometry.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/text/glyph.hpp> #include <vector> -namespace llmr { +namespace mbgl { class TextBucket; class StyleBucketText; diff --git a/include/llmr/text/rotation_range.hpp b/include/mbgl/text/rotation_range.hpp index dcdcc0143c..4968fda164 100644 --- a/include/llmr/text/rotation_range.hpp +++ b/include/mbgl/text/rotation_range.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_TEXT_ROTATION_RANGE -#define LLMR_TEXT_ROTATION_RANGE +#ifndef MBGL_TEXT_ROTATION_RANGE +#define MBGL_TEXT_ROTATION_RANGE -#include <llmr/util/math.hpp> -#include <llmr/text/types.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/text/types.hpp> #include <vector> #include <cassert> -namespace llmr { +namespace mbgl { /* * Combine an array of collision ranges to form a continuous diff --git a/include/llmr/text/types.hpp b/include/mbgl/text/types.hpp index 46a130d0e3..9a9284b588 100644 --- a/include/llmr/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_TEXT_TYPES -#define LLMR_TEXT_TYPES +#ifndef MBGL_TEXT_TYPES +#define MBGL_TEXT_TYPES -#include <llmr/util/vec.hpp> -#include <llmr/util/rect.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/util/rect.hpp> #include <array> #include <vector> -namespace llmr { +namespace mbgl { typedef vec2<float> CollisionPoint; typedef vec2<float> CollisionAnchor; diff --git a/include/llmr/util/clip_ids.hpp b/include/mbgl/util/clip_ids.hpp index 4e4d0abe34..748d3d8f5f 100644 --- a/include/llmr/util/clip_ids.hpp +++ b/include/mbgl/util/clip_ids.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_UTIL_CLIP_IDS -#define LLMR_UTIL_CLIP_IDS +#ifndef MBGL_UTIL_CLIP_IDS +#define MBGL_UTIL_CLIP_IDS -#include <llmr/map/tile.hpp> +#include <mbgl/map/tile.hpp> #include <list> #include <set> #include <map> -namespace llmr { +namespace mbgl { static constexpr uint8_t clipMask[9] { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; diff --git a/include/llmr/util/constants.hpp b/include/mbgl/util/constants.hpp index 999ef05fcc..89e8af2ef1 100644 --- a/include/llmr/util/constants.hpp +++ b/include/mbgl/util/constants.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_CONSTANTS -#define LLMR_UTIL_CONSTANTS +#ifndef MBGL_UTIL_CONSTANTS +#define MBGL_UTIL_CONSTANTS #include <cmath> #include "vec.hpp" -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/enum.hpp b/include/mbgl/util/enum.hpp index 85a2d7c896..195aaab5a5 100644 --- a/include/llmr/util/enum.hpp +++ b/include/mbgl/util/enum.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_UTIL_ENUM -#define LLMR_UTIL_ENUM +#ifndef MBGL_UTIL_ENUM +#define MBGL_UTIL_ENUM #include <iosfwd> #include <string> -namespace llmr { +namespace mbgl { template <typename Type> struct EnumValue { @@ -44,9 +44,9 @@ public: inline constexpr operator Type() const { return value; } }; -#define LLMR_DEFINE_ENUM_CLASS(name, type, strings...) \ - const constexpr ::llmr::EnumValue<type> type##_names[] = strings; \ - using name = ::llmr::Enum<type, type##_names, sizeof(type##_names) / sizeof(::llmr::EnumValue<type>)>; \ +#define MBGL_DEFINE_ENUM_CLASS(name, type, strings...) \ + const constexpr ::mbgl::EnumValue<type> type##_names[] = strings; \ + using name = ::mbgl::Enum<type, type##_names, sizeof(type##_names) / sizeof(::mbgl::EnumValue<type>)>; \ inline std::ostream& operator<<(std::ostream& os, type t) { return os << name(t).str(); } } diff --git a/include/llmr/util/error.hpp b/include/mbgl/util/error.hpp index 95106ff2cd..99e27f770c 100644 --- a/include/llmr/util/error.hpp +++ b/include/mbgl/util/error.hpp @@ -1,10 +1,10 @@ -#ifndef LLMR_UTIL_ERROR -#define LLMR_UTIL_ERROR +#ifndef MBGL_UTIL_ERROR +#define MBGL_UTIL_ERROR #include <stdexcept> #include <string> -namespace llmr { +namespace mbgl { namespace error { struct style_parse : std::exception { diff --git a/include/llmr/util/image.hpp b/include/mbgl/util/image.hpp index ac20473e82..dc8f6a8150 100644 --- a/include/llmr/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_IMAGE -#define LLMR_UTIL_IMAGE +#ifndef MBGL_UTIL_IMAGE +#define MBGL_UTIL_IMAGE #include <string> #include <cstring> #include <stdexcept> -namespace llmr { +namespace mbgl { namespace util { std::string compress_png(int width, int height, void *rgba, bool flip = false); diff --git a/include/llmr/util/io.hpp b/include/mbgl/util/io.hpp index cdad979134..e95fc16d9d 100644 --- a/include/llmr/util/io.hpp +++ b/include/mbgl/util/io.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_IO -#define LLMR_UTIL_IO +#ifndef MBGL_UTIL_IO +#define MBGL_UTIL_IO #include <string> -namespace llmr { +namespace mbgl { namespace util { void write_file(const std::string &filename, const std::string &data); diff --git a/include/llmr/util/mat4.hpp b/include/mbgl/util/mat4.hpp index a5dc83f7d1..4279113d21 100644 --- a/include/llmr/util/mat4.hpp +++ b/include/mbgl/util/mat4.hpp @@ -20,12 +20,12 @@ // // 3. This notice may not be removed or altered from any source distribution. -#ifndef LLMR_UTIL_MAT4 -#define LLMR_UTIL_MAT4 +#ifndef MBGL_UTIL_MAT4 +#define MBGL_UTIL_MAT4 #include <array> -namespace llmr { +namespace mbgl { typedef std::array<float, 16> mat4; diff --git a/include/llmr/util/math.hpp b/include/mbgl/util/math.hpp index ab8e392c48..277fdc8fc3 100644 --- a/include/llmr/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -1,12 +1,12 @@ -#ifndef LLMR_UTIL_MATH -#define LLMR_UTIL_MATH +#ifndef MBGL_UTIL_MATH +#define MBGL_UTIL_MATH #include <cmath> #include <array> #include "vec.hpp" -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/noncopyable.hpp b/include/mbgl/util/noncopyable.hpp index 7891e529e3..ada701efc6 100644 --- a/include/llmr/util/noncopyable.hpp +++ b/include/mbgl/util/noncopyable.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_UTIL_NONCOPYABLE -#define LLMR_UTIL_NONCOPYABLE +#ifndef MBGL_UTIL_NONCOPYABLE +#define MBGL_UTIL_NONCOPYABLE -namespace llmr { namespace util { +namespace mbgl { namespace util { namespace non_copyable_ { @@ -20,4 +20,4 @@ typedef non_copyable_::noncopyable noncopyable; }} -#endif //LLMR_UTIL_NONCOPYABLE +#endif diff --git a/include/llmr/util/pbf.hpp b/include/mbgl/util/pbf.hpp index 13fe8d6ee1..1f78a0072f 100644 --- a/include/llmr/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_PBF -#define LLMR_UTIL_PBF +#ifndef MBGL_UTIL_PBF +#define MBGL_UTIL_PBF /* * Some parts are from upb - a minimalist implementation of protocol buffers. @@ -11,7 +11,7 @@ #include <string> #include <cstring> -namespace llmr { +namespace mbgl { struct pbf { struct exception : std::exception { const char *what() const noexcept { return "pbf exception"; } }; @@ -179,6 +179,6 @@ void pbf::skipBytes(uint32_t bytes) { data += bytes; } -} // end namespace llmr +} // end namespace mbgl #endif diff --git a/include/llmr/util/raster.hpp b/include/mbgl/util/raster.hpp index cbc342d562..04c85169e2 100644 --- a/include/llmr/util/raster.hpp +++ b/include/mbgl/util/raster.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_RASTER -#define LLMR_UTIL_RASTER +#ifndef MBGL_UTIL_RASTER +#define MBGL_UTIL_RASTER -#include <llmr/util/transition.hpp> -#include <llmr/util/texturepool.hpp> -#include <llmr/util/image.hpp> +#include <mbgl/util/transition.hpp> +#include <mbgl/util/texturepool.hpp> +#include <mbgl/util/image.hpp> #include <string> #include <mutex> @@ -11,7 +11,7 @@ typedef struct uv_loop_s uv_loop_t; -namespace llmr { +namespace mbgl { class Raster : public std::enable_shared_from_this<Raster> { diff --git a/include/llmr/util/rect.hpp b/include/mbgl/util/rect.hpp index 2e142c3018..a216b8e145 100644 --- a/include/llmr/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -1,7 +1,7 @@ -#ifndef LLMR_UTIL_RECT -#define LLMR_UTIL_RECT +#ifndef MBGL_UTIL_RECT +#define MBGL_UTIL_RECT -namespace llmr { +namespace mbgl { template <typename T> struct Rect { diff --git a/include/llmr/util/recursive_wrapper.hpp b/include/mbgl/util/recursive_wrapper.hpp index b87dc5699a..a616805c0f 100644 --- a/include/llmr/util/recursive_wrapper.hpp +++ b/include/mbgl/util/recursive_wrapper.hpp @@ -3,7 +3,7 @@ #include <utility> -namespace llmr { namespace util { +namespace mbgl { namespace util { template <typename T> class recursive_wrapper diff --git a/include/llmr/util/std.hpp b/include/mbgl/util/std.hpp index fad3380bc4..051f89bb60 100644 --- a/include/llmr/util/std.hpp +++ b/include/mbgl/util/std.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_STD -#define LLMR_UTIL_STD +#ifndef MBGL_UTIL_STD +#define MBGL_UTIL_STD #include <memory> @@ -13,7 +13,7 @@ template<typename T, typename ...Args> } -namespace llmr { +namespace mbgl { namespace util { template <typename Container, typename ForwardIterator, typename Predicate> diff --git a/include/llmr/util/string.hpp b/include/mbgl/util/string.hpp index 50293b9f40..f17d55cec3 100644 --- a/include/llmr/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_STRING -#define LLMR_UTIL_STRING +#ifndef MBGL_UTIL_STRING +#define MBGL_UTIL_STRING #include <string> -namespace llmr { +namespace mbgl { namespace util { template<size_t max, typename... Args> diff --git a/include/llmr/util/texturepool.hpp b/include/mbgl/util/texturepool.hpp index 348d25d29a..566d8c1750 100644 --- a/include/llmr/util/texturepool.hpp +++ b/include/mbgl/util/texturepool.hpp @@ -1,13 +1,13 @@ -#ifndef LLMR_UTIL_TEXTUREPOOL -#define LLMR_UTIL_TEXTUREPOOL +#ifndef MBGL_UTIL_TEXTUREPOOL +#define MBGL_UTIL_TEXTUREPOOL -#include <llmr/util/noncopyable.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/platform/gl.hpp> #include <set> #include <mutex> -namespace llmr { +namespace mbgl { class Texturepool : private util::noncopyable { diff --git a/include/llmr/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp index c3649c60e5..497d4e3083 100644 --- a/include/llmr/util/threadpool.hpp +++ b/include/mbgl/util/threadpool.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_THREADPOOL -#define LLMR_UTIL_THREADPOOL +#ifndef MBGL_UTIL_THREADPOOL +#define MBGL_UTIL_THREADPOOL #include <pthread.h> #include <forward_list> #include <queue> -namespace llmr { +namespace mbgl { namespace util { class Threadpool { diff --git a/include/llmr/util/time.hpp b/include/mbgl/util/time.hpp index 9a27cdbe31..eacee2c982 100644 --- a/include/llmr/util/time.hpp +++ b/include/mbgl/util/time.hpp @@ -1,9 +1,9 @@ -#ifndef LLMR_UTIL_TIME -#define LLMR_UTIL_TIME +#ifndef MBGL_UTIL_TIME +#define MBGL_UTIL_TIME #include <uv.h> -namespace llmr { +namespace mbgl { typedef uint64_t timestamp; diff --git a/include/llmr/util/timer.hpp b/include/mbgl/util/timer.hpp index 5dc0cfaf3f..8171c2f5d1 100644 --- a/include/llmr/util/timer.hpp +++ b/include/mbgl/util/timer.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_TIMER -#define LLMR_UTIL_TIMER +#ifndef MBGL_UTIL_TIMER +#define MBGL_UTIL_TIMER -#include <llmr/platform/event.hpp> +#include <mbgl/platform/event.hpp> #include <string> -namespace llmr { +namespace mbgl { namespace util { #ifndef DISABLE_TIMER diff --git a/include/llmr/util/token.hpp b/include/mbgl/util/token.hpp index 6795b97d12..a794e0489c 100644 --- a/include/llmr/util/token.hpp +++ b/include/mbgl/util/token.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_TOKEN -#define LLMR_UTIL_TOKEN +#ifndef MBGL_UTIL_TOKEN +#define MBGL_UTIL_TOKEN #ifdef __linux__ #include <boost/regex.hpp> @@ -11,7 +11,7 @@ namespace regex_impl = std; #include <map> -namespace llmr { +namespace mbgl { namespace util { namespace detail { @@ -47,6 +47,6 @@ inline std::string replaceTokens(const std::string &source, const std::map<std:: } } // end namespace util -} // end namespace llmr +} // end namespace mbgl #endif diff --git a/include/llmr/util/transition.hpp b/include/mbgl/util/transition.hpp index fbf33d10f9..b12527124e 100644 --- a/include/llmr/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -1,11 +1,11 @@ -#ifndef LLMR_UTIL_TRANSITION -#define LLMR_UTIL_TRANSITION +#ifndef MBGL_UTIL_TRANSITION +#define MBGL_UTIL_TRANSITION -#include <llmr/util/noncopyable.hpp> -#include <llmr/util/time.hpp> -#include <llmr/style/types.hpp> +#include <mbgl/util/noncopyable.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/style/types.hpp> -namespace llmr { +namespace mbgl { namespace util { class transition : private noncopyable { diff --git a/include/llmr/util/unitbezier.hpp b/include/mbgl/util/unitbezier.hpp index 6acae7a3de..095e15f809 100644 --- a/include/llmr/util/unitbezier.hpp +++ b/include/mbgl/util/unitbezier.hpp @@ -23,12 +23,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LLMR_UTIL_UNITBEZIER -#define LLMR_UTIL_UNITBEZIER +#ifndef MBGL_UTIL_UNITBEZIER +#define MBGL_UTIL_UNITBEZIER #include <cmath> -namespace llmr { +namespace mbgl { namespace util { struct UnitBezier { diff --git a/include/llmr/util/utf.hpp b/include/mbgl/util/utf.hpp index fc9fb57d58..5dfc4ad2d1 100644 --- a/include/llmr/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_UTF -#define LLMR_UTIL_UTF +#ifndef MBGL_UTIL_UTF +#define MBGL_UTIL_UTF #include <memory> @@ -16,7 +16,7 @@ #include <locale> #endif -namespace llmr { +namespace mbgl { namespace util { diff --git a/include/llmr/util/uv.hpp b/include/mbgl/util/uv.hpp index 69d1e8ef98..f36da83e4d 100644 --- a/include/llmr/util/uv.hpp +++ b/include/mbgl/util/uv.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_UV -#define LLMR_UTIL_UV +#ifndef MBGL_UTIL_UV +#define MBGL_UTIL_UV #include <uv.h> #include <functional> diff --git a/include/llmr/util/variant.hpp b/include/mbgl/util/variant.hpp index 57f8593439..ddc82ee311 100644 --- a/include/llmr/util/variant.hpp +++ b/include/mbgl/util/variant.hpp @@ -35,7 +35,7 @@ // translates to 100 #define VARIANT_VERSION (VARIANT_MAJOR_VERSION*100000) + (VARIANT_MINOR_VERSION*100) + (VARIANT_PATCH_VERSION) -namespace llmr { namespace util { namespace detail { +namespace mbgl { namespace util { namespace detail { static constexpr std::size_t invalid_value = std::size_t(-1); diff --git a/include/llmr/util/vec.hpp b/include/mbgl/util/vec.hpp index 828a6a5fb2..0b9bf63d53 100644 --- a/include/llmr/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -1,5 +1,5 @@ -#ifndef LLMR_UTIL_VEC -#define LLMR_UTIL_VEC +#ifndef MBGL_UTIL_VEC +#define MBGL_UTIL_VEC #include <limits> #include <type_traits> @@ -7,7 +7,7 @@ #include <cstdint> #include <array> -namespace llmr { +namespace mbgl { template <typename T = double> struct vec2 { diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa -Subproject 9d403d2cefcd63797a3da2c67d4b653e287aeec +Subproject 6d29b1a2be6cf29e84349605a42140c038d80c8 diff --git a/linux/main.cpp b/linux/main.cpp index 11a21880f1..e603be55e4 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -1,5 +1,5 @@ -#include <llmr/llmr.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/mbgl.hpp> +#include <mbgl/platform/platform.hpp> #include <signal.h> #include <getopt.h> @@ -23,7 +23,7 @@ void quit_handler(int) { } int main(int argc, char *argv[]) { - llmr::Log::Set<llmr::StderrLogBackend>(); + mbgl::Log::Set<mbgl::StderrLogBackend>(); int fullscreen_flag = 0; @@ -55,10 +55,10 @@ int main(int argc, char *argv[]) { stylejson << stylefile.rdbuf(); view = new GLFWView(); - llmr::Map map(*view); + mbgl::Map map(*view); // Load settings - llmr::Settings_JSON settings; + mbgl::Settings_JSON settings; map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); map.setAngle(settings.angle); map.setDebug(settings.debug); @@ -66,7 +66,7 @@ int main(int argc, char *argv[]) { // Set access token if present const char *token = getenv("MAPBOX_ACCESS_TOKEN"); if (token == nullptr) { - llmr::Log::Warning(llmr::Event::Setup, "no access token set. mapbox.com tiles won't work."); + mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work."); } else { map.setAccessToken(std::string(token)); } diff --git a/linux/llmr-app.gyp b/linux/mapboxgl-app.gyp index e53a122240..1d09b5444b 100644 --- a/linux/llmr-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -52,9 +52,9 @@ }], ], 'dependencies': [ - '../llmr.gyp:llmr-x86', - '../llmr.gyp:copy_default_stylesheet', - '../llmr.gyp:copy_certificate_bundle', + '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:copy_default_stylesheet', + '../mapboxgl.gyp:copy_certificate_bundle', ], }, ], diff --git a/macosx/Info.plist b/macosx/Info.plist index 88b4c38764..366a5d8abc 100644 --- a/macosx/Info.plist +++ b/macosx/Info.plist @@ -23,7 +23,7 @@ <key>CFBundleShortVersionString</key> <string>0.0.1</string> <key>CFBundleSignature</key> - <string>LLMR</string> + <string>MBGL</string> <key>CFBundleVersion</key> <string>0.0.1</string> <key>CSResourcesFileMapped</key> diff --git a/macosx/main.mm b/macosx/main.mm index e12103f35e..da78f089c5 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -5,20 +5,20 @@ #import <Foundation/Foundation.h> int main() { - llmr::Log::Set<llmr::NSLogBackend>(); + mbgl::Log::Set<mbgl::NSLogBackend>(); GLFWView view; - llmr::Map map(view); + mbgl::Map map(view); // Load settings - llmr::Settings_NSUserDefaults settings; + mbgl::Settings_NSUserDefaults settings; map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); map.setAngle(settings.angle); map.setDebug(settings.debug); // Set access token if present NSString *accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"]; - if ( ! accessToken) llmr::Log::Warning(llmr::Event::Setup, "No access token set. Mapbox vector tiles won't work."); + if ( ! accessToken) mbgl::Log::Warning(mbgl::Event::Setup, "No access token set. Mapbox vector tiles won't work."); if (accessToken) map.setAccessToken([accessToken cStringUsingEncoding:[NSString defaultCStringEncoding]]); // Load style diff --git a/macosx/llmr-app.gyp b/macosx/mapboxgl-app.gyp index 139cb744c5..59dfc66470 100644 --- a/macosx/llmr-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -40,7 +40,7 @@ 'CLANG_ENABLE_OBJC_ARC': 'YES' }, 'dependencies': [ - '../llmr.gyp:llmr-x86' + '../mapboxgl.gyp:mapboxgl' ] } ] diff --git a/llmr.gyp b/mapboxgl.gyp index 2e17c2c6a4..9930cd3fbd 100644 --- a/llmr.gyp +++ b/mapboxgl.gyp @@ -18,7 +18,7 @@ '<!@(find src -name "*.glsl")' ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/include/llmr/shader/shaders.hpp', + '<(SHARED_INTERMEDIATE_DIR)/include/mbgl/shader/shaders.hpp', '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gl.cpp', '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gles2.cpp', ], @@ -27,7 +27,7 @@ ], 'direct_dependent_settings': { 'sources': [ - '<(SHARED_INTERMEDIATE_DIR)/include/llmr/shader/shaders.hpp', + '<(SHARED_INTERMEDIATE_DIR)/include/mbgl/shader/shaders.hpp', '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gl.cpp', '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gles2.cpp' ], @@ -115,8 +115,8 @@ ] }, { - 'target_name': 'llmr-x86', - 'product_name': 'llmr-x86', + 'target_name': 'mapboxgl', + 'product_name': 'mapboxgl', 'type': 'static_library', 'hard_dependency': 1, 'dependencies': [ @@ -183,8 +183,8 @@ } }, { - 'target_name': 'llmr-ios', - 'product_name': 'llmr-ios', + 'target_name': 'mapboxgl-ios', + 'product_name': 'mapboxgl-ios', 'type': 'static_library', 'hard_dependency': 1, 'dependencies': [ diff --git a/proto/glyphs.proto b/proto/glyphs.proto index 606050f7af..6930b47a2b 100644 --- a/proto/glyphs.proto +++ b/proto/glyphs.proto @@ -1,6 +1,6 @@ // Protocol Version 1 -package llmr.glyphs; +package mapboxgl.glyphs; option optimize_for = LITE_RUNTIME; diff --git a/proto/vector_tile.proto b/proto/vector_tile.proto index ea482adb26..1cde2c7aa9 100644 --- a/proto/vector_tile.proto +++ b/proto/vector_tile.proto @@ -1,6 +1,6 @@ // Protocol Version 1 -package llmr.vector; +package mapboxgl.vector; option optimize_for = LITE_RUNTIME; diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp index 9febbc518d..387a646299 100644 --- a/src/geometry/debug_font_buffer.cpp +++ b/src/geometry/debug_font_buffer.cpp @@ -1,11 +1,11 @@ -#include <llmr/geometry/debug_font_buffer.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/geometry/debug_font_buffer.hpp> +#include <mbgl/platform/gl.hpp> #include <cmath> #include <cstring> #include "debug_font.cpp" -using namespace llmr; +using namespace mbgl; void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { uint16_t *coords = nullptr; diff --git a/src/geometry/elements_buffer.cpp b/src/geometry/elements_buffer.cpp index 71a3a12b1a..79af1b7e35 100644 --- a/src/geometry/elements_buffer.cpp +++ b/src/geometry/elements_buffer.cpp @@ -1,6 +1,6 @@ -#include <llmr/geometry/elements_buffer.hpp> +#include <mbgl/geometry/elements_buffer.hpp> -using namespace llmr; +using namespace mbgl; void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) { element_type *elements = static_cast<element_type *>(addElement()); diff --git a/src/geometry/fill_buffer.cpp b/src/geometry/fill_buffer.cpp index 61aee76c53..c75ad3477d 100644 --- a/src/geometry/fill_buffer.cpp +++ b/src/geometry/fill_buffer.cpp @@ -1,9 +1,9 @@ -#include <llmr/geometry/fill_buffer.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/geometry/fill_buffer.hpp> +#include <mbgl/platform/gl.hpp> #include <climits> -using namespace llmr; +using namespace mbgl; void FillVertexBuffer::add(vertex_type x, vertex_type y) { vertex_type *vertices = static_cast<vertex_type *>(addElement()); diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index afb9044073..76df941d90 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -1,13 +1,13 @@ -#include <llmr/geometry/glyph_atlas.hpp> -#include <llmr/map/vector_tile.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/geometry/glyph_atlas.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/platform/platform.hpp> #include <cassert> #include <algorithm> -using namespace llmr; +using namespace mbgl; GlyphAtlas::GlyphAtlas(uint16_t width, uint16_t height) : width(width), diff --git a/src/geometry/icon_buffer.cpp b/src/geometry/icon_buffer.cpp index 22a47ff093..a25b2de068 100644 --- a/src/geometry/icon_buffer.cpp +++ b/src/geometry/icon_buffer.cpp @@ -1,9 +1,9 @@ -#include <llmr/geometry/icon_buffer.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/geometry/icon_buffer.hpp> +#include <mbgl/platform/gl.hpp> #include <cmath> -using namespace llmr; +using namespace mbgl; void IconVertexBuffer::add(vertex_type x, vertex_type y, uint16_t tx, uint16_t ty) { void *data = addElement(); diff --git a/src/geometry/interpolate.cpp b/src/geometry/interpolate.cpp index cb4165cf2b..d9cfdfa1db 100644 --- a/src/geometry/interpolate.cpp +++ b/src/geometry/interpolate.cpp @@ -1,6 +1,6 @@ -#include <llmr/geometry/interpolate.hpp> +#include <mbgl/geometry/interpolate.hpp> -namespace llmr { +namespace mbgl { Anchors interpolate(const std::vector<Coordinate> &vertices, float spacing, float minScale, int start) { diff --git a/src/geometry/line_buffer.cpp b/src/geometry/line_buffer.cpp index a80ded5fbe..50a6e66b93 100644 --- a/src/geometry/line_buffer.cpp +++ b/src/geometry/line_buffer.cpp @@ -1,9 +1,9 @@ -#include <llmr/geometry/line_buffer.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/geometry/line_buffer.hpp> +#include <mbgl/platform/gl.hpp> #include <cmath> -using namespace llmr; +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(); diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 8a055e5a68..8fa3e83888 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -1,18 +1,18 @@ -#include <llmr/geometry/sprite_atlas.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/platform/platform.hpp> -#include <llmr/util/math.hpp> -#include <llmr/util/std.hpp> -#include <llmr/util/constants.hpp> +#include <mbgl/geometry/sprite_atlas.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/util/constants.hpp> -#include <llmr/map/sprite.hpp> +#include <mbgl/map/sprite.hpp> #include <cassert> #include <cmath> #include <algorithm> -using namespace llmr; +using namespace mbgl; SpriteAtlas::SpriteAtlas(dimension width, dimension height) : width(width), @@ -128,9 +128,7 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(size_t width, size_t hei Rect<SpriteAtlas::dimension> SpriteAtlas::getIcon(const int size, const std::string &name) { std::lock_guard<std::mutex> lock(mtx); - const std::string id = name + "-" + std::to_string(size); - - auto rect_it = images.find(id); + auto rect_it = images.find(name); if (rect_it != images.end()) { return rect_it->second; } @@ -143,7 +141,7 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getIcon(const int size, const std::str return rect; } - images.emplace(id, rect); + images.emplace(name, rect); allocate(); @@ -158,7 +156,7 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getIcon(const int size, const std::str 1.0f / size / pixelRatio ); - uninitialized.emplace(id); + uninitialized.emplace(name); dirty = true; @@ -251,11 +249,13 @@ void SpriteAtlas::update(const Sprite &sprite) { } void SpriteAtlas::bind(bool linear) { + bool first = false; if (!texture) { glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); 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); } @@ -270,20 +270,34 @@ void SpriteAtlas::bind(bool linear) { if (dirty) { std::lock_guard<std::mutex> lock(mtx); allocate(); - 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 - ); + + 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 + ); + } #if defined(DEBUG) - // platform::show_color_debug_image("Sprite Atlas", data, width, height, width * pixelRatio, height * pixelRatio); + // platform::show_color_debug_image("Sprite Atlas", reinterpret_cast<char *>(data), width, height, width * pixelRatio, height * pixelRatio); #endif dirty = false; } @@ -291,6 +305,10 @@ void SpriteAtlas::bind(bool linear) { SpriteAtlas::~SpriteAtlas() { std::lock_guard<std::mutex> lock(mtx); + + glDeleteTextures(1, &texture); + texture = 0; + if (data) { free(data); data = nullptr; diff --git a/src/geometry/text_buffer.cpp b/src/geometry/text_buffer.cpp index d3529c5604..cb30101839 100644 --- a/src/geometry/text_buffer.cpp +++ b/src/geometry/text_buffer.cpp @@ -1,10 +1,10 @@ -#include <llmr/geometry/text_buffer.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/util/math.hpp> +#include <mbgl/geometry/text_buffer.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/math.hpp> #include <cmath> -using namespace llmr; +using namespace mbgl; const double TextVertexBuffer::angleFactor = 128.0 / M_PI; diff --git a/src/geometry/vertex_buffer.cpp b/src/geometry/vertex_buffer.cpp index 0ce21fd51c..56072e161d 100644 --- a/src/geometry/vertex_buffer.cpp +++ b/src/geometry/vertex_buffer.cpp @@ -1,7 +1,7 @@ -#include <llmr/geometry/vertex_buffer.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/geometry/vertex_buffer.hpp> +#include <mbgl/platform/gl.hpp> -using namespace llmr; +using namespace mbgl; VertexBuffer::VertexBuffer(std::initializer_list<int16_t> init) : array(init) {} diff --git a/src/map/map.cpp b/src/map/map.cpp index 68db663709..c7039cc927 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1,28 +1,28 @@ -#include <llmr/map/map.hpp> -#include <llmr/map/source.hpp> -#include <llmr/platform/platform.hpp> -#include <llmr/map/sprite.hpp> -#include <llmr/util/transition.hpp> -#include <llmr/util/time.hpp> -#include <llmr/util/math.hpp> -#include <llmr/util/clip_ids.hpp> -#include <llmr/util/string.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/uv.hpp> -#include <llmr/util/std.hpp> -#include <llmr/style/style_layer_group.hpp> -#include <llmr/style/style_bucket.hpp> -#include <llmr/geometry/sprite_atlas.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/source.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/map/sprite.hpp> +#include <mbgl/util/transition.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/util/clip_ids.hpp> +#include <mbgl/util/string.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/uv.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/style/style_layer_group.hpp> +#include <mbgl/style/style_bucket.hpp> +#include <mbgl/geometry/sprite_atlas.hpp> #include <algorithm> #include <memory> #include <iostream> -using namespace llmr; +using namespace mbgl; Map::Map(View& view) : view(view), - transform(), + transform(view), style(std::make_shared<Style>()), glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)), spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)), @@ -97,6 +97,7 @@ void Map::run() { // If the map rendering wasn't started asynchronously, we perform one render // *after* all events have been processed. if (!async) { + prepare(); render(); } } diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index 7892458f91..ef6bea7e62 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -1,8 +1,8 @@ -#include <llmr/map/map.hpp> -#include <llmr/map/raster_tile_data.hpp> -#include <llmr/style/style.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/raster_tile_data.hpp> +#include <mbgl/style/style.hpp> -using namespace llmr; +using namespace mbgl; RasterTileData::RasterTileData(Tile::ID id, Map &map, const std::string url) diff --git a/src/map/source.cpp b/src/map/source.cpp index 55a2bea4e1..e46bb0abd8 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -1,22 +1,22 @@ -#include <llmr/map/source.hpp> -#include <llmr/map/map.hpp> -#include <llmr/map/transform.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/raster.hpp> -#include <llmr/util/string.hpp> -#include <llmr/util/texturepool.hpp> -#include <llmr/util/vec.hpp> -#include <llmr/util/token.hpp> -#include <llmr/util/std.hpp> -#include <llmr/geometry/glyph_atlas.hpp> -#include <llmr/style/style_layer.hpp> - - -#include <llmr/map/vector_tile_data.hpp> -#include <llmr/map/raster_tile_data.hpp> - -namespace llmr { +#include <mbgl/map/source.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/transform.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/raster.hpp> +#include <mbgl/util/string.hpp> +#include <mbgl/util/texturepool.hpp> +#include <mbgl/util/vec.hpp> +#include <mbgl/util/token.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/geometry/glyph_atlas.hpp> +#include <mbgl/style/style_layer.hpp> + + +#include <mbgl/map/vector_tile_data.hpp> +#include <mbgl/map/raster_tile_data.hpp> + +namespace mbgl { Source::Source(StyleSource style_source, const std::string &access_token) : type(style_source.type), @@ -330,7 +330,7 @@ struct edge { typedef const std::function<void(int32_t, int32_t, int32_t, int32_t)> ScanLine; // scan-line conversion -edge _edge(const llmr::vec2<double> a, const llmr::vec2<double> b) { +edge _edge(const mbgl::vec2<double> a, const mbgl::vec2<double> b) { if (a.y > b.y) { return { b.x, b.y, a.x, a.y, a.x - b.x, a.y - b.y }; } else { @@ -363,7 +363,7 @@ void _scanSpans(edge e0, edge e1, int32_t ymin, int32_t ymax, ScanLine scanLine) } // scan-line conversion -void _scanTriangle(const llmr::vec2<double> a, const llmr::vec2<double> b, const llmr::vec2<double> c, int32_t ymin, int32_t ymax, ScanLine& scanLine) { +void _scanTriangle(const mbgl::vec2<double> a, const mbgl::vec2<double> b, const mbgl::vec2<double> c, int32_t ymin, int32_t ymax, ScanLine& scanLine) { edge ab = _edge(a, b); edge bc = _edge(b, c); edge ca = _edge(c, a); @@ -384,9 +384,9 @@ double Source::getZoom(const TransformState &state) const { return state.getZoom() + offset; } -std::forward_list<llmr::Tile::ID> Source::covering_tiles(const TransformState &state, int32_t clamped_zoom, const box& points) { +std::forward_list<mbgl::Tile::ID> Source::covering_tiles(const TransformState &state, int32_t clamped_zoom, const box& points) { int32_t dim = std::pow(2, clamped_zoom); - std::forward_list<llmr::Tile::ID> tiles; + std::forward_list<mbgl::Tile::ID> tiles; bool is_raster = (type == SourceType::Raster); double search_zoom = getZoom(state); diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index 4b23b120c6..fd8a4ec7b5 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -1,15 +1,16 @@ -#include <llmr/map/sprite.hpp> -#include <llmr/map/map.hpp> -#include <llmr/util/raster.hpp> +#include <mbgl/map/sprite.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/util/raster.hpp> +#include <mbgl/platform/log.hpp> #include <string> -#include <llmr/platform/platform.hpp> -#include <llmr/util/uv.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/util/uv.hpp> +#include <mbgl/util/std.hpp> #include <rapidjson/document.h> -using namespace llmr; +using namespace mbgl; SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t pixelRatio) : x(x), @@ -27,6 +28,8 @@ Sprite::Sprite(Map &map, float pixelRatio) } void Sprite::load(const std::string& base_url) { + loaded = false; + url = base_url; std::shared_ptr<Sprite> sprite = shared_from_this(); std::string suffix = (pixelRatio > 1 ? "@2x" : ""); @@ -53,12 +56,12 @@ void Sprite::load(const std::string& base_url) { } void Sprite::complete(std::shared_ptr<Sprite> &sprite) { - if (sprite->raster && sprite->pos.size()) { + const bool raster = bool(sprite->raster); + const bool json = bool(sprite->pos.size()); + if (raster && json && !sprite->loaded) { sprite->loaded = true; sprite->map.update(); -#if defined(DEBUG) - fprintf(stderr, "sprite loaded\n"); -#endif + Log::Info(Event::Sprite, "loaded %s", sprite->url.c_str()); } } diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 45fe88ee29..e073960116 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -1,8 +1,8 @@ -#include <llmr/map/tile.hpp> +#include <mbgl/map/tile.hpp> #include <cassert> -using namespace llmr; +using namespace mbgl; #include <iostream> diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 4b926f435e..82f8fdedfc 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -1,9 +1,9 @@ -#include <llmr/map/tile_data.hpp> -#include <llmr/map/map.hpp> +#include <mbgl/map/tile_data.hpp> +#include <mbgl/map/map.hpp> -#include <llmr/util/string.hpp> +#include <mbgl/util/string.hpp> -using namespace llmr; +using namespace mbgl; TileData::TileData(Tile::ID id, Map &map, const std::string url) : id(id), diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 2208094cf8..8af61c6aab 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -1,23 +1,23 @@ -#include <llmr/map/tile_parser.hpp> - -#include <llmr/map/vector_tile_data.hpp> -#include <llmr/style/style.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/style/style_layer_group.hpp> -#include <llmr/renderer/fill_bucket.hpp> -#include <llmr/renderer/line_bucket.hpp> -#include <llmr/renderer/icon_bucket.hpp> -#include <llmr/renderer/text_bucket.hpp> -#include <llmr/renderer/raster_bucket.hpp> -#include <llmr/util/raster.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/token.hpp> -#include <llmr/geometry/glyph_atlas.hpp> -#include <llmr/text/glyph_store.hpp> -#include <llmr/text/glyph.hpp> - -#include <llmr/util/std.hpp> -#include <llmr/util/utf.hpp> +#include <mbgl/map/tile_parser.hpp> + +#include <mbgl/map/vector_tile_data.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/style/style_layer_group.hpp> +#include <mbgl/renderer/fill_bucket.hpp> +#include <mbgl/renderer/line_bucket.hpp> +#include <mbgl/renderer/icon_bucket.hpp> +#include <mbgl/renderer/text_bucket.hpp> +#include <mbgl/renderer/raster_bucket.hpp> +#include <mbgl/util/raster.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/token.hpp> +#include <mbgl/geometry/glyph_atlas.hpp> +#include <mbgl/text/glyph_store.hpp> +#include <mbgl/text/glyph.hpp> + +#include <mbgl/util/std.hpp> +#include <mbgl/util/utf.hpp> #include <locale> @@ -29,7 +29,7 @@ namespace regex_impl = boost; namespace regex_impl = std; #endif -using namespace llmr; +using namespace mbgl; TileParser::TileParser(const std::string &data, VectorTileData &tile, const std::shared_ptr<const Style> &style, diff --git a/src/map/transform.cpp b/src/map/transform.cpp index eb9aef69ec..ccf92f974b 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -1,20 +1,22 @@ -#include <llmr/map/transform.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/mat4.hpp> -#include <llmr/util/std.hpp> -#include <llmr/util/math.hpp> -#include <llmr/util/time.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/map/transform.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/mat4.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/platform/platform.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; const double D2R = M_PI / 180.0; const double R2D = 180.0 / M_PI; const double M2PI = 2 * M_PI; const double MIN_ROTATE_SCALE = 8; -Transform::Transform() { +Transform::Transform(View &view) + : view(view) { + setScale(current.scale); setAngle(current.angle); } @@ -28,7 +30,7 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, if (final.width != w || final.height != h || final.pixelRatio != ratio || final.framebuffer[0] != fb_w || final.framebuffer[1] != fb_h) { - platform::notify_map_change(platform::MapChangeRegionWillChange); + view.notify_map_change(MapChangeRegionWillChange); current.width = final.width = w; current.height = final.height = h; @@ -38,7 +40,7 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, if (!canRotate() && current.angle) _setAngle(0); constrain(current.scale, current.y); - platform::notify_map_change(platform::MapChangeRegionDidChange); + view.notify_map_change(MapChangeRegionDidChange); return true; } else { @@ -57,9 +59,9 @@ void Transform::moveBy(const double dx, const double dy, const timestamp duratio void Transform::_moveBy(const double dx, const double dy, const timestamp duration) { // This is only called internally, so we don't need a lock here. - platform::notify_map_change(duration ? - platform::MapChangeRegionWillChangeAnimated : - platform::MapChangeRegionWillChange); + view.notify_map_change(duration ? + MapChangeRegionWillChangeAnimated : + MapChangeRegionWillChange); final.x = current.x + std::cos(current.angle) * dx + std::sin(current.angle) * dy; final.y = current.y + std::cos(current.angle) * dy + std::sin(-current.angle) * dx; @@ -84,9 +86,10 @@ void Transform::_moveBy(const double dx, const double dy, const timestamp durati std::make_shared<util::ease_transition<double>>(current.y, final.y, current.y, start, duration)); } - platform::notify_map_change(duration ? - platform::MapChangeRegionDidChangeAnimated : - platform::MapChangeRegionDidChange); + view.notify_map_change(duration ? + MapChangeRegionDidChangeAnimated : + MapChangeRegionDidChange, + duration); } void Transform::setLonLat(const double lon, const double lat, const timestamp duration) { @@ -275,9 +278,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl const timestamp duration) { // This is only called internally, so we don't need a lock here. - platform::notify_map_change(duration ? - platform::MapChangeRegionWillChangeAnimated : - platform::MapChangeRegionWillChange); + view.notify_map_change(duration ? + MapChangeRegionWillChangeAnimated : + MapChangeRegionWillChange); final.scale = new_scale; final.x = xn; @@ -308,9 +311,10 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl Bc = s / 360; Cc = s / (2 * M_PI); - platform::notify_map_change(duration ? - platform::MapChangeRegionDidChangeAnimated : - platform::MapChangeRegionDidChange); + view.notify_map_change(duration ? + MapChangeRegionDidChangeAnimated : + MapChangeRegionDidChange, + duration); } #pragma mark - Constraints @@ -386,9 +390,9 @@ void Transform::setAngle(const double new_angle, const double cx, const double c void Transform::_setAngle(double new_angle, const timestamp duration) { // This is only called internally, so we don't need a lock here. - platform::notify_map_change(duration ? - platform::MapChangeRegionWillChangeAnimated : - platform::MapChangeRegionWillChange); + view.notify_map_change(duration ? + MapChangeRegionWillChangeAnimated : + MapChangeRegionWillChange); while (new_angle > M_PI) new_angle -= M2PI; @@ -408,9 +412,10 @@ void Transform::_setAngle(double new_angle, const timestamp duration) { current.angle, final.angle, current.angle, start, duration)); } - platform::notify_map_change(duration ? - platform::MapChangeRegionDidChangeAnimated : - platform::MapChangeRegionDidChange); + view.notify_map_change(duration ? + MapChangeRegionDidChangeAnimated : + MapChangeRegionDidChange, + duration); } double Transform::getAngle() const { diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index 2bc8e71a47..d103897375 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -1,7 +1,7 @@ -#include <llmr/map/transform_state.hpp> -#include <llmr/util/constants.hpp> +#include <mbgl/map/transform_state.hpp> +#include <mbgl/util/constants.hpp> -using namespace llmr; +using namespace mbgl; #pragma mark - Matrix diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index a32db7fb35..8644c3e044 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -1,12 +1,14 @@ -#include <llmr/map/vector_tile.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/style/filter_expression_private.hpp> +#include <mbgl/style/filter_comparison_private.hpp> #include <algorithm> #include <iostream> -using namespace llmr; +using namespace mbgl; -std::ostream& llmr::operator<<(std::ostream& os, const FeatureType& type) { +std::ostream& mbgl::operator<<(std::ostream& os, const FeatureType& type) { switch (type) { case FeatureType::Unknown: return os << "Unknown"; case FeatureType::Point: return os << "Point"; @@ -52,7 +54,7 @@ VectorTileFeature::VectorTileFeature(pbf feature, const VectorTileLayer& layer) } -std::ostream& llmr::operator<<(std::ostream& os, const VectorTileFeature& feature) { +std::ostream& mbgl::operator<<(std::ostream& os, const VectorTileFeature& feature) { os << "Feature(" << feature.id << "): " << feature.type << std::endl; for (const auto& prop : feature.properties) { os << " - " << prop.first << ": " << prop.second << std::endl; @@ -203,12 +205,11 @@ void VectorTileTagExtractor::setTags(const pbf &pbf) { tags_ = pbf; } -std::forward_list<Value> VectorTileTagExtractor::getValues(const std::string &key) const { - std::forward_list<Value> values; +std::vector<Value> VectorTileTagExtractor::getValues(const std::string &key) const { + std::vector<Value> values; auto field_it = layer_.key_index.find(key); if (field_it != layer_.key_index.end()) { - auto it = values.before_begin(); const uint32_t filter_key = field_it->second; // Now loop through all the key/value pair tags. @@ -227,7 +228,7 @@ std::forward_list<Value> VectorTileTagExtractor::getValues(const std::string &ke if (tag_key == filter_key) { if (layer_.values.size() > tag_val) { - it = values.emplace_after(it, layer_.values[tag_val]); + values.emplace_back(layer_.values[tag_val]); } else { fprintf(stderr, "[WARNING] feature references out of range value\n"); break; diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 051ebb7eac..7d0e0fb5a8 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -1,10 +1,10 @@ -#include <llmr/map/vector_tile_data.hpp> -#include <llmr/util/std.hpp> -#include <llmr/map/map.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/style/style_bucket.hpp> +#include <mbgl/map/vector_tile_data.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/style/style_bucket.hpp> -using namespace llmr; +using namespace mbgl; VectorTileData::VectorTileData(Tile::ID id, Map &map, const std::string url) : TileData(id, map, url) { diff --git a/src/platform/gl.cpp b/src/platform/gl.cpp index 90a8861415..a1bf0ffc6c 100644 --- a/src/platform/gl.cpp +++ b/src/platform/gl.cpp @@ -1,4 +1,4 @@ -#include <llmr/platform/gl.hpp> +#include <mbgl/platform/gl.hpp> #include <iostream> diff --git a/src/platform/log.cpp b/src/platform/log.cpp index 7974e5ed86..b83c7a9322 100644 --- a/src/platform/log.cpp +++ b/src/platform/log.cpp @@ -1,6 +1,6 @@ -#include <llmr/platform/log.hpp> +#include <mbgl/platform/log.hpp> -namespace llmr { +namespace mbgl { std::unique_ptr<LogBackend> Log::Backend; diff --git a/src/platform/request.cpp b/src/platform/request.cpp index 5ec08197b0..9382892a91 100644 --- a/src/platform/request.cpp +++ b/src/platform/request.cpp @@ -1,9 +1,9 @@ -#include <llmr/platform/request.hpp> -#include <llmr/platform/platform.hpp> -#include <llmr/util/std.hpp> -#include <llmr/util/uv.hpp> +#include <mbgl/platform/request.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/util/uv.hpp> -using namespace llmr::platform; +using namespace mbgl::platform; Request::Request(const std::string &url, std::function<void(Response *)> callback, diff --git a/src/renderer/debug_bucket.cpp b/src/renderer/debug_bucket.cpp index 12e6cf5b5a..c9a68e2efb 100644 --- a/src/renderer/debug_bucket.cpp +++ b/src/renderer/debug_bucket.cpp @@ -1,14 +1,14 @@ -#include <llmr/renderer/debug_bucket.hpp> +#include <mbgl/renderer/debug_bucket.hpp> -#include <llmr/renderer/painter.hpp> +#include <mbgl/renderer/painter.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/platform/gl.hpp> #include <cassert> struct geometry_too_long_exception : std::exception {}; -using namespace llmr; +using namespace mbgl; DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer) : fontBuffer(fontBuffer) { diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index c6c69ed565..17aa2bccfc 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -1,20 +1,20 @@ -#include <llmr/renderer/fill_bucket.hpp> -#include <llmr/geometry/fill_buffer.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/geometry.hpp> +#include <mbgl/renderer/fill_bucket.hpp> +#include <mbgl/geometry/fill_buffer.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/geometry.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style.hpp> -#include <llmr/map/vector_tile.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/map/vector_tile.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/platform/gl.hpp> #include <cassert> struct geometry_too_long_exception : std::exception {}; -using namespace llmr; +using namespace mbgl; diff --git a/src/renderer/frame_history.cpp b/src/renderer/frame_history.cpp index e0f40df86a..6a11f0d4c6 100644 --- a/src/renderer/frame_history.cpp +++ b/src/renderer/frame_history.cpp @@ -1,6 +1,6 @@ -#include <llmr/renderer/frame_history.hpp> +#include <mbgl/renderer/frame_history.hpp> -using namespace llmr; +using namespace mbgl; // Record frame history that will be used to calculate fading params void FrameHistory::record(timestamp now, float zoom) { diff --git a/src/renderer/icon_bucket.cpp b/src/renderer/icon_bucket.cpp index 646634a450..af988fee80 100644 --- a/src/renderer/icon_bucket.cpp +++ b/src/renderer/icon_bucket.cpp @@ -1,23 +1,23 @@ -#include <llmr/renderer/icon_bucket.hpp> -#include <llmr/geometry/icon_buffer.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/geometry.hpp> -#include <llmr/geometry/sprite_atlas.hpp> +#include <mbgl/renderer/icon_bucket.hpp> +#include <mbgl/geometry/icon_buffer.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/geometry.hpp> +#include <mbgl/geometry/sprite_atlas.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style.hpp> -#include <llmr/map/sprite.hpp> -#include <llmr/map/vector_tile.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/map/sprite.hpp> +#include <mbgl/map/vector_tile.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/token.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/token.hpp> #include <cassert> struct geometry_too_long_exception : std::exception {}; -using namespace llmr; +using namespace mbgl; IconBucket::IconBucket(IconVertexBuffer& vertexBuffer, const StyleBucketIcon& properties) diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 143a67c1c4..44fe784b1a 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -1,13 +1,13 @@ -#include <llmr/renderer/line_bucket.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/geometry.hpp> +#include <mbgl/renderer/line_bucket.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/geometry.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style.hpp> -#include <llmr/map/vector_tile.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/map/vector_tile.hpp> -#include <llmr/util/math.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/platform/gl.hpp> #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) @@ -15,7 +15,7 @@ struct geometry_too_long_exception : std::exception {}; -using namespace llmr; +using namespace mbgl; LineBucket::LineBucket(LineVertexBuffer& vertexBuffer, TriangleElementsBuffer& triangleElementsBuffer, diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 253cb7eeb8..a323b0582a 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -1,19 +1,19 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/map/map.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/util/std.hpp> -#include <llmr/util/string.hpp> -#include <llmr/util/time.hpp> -#include <llmr/util/clip_ids.hpp> -#include <llmr/util/constants.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/util/string.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/clip_ids.hpp> +#include <mbgl/util/constants.hpp> #if defined(DEBUG) -#include <llmr/util/timer.hpp> +#include <mbgl/util/timer.hpp> #endif #include <cassert> #include <algorithm> -using namespace llmr; +using namespace mbgl; #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) diff --git a/src/renderer/painter_clipping.cpp b/src/renderer/painter_clipping.cpp index 25fe0658fc..95e97eadc9 100644 --- a/src/renderer/painter_clipping.cpp +++ b/src/renderer/painter_clipping.cpp @@ -1,10 +1,10 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/fill_bucket.hpp> -#include <llmr/map/map.hpp> -#include <llmr/map/source.hpp> -#include <llmr/util/clip_ids.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/fill_bucket.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/source.hpp> +#include <mbgl/util/clip_ids.hpp> -using namespace llmr; +using namespace mbgl; void Painter::drawClippingMasks(const std::set<std::shared_ptr<StyleSource>> &sources) { gl::group group("clipping masks"); diff --git a/src/renderer/painter_composite.cpp b/src/renderer/painter_composite.cpp index 4ed5076676..42d0ad5592 100644 --- a/src/renderer/painter_composite.cpp +++ b/src/renderer/painter_composite.cpp @@ -1,9 +1,9 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style_properties.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style_properties.hpp> #include <iostream> -using namespace llmr; +using namespace mbgl; void Painter::drawComposite(GLuint texture, const CompositeProperties &properties) { // We're doing full-screen framebuffer blending, so no need to do stencil testing here. diff --git a/src/renderer/painter_debug.cpp b/src/renderer/painter_debug.cpp index eb26b0b263..d79493e61e 100644 --- a/src/renderer/painter_debug.cpp +++ b/src/renderer/painter_debug.cpp @@ -1,9 +1,9 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/debug_bucket.hpp> -#include <llmr/map/map.hpp> -#include <llmr/util/string.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/debug_bucket.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/util/string.hpp> -using namespace llmr; +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)); diff --git a/src/renderer/painter_fill.cpp b/src/renderer/painter_fill.cpp index f92921d0c2..f78f006df0 100644 --- a/src/renderer/painter_fill.cpp +++ b/src/renderer/painter_fill.cpp @@ -1,12 +1,12 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/fill_bucket.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/map/map.hpp> -#include <llmr/map/sprite.hpp> -#include <llmr/geometry/sprite_atlas.hpp> -#include <llmr/util/std.hpp> - -using namespace llmr; +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/fill_bucket.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/sprite.hpp> +#include <mbgl/geometry/sprite_atlas.hpp> +#include <mbgl/util/std.hpp> + +using namespace mbgl; diff --git a/src/renderer/painter_framebuffers.cpp b/src/renderer/painter_framebuffers.cpp index 36c97ed15c..83ad189877 100644 --- a/src/renderer/painter_framebuffers.cpp +++ b/src/renderer/painter_framebuffers.cpp @@ -1,9 +1,9 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/fill_bucket.hpp> -#include <llmr/map/map.hpp> -#include <llmr/util/clip_ids.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/fill_bucket.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/util/clip_ids.hpp> -using namespace llmr; +using namespace mbgl; void Painter::clearFramebuffers() { diff --git a/src/renderer/painter_icon.cpp b/src/renderer/painter_icon.cpp index 499b124fb8..158030df19 100644 --- a/src/renderer/painter_icon.cpp +++ b/src/renderer/painter_icon.cpp @@ -1,12 +1,12 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/icon_bucket.hpp> -#include <llmr/map/map.hpp> -#include <llmr/map/sprite.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/geometry/sprite_atlas.hpp> -#include <llmr/util/math.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/icon_bucket.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/map/sprite.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/geometry/sprite_atlas.hpp> +#include <mbgl/util/math.hpp> -using namespace llmr; +using namespace mbgl; void Painter::renderIcon(IconBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) { // Abort early. @@ -23,7 +23,7 @@ void Painter::renderIcon(IconBucket& bucket, std::shared_ptr<StyleLayer> layer_d useProgram(iconShader->program); iconShader->setMatrix(matrix); // TODO: update -// iconShader->setColor(color); + iconShader->setColor({{ 1, 1, 1, 1 }}); iconShader->setImage(0); iconShader->setRatio(map.getState().getPixelRatio()); iconShader->setDimension({{ diff --git a/src/renderer/painter_line.cpp b/src/renderer/painter_line.cpp index a5ed68cc0f..00b3a48474 100644 --- a/src/renderer/painter_line.cpp +++ b/src/renderer/painter_line.cpp @@ -1,9 +1,9 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/line_bucket.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/map/map.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/line_bucket.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/map/map.hpp> -using namespace llmr; +using namespace mbgl; void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) { // Abort early. diff --git a/src/renderer/painter_prerender.cpp b/src/renderer/painter_prerender.cpp index 76fbc74cd7..ea461ca5d2 100644 --- a/src/renderer/painter_prerender.cpp +++ b/src/renderer/painter_prerender.cpp @@ -1,7 +1,7 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style_properties.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style_properties.hpp> -using namespace llmr; +using namespace mbgl; void Painter::preparePrerender(PrerenderedTexture &texture) { glDisable(GL_DEPTH_TEST); diff --git a/src/renderer/painter_raster.cpp b/src/renderer/painter_raster.cpp index bbd4c36d92..228d609aaa 100644 --- a/src/renderer/painter_raster.cpp +++ b/src/renderer/painter_raster.cpp @@ -1,9 +1,9 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/raster_bucket.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/map/map.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/raster_bucket.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/map/map.hpp> -using namespace llmr; +using namespace mbgl; void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& /*id*/) { if (pass == Translucent) return; diff --git a/src/renderer/painter_text.cpp b/src/renderer/painter_text.cpp index 3d064d9eef..54fa1a7371 100644 --- a/src/renderer/painter_text.cpp +++ b/src/renderer/painter_text.cpp @@ -1,11 +1,11 @@ -#include <llmr/renderer/painter.hpp> -#include <llmr/renderer/text_bucket.hpp> -#include <llmr/style/style_layer.hpp> -#include <llmr/map/map.hpp> -#include <llmr/util/math.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/renderer/text_bucket.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/util/math.hpp> #include <cmath> -using namespace llmr; +using namespace mbgl; void Painter::renderText(TextBucket& bucket, std::shared_ptr<StyleLayer> layer_desc, const Tile::ID& id) { // Abort early. diff --git a/src/renderer/prerendered_texture.cpp b/src/renderer/prerendered_texture.cpp index 76a4842bec..6b08a38a4c 100644 --- a/src/renderer/prerendered_texture.cpp +++ b/src/renderer/prerendered_texture.cpp @@ -1,8 +1,8 @@ -#include <llmr/renderer/prerendered_texture.hpp> +#include <mbgl/renderer/prerendered_texture.hpp> -#include <llmr/renderer/painter.hpp> +#include <mbgl/renderer/painter.hpp> -using namespace llmr; +using namespace mbgl; PrerenderedTexture::PrerenderedTexture(const RasterizedProperties &properties) : properties(properties) { diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index 670d22eb65..0d5bf21226 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -1,7 +1,7 @@ -#include <llmr/renderer/raster_bucket.hpp> -#include <llmr/renderer/painter.hpp> +#include <mbgl/renderer/raster_bucket.hpp> +#include <mbgl/renderer/painter.hpp> -using namespace llmr; +using namespace mbgl; RasterBucket::RasterBucket(const std::shared_ptr<Texturepool> &texturepool) : raster(texturepool) { diff --git a/src/renderer/text_bucket.cpp b/src/renderer/text_bucket.cpp index 165d636f53..45c7bf971f 100644 --- a/src/renderer/text_bucket.cpp +++ b/src/renderer/text_bucket.cpp @@ -1,23 +1,23 @@ -#include <llmr/renderer/text_bucket.hpp> -#include <llmr/geometry/text_buffer.hpp> -#include <llmr/geometry/elements_buffer.hpp> -#include <llmr/geometry/geometry.hpp> +#include <mbgl/renderer/text_bucket.hpp> +#include <mbgl/geometry/text_buffer.hpp> +#include <mbgl/geometry/elements_buffer.hpp> +#include <mbgl/geometry/geometry.hpp> -#include <llmr/renderer/painter.hpp> -#include <llmr/style/style.hpp> -#include <llmr/map/vector_tile.hpp> -#include <llmr/text/placement.hpp> -#include <llmr/text/glyph_store.hpp> -#include <llmr/util/constants.hpp> +#include <mbgl/renderer/painter.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/text/placement.hpp> +#include <mbgl/text/glyph_store.hpp> +#include <mbgl/util/constants.hpp> -#include <llmr/util/math.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/platform/gl.hpp> #include <iostream> #include <cassert> -using namespace llmr; +using namespace mbgl; TextBucket::TextBucket( TextVertexBuffer &vertexBuffer, diff --git a/src/shader/composite_shader.cpp b/src/shader/composite_shader.cpp index eb86b1c884..07fe0c0740 100644 --- a/src/shader/composite_shader.cpp +++ b/src/shader/composite_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/composite_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/composite_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; CompositeShader::CompositeShader() : Shader( diff --git a/src/shader/dot_shader.cpp b/src/shader/dot_shader.cpp index e159f0f11b..8e2837f2cc 100644 --- a/src/shader/dot_shader.cpp +++ b/src/shader/dot_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/dot_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/dot_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; DotShader::DotShader() : Shader( diff --git a/src/shader/gaussian_shader.cpp b/src/shader/gaussian_shader.cpp index 03509de412..eb88677565 100644 --- a/src/shader/gaussian_shader.cpp +++ b/src/shader/gaussian_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/gaussian_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/gaussian_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; GaussianShader::GaussianShader() : Shader( diff --git a/src/shader/icon_shader.cpp b/src/shader/icon_shader.cpp index c656eb3338..b3ac9272ba 100644 --- a/src/shader/icon_shader.cpp +++ b/src/shader/icon_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/icon_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/icon_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; IconShader::IconShader() : Shader( diff --git a/src/shader/line_shader.cpp b/src/shader/line_shader.cpp index 031e1002ef..1330089896 100644 --- a/src/shader/line_shader.cpp +++ b/src/shader/line_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/line_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/line_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; LineShader::LineShader() : Shader( diff --git a/src/shader/linejoin_shader.cpp b/src/shader/linejoin_shader.cpp index 980b2e408c..73b7a1e745 100644 --- a/src/shader/linejoin_shader.cpp +++ b/src/shader/linejoin_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/linejoin_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/linejoin_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; LinejoinShader::LinejoinShader() : Shader( diff --git a/src/shader/outline_shader.cpp b/src/shader/outline_shader.cpp index 96b25c2ea6..b1e57bf0f3 100644 --- a/src/shader/outline_shader.cpp +++ b/src/shader/outline_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/outline_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/outline_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; OutlineShader::OutlineShader() : Shader( diff --git a/src/shader/pattern_shader.cpp b/src/shader/pattern_shader.cpp index 9f140b21d9..f3943b964e 100644 --- a/src/shader/pattern_shader.cpp +++ b/src/shader/pattern_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/pattern_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/pattern_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; PatternShader::PatternShader() : Shader( diff --git a/src/shader/plain_shader.cpp b/src/shader/plain_shader.cpp index ac4b7edeb0..3abc57eaa4 100644 --- a/src/shader/plain_shader.cpp +++ b/src/shader/plain_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/plain_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/plain_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; PlainShader::PlainShader() : Shader( diff --git a/src/shader/raster_shader.cpp b/src/shader/raster_shader.cpp index f083d3e263..1a21a2edc6 100644 --- a/src/shader/raster_shader.cpp +++ b/src/shader/raster_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/raster_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/raster_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; RasterShader::RasterShader() : Shader( diff --git a/src/shader/shader.cpp b/src/shader/shader.cpp index aa3e76825b..fa073c42d0 100644 --- a/src/shader/shader.cpp +++ b/src/shader/shader.cpp @@ -1,12 +1,12 @@ -#include <llmr/shader/shader.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/util/timer.hpp> -#include <llmr/platform/log.hpp> +#include <mbgl/shader/shader.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/timer.hpp> +#include <mbgl/platform/log.hpp> #include <cstring> #include <cstdlib> -using namespace llmr; +using namespace mbgl; Shader::Shader(const GLchar *vertSource, const GLchar *fragSource) : valid(false), diff --git a/src/shader/text_shader.cpp b/src/shader/text_shader.cpp index 41b19ca766..c7cbbf560e 100644 --- a/src/shader/text_shader.cpp +++ b/src/shader/text_shader.cpp @@ -1,10 +1,10 @@ -#include <llmr/shader/text_shader.hpp> -#include <llmr/shader/shaders.hpp> -#include <llmr/platform/gl.hpp> +#include <mbgl/shader/text_shader.hpp> +#include <mbgl/shader/shaders.hpp> +#include <mbgl/platform/gl.hpp> #include <cstdio> -using namespace llmr; +using namespace mbgl; TextShader::TextShader() : Shader( diff --git a/src/style/applied_class_properties.cpp b/src/style/applied_class_properties.cpp index dfe419ebde..ca9c09436c 100644 --- a/src/style/applied_class_properties.cpp +++ b/src/style/applied_class_properties.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/applied_class_properties.hpp> +#include <mbgl/style/applied_class_properties.hpp> -namespace llmr { +namespace mbgl { AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value) : name(class_id), diff --git a/src/style/class_dictionary.cpp b/src/style/class_dictionary.cpp index a641295c6f..6e1eb5a879 100644 --- a/src/style/class_dictionary.cpp +++ b/src/style/class_dictionary.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/class_dictionary.hpp> +#include <mbgl/style/class_dictionary.hpp> -namespace llmr { +namespace mbgl { ClassID ClassDictionary::Lookup(const std::string &class_name) { auto it = store.find(class_name); diff --git a/src/style/class_properties.cpp b/src/style/class_properties.cpp index e326f56561..e7bf855bfc 100644 --- a/src/style/class_properties.cpp +++ b/src/style/class_properties.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/class_properties.hpp> +#include <mbgl/style/class_properties.hpp> -namespace llmr { +namespace mbgl { const PropertyTransition &ClassProperties::getTransition(PropertyKey key, const PropertyTransition &defaultTransition) const { auto it = transitions.find(key); diff --git a/src/style/filter_comparison.cpp b/src/style/filter_comparison.cpp new file mode 100644 index 0000000000..b3f3a9ef08 --- /dev/null +++ b/src/style/filter_comparison.cpp @@ -0,0 +1,143 @@ +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/style/filter_comparison_private.hpp> + +#include <mbgl/style/value_comparison.hpp> + +#include <ostream> + +namespace mbgl { + + +inline bool includes(const Value &property_value, const std::vector<Value> &filter_values) { + for (const Value &filter_value : filter_values) { + if (util::relaxed_equal(property_value, filter_value)) { + return true; + } + } + return false; +} + +template <typename Comparer> +inline bool compare(const Value &property_value, const std::vector<Value> &filter_values, const Comparer &comparer) { + for (const Value &filter_value : filter_values) { + if (!comparer(property_value, filter_value)) { + return false; + } + } + return true; +} + +template <typename Comparer> +inline bool all(const std::vector<Value> &property_values, const std::vector<Value> &filter_values, const Comparer &comparer) { + for (const Value &property_value : property_values) { + if (!compare(property_value, filter_values, comparer)) { + return false; + } + } + return true; +} + + +inline bool set_equal(const std::vector<Value> &property_values, const std::vector<Value> &filter_values) { + for (const Value &property_value : property_values) { + if (!includes(property_value, filter_values)) { + return false; + } + } + if (property_values.size() == filter_values.size()) { + // Optimization: When the count is the same, the set is guaranteed to be identical. + return true; + } + // Otherwise, check again for identical reverse-mapped values. + for (const Value &filter_value : filter_values) { + if (!includes(filter_value, property_values)) { + return false; + } + } + return true; +} + + +bool FilterComparison::Instance::compare(const std::vector<Value> &property_values) const { + switch (op) { + case Operator::Equal: + return set_equal(property_values, values); + case Operator::NotEqual: + return !set_equal(property_values, values); + case Operator::In: + for (const Value &property_value : property_values) { + if (includes(property_value, values)) { + return true; + } + } + return false; + case Operator::NotIn: + for (const Value &property_value : property_values) { + if (!includes(property_value, values)) { + return true; + } + } + return false; + case Operator::Greater: + return all(property_values, values, util::relaxed_greater); + case Operator::GreaterEqual: + return all(property_values, values, util::relaxed_greater_equal); + case Operator::Less: + return all(property_values, values, util::relaxed_less); + case Operator::LessEqual: + return all(property_values, values, util::relaxed_less_equal); + default: + return false; + } +} + + +const std::string &FilterComparison::getField() const { + return field; +} + +std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison) { + s << "comparison" << std::endl; + for (const FilterComparison::Instance &instance : comparison.instances) { + s << " - " << comparison.field << " " << instance << std::endl; + } + return s; +} + + +std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance) { + switch (instance.op) { + case FilterComparison::Operator::Equal: s << "=="; break; + case FilterComparison::Operator::NotEqual: s << "!="; break; + case FilterComparison::Operator::Greater: s << ">"; break; + case FilterComparison::Operator::GreaterEqual: s << ">="; break; + case FilterComparison::Operator::Less: s << "<"; break; + case FilterComparison::Operator::LessEqual: s << "<="; break; + case FilterComparison::Operator::In: s << "in"; break; + case FilterComparison::Operator::NotIn: s << "!in"; break; + } + + s << " [ "; + for (const Value &value : instance.values) { + s << toString(value) << " "; + } + s << "]"; + return s; +} + + +FilterComparison::Operator parseFilterComparisonOperator(const std::string &op) { + if (op == "==") return FilterComparison::Operator::Equal; + if (op == "!=") return FilterComparison::Operator::NotEqual; + if (op == ">") return FilterComparison::Operator::Greater; + if (op == ">=") return FilterComparison::Operator::GreaterEqual; + if (op == "<") return FilterComparison::Operator::Less; + if (op == "<=") return FilterComparison::Operator::LessEqual; + if (op == "in") return FilterComparison::Operator::In; + if (op == "!in") return FilterComparison::Operator::NotIn; + return FilterComparison::Operator::Equal; +} + +template bool FilterComparison::compare(const VectorTileTagExtractor &extractor) const; + +} diff --git a/src/style/filter_expression.cpp b/src/style/filter_expression.cpp index 58483accac..ff4073b129 100644 --- a/src/style/filter_expression.cpp +++ b/src/style/filter_expression.cpp @@ -1,166 +1,11 @@ -#include <llmr/style/filter_expression.hpp> -#include <llmr/map/vector_tile.hpp> +#include <mbgl/style/filter_expression_private.hpp> +#include <mbgl/map/vector_tile.hpp> -namespace llmr { +#include <mbgl/style/value_comparison.hpp> +#include <ostream> -template <typename Comparer> -inline bool FilterComparison::Instance::includes(const Value &property_value, const Comparer &comparer) const { - for (const Value &filter_value : values) { - if (comparer(property_value, filter_value)) { - return true; - } - } - return false; -} - -template <typename Comparer> -inline bool FilterComparison::Instance::compare(const Value &property_value, const Comparer &comparer) const { - for (const Value &filter_value : values) { - if (!comparer(property_value, filter_value)) { - return false; - } - } - return true; -} - -template <typename Comparer> -inline bool FilterComparison::Instance::all(const std::forward_list<Value> &property_values, const Comparer &comparer) const { - for (const Value &property_value : property_values) { - if (!compare(property_value, comparer)) { - return false; - } - } - return true; -} - - - -bool FilterComparison::Instance::compare(const Value &property_value) const { - switch (op) { - case Operator::Equal: - case Operator::In: - return includes(property_value, util::relaxed_equal); - case Operator::NotEqual: - case Operator::NotIn: - return !includes(property_value, util::relaxed_equal); - case Operator::Greater: - return compare(property_value, util::relaxed_greater); - case Operator::GreaterEqual: - return compare(property_value, util::relaxed_greater_equal); - case Operator::Less: - return compare(property_value, util::relaxed_less); - case Operator::LessEqual: - return compare(property_value, util::relaxed_less_equal); - default: - return false; - } -} - -bool FilterComparison::Instance::compare(const std::forward_list<Value> &property_values) const { - switch (op) { - case Operator::Equal: - for (const Value &property_value : property_values) { - if (!includes(property_value, util::relaxed_equal)) { - return false; - } - } - return true; - case Operator::NotEqual: - for (const Value &property_value : property_values) { - if (includes(property_value, util::relaxed_equal)) { - return false; - } - } - return true; - case Operator::In: - for (const Value &property_value : property_values) { - if (includes(property_value, util::relaxed_equal)) { - return true; - } - } - return false; - case Operator::NotIn: - for (const Value &property_value : property_values) { - if (!includes(property_value, util::relaxed_equal)) { - return true; - } - } - return false; - case Operator::Greater: - return all(property_values, util::relaxed_greater); - case Operator::GreaterEqual: - return all(property_values, util::relaxed_greater_equal); - case Operator::Less: - return all(property_values, util::relaxed_less); - case Operator::LessEqual: - return all(property_values, util::relaxed_less_equal); - default: - return false; - } -} - - -const std::string &FilterComparison::getField() const { - return field; -} - -inline bool FilterComparison::compare(const VectorTileTagExtractor &extractor) const { - const std::forward_list<Value> values = extractor.getValues(field); - - // All instances are ANDed together. - for (const Instance &instance : instances) { - if (!instance.compare(values)) { - return false; - } - } - return true; -} - - - -std::ostream& operator <<(std::ostream &s, const FilterComparison &comparison) { - s << "comparison" << std::endl; - for (const FilterComparison::Instance &instance : comparison.instances) { - s << " - " << comparison.field << " " << instance << std::endl; - } - return s; -} - - -std::ostream& operator <<(std::ostream &s, const FilterComparison::Instance &instance) { - switch (instance.op) { - case FilterComparison::Operator::Equal: s << "=="; break; - case FilterComparison::Operator::NotEqual: s << "!="; break; - case FilterComparison::Operator::Greater: s << ">"; break; - case FilterComparison::Operator::GreaterEqual: s << ">="; break; - case FilterComparison::Operator::Less: s << "<"; break; - case FilterComparison::Operator::LessEqual: s << "<="; break; - case FilterComparison::Operator::In: s << "in"; break; - case FilterComparison::Operator::NotIn: s << "!in"; break; - } - - s << " [ "; - for (const Value &value : instance.values) { - s << toString(value) << " "; - } - s << "]"; - return s; -} - - -FilterComparison::Operator parseFilterComparisonOperator(const std::string &op) { - if (op == "==") return FilterComparison::Operator::Equal; - if (op == "!=") return FilterComparison::Operator::NotEqual; - if (op == ">") return FilterComparison::Operator::Greater; - if (op == ">=") return FilterComparison::Operator::GreaterEqual; - if (op == "<") return FilterComparison::Operator::Less; - if (op == "<=") return FilterComparison::Operator::LessEqual; - if (op == "in") return FilterComparison::Operator::In; - if (op == "!in") return FilterComparison::Operator::NotIn; - return FilterComparison::Operator::Equal; -} - +namespace mbgl { std::ostream& operator <<(std::ostream &s, FilterExpression::Operator op) { switch (op) { @@ -183,81 +28,16 @@ std::ostream& operator <<(std::ostream &s, FilterExpression::GeometryType type) return s; } - - -bool FilterExpression::compare(const VectorTileTagExtractor &extractor) const { - if (type != GeometryType::Any && extractor.getType() != type && extractor.getType() != GeometryType::Any) { - return false; - } - - switch (op) { - case Operator::And: - for (const FilterComparison &comparison : comparisons) { - if (!comparison.compare(extractor)) { - return false; - } - } - for (const FilterExpression &expression: expressions) { - if (!expression.compare(extractor)) { - return false; - } - } - return true; - case Operator::Or: - for (const FilterComparison &comparison : comparisons) { - if (comparison.compare(extractor)) { - return true; - } - } - for (const FilterExpression &expression: expressions) { - if (expression.compare(extractor)) { - return true; - } - } - return false; - case Operator::Xor: { - int count = 0; - for (const FilterComparison &comparison : comparisons) { - count += comparison.compare(extractor); - if (count > 1) { - return false; - } - } - for (const FilterExpression &expression: expressions) { - count += expression.compare(extractor); - if (count > 1) { - return false; - } - } - return count == 1; - } - case Operator::Nor: - for (const FilterComparison &comparison : comparisons) { - if (comparison.compare(extractor)) { - return false; - } - } - for (const FilterExpression &expression: expressions) { - if (expression.compare(extractor)) { - return false; - } - } - return true; - default: - return true; - } -} - bool FilterExpression::empty() const { return type == GeometryType::Any && comparisons.empty() && expressions.empty(); } void FilterExpression::add(const FilterComparison &comparison) { - comparisons.emplace_front(comparison); + comparisons.emplace_back(comparison); } void FilterExpression::add(const FilterExpression &expression) { - expressions.emplace_front(expression); + expressions.emplace_back(expression); } void FilterExpression::setGeometryType(GeometryType g) { @@ -281,4 +61,6 @@ std::ostream& operator <<(std::ostream &s, const FilterExpression &expression) { return s; } +template bool FilterExpression::compare(const VectorTileTagExtractor &extractor) const; + } diff --git a/src/style/function_properties.cpp b/src/style/function_properties.cpp index 9ed04b1b51..2b378fb6b9 100644 --- a/src/style/function_properties.cpp +++ b/src/style/function_properties.cpp @@ -1,9 +1,9 @@ -#include <llmr/style/function_properties.hpp> -#include <llmr/style/types.hpp> +#include <mbgl/style/function_properties.hpp> +#include <mbgl/style/types.hpp> #include <cmath> -namespace llmr { +namespace mbgl { template <> diff --git a/src/style/property_fallback.cpp b/src/style/property_fallback.cpp index 38eae89c51..949dc1a5cb 100644 --- a/src/style/property_fallback.cpp +++ b/src/style/property_fallback.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/property_fallback.hpp> +#include <mbgl/style/property_fallback.hpp> -namespace llmr { +namespace mbgl { const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = { { PropertyKey::FillAntialias, true }, diff --git a/src/style/style.cpp b/src/style/style.cpp index c5204720ab..f867616970 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -1,16 +1,16 @@ -#include <llmr/style/style.hpp> -#include <llmr/style/style_layer_group.hpp> -#include <llmr/style/style_parser.hpp> -#include <llmr/style/style_bucket.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/time.hpp> -#include <llmr/util/error.hpp> +#include <mbgl/style/style.hpp> +#include <mbgl/style/style_layer_group.hpp> +#include <mbgl/style/style_parser.hpp> +#include <mbgl/style/style_bucket.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/error.hpp> #include <csscolorparser/csscolorparser.hpp> #include <rapidjson/document.h> -namespace llmr { +namespace mbgl { Style::Style() { } diff --git a/src/style/style_bucket.cpp b/src/style/style_bucket.cpp index 664d5a9488..afd4bc09f7 100644 --- a/src/style/style_bucket.cpp +++ b/src/style/style_bucket.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/style_bucket.hpp> +#include <mbgl/style/style_bucket.hpp> -namespace llmr { +namespace mbgl { StyleBucket::StyleBucket(StyleLayerType type) { switch (type) { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index c2a8065c18..69c5a8c8ca 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -1,9 +1,9 @@ -#include <llmr/style/style_layer.hpp> -#include <llmr/style/style_bucket.hpp> -#include <llmr/style/style_layer_group.hpp> -#include <llmr/style/property_fallback.hpp> +#include <mbgl/style/style_layer.hpp> +#include <mbgl/style/style_bucket.hpp> +#include <mbgl/style/style_layer_group.hpp> +#include <mbgl/style/property_fallback.hpp> -namespace llmr { +namespace mbgl { StyleLayer::StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles, std::unique_ptr<const RasterizeProperties> &&rasterize) diff --git a/src/style/style_layer_group.cpp b/src/style/style_layer_group.cpp index 86fe6fa241..c7e4360d21 100644 --- a/src/style/style_layer_group.cpp +++ b/src/style/style_layer_group.cpp @@ -1,7 +1,7 @@ -#include <llmr/style/style_layer_group.hpp> +#include <mbgl/style/style_layer_group.hpp> -namespace llmr { +namespace mbgl { void StyleLayerGroup::setClasses(const std::vector<std::string> &class_names, timestamp now, const PropertyTransition &defaultTransition) { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 93e309d685..c4faf81f5a 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -1,11 +1,11 @@ -#include <llmr/style/style_parser.hpp> -#include <llmr/style/style_layer_group.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/std.hpp> -#include <llmr/platform/log.hpp> +#include <mbgl/style/style_parser.hpp> +#include <mbgl/style/style_layer_group.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/std.hpp> +#include <mbgl/platform/log.hpp> #include <csscolorparser/csscolorparser.hpp> -namespace llmr { +namespace mbgl { using JSVal = const rapidjson::Value&; @@ -792,7 +792,7 @@ FilterExpression StyleParser::parseFilter(JSVal value, FilterExpression::Operato } else if (filterValue.IsArray()) { comparison.add(FilterComparison::Operator::In, parseValues(filterValue)); } else { - comparison.add(FilterComparison::Operator::Equal, std::forward_list<Value>({ parseValue(filterValue) })); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value>({ parseValue(filterValue) })); } expression.add(comparison); } @@ -830,15 +830,14 @@ Value StyleParser::parseValue(JSVal value) { } } -std::forward_list<Value> StyleParser::parseValues(JSVal value) { - std::forward_list<Value> values; +std::vector<Value> StyleParser::parseValues(JSVal value) { + std::vector<Value> values; if (value.IsArray()) { - auto it = values.before_begin(); for (rapidjson::SizeType i = 0; i < value.Size(); i++) { - it = values.emplace_after(it, parseValue(replaceConstant(value[i]))); + values.emplace_back(parseValue(replaceConstant(value[i]))); } } else { - values.emplace_front(parseValue(value)); + values.emplace_back(parseValue(value)); } return values; } diff --git a/src/style/style_properties.cpp b/src/style/style_properties.cpp index f2b5af651e..3d6bc41b81 100644 --- a/src/style/style_properties.cpp +++ b/src/style/style_properties.cpp @@ -1,6 +1,6 @@ -#include <llmr/style/style_properties.hpp> +#include <mbgl/style/style_properties.hpp> -namespace llmr { +namespace mbgl { template<> const FillProperties &defaultStyleProperties() { static const FillProperties p; return p; } template<> const LineProperties &defaultStyleProperties() { static const LineProperties p; return p; } diff --git a/src/style/value.cpp b/src/style/value.cpp index f41acb3a06..5cd32376ab 100644 --- a/src/style/value.cpp +++ b/src/style/value.cpp @@ -1,4 +1,4 @@ -#include <llmr/style/value.hpp> +#include <mbgl/style/value.hpp> #pragma GCC diagnostic push #ifndef __clang__ @@ -7,7 +7,7 @@ #include <boost/lexical_cast.hpp> #pragma GCC diagnostic pop -llmr::Value llmr::parseValue(pbf data) { +mbgl::Value mbgl::parseValue(pbf data) { while (data.next()) { switch (data.tag) @@ -34,7 +34,7 @@ llmr::Value llmr::parseValue(pbf data) { return false; } -std::string llmr::toString(const llmr::Value& value) { +std::string mbgl::toString(const mbgl::Value& value) { if (value.is<std::string>()) return value.get<std::string>(); else if (value.is<bool>()) return value.get<bool>() ? "true" : "false"; else if (value.is<int64_t>()) return std::to_string(value.get<int64_t>()); diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 0b4c65885a..54b47e438b 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -1,6 +1,6 @@ -#include <llmr/text/collision.hpp> -#include <llmr/text/rotation_range.hpp> -#include <llmr/util/math.hpp> +#include <mbgl/text/collision.hpp> +#include <mbgl/text/rotation_range.hpp> +#include <mbgl/util/math.hpp> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -14,7 +14,7 @@ #include <boost/geometry/index/rtree.hpp> #pragma GCC diagnostic pop -namespace llmr { +namespace mbgl { namespace bg = boost::geometry; namespace bgm = bg::model; namespace bgi = bg::index; @@ -24,7 +24,7 @@ typedef std::pair<Box, PlacementBox> PlacementValue; typedef bgi::rtree<PlacementValue, bgi::rstar<16>> Tree; } -using namespace llmr; +using namespace mbgl; Collision::~Collision() { delete ((Tree *)cTree); diff --git a/src/text/glyph.cpp b/src/text/glyph.cpp index 32f7e7ccc3..7dea7246d7 100644 --- a/src/text/glyph.cpp +++ b/src/text/glyph.cpp @@ -1,6 +1,6 @@ -#include <llmr/text/glyph.hpp> +#include <mbgl/text/glyph.hpp> -namespace llmr { +namespace mbgl { // Note: this only works for the BMP // Note: we could use a binary lookup table to get averaged constant time lookups, however, diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index f83d810899..edcecde7ff 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -1,16 +1,16 @@ -#include <llmr/text/glyph_store.hpp> - -#include <llmr/util/std.hpp> -#include <llmr/util/string.hpp> -#include <llmr/util/utf.hpp> -#include <llmr/util/pbf.hpp> -#include <llmr/util/constants.hpp> -#include <llmr/util/token.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/text/glyph_store.hpp> + +#include <mbgl/util/std.hpp> +#include <mbgl/util/string.hpp> +#include <mbgl/util/utf.hpp> +#include <mbgl/util/pbf.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/token.hpp> +#include <mbgl/platform/platform.hpp> #include <uv.h> #include <algorithm> -namespace llmr { +namespace mbgl { void FontStack::insert(uint32_t id, const SDFGlyph &glyph) { diff --git a/src/text/placement.cpp b/src/text/placement.cpp index aef5288bf2..e33a4bdec6 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -1,13 +1,13 @@ -#include <llmr/text/placement.hpp> -#include <llmr/map/vector_tile.hpp> -#include <llmr/geometry/interpolate.hpp> -#include <llmr/renderer/text_bucket.hpp> -#include <llmr/util/math.hpp> -#include <llmr/util/constants.hpp> +#include <mbgl/text/placement.hpp> +#include <mbgl/map/vector_tile.hpp> +#include <mbgl/geometry/interpolate.hpp> +#include <mbgl/renderer/text_bucket.hpp> +#include <mbgl/util/math.hpp> +#include <mbgl/util/constants.hpp> #include <algorithm> -using namespace llmr; +using namespace mbgl; const int Placement::tileExtent = 4096; const int Placement::glyphSize = diff --git a/src/text/rotation_range.cpp b/src/text/rotation_range.cpp index 9cbf958b71..943253a3da 100644 --- a/src/text/rotation_range.cpp +++ b/src/text/rotation_range.cpp @@ -1,9 +1,9 @@ -#include <llmr/text/rotation_range.hpp> +#include <mbgl/text/rotation_range.hpp> #include <cassert> #include <algorithm> -namespace llmr { +namespace mbgl { /* * Combine an array of collision ranges to form a continuous diff --git a/src/util/clip_ids.cpp b/src/util/clip_ids.cpp index cd10ef96c8..d815876a06 100644 --- a/src/util/clip_ids.cpp +++ b/src/util/clip_ids.cpp @@ -1,7 +1,7 @@ -#include <llmr/util/clip_ids.hpp> -#include <llmr/map/tile.hpp> +#include <mbgl/util/clip_ids.hpp> +#include <mbgl/map/tile.hpp> -#include <llmr/util/math.hpp> +#include <mbgl/util/math.hpp> #include <list> #include <vector> @@ -10,7 +10,7 @@ #include <iostream> #include <algorithm> -namespace llmr { +namespace mbgl { struct TileHierarchy { TileHierarchy(Tile::ID id, std::list<TileHierarchy> &&children) diff --git a/src/util/image.cpp b/src/util/image.cpp index f29f3451b5..28906c4e91 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -1,11 +1,11 @@ -#include <llmr/util/image.hpp> +#include <mbgl/util/image.hpp> #include <png.h> #include <cassert> #include <cstdlib> -std::string llmr::util::compress_png(int width, int height, void *rgba, bool flip) { +std::string mbgl::util::compress_png(int width, int height, void *rgba, bool flip) { png_voidp error_ptr = 0; png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr, NULL, NULL); if (!png_ptr) { @@ -53,7 +53,7 @@ std::string llmr::util::compress_png(int width, int height, void *rgba, bool fli } -using namespace llmr::util; +using namespace mbgl::util; struct Buffer { diff --git a/src/util/io.cpp b/src/util/io.cpp index 1312b907ba..b889567437 100644 --- a/src/util/io.cpp +++ b/src/util/io.cpp @@ -1,4 +1,4 @@ -#include <llmr/util/io.hpp> +#include <mbgl/util/io.hpp> #include <cstdio> #include <iostream> @@ -6,7 +6,7 @@ #include <fstream> #include <stdexcept> -namespace llmr { +namespace mbgl { namespace util { void write_file(const std::string &filename, const std::string &data) { @@ -15,7 +15,7 @@ void write_file(const std::string &filename, const std::string &data) { fwrite(data.data(), sizeof(std::string::value_type), data.size(), fd); fclose(fd); } else { - fprintf(stderr, "Failed to open file\n"); + throw std::runtime_error(std::string("Failed to open file ") + filename); } } @@ -26,7 +26,7 @@ std::string read_file(const std::string &filename) { data << file.rdbuf(); return data.str(); } else { - throw std::runtime_error("Cannot read file " + filename); + throw std::runtime_error(std::string("Cannot read file ") + filename); } } diff --git a/src/util/mat4.cpp b/src/util/mat4.cpp index 5f9f50bcd2..50270d9217 100644 --- a/src/util/mat4.cpp +++ b/src/util/mat4.cpp @@ -20,11 +20,11 @@ // // 3. This notice may not be removed or altered from any source distribution. -#include <llmr/util/mat4.hpp> +#include <mbgl/util/mat4.hpp> #include <cmath> -using namespace llmr; +using namespace mbgl; void matrix::identity(mat4& out) { out[0] = 1.0f; diff --git a/src/util/raster.cpp b/src/util/raster.cpp index d4b64d0ede..4a040f9cb6 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -1,18 +1,18 @@ -#include <llmr/util/raster.hpp> +#include <mbgl/util/raster.hpp> #include <memory> #include <cassert> #include <cstring> -#include <llmr/platform/platform.hpp> -#include <llmr/platform/gl.hpp> -#include <llmr/util/time.hpp> -#include <llmr/util/uv.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/platform/gl.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/util/uv.hpp> +#include <mbgl/util/std.hpp> #include <png.h> -using namespace llmr; +using namespace mbgl; Raster::Raster(const std::shared_ptr<Texturepool> &texturepool) : texturepool(texturepool) diff --git a/src/util/texturepool.cpp b/src/util/texturepool.cpp index 579f804729..67685eeee1 100644 --- a/src/util/texturepool.cpp +++ b/src/util/texturepool.cpp @@ -1,10 +1,10 @@ -#include <llmr/util/texturepool.hpp> +#include <mbgl/util/texturepool.hpp> #include <vector> const int TextureMax = 64; -using namespace llmr; +using namespace mbgl; GLuint Texturepool::getTextureID() { if (texture_ids.empty()) { diff --git a/src/util/threadpool.cpp b/src/util/threadpool.cpp index 29ab11f1c2..f19032ee01 100644 --- a/src/util/threadpool.cpp +++ b/src/util/threadpool.cpp @@ -1,11 +1,11 @@ -#include <llmr/util/threadpool.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/util/threadpool.hpp> +#include <mbgl/util/std.hpp> #include <thread> #include <memory> -using namespace llmr::util; +using namespace mbgl::util; -std::unique_ptr<Threadpool> llmr::util::threadpool = std::make_unique<Threadpool>(std::thread::hardware_concurrency()); +std::unique_ptr<Threadpool> mbgl::util::threadpool = std::make_unique<Threadpool>(std::thread::hardware_concurrency()); Threadpool::Threadpool(int max_workers) : max_workers(max_workers) { diff --git a/src/util/timer.cpp b/src/util/timer.cpp index efa2b974dc..d56860d193 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -1,12 +1,12 @@ #ifndef DISABLE_TIMER -#include <llmr/util/timer.hpp> -#include <llmr/util/time.hpp> -#include <llmr/platform/log.hpp> +#include <mbgl/util/timer.hpp> +#include <mbgl/util/time.hpp> +#include <mbgl/platform/log.hpp> #include <iostream> #include <atomic> -using namespace llmr::util; +using namespace mbgl::util; timer::timer(Event event) : event(event), start(now()) {} diff --git a/src/util/transition.cpp b/src/util/transition.cpp index 10f94c78b2..c91c8019b7 100644 --- a/src/util/transition.cpp +++ b/src/util/transition.cpp @@ -1,8 +1,8 @@ -#include <llmr/util/transition.hpp> -#include <llmr/util/unitbezier.hpp> -#include <llmr/platform/platform.hpp> +#include <mbgl/util/transition.hpp> +#include <mbgl/util/unitbezier.hpp> +#include <mbgl/platform/platform.hpp> -namespace llmr { namespace util { +namespace mbgl { namespace util { UnitBezier ease(0, 0, 0.25, 1); @@ -16,7 +16,7 @@ float transition::interpolateFloat(float from, float to, double t) const { return from + (to - from) * (float)t; } -llmr::Color transition::interpolateColor(llmr::Color from, llmr::Color to, double t) const { +mbgl::Color transition::interpolateColor(mbgl::Color from, mbgl::Color to, double t) const { return {{ interpolateFloat(from[0], to[0], t), interpolateFloat(from[1], to[1], t), interpolateFloat(from[2], to[2], t), @@ -40,7 +40,7 @@ transition::state ease_transition<double>::update(timestamp now) const { } template <> -transition::state ease_transition<llmr::Color>::update(timestamp now) const { +transition::state ease_transition<mbgl::Color>::update(timestamp now) const { float t = progress(now); if (t >= 1) { value = to; diff --git a/test/clip_ids.cpp b/test/clip_ids.cpp index 6ae889e1ff..f2e8be98bc 100644 --- a/test/clip_ids.cpp +++ b/test/clip_ids.cpp @@ -3,10 +3,10 @@ #include <algorithm> -#include <llmr/util/clip_ids.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/util/clip_ids.hpp> +#include <mbgl/util/std.hpp> -using namespace llmr; +using namespace mbgl; TEST(ClipIDs, ClipMasks) { ASSERT_EQ(0, clipMask[0]); diff --git a/test/comparisons.cpp b/test/comparisons.cpp new file mode 100644 index 0000000000..e1e991d41c --- /dev/null +++ b/test/comparisons.cpp @@ -0,0 +1,306 @@ +#include <iostream> +#include "gtest/gtest.h" + +#include <mbgl/style/filter_comparison_private.hpp> +#include <mbgl/style/filter_expression_private.hpp> + +#include <map> + + + +class MockExtractor { +public: + inline MockExtractor(const std::multimap<std::string, mbgl::Value> &values) : values(values) {} + inline MockExtractor() {} + + inline std::vector<mbgl::Value> getValues(const std::string &key) const { + std::vector<mbgl::Value> result; + // Find all values with the requested key. + const auto ret = values.equal_range(key); + for (auto it = ret.first; it != ret.second; it++) { + // Append the newly found value to the forward list. + result.emplace_back(it->second); + } + return result; + } + +private: + const std::multimap<std::string, mbgl::Value> values; +}; + + +TEST(FilterComparison, EqualsSingleStringValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { std::string("bar") }); + // comparison is { "test": { "==": "bar" } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor())); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("barst") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(32.8) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + + +TEST(FilterComparison, EqualsSingleDoubleValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { double(32.8) }); + // comparison is { "test": { "==": 32.8 } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(32.8) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("32.8") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", double(32.8) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(32.8) }, { "test", std::string("booz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", double(32.8) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor())); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(32.9) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + +TEST(FilterComparison, EqualsSingleUintValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { uint64_t(42) }); + // comparison is { "test": { "==": 42 } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("42") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", uint64_t(42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(42) }, { "test", std::string("booz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", uint64_t(42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor())); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(43) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + +TEST(FilterComparison, EqualsSingleIntValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { int64_t(-42) }); + // comparison is { "test": { "==": -42 } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(-42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("-42") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", int64_t(-42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-42) }, { "test", std::string("booz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", int64_t(-42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor())); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-43) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(-43) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(-42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + +TEST(FilterComparison, EqualsSingleBoolValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { bool(true) }); + // comparison is { "test": { "==": true } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(1) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(1) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(1) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("1") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", bool(true) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }, { "test", std::string("booz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", bool(true) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor())); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); +} + + + +TEST(FilterComparison, EqualsMultipleStringValues) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { std::string("bar"), std::string("baz") }); + // comparison is { "test": { "==": ["bar", "baz"]̇ } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("baz") }, { "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("baz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }, { "test", std::string("boo") }}))); +} + +TEST(FilterComparison, EqualsMultipleIdenticalStringValues) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::Equal, std::vector<Value> { std::string("bar"), std::string("bar") }); + // comparison is { "test": { "==": ["bar", "bar"]̇ } } + + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("baz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }}))); +} + + + +TEST(FilterComparison, NotEqualsSingleStringValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { std::string("bar") }); + // comparison is { "test": { "!=": "bar" } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor())); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("barst") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(32.8) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + + +TEST(FilterComparison, NotEqualsSingleDoubleValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { double(32.8) }); + // comparison is { "test": { "!=": 32.8 } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(32.8) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("32.8") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", double(32.8) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(32.8) }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", double(32.8) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor())); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(32.9) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + +TEST(FilterComparison, NotEqualsSingleUintValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { uint64_t(42) }); + // comparison is { "test": { "!=": 42 } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("42") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", uint64_t(42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(42) }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", uint64_t(42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor())); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(43) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + + +TEST(FilterComparison, NotEqualsSingleIntValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { int64_t(-42) }); + // comparison is { "test": { "!=": -42 } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(-42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(-42) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("-42") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", int64_t(-42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-42) }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", int64_t(-42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor())); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-43) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", double(-43) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(-42) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); +} + + +TEST(FilterComparison, NotEqualsSingleBoolValue) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { bool(true) }); + // comparison is { "test": { "!=": true } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", bool(true) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", int64_t(1) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", uint64_t(1) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", double(1) }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("1") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "other", std::string("bar") }, { "test", bool(true) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(true) }, { "test", std::string("booz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "other", bool(true) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor())); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", bool(false) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", int64_t(-18932) }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", uint64_t(18932) }}))); +} + + + +TEST(FilterComparison, NotEqualsMultipleStringValues) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { std::string("bar"), std::string("baz") }); + // comparison is { "test": { "!=": ["bar", "baz"]̇ } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("baz") }, { "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("baz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }, { "test", std::string("boo") }}))); +} + + + +TEST(FilterComparison, NotEqualsMultipleIdenticalStringValues) { + using namespace mbgl; + + FilterComparison comparison("test"); + comparison.add(FilterComparison::Operator::NotEqual, std::vector<Value> { std::string("bar"), std::string("bar") }); + // comparison is { "test": { "!=": ["bar", "bar"]̇ } } + + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }}))); + ASSERT_FALSE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("bar") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("baz") }}))); + ASSERT_TRUE(comparison.compare(MockExtractor({{ "test", std::string("bar") }, { "test", std::string("baz") }}))); +} diff --git a/test/enums.cpp b/test/enums.cpp index 3a5ddc9b05..e959994a57 100644 --- a/test/enums.cpp +++ b/test/enums.cpp @@ -3,9 +3,9 @@ #include <algorithm> -#include <llmr/style/types.hpp> +#include <mbgl/style/types.hpp> -using namespace llmr; +using namespace mbgl; TEST(Enums, StyleLayerType) { std::cerr << StyleLayerType::Raster; diff --git a/test/fixtures/fixture_log.cpp b/test/fixtures/fixture_log.cpp index 44e9821446..c2c10fc9eb 100644 --- a/test/fixtures/fixture_log.cpp +++ b/test/fixtures/fixture_log.cpp @@ -2,7 +2,7 @@ #include <iostream> -namespace llmr { +namespace mbgl { FixtureLogBackend::~FixtureLogBackend() { std::cerr << unchecked(); @@ -24,6 +24,7 @@ std::vector<FixtureLogBackend::LogMessage> FixtureLogBackend::unchecked() const for (const LogMessage &msg : messages) { if (!msg.checked) { unchecked.push_back(msg); + msg.checked = true; } } return unchecked; @@ -39,8 +40,8 @@ std::vector<FixtureLogBackend::LogMessage> FixtureLogBackend::unchecked() const ::std::ostream& operator<<(::std::ostream& os, const FixtureLogBackend::LogMessage& message) { os << "[\"" << message.severity.get() << "\", \"" << message.event.get() << "\""; if (message.code) os << ", " << message.code.get(); - if (message.msg) os << ", \"" << message.msg.get(); - return os << "\"]" << std::endl; + if (message.msg) os << ", \"" << message.msg.get() << "\""; + return os << "]" << std::endl; } } diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index c41d74ab9c..263871575b 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -1,15 +1,15 @@ -#ifndef LLMR_TEST_FIXTURE_LOG -#define LLMR_TEST_FIXTURE_LOG +#ifndef MBGL_TEST_FIXTURE_LOG +#define MBGL_TEST_FIXTURE_LOG -#include <llmr/platform/log.hpp> -#include <llmr/util/noncopyable.hpp> +#include <mbgl/platform/log.hpp> +#include <mbgl/util/noncopyable.hpp> #include <boost/optional.hpp> #include <vector> #include <cstdarg> -namespace llmr { +namespace mbgl { class FixtureLogBackend : public LogBackend, private util::noncopyable { public: diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index b106dfe306..b73020590c 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -1,7 +1,7 @@ -#include <llmr/platform/platform.hpp> -#include <llmr/platform/request.hpp> -#include <llmr/util/uv.hpp> -#include <llmr/platform/log.hpp> +#include <mbgl/platform/platform.hpp> +#include <mbgl/platform/request.hpp> +#include <mbgl/util/uv.hpp> +#include <mbgl/platform/log.hpp> const std::string base_directory = []{ std::string fn = __FILE__; @@ -10,7 +10,7 @@ const std::string base_directory = []{ }(); -namespace llmr { +namespace mbgl { std::shared_ptr<platform::Request> platform::request_http(const std::string &url, @@ -103,4 +103,4 @@ void platform::cancel_request_http(const std::shared_ptr<Request> &req) { } } -} // end namespace llmr +} diff --git a/test/fixtures/styles/icons.info.json b/test/fixtures/styles/icons.info.json new file mode 100644 index 0000000000..e116913aa4 --- /dev/null +++ b/test/fixtures/styles/icons.info.json @@ -0,0 +1,18 @@ +{ + "default": { + "zoom": 14, + "center": [52.499167, 13.418056], + "height": 256, + "log": [ + [1, "INFO", "HttpRequest", 200, "sprites/outdoors.json"], + [1, "INFO", "HttpRequest", 200, "sprites/outdoors.png"], + [1, "INFO", "HttpRequest", 200, "tiles/14-8803-5375.vector.pbf"], + [1, "INFO", "HttpRequest", 200, "tiles/14-8802-5375.vector.pbf"], + [1, "INFO", "HttpRequest", 200, "tiles/14-8803-5374.vector.pbf"], + [1, "INFO", "HttpRequest", 200, "tiles/14-8802-5374.vector.pbf"], + [6, "INFO", "HttpRequest"], + + [1, "INFO", "Sprite", "loaded sprites/outdoors"] + ] + } +} diff --git a/test/fixtures/styles/icons.style.json b/test/fixtures/styles/icons.style.json new file mode 100644 index 0000000000..46adfbd408 --- /dev/null +++ b/test/fixtures/styles/icons.style.json @@ -0,0 +1,33 @@ +{ + "version": 3, + "sources": { + "mapbox": { + "type": "vector", + "url": "tiles/{z}-{x}-{y}.vector.pbf", + "tileSize": 512, + "maxZoom": 14 + } + }, + "sprite": "sprites/outdoors", + "layers": [ + { + "id": "background", + "type": "background", + "style": { + "background-color": "green" + } + }, + { + "id": "poi", + "source": "mapbox", + "source-layer": "poi_label", + "type": "icon", + "filter": { "maki": "restaurant" }, + "render": { + "icon-image": "{maki}-12", + "icon-size": 12, + "icon-allow-overlap": true + } + } + ] +} diff --git a/test/fixtures/styles/icons/default.expected.png b/test/fixtures/styles/icons/default.expected.png Binary files differnew file mode 100644 index 0000000000..17e3252c88 --- /dev/null +++ b/test/fixtures/styles/icons/default.expected.png diff --git a/test/functions.cpp b/test/functions.cpp index dbaeaeee84..a2ad93c4e1 100644 --- a/test/functions.cpp +++ b/test/functions.cpp @@ -1,25 +1,25 @@ #include <iostream> #include "gtest/gtest.h" -#include <llmr/style/function_properties.hpp> +#include <mbgl/style/function_properties.hpp> -using namespace llmr; +using namespace mbgl; TEST(Function, Constant) { - EXPECT_EQ(2.0f, llmr::ConstantFunction<float>(2).evaluate(0)); - EXPECT_EQ(3.8f, llmr::ConstantFunction<float>(3.8).evaluate(0)); - EXPECT_EQ(22.0f, llmr::ConstantFunction<float>(22).evaluate(0)); - EXPECT_EQ(2.0f, llmr::ConstantFunction<float>(2).evaluate(4)); - EXPECT_EQ(3.8f, llmr::ConstantFunction<float>(3.8).evaluate(4)); - EXPECT_EQ(22.0f, llmr::ConstantFunction<float>(22).evaluate(4)); - EXPECT_EQ(2.0f, llmr::ConstantFunction<float>(2).evaluate(22)); - EXPECT_EQ(3.8f, llmr::ConstantFunction<float>(3.8).evaluate(22)); - EXPECT_EQ(22.0f, llmr::ConstantFunction<float>(22).evaluate(22)); + EXPECT_EQ(2.0f, mbgl::ConstantFunction<float>(2).evaluate(0)); + EXPECT_EQ(3.8f, mbgl::ConstantFunction<float>(3.8).evaluate(0)); + EXPECT_EQ(22.0f, mbgl::ConstantFunction<float>(22).evaluate(0)); + EXPECT_EQ(2.0f, mbgl::ConstantFunction<float>(2).evaluate(4)); + EXPECT_EQ(3.8f, mbgl::ConstantFunction<float>(3.8).evaluate(4)); + EXPECT_EQ(22.0f, mbgl::ConstantFunction<float>(22).evaluate(4)); + EXPECT_EQ(2.0f, mbgl::ConstantFunction<float>(2).evaluate(22)); + EXPECT_EQ(3.8f, mbgl::ConstantFunction<float>(3.8).evaluate(22)); + EXPECT_EQ(22.0f, mbgl::ConstantFunction<float>(22).evaluate(22)); } TEST(Function, Stops) { // Explicit constant slope in fringe regions. - llmr::StopsFunction<float> slope_1({ { 0, 1.5 }, { 6, 1.5 }, { 8, 3 }, { 22, 3 } }); + mbgl::StopsFunction<float> slope_1({ { 0, 1.5 }, { 6, 1.5 }, { 8, 3 }, { 22, 3 } }); EXPECT_EQ(1.5, slope_1.evaluate(0)); EXPECT_EQ(1.5, slope_1.evaluate(4)); EXPECT_EQ(1.5, slope_1.evaluate(6)); @@ -31,7 +31,7 @@ TEST(Function, Stops) { // Test constant values in fringe regions. - llmr::StopsFunction<float> slope_2({ { 6, 1.5 }, { 8, 3 } }); + mbgl::StopsFunction<float> slope_2({ { 6, 1.5 }, { 8, 3 } }); EXPECT_EQ(1.5, slope_2.evaluate(0)); EXPECT_EQ(1.5, slope_2.evaluate(4)); EXPECT_EQ(1.5, slope_2.evaluate(6)); @@ -42,7 +42,7 @@ TEST(Function, Stops) { EXPECT_EQ(3.0, slope_2.evaluate(22)); // Test no values. - llmr::StopsFunction<float> slope_3({}); + mbgl::StopsFunction<float> slope_3({}); EXPECT_EQ(1, slope_3.evaluate(2)); EXPECT_EQ(1, slope_3.evaluate(6)); EXPECT_EQ(1, slope_3.evaluate(12)); @@ -50,7 +50,7 @@ TEST(Function, Stops) { TEST(Function, Linear) { - llmr::LinearFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* slope */ 2, /* min */ 7.5, /* max */ 20); + mbgl::LinearFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* slope */ 2, /* min */ 7.5, /* max */ 20); ASSERT_FLOAT_EQ(7.5, slope_1.evaluate(3)); ASSERT_FLOAT_EQ(7.5, slope_1.evaluate(4)); ASSERT_FLOAT_EQ(8.5, slope_1.evaluate(4.5)); @@ -63,7 +63,7 @@ TEST(Function, Linear) { TEST(Function, Exponential) { - llmr::ExponentialFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* exp_base */ 1.75, /* slope */ 2, /* min */ 7.5, /* max */ 20); + mbgl::ExponentialFunction<float> slope_1(/* val */ 7.5, /* z_base */ 4, /* exp_base */ 1.75, /* slope */ 2, /* min */ 7.5, /* max */ 20); ASSERT_FLOAT_EQ(8.6428576, slope_1.evaluate(3)); // 7.5 + 1.75^(3 - 4) * 2 ASSERT_FLOAT_EQ(9.5, slope_1.evaluate(4)); // 7.5 + 1.75^(4 - 4) * 2 ASSERT_FLOAT_EQ(10.145751, slope_1.evaluate(4.5)); // 7.5 + 1.75^(4.5 - 4) * 2 diff --git a/test/headless.cpp b/test/headless.cpp index a7f34b9d49..18a17d6bdf 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -1,9 +1,9 @@ #include "gtest/gtest.h" -#include <llmr/map/map.hpp> -#include <llmr/util/image.hpp> -#include <llmr/util/io.hpp> -#include <llmr/util/std.hpp> +#include <mbgl/map/map.hpp> +#include <mbgl/util/image.hpp> +#include <mbgl/util/io.hpp> +#include <mbgl/util/std.hpp> #include <rapidjson/document.h> @@ -22,7 +22,7 @@ const std::string base_directory = []{ class HeadlessTest : public ::testing::TestWithParam<std::string> {}; TEST_P(HeadlessTest, render) { - using namespace llmr; + using namespace mbgl; const std::string &base = GetParam(); diff --git a/test/rotation_range.cpp b/test/rotation_range.cpp index e0089464a4..987d422686 100644 --- a/test/rotation_range.cpp +++ b/test/rotation_range.cpp @@ -3,9 +3,9 @@ #include <algorithm> -#include <llmr/text/rotation_range.hpp> +#include <mbgl/text/rotation_range.hpp> -using namespace llmr; +using namespace mbgl; double deg(double x) { return x / M_PI * 180.0; } diff --git a/test/style.cpp b/test/style.cpp index 1198b2a2eb..a67ab06777 100644 --- a/test/style.cpp +++ b/test/style.cpp @@ -1,12 +1,12 @@ #include "gtest/gtest.h" -#include <llmr/style/style.hpp> +#include <mbgl/style/style.hpp> #include "./fixtures/fixture_log.hpp" #include <iostream> #include <fstream> -using namespace llmr; +using namespace mbgl; typedef std::vector<std::pair<uint32_t, std::string>> Messages; diff --git a/test/test.gyp b/test/test.gyp index 1a3915131c..f27344330b 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -71,7 +71,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -87,7 +87,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -103,7 +103,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -121,7 +121,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86", + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -137,7 +137,23 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" + ] + }, + { + "target_name": "comparisons", + "product_name": "test_comparisons", + "type": "executable", + "libraries": [ + "-lpthread", + ], + "sources": [ + "./main.cpp", + "./comparisons.cpp", + ], + "dependencies": [ + "../deps/gtest/gtest.gyp:gtest", + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -153,7 +169,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -169,7 +185,7 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86" + "../mapboxgl.gyp:mapboxgl" ] }, { @@ -190,9 +206,9 @@ ], "dependencies": [ "../deps/gtest/gtest.gyp:gtest", - "../llmr.gyp:llmr-x86", + "../mapboxgl.gyp:mapboxgl", "link_gl", - '../llmr.gyp:copy_default_stylesheet', + '../mapboxgl.gyp:copy_default_stylesheet', ] }, { @@ -207,6 +223,7 @@ "functions", "headless", "style", + "comparisons", ], } ] diff --git a/test/tile.cpp b/test/tile.cpp index 9e36fbecff..8a580f55a9 100644 --- a/test/tile.cpp +++ b/test/tile.cpp @@ -1,9 +1,9 @@ #include <iostream> #include "gtest/gtest.h" -#include <llmr/map/tile.hpp> +#include <mbgl/map/tile.hpp> -using namespace llmr; +using namespace mbgl; TEST(Variant, isChild) { diff --git a/test/variant.cpp b/test/variant.cpp index 9b0de9f3a6..dd4578b49d 100644 --- a/test/variant.cpp +++ b/test/variant.cpp @@ -1,7 +1,8 @@ #include <iostream> #include "gtest/gtest.h" -#include <llmr/style/value.hpp> +#include <mbgl/style/value.hpp> +#include <mbgl/style/value_comparison.hpp> #pragma GCC diagnostic push #ifndef __clang__ @@ -10,54 +11,131 @@ #include <boost/lexical_cast.hpp> #pragma GCC diagnostic pop -using namespace llmr; +using namespace mbgl; TEST(Variant, toString) { - EXPECT_EQ("lord", llmr::toString( (std::string)"lord" )); - EXPECT_EQ("36", llmr::toString( (uint64_t)36 )); - EXPECT_EQ("-239", llmr::toString( (int64_t)-239 )); - EXPECT_EQ("0", llmr::toString( (int64_t)0 )); - EXPECT_EQ("3.14159268", llmr::toString( (double)3.14159268 )); - EXPECT_EQ("3.1415926535897931", llmr::toString( (double)3.1415926535897931 )); - EXPECT_EQ("true", llmr::toString( true )); - EXPECT_EQ("false", llmr::toString( false )); + EXPECT_EQ("lord", toString( (std::string)"lord" )); + EXPECT_EQ("36", toString( (uint64_t)36 )); + EXPECT_EQ("-239", toString( (int64_t)-239 )); + EXPECT_EQ("0", toString( (int64_t)0 )); + EXPECT_EQ("3.14159268", toString( (double)3.14159268 )); + EXPECT_EQ("3.1415926535897931", toString( (double)3.1415926535897931 )); + EXPECT_EQ("true", toString( true )); + EXPECT_EQ("false", toString( false )); } +TEST(Variant, RelaxedEqualityStringToBool) { + // 1-ish values are true + EXPECT_TRUE(util::relaxed_equal(std::string("1"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string("1.0"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 1"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0x1"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0X1"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 1.0"), bool(true))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 1 "), bool(true))); + + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string("1"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string("1.0"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string(" 1"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string(" 0x1"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string(" 0X1"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string(" 1.0"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string(" 1 "))); + + // 0-ish values are false + EXPECT_TRUE(util::relaxed_equal(std::string("0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string("0.0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0x0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0X0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0.0"), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" 0 "), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(""), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string(" "), bool(false))); + + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("0.0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" 0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" 0x0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" 0X0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" 0.0"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" 0 "))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(""))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(" "))); + + + // other string values are neither true nor false + EXPECT_FALSE(util::relaxed_equal(std::string(" 1.0 g"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("foo"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("true"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("false"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string(" inf "), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string(" inFINITY "), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string(" nan "), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string(" NAN "), bool(true))); + + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(" 1.0 g"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("foo"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("true"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("false"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(" inf "))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(" inFINITY "))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(" nan "))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(" NAN "))); + + + EXPECT_FALSE(util::relaxed_equal(std::string(" 1.0 g"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("foo"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("true"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("false"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string(" inf "), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string(" inFINITY "), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string(" nan "), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string(" NAN "), bool(false))); + + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string(" 1.0 g"))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string("foo"))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string("true"))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string("false"))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string(" inf "))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string(" inFINITY "))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string(" nan "))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string(" NAN "))); +} + TEST(Variant, RelaxedEquality) { // Compare to bool - EXPECT_TRUE(util::relaxed_equal(bool(true), int64_t(386))); - EXPECT_TRUE(util::relaxed_equal(bool(true), int64_t(-7042))); + EXPECT_TRUE(util::relaxed_equal(bool(false), bool(false))); EXPECT_TRUE(util::relaxed_equal(bool(false), int64_t(0))); - EXPECT_TRUE(util::relaxed_equal(bool(true), uint64_t(386))); EXPECT_TRUE(util::relaxed_equal(bool(false), uint64_t(0))); - EXPECT_TRUE(util::relaxed_equal(bool(true), double(386))); EXPECT_TRUE(util::relaxed_equal(bool(false), double(0))); - EXPECT_TRUE(util::relaxed_equal(bool(true), std::string("386"))); + EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("0"))); EXPECT_TRUE(util::relaxed_equal(bool(false), std::string(""))); - EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("false"))); - EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("False"))); - EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("null"))); - EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("nuLL"))); - EXPECT_TRUE(util::relaxed_equal(bool(false), std::string("NULL"))); + EXPECT_TRUE(util::relaxed_equal(bool(true), bool(true))); - EXPECT_TRUE(util::relaxed_equal(bool(false), bool(false))); + EXPECT_TRUE(util::relaxed_equal(bool(true), int64_t(1))); + EXPECT_TRUE(util::relaxed_equal(bool(true), uint64_t(1))); + EXPECT_TRUE(util::relaxed_equal(bool(true), double(1))); + EXPECT_TRUE(util::relaxed_equal(bool(true), std::string("1"))); - EXPECT_FALSE(util::relaxed_equal(bool(true), int64_t(0))); - EXPECT_FALSE(util::relaxed_equal(bool(true), uint64_t(0))); - EXPECT_FALSE(util::relaxed_equal(bool(true), double(0))); - EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(""))); - EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("false"))); - EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("FALSE"))); - EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("null"))); - EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("Null"))); - EXPECT_FALSE(util::relaxed_equal(bool(false), int64_t(-754))); - EXPECT_FALSE(util::relaxed_equal(bool(false), uint64_t(3))); + + EXPECT_FALSE(util::relaxed_equal(bool(false), bool(true))); + EXPECT_FALSE(util::relaxed_equal(bool(false), int64_t(386))); + EXPECT_FALSE(util::relaxed_equal(bool(false), int64_t(-7042))); + EXPECT_FALSE(util::relaxed_equal(bool(false), uint64_t(386))); EXPECT_FALSE(util::relaxed_equal(bool(false), double(3.145))); + EXPECT_FALSE(util::relaxed_equal(bool(false), std::string("386"))); EXPECT_FALSE(util::relaxed_equal(bool(false), std::string("test"))); - EXPECT_FALSE(util::relaxed_equal(bool(true), bool(false))); - EXPECT_FALSE(util::relaxed_equal(bool(false), bool(true))); + EXPECT_FALSE(util::relaxed_equal(bool(true), bool(false))); + EXPECT_FALSE(util::relaxed_equal(bool(true), int64_t(386))); + EXPECT_FALSE(util::relaxed_equal(bool(true), int64_t(-7042))); + EXPECT_FALSE(util::relaxed_equal(bool(true), uint64_t(386))); + EXPECT_FALSE(util::relaxed_equal(bool(true), double(3.145))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("386"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string("test"))); + EXPECT_FALSE(util::relaxed_equal(bool(true), std::string(""))); // Compare to int64_t EXPECT_TRUE(util::relaxed_equal(int64_t(386), int64_t(386))); @@ -67,8 +145,6 @@ TEST(Variant, RelaxedEquality) { EXPECT_TRUE(util::relaxed_equal(int64_t(386), std::string("386"))); EXPECT_TRUE(util::relaxed_equal(int64_t(1), bool(true))); EXPECT_TRUE(util::relaxed_equal(int64_t(0), bool(false))); - EXPECT_TRUE(util::relaxed_equal(int64_t(1), std::string("true"))); - EXPECT_TRUE(util::relaxed_equal(int64_t(0), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(int64_t(386), int64_t(387))); EXPECT_FALSE(util::relaxed_equal(int64_t(-7042), int64_t(-7043))); @@ -77,6 +153,8 @@ TEST(Variant, RelaxedEquality) { EXPECT_FALSE(util::relaxed_equal(int64_t(386), std::string("387"))); EXPECT_FALSE(util::relaxed_equal(int64_t(1), bool(false))); EXPECT_FALSE(util::relaxed_equal(int64_t(0), bool(true))); + EXPECT_FALSE(util::relaxed_equal(int64_t(1), std::string("true"))); + EXPECT_FALSE(util::relaxed_equal(int64_t(0), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(int64_t(1), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(int64_t(0), std::string("true"))); @@ -89,8 +167,6 @@ TEST(Variant, RelaxedEquality) { EXPECT_TRUE(util::relaxed_equal(uint64_t(386), std::string("386"))); EXPECT_TRUE(util::relaxed_equal(uint64_t(1), bool(true))); EXPECT_TRUE(util::relaxed_equal(uint64_t(0), bool(false))); - EXPECT_TRUE(util::relaxed_equal(uint64_t(1), std::string("true"))); - EXPECT_TRUE(util::relaxed_equal(uint64_t(0), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(uint64_t(386), int64_t(387))); EXPECT_FALSE(util::relaxed_equal(uint64_t(386), uint64_t(387))); @@ -99,6 +175,8 @@ TEST(Variant, RelaxedEquality) { EXPECT_FALSE(util::relaxed_equal(uint64_t(386), std::string("387"))); EXPECT_FALSE(util::relaxed_equal(uint64_t(1), bool(false))); EXPECT_FALSE(util::relaxed_equal(uint64_t(0), bool(true))); + EXPECT_FALSE(util::relaxed_equal(uint64_t(1), std::string("true"))); + EXPECT_FALSE(util::relaxed_equal(uint64_t(0), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(uint64_t(1), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(uint64_t(0), std::string("true"))); @@ -112,12 +190,6 @@ TEST(Variant, RelaxedEquality) { EXPECT_TRUE(util::relaxed_equal(double(386), std::string("386"))); EXPECT_TRUE(util::relaxed_equal(double(1), bool(true))); EXPECT_TRUE(util::relaxed_equal(double(0), bool(false))); - EXPECT_TRUE(util::relaxed_equal(double(1), std::string("true"))); - EXPECT_TRUE(util::relaxed_equal(double(1), std::string("TRue"))); - EXPECT_TRUE(util::relaxed_equal(double(0), std::string("false"))); - EXPECT_TRUE(util::relaxed_equal(double(0), std::string("FALSe"))); - EXPECT_TRUE(util::relaxed_equal(double(0), std::string("null"))); - EXPECT_TRUE(util::relaxed_equal(double(0), std::string("Null"))); EXPECT_FALSE(util::relaxed_equal(double(3.159385), double(3.159383))); EXPECT_FALSE(util::relaxed_equal(double(386), int64_t(387))); @@ -127,6 +199,12 @@ TEST(Variant, RelaxedEquality) { EXPECT_FALSE(util::relaxed_equal(double(386), std::string("387"))); EXPECT_FALSE(util::relaxed_equal(double(1), bool(false))); EXPECT_FALSE(util::relaxed_equal(double(0), bool(true))); + EXPECT_FALSE(util::relaxed_equal(double(1), std::string("true"))); + EXPECT_FALSE(util::relaxed_equal(double(1), std::string("TRue"))); + EXPECT_FALSE(util::relaxed_equal(double(0), std::string("false"))); + EXPECT_FALSE(util::relaxed_equal(double(0), std::string("FALSe"))); + EXPECT_FALSE(util::relaxed_equal(double(0), std::string("null"))); + EXPECT_FALSE(util::relaxed_equal(double(0), std::string("Null"))); EXPECT_FALSE(util::relaxed_equal(double(1), std::string("false"))); EXPECT_FALSE(util::relaxed_equal(double(1), std::string("False"))); EXPECT_FALSE(util::relaxed_equal(double(1), std::string("null"))); @@ -141,20 +219,21 @@ TEST(Variant, RelaxedEquality) { EXPECT_TRUE(util::relaxed_equal(std::string("-386"), int64_t(-386))); EXPECT_TRUE(util::relaxed_equal(std::string("386"), uint64_t(386))); EXPECT_TRUE(util::relaxed_equal(std::string("386.36"), double(386.36))); - EXPECT_TRUE(util::relaxed_equal(std::string("true"), bool(true))); - EXPECT_TRUE(util::relaxed_equal(std::string("True"), bool(true))); - EXPECT_TRUE(util::relaxed_equal(std::string("some string"), bool(true))); - EXPECT_TRUE(util::relaxed_equal(std::string("false"), bool(false))); - EXPECT_TRUE(util::relaxed_equal(std::string("fAlse"), bool(false))); - EXPECT_TRUE(util::relaxed_equal(std::string("null"), bool(false))); - EXPECT_TRUE(util::relaxed_equal(std::string("NULl"), bool(false))); EXPECT_TRUE(util::relaxed_equal(std::string(""), bool(false))); + EXPECT_TRUE(util::relaxed_equal(std::string("1"), bool(true))); EXPECT_FALSE(util::relaxed_equal(std::string("lord"), std::string("baron"))); EXPECT_FALSE(util::relaxed_equal(std::string("386"), int64_t(387))); EXPECT_FALSE(util::relaxed_equal(std::string("-386"), int64_t(-387))); EXPECT_FALSE(util::relaxed_equal(std::string("386"), uint64_t(387))); EXPECT_FALSE(util::relaxed_equal(std::string("386.36"), double(386.37))); + EXPECT_FALSE(util::relaxed_equal(std::string("some string"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("true"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("True"), bool(true))); + EXPECT_FALSE(util::relaxed_equal(std::string("false"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("fAlse"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("null"), bool(false))); + EXPECT_FALSE(util::relaxed_equal(std::string("NULl"), bool(false))); EXPECT_FALSE(util::relaxed_equal(std::string("true"), bool(false))); EXPECT_FALSE(util::relaxed_equal(std::string("TRUE"), bool(false))); EXPECT_FALSE(util::relaxed_equal(std::string("some string"), bool(false))); @@ -190,11 +269,23 @@ TEST(Variant, RelaxedGreater) { EXPECT_TRUE(util::relaxed_greater(double(387), double(386.7))); EXPECT_TRUE(util::relaxed_greater(bool(true), double(0))); + EXPECT_TRUE(util::relaxed_greater(std::string("387"), bool(true))); EXPECT_TRUE(util::relaxed_greater(std::string("387"), bool(false))); EXPECT_TRUE(util::relaxed_greater(uint64_t(387), bool(false))); EXPECT_TRUE(util::relaxed_greater(int64_t(387), bool(false))); EXPECT_TRUE(util::relaxed_greater(double(387), bool(false))); - EXPECT_TRUE(util::relaxed_greater(bool(true), double(false))); + EXPECT_TRUE(util::relaxed_greater(double(387), bool(false))); + EXPECT_TRUE(util::relaxed_greater(uint64_t(387), bool(true))); + EXPECT_TRUE(util::relaxed_greater(int64_t(387), bool(true))); + EXPECT_TRUE(util::relaxed_greater(double(387), bool(true))); + EXPECT_TRUE(util::relaxed_greater(double(387), bool(true))); + + EXPECT_TRUE(util::relaxed_greater(bool(true), double(0))); + EXPECT_TRUE(util::relaxed_greater(bool(true), double(0.5))); + EXPECT_TRUE(util::relaxed_greater(bool(true), bool(false))); + EXPECT_TRUE(util::relaxed_greater(bool(true), int64_t(0))); + EXPECT_TRUE(util::relaxed_greater(bool(true), uint64_t(0))); + EXPECT_TRUE(util::relaxed_greater(bool(true), bool(false))); @@ -222,12 +313,8 @@ TEST(Variant, RelaxedGreater) { EXPECT_FALSE(util::relaxed_greater(int64_t(387), double(388.7))); EXPECT_FALSE(util::relaxed_greater(double(387), double(388.7))); EXPECT_FALSE(util::relaxed_greater(bool(true), double(388))); - - EXPECT_FALSE(util::relaxed_greater(std::string("387"), bool(true))); - EXPECT_FALSE(util::relaxed_greater(uint64_t(387), bool(true))); - EXPECT_FALSE(util::relaxed_greater(int64_t(387), bool(true))); - EXPECT_FALSE(util::relaxed_greater(double(387), bool(true))); EXPECT_FALSE(util::relaxed_greater(bool(true), bool(true))); + EXPECT_FALSE(util::relaxed_greater(bool(false), bool(false))); } @@ -344,6 +431,11 @@ TEST(Variant, RelaxedLess) { EXPECT_TRUE(util::relaxed_less(double(0), bool(true))); EXPECT_TRUE(util::relaxed_less(bool(false), bool(true))); + EXPECT_TRUE(util::relaxed_less(bool(true), std::string("386"))); + EXPECT_TRUE(util::relaxed_less(bool(true), uint64_t(386))); + EXPECT_TRUE(util::relaxed_less(bool(true), int64_t(386))); + EXPECT_TRUE(util::relaxed_less(bool(true), double(386))); + @@ -351,31 +443,28 @@ TEST(Variant, RelaxedLess) { EXPECT_FALSE(util::relaxed_less(uint64_t(387), std::string("386"))); EXPECT_FALSE(util::relaxed_less(int64_t(387), std::string("386"))); EXPECT_FALSE(util::relaxed_less(double(387), std::string("386"))); - EXPECT_FALSE(util::relaxed_less(bool(true), std::string("386"))); EXPECT_FALSE(util::relaxed_less(std::string("387"), uint64_t(386))); EXPECT_FALSE(util::relaxed_less(uint64_t(387), uint64_t(386))); EXPECT_FALSE(util::relaxed_less(int64_t(387), uint64_t(386))); EXPECT_FALSE(util::relaxed_less(double(387), uint64_t(386))); - EXPECT_FALSE(util::relaxed_less(bool(true), uint64_t(386))); EXPECT_FALSE(util::relaxed_less(std::string("387"), int64_t(386))); EXPECT_FALSE(util::relaxed_less(uint64_t(387), int64_t(386))); EXPECT_FALSE(util::relaxed_less(int64_t(387), int64_t(386))); EXPECT_FALSE(util::relaxed_less(double(387), int64_t(386))); - EXPECT_FALSE(util::relaxed_less(bool(true), int64_t(386))); EXPECT_FALSE(util::relaxed_less(std::string("387"), double(386.7))); EXPECT_FALSE(util::relaxed_less(uint64_t(387), double(386.7))); EXPECT_FALSE(util::relaxed_less(int64_t(387), double(386.7))); EXPECT_FALSE(util::relaxed_less(double(387), double(386.7))); - EXPECT_FALSE(util::relaxed_less(bool(true), double(386))); EXPECT_FALSE(util::relaxed_less(std::string("387"), bool(true))); EXPECT_FALSE(util::relaxed_less(uint64_t(387), bool(true))); EXPECT_FALSE(util::relaxed_less(int64_t(387), bool(true))); EXPECT_FALSE(util::relaxed_less(double(387), bool(true))); EXPECT_FALSE(util::relaxed_less(bool(true), bool(true))); + EXPECT_FALSE(util::relaxed_less(bool(false), bool(false))); } |