mapbox-gl 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +61 -0
- package/CHANGELOG.md +2485 -0
- package/LICENSE.txt +84 -0
- package/README.md +34 -0
- package/build/banner.js +4 -0
- package/build/check-bundle-size.js +140 -0
- package/build/diff-tarball.js +18 -0
- package/build/generate-access-token-script.js +11 -0
- package/build/generate-flow-typed-style-spec.js +188 -0
- package/build/generate-release-list.js +21 -0
- package/build/generate-struct-arrays.js +243 -0
- package/build/generate-style-code.js +159 -0
- package/build/mapbox-gl.js.flow +3 -0
- package/build/print-release-url.js +6 -0
- package/build/rollup_plugin_minify_style_spec.js +24 -0
- package/build/rollup_plugins.js +80 -0
- package/build/run-node +3 -0
- package/build/run-tap +8 -0
- package/build/test/build-tape.js +19 -0
- package/dist/mapbox-gl-csp-worker.js +2 -0
- package/dist/mapbox-gl-csp-worker.js.map +1 -0
- package/dist/mapbox-gl-csp.js +2 -0
- package/dist/mapbox-gl-csp.js.map +1 -0
- package/dist/mapbox-gl-dev.js +65889 -0
- package/dist/mapbox-gl-dev.js.flow +3 -0
- package/dist/mapbox-gl-unminified.js +42889 -0
- package/dist/mapbox-gl-unminified.js.map +1 -0
- package/dist/mapbox-gl.css +1 -0
- package/dist/mapbox-gl.js +42 -0
- package/dist/mapbox-gl.js.flow +3 -0
- package/dist/mapbox-gl.js.map +1 -0
- package/dist/style-spec/index.es.js +15032 -0
- package/dist/style-spec/index.es.js.map +1 -0
- package/dist/style-spec/index.js +15058 -0
- package/dist/style-spec/index.js.map +1 -0
- package/flow-typed/gl.js +5 -0
- package/flow-typed/jsdom.js +18 -0
- package/flow-typed/mapbox-gl-supported.js +9 -0
- package/flow-typed/mapbox-unitbezier.js +14 -0
- package/flow-typed/offscreen-canvas.js +9 -0
- package/flow-typed/pbf.js +25 -0
- package/flow-typed/point-geometry.js +44 -0
- package/flow-typed/potpack.js +12 -0
- package/flow-typed/sinon.js +28 -0
- package/flow-typed/vector-tile.js +41 -0
- package/package.json +173 -0
- package/src/css/mapbox-gl.css +812 -0
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-compass.svg +4 -0
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +5 -0
- package/src/css/svg/mapboxgl-ctrl-logo.svg +20 -0
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +3 -0
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +3 -0
- package/src/data/array_types.js +1135 -0
- package/src/data/bucket/circle_attributes.js +9 -0
- package/src/data/bucket/circle_bucket.js +201 -0
- package/src/data/bucket/fill_attributes.js +9 -0
- package/src/data/bucket/fill_bucket.js +229 -0
- package/src/data/bucket/fill_extrusion_attributes.js +10 -0
- package/src/data/bucket/fill_extrusion_bucket.js +283 -0
- package/src/data/bucket/heatmap_bucket.js +17 -0
- package/src/data/bucket/line_attributes.js +10 -0
- package/src/data/bucket/line_attributes_ext.js +10 -0
- package/src/data/bucket/line_bucket.js +594 -0
- package/src/data/bucket/pattern_attributes.js +12 -0
- package/src/data/bucket/pattern_bucket_features.js +60 -0
- package/src/data/bucket/symbol_attributes.js +117 -0
- package/src/data/bucket/symbol_bucket.js +937 -0
- package/src/data/bucket.js +123 -0
- package/src/data/dem_data.js +125 -0
- package/src/data/evaluation_feature.js +25 -0
- package/src/data/extent.js +18 -0
- package/src/data/feature_index.js +322 -0
- package/src/data/feature_position_map.js +131 -0
- package/src/data/index_array_type.js +16 -0
- package/src/data/load_geometry.js +46 -0
- package/src/data/pos_attributes.js +6 -0
- package/src/data/program_configuration.js +708 -0
- package/src/data/raster_bounds_attributes.js +7 -0
- package/src/data/segment.js +76 -0
- package/src/geo/edge_insets.js +102 -0
- package/src/geo/lng_lat.js +168 -0
- package/src/geo/lng_lat_bounds.js +276 -0
- package/src/geo/mercator_coordinate.js +150 -0
- package/src/geo/transform.js +834 -0
- package/src/gl/color_mode.js +34 -0
- package/src/gl/context.js +302 -0
- package/src/gl/cull_face_mode.js +26 -0
- package/src/gl/depth_mode.js +29 -0
- package/src/gl/framebuffer.js +44 -0
- package/src/gl/index_buffer.js +55 -0
- package/src/gl/stencil_mode.js +30 -0
- package/src/gl/types.js +84 -0
- package/src/gl/value.js +520 -0
- package/src/gl/vertex_buffer.js +119 -0
- package/src/index.js +230 -0
- package/src/render/draw_background.js +57 -0
- package/src/render/draw_circle.js +113 -0
- package/src/render/draw_collision_debug.js +172 -0
- package/src/render/draw_custom.js +49 -0
- package/src/render/draw_debug.js +127 -0
- package/src/render/draw_fill.js +124 -0
- package/src/render/draw_fill_extrusion.js +95 -0
- package/src/render/draw_heatmap.js +133 -0
- package/src/render/draw_hillshade.js +107 -0
- package/src/render/draw_line.js +125 -0
- package/src/render/draw_raster.js +125 -0
- package/src/render/draw_symbol.js +392 -0
- package/src/render/glyph_atlas.js +71 -0
- package/src/render/glyph_manager.js +182 -0
- package/src/render/image_atlas.js +149 -0
- package/src/render/image_manager.js +306 -0
- package/src/render/line_atlas.js +210 -0
- package/src/render/painter.js +654 -0
- package/src/render/program/background_program.js +103 -0
- package/src/render/program/circle_program.js +69 -0
- package/src/render/program/clipping_mask_program.js +20 -0
- package/src/render/program/collision_program.js +76 -0
- package/src/render/program/debug_program.js +35 -0
- package/src/render/program/fill_extrusion_program.js +122 -0
- package/src/render/program/fill_program.js +126 -0
- package/src/render/program/heatmap_program.js +83 -0
- package/src/render/program/hillshade_program.js +119 -0
- package/src/render/program/line_program.js +211 -0
- package/src/render/program/pattern.js +102 -0
- package/src/render/program/program_uniforms.js +42 -0
- package/src/render/program/raster_program.js +92 -0
- package/src/render/program/symbol_program.js +224 -0
- package/src/render/program.js +188 -0
- package/src/render/texture.js +122 -0
- package/src/render/uniform_binding.js +147 -0
- package/src/render/vertex_array_object.js +163 -0
- package/src/shaders/README.md +42 -0
- package/src/shaders/_prelude.fragment.glsl +17 -0
- package/src/shaders/_prelude.vertex.glsl +73 -0
- package/src/shaders/background.fragment.glsl +10 -0
- package/src/shaders/background.vertex.glsl +7 -0
- package/src/shaders/background_pattern.fragment.glsl +28 -0
- package/src/shaders/background_pattern.vertex.glsl +20 -0
- package/src/shaders/circle.fragment.glsl +39 -0
- package/src/shaders/circle.vertex.glsl +64 -0
- package/src/shaders/clipping_mask.fragment.glsl +3 -0
- package/src/shaders/clipping_mask.vertex.glsl +7 -0
- package/src/shaders/collision_box.fragment.glsl +21 -0
- package/src/shaders/collision_box.vertex.glsl +27 -0
- package/src/shaders/collision_circle.fragment.glsl +17 -0
- package/src/shaders/collision_circle.vertex.glsl +59 -0
- package/src/shaders/debug.fragment.glsl +9 -0
- package/src/shaders/debug.vertex.glsl +12 -0
- package/src/shaders/encode_attribute.js +17 -0
- package/src/shaders/fill.fragment.glsl +13 -0
- package/src/shaders/fill.vertex.glsl +13 -0
- package/src/shaders/fill_extrusion.fragment.glsl +9 -0
- package/src/shaders/fill_extrusion.vertex.glsl +66 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +45 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +79 -0
- package/src/shaders/fill_outline.fragment.glsl +17 -0
- package/src/shaders/fill_outline.vertex.glsl +17 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl +43 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl +44 -0
- package/src/shaders/fill_pattern.fragment.glsl +36 -0
- package/src/shaders/fill_pattern.vertex.glsl +39 -0
- package/src/shaders/heatmap.fragment.glsl +22 -0
- package/src/shaders/heatmap.vertex.glsl +54 -0
- package/src/shaders/heatmap_texture.fragment.glsl +14 -0
- package/src/shaders/heatmap_texture.vertex.glsl +11 -0
- package/src/shaders/hillshade.fragment.glsl +52 -0
- package/src/shaders/hillshade.vertex.glsl +11 -0
- package/src/shaders/hillshade_prepare.fragment.glsl +75 -0
- package/src/shaders/hillshade_prepare.vertex.glsl +15 -0
- package/src/shaders/index.js +20 -0
- package/src/shaders/line.fragment.glsl +30 -0
- package/src/shaders/line.vertex.glsl +85 -0
- package/src/shaders/line_gradient.fragment.glsl +34 -0
- package/src/shaders/line_gradient.vertex.glsl +88 -0
- package/src/shaders/line_pattern.fragment.glsl +74 -0
- package/src/shaders/line_pattern.vertex.glsl +99 -0
- package/src/shaders/line_sdf.fragment.glsl +45 -0
- package/src/shaders/line_sdf.vertex.glsl +98 -0
- package/src/shaders/raster.fragment.glsl +52 -0
- package/src/shaders/raster.vertex.glsl +21 -0
- package/src/shaders/shaders.js +185 -0
- package/src/shaders/symbol_icon.fragment.glsl +17 -0
- package/src/shaders/symbol_icon.vertex.glsl +94 -0
- package/src/shaders/symbol_sdf.fragment.glsl +52 -0
- package/src/shaders/symbol_sdf.vertex.glsl +115 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl +68 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl +116 -0
- package/src/source/canvas_source.js +238 -0
- package/src/source/geojson_source.js +370 -0
- package/src/source/geojson_worker_source.js +366 -0
- package/src/source/geojson_wrapper.js +94 -0
- package/src/source/image_source.js +307 -0
- package/src/source/load_tilejson.js +39 -0
- package/src/source/pixels_to_tile_units.js +21 -0
- package/src/source/query_features.js +208 -0
- package/src/source/raster_dem_tile_source.js +138 -0
- package/src/source/raster_dem_tile_worker_source.js +62 -0
- package/src/source/raster_tile_source.js +169 -0
- package/src/source/rtl_text_plugin.js +143 -0
- package/src/source/source.js +137 -0
- package/src/source/source_cache.js +953 -0
- package/src/source/source_state.js +159 -0
- package/src/source/tile.js +458 -0
- package/src/source/tile_bounds.js +38 -0
- package/src/source/tile_cache.js +212 -0
- package/src/source/tile_id.js +199 -0
- package/src/source/vector_tile_source.js +259 -0
- package/src/source/vector_tile_worker_source.js +216 -0
- package/src/source/video_source.js +203 -0
- package/src/source/worker.js +240 -0
- package/src/source/worker_source.js +107 -0
- package/src/source/worker_tile.js +224 -0
- package/src/style/create_style_layer.js +36 -0
- package/src/style/evaluation_parameters.js +62 -0
- package/src/style/format_section_override.js +56 -0
- package/src/style/light.js +130 -0
- package/src/style/load_glyph_range.js +38 -0
- package/src/style/load_sprite.js +67 -0
- package/src/style/parse_glyph_pbf.js +44 -0
- package/src/style/pauseable_placement.js +132 -0
- package/src/style/properties.js +753 -0
- package/src/style/query_utils.js +43 -0
- package/src/style/style.js +1374 -0
- package/src/style/style_glyph.js +17 -0
- package/src/style/style_image.js +137 -0
- package/src/style/style_layer/background_style_layer.js +21 -0
- package/src/style/style_layer/background_style_layer_properties.js +40 -0
- package/src/style/style_layer/circle_style_layer.js +98 -0
- package/src/style/style_layer/circle_style_layer_properties.js +63 -0
- package/src/style/style_layer/custom_style_layer.js +223 -0
- package/src/style/style_layer/fill_extrusion_style_layer.js +224 -0
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +50 -0
- package/src/style/style_layer/fill_style_layer.js +67 -0
- package/src/style/style_layer/fill_style_layer_properties.js +55 -0
- package/src/style/style_layer/heatmap_style_layer.js +73 -0
- package/src/style/style_layer/heatmap_style_layer_properties.js +44 -0
- package/src/style/style_layer/hillshade_style_layer.js +25 -0
- package/src/style/style_layer/hillshade_style_layer_properties.js +46 -0
- package/src/style/style_layer/layer_properties.js.ejs +69 -0
- package/src/style/style_layer/line_style_layer.js +150 -0
- package/src/style/style_layer/line_style_layer_properties.js +71 -0
- package/src/style/style_layer/raster_style_layer.js +21 -0
- package/src/style/style_layer/raster_style_layer_properties.js +50 -0
- package/src/style/style_layer/symbol_style_layer.js +190 -0
- package/src/style/style_layer/symbol_style_layer_properties.js +153 -0
- package/src/style/style_layer/typed_style_layer.js +17 -0
- package/src/style/style_layer.js +283 -0
- package/src/style/style_layer_index.js +80 -0
- package/src/style/validate_style.js +42 -0
- package/src/style/zoom_history.js +44 -0
- package/src/style-spec/.eslintrc +5 -0
- package/src/style-spec/CHANGELOG.md +468 -0
- package/src/style-spec/README.md +59 -0
- package/src/style-spec/bin/gl-style-composite +9 -0
- package/src/style-spec/bin/gl-style-format +22 -0
- package/src/style-spec/bin/gl-style-migrate +9 -0
- package/src/style-spec/bin/gl-style-validate +50 -0
- package/src/style-spec/composite.js +50 -0
- package/src/style-spec/declass.js +42 -0
- package/src/style-spec/deref.js +52 -0
- package/src/style-spec/diff.js +393 -0
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/dist/index.es.js +15032 -0
- package/src/style-spec/dist/index.es.js.map +1 -0
- package/src/style-spec/dist/index.js +15058 -0
- package/src/style-spec/dist/index.js.map +1 -0
- package/src/style-spec/empty.js +29 -0
- package/src/style-spec/error/parsing_error.js +16 -0
- package/src/style-spec/error/validation_error.js +18 -0
- package/src/style-spec/expression/compound_expression.js +162 -0
- package/src/style-spec/expression/definitions/assertion.js +130 -0
- package/src/style-spec/expression/definitions/at.js +70 -0
- package/src/style-spec/expression/definitions/case.js +85 -0
- package/src/style-spec/expression/definitions/coalesce.js +93 -0
- package/src/style-spec/expression/definitions/coercion.js +133 -0
- package/src/style-spec/expression/definitions/collator.js +78 -0
- package/src/style-spec/expression/definitions/comparison.js +184 -0
- package/src/style-spec/expression/definitions/format.js +144 -0
- package/src/style-spec/expression/definitions/image.js +52 -0
- package/src/style-spec/expression/definitions/in.js +72 -0
- package/src/style-spec/expression/definitions/index.js +565 -0
- package/src/style-spec/expression/definitions/index_of.js +89 -0
- package/src/style-spec/expression/definitions/interpolate.js +267 -0
- package/src/style-spec/expression/definitions/length.js +61 -0
- package/src/style-spec/expression/definitions/let.js +72 -0
- package/src/style-spec/expression/definitions/literal.js +77 -0
- package/src/style-spec/expression/definitions/match.js +158 -0
- package/src/style-spec/expression/definitions/number_format.js +142 -0
- package/src/style-spec/expression/definitions/slice.js +86 -0
- package/src/style-spec/expression/definitions/step.js +120 -0
- package/src/style-spec/expression/definitions/var.js +46 -0
- package/src/style-spec/expression/definitions/within.js +342 -0
- package/src/style-spec/expression/evaluation_context.js +59 -0
- package/src/style-spec/expression/expression.js +27 -0
- package/src/style-spec/expression/index.js +392 -0
- package/src/style-spec/expression/is_constant.js +59 -0
- package/src/style-spec/expression/parsing_context.js +233 -0
- package/src/style-spec/expression/parsing_error.js +13 -0
- package/src/style-spec/expression/runtime_error.js +17 -0
- package/src/style-spec/expression/scope.js +36 -0
- package/src/style-spec/expression/stops.js +39 -0
- package/src/style-spec/expression/types/collator.js +61 -0
- package/src/style-spec/expression/types/formatted.js +73 -0
- package/src/style-spec/expression/types/resolved_image.js +29 -0
- package/src/style-spec/expression/types.js +126 -0
- package/src/style-spec/expression/values.js +123 -0
- package/src/style-spec/feature_filter/README.md +55 -0
- package/src/style-spec/feature_filter/convert.js +208 -0
- package/src/style-spec/feature_filter/index.js +175 -0
- package/src/style-spec/format.js +51 -0
- package/src/style-spec/function/convert.js +270 -0
- package/src/style-spec/function/index.js +262 -0
- package/src/style-spec/group_by_layout.js +75 -0
- package/src/style-spec/migrate/expressions.js +39 -0
- package/src/style-spec/migrate/v8.js +203 -0
- package/src/style-spec/migrate/v9.js +26 -0
- package/src/style-spec/migrate.js +36 -0
- package/src/style-spec/package.json +41 -0
- package/src/style-spec/read_style.js +14 -0
- package/src/style-spec/reference/latest.js +3 -0
- package/src/style-spec/reference/v8.json +5914 -0
- package/src/style-spec/rollup.config.js +65 -0
- package/src/style-spec/style-spec.js +124 -0
- package/src/style-spec/types.js +432 -0
- package/src/style-spec/util/color.js +95 -0
- package/src/style-spec/util/color_spaces.js +139 -0
- package/src/style-spec/util/deep_equal.js +28 -0
- package/src/style-spec/util/extend.js +10 -0
- package/src/style-spec/util/get_type.js +17 -0
- package/src/style-spec/util/interpolate.js +22 -0
- package/src/style-spec/util/properties.js +15 -0
- package/src/style-spec/util/ref_properties.js +2 -0
- package/src/style-spec/util/result.js +19 -0
- package/src/style-spec/util/unbundle_jsonlint.js +24 -0
- package/src/style-spec/validate/latest.js +11 -0
- package/src/style-spec/validate/validate.js +75 -0
- package/src/style-spec/validate/validate_array.js +52 -0
- package/src/style-spec/validate/validate_boolean.js +15 -0
- package/src/style-spec/validate/validate_color.js +20 -0
- package/src/style-spec/validate/validate_constants.js +13 -0
- package/src/style-spec/validate/validate_enum.js +21 -0
- package/src/style-spec/validate/validate_expression.js +43 -0
- package/src/style-spec/validate/validate_filter.js +117 -0
- package/src/style-spec/validate/validate_formatted.js +11 -0
- package/src/style-spec/validate/validate_function.js +207 -0
- package/src/style-spec/validate/validate_glyphs_url.js +21 -0
- package/src/style-spec/validate/validate_image.js +11 -0
- package/src/style-spec/validate/validate_layer.js +134 -0
- package/src/style-spec/validate/validate_layout_property.js +6 -0
- package/src/style-spec/validate/validate_light.js +47 -0
- package/src/style-spec/validate/validate_number.js +29 -0
- package/src/style-spec/validate/validate_object.js +61 -0
- package/src/style-spec/validate/validate_paint_property.js +6 -0
- package/src/style-spec/validate/validate_property.js +64 -0
- package/src/style-spec/validate/validate_source.js +111 -0
- package/src/style-spec/validate/validate_string.js +15 -0
- package/src/style-spec/validate_mapbox_api_supported.js +171 -0
- package/src/style-spec/validate_style.js +39 -0
- package/src/style-spec/validate_style.min.js +78 -0
- package/src/style-spec/visit.js +77 -0
- package/src/symbol/anchor.js +26 -0
- package/src/symbol/check_max_angle.js +81 -0
- package/src/symbol/clip_line.js +71 -0
- package/src/symbol/collision_feature.js +109 -0
- package/src/symbol/collision_index.js +373 -0
- package/src/symbol/cross_tile_symbol_index.js +301 -0
- package/src/symbol/get_anchors.js +167 -0
- package/src/symbol/grid_index.js +335 -0
- package/src/symbol/mergelines.js +82 -0
- package/src/symbol/one_em.js +4 -0
- package/src/symbol/opacity_state.js +27 -0
- package/src/symbol/path_interpolator.js +61 -0
- package/src/symbol/placement.js +1124 -0
- package/src/symbol/projection.js +451 -0
- package/src/symbol/quads.js +334 -0
- package/src/symbol/shaping.js +816 -0
- package/src/symbol/symbol_layout.js +796 -0
- package/src/symbol/symbol_size.js +113 -0
- package/src/symbol/transform_text.js +29 -0
- package/src/types/callback.js +17 -0
- package/src/types/cancelable.js +3 -0
- package/src/types/tilejson.js +17 -0
- package/src/types/transferable.js +3 -0
- package/src/types/window.js +172 -0
- package/src/ui/anchor.js +32 -0
- package/src/ui/camera.js +1277 -0
- package/src/ui/control/attribution_control.js +212 -0
- package/src/ui/control/fullscreen_control.js +147 -0
- package/src/ui/control/geolocate_control.js +707 -0
- package/src/ui/control/logo_control.js +92 -0
- package/src/ui/control/navigation_control.js +257 -0
- package/src/ui/control/scale_control.js +142 -0
- package/src/ui/default_locale.js +22 -0
- package/src/ui/events.js +1301 -0
- package/src/ui/handler/box_zoom.js +170 -0
- package/src/ui/handler/click_zoom.js +52 -0
- package/src/ui/handler/handler_util.js +12 -0
- package/src/ui/handler/keyboard.js +208 -0
- package/src/ui/handler/map_event.js +156 -0
- package/src/ui/handler/mouse.js +171 -0
- package/src/ui/handler/scroll_zoom.js +350 -0
- package/src/ui/handler/shim/dblclick_zoom.js +62 -0
- package/src/ui/handler/shim/drag_pan.js +88 -0
- package/src/ui/handler/shim/drag_rotate.js +67 -0
- package/src/ui/handler/shim/touch_zoom_rotate.js +108 -0
- package/src/ui/handler/tap_drag_zoom.js +103 -0
- package/src/ui/handler/tap_recognizer.js +133 -0
- package/src/ui/handler/tap_zoom.js +93 -0
- package/src/ui/handler/touch_pan.js +101 -0
- package/src/ui/handler/touch_zoom_rotate.js +305 -0
- package/src/ui/handler_inertia.js +158 -0
- package/src/ui/handler_manager.js +531 -0
- package/src/ui/hash.js +148 -0
- package/src/ui/map.js +2874 -0
- package/src/ui/marker.js +672 -0
- package/src/ui/popup.js +640 -0
- package/src/util/actor.js +212 -0
- package/src/util/ajax.js +388 -0
- package/src/util/browser/web_worker.js +10 -0
- package/src/util/browser/window.js +6 -0
- package/src/util/browser.js +70 -0
- package/src/util/classify_rings.js +52 -0
- package/src/util/color_ramp.js +61 -0
- package/src/util/config.js +30 -0
- package/src/util/debug.js +28 -0
- package/src/util/dictionary_coder.js +30 -0
- package/src/util/dispatcher.js +70 -0
- package/src/util/dom.js +142 -0
- package/src/util/evented.js +174 -0
- package/src/util/find_pole_of_inaccessibility.js +129 -0
- package/src/util/global_worker_pool.js +35 -0
- package/src/util/image.js +142 -0
- package/src/util/intersection_tests.js +208 -0
- package/src/util/is_char_in_unicode_block.js +311 -0
- package/src/util/mapbox.js +491 -0
- package/src/util/offscreen_canvas_supported.js +14 -0
- package/src/util/performance.js +112 -0
- package/src/util/primitives.js +145 -0
- package/src/util/resolve_tokens.js +16 -0
- package/src/util/script_detection.js +328 -0
- package/src/util/sku_token.js +42 -0
- package/src/util/smart_wrap.js +55 -0
- package/src/util/struct_array.js +243 -0
- package/src/util/struct_array.js.ejs +112 -0
- package/src/util/struct_array_layout.js.ejs +98 -0
- package/src/util/task_queue.js +68 -0
- package/src/util/throttle.js +27 -0
- package/src/util/throttled_invoker.js +46 -0
- package/src/util/tile_request_cache.js +172 -0
- package/src/util/util.js +524 -0
- package/src/util/vectortile_to_geojson.js +50 -0
- package/src/util/verticalize_punctuation.js +114 -0
- package/src/util/web_worker.js +91 -0
- package/src/util/web_worker_transfer.js +266 -0
- package/src/util/webp_supported.js +69 -0
- package/src/util/window.js +102 -0
- package/src/util/worker_pool.js +57 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import DepthMode from '../gl/depth_mode';
|
|
4
|
+
import CullFaceMode from '../gl/cull_face_mode';
|
|
5
|
+
import Texture from './texture';
|
|
6
|
+
import {
|
|
7
|
+
lineUniformValues,
|
|
8
|
+
linePatternUniformValues,
|
|
9
|
+
lineSDFUniformValues,
|
|
10
|
+
lineGradientUniformValues
|
|
11
|
+
} from './program/line_program';
|
|
12
|
+
|
|
13
|
+
import type Painter from './painter';
|
|
14
|
+
import type SourceCache from '../source/source_cache';
|
|
15
|
+
import type LineStyleLayer from '../style/style_layer/line_style_layer';
|
|
16
|
+
import type LineBucket from '../data/bucket/line_bucket';
|
|
17
|
+
import type {OverscaledTileID} from '../source/tile_id';
|
|
18
|
+
import {clamp, nextPowerOfTwo} from '../util/util';
|
|
19
|
+
import {renderColorRamp} from '../util/color_ramp';
|
|
20
|
+
import EXTENT from '../data/extent';
|
|
21
|
+
|
|
22
|
+
export default function drawLine(painter: Painter, sourceCache: SourceCache, layer: LineStyleLayer, coords: Array<OverscaledTileID>) {
|
|
23
|
+
if (painter.renderPass !== 'translucent') return;
|
|
24
|
+
|
|
25
|
+
const opacity = layer.paint.get('line-opacity');
|
|
26
|
+
const width = layer.paint.get('line-width');
|
|
27
|
+
if (opacity.constantOr(1) === 0 || width.constantOr(1) === 0) return;
|
|
28
|
+
|
|
29
|
+
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
30
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
31
|
+
|
|
32
|
+
const dasharray = layer.paint.get('line-dasharray');
|
|
33
|
+
const patternProperty = layer.paint.get('line-pattern');
|
|
34
|
+
const image = patternProperty.constantOr((1: any));
|
|
35
|
+
|
|
36
|
+
const gradient = layer.paint.get('line-gradient');
|
|
37
|
+
const crossfade = layer.getCrossfadeParameters();
|
|
38
|
+
|
|
39
|
+
const programId =
|
|
40
|
+
image ? 'linePattern' :
|
|
41
|
+
dasharray ? 'lineSDF' :
|
|
42
|
+
gradient ? 'lineGradient' : 'line';
|
|
43
|
+
|
|
44
|
+
const context = painter.context;
|
|
45
|
+
const gl = context.gl;
|
|
46
|
+
|
|
47
|
+
let firstTile = true;
|
|
48
|
+
|
|
49
|
+
for (const coord of coords) {
|
|
50
|
+
const tile = sourceCache.getTile(coord);
|
|
51
|
+
|
|
52
|
+
if (image && !tile.patternsLoaded()) continue;
|
|
53
|
+
|
|
54
|
+
const bucket: ?LineBucket = (tile.getBucket(layer): any);
|
|
55
|
+
if (!bucket) continue;
|
|
56
|
+
|
|
57
|
+
const programConfiguration = bucket.programConfigurations.get(layer.id);
|
|
58
|
+
const prevProgram = painter.context.program.get();
|
|
59
|
+
const program = painter.useProgram(programId, programConfiguration);
|
|
60
|
+
const programChanged = firstTile || program.program !== prevProgram;
|
|
61
|
+
|
|
62
|
+
const constantPattern = patternProperty.constantOr(null);
|
|
63
|
+
if (constantPattern && tile.imageAtlas) {
|
|
64
|
+
const atlas = tile.imageAtlas;
|
|
65
|
+
const posTo = atlas.patternPositions[constantPattern.to.toString()];
|
|
66
|
+
const posFrom = atlas.patternPositions[constantPattern.from.toString()];
|
|
67
|
+
if (posTo && posFrom) programConfiguration.setConstantPatternPositions(posTo, posFrom);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const uniformValues = image ? linePatternUniformValues(painter, tile, layer, crossfade) :
|
|
71
|
+
dasharray ? lineSDFUniformValues(painter, tile, layer, dasharray, crossfade) :
|
|
72
|
+
gradient ? lineGradientUniformValues(painter, tile, layer, bucket.lineClipsArray.length) :
|
|
73
|
+
lineUniformValues(painter, tile, layer);
|
|
74
|
+
|
|
75
|
+
if (image) {
|
|
76
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
77
|
+
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
78
|
+
programConfiguration.updatePaintBuffers(crossfade);
|
|
79
|
+
} else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {
|
|
80
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
81
|
+
painter.lineAtlas.bind(context);
|
|
82
|
+
} else if (gradient) {
|
|
83
|
+
const layerGradient = bucket.gradients[layer.id];
|
|
84
|
+
let gradientTexture = layerGradient.texture;
|
|
85
|
+
if (layer.gradientVersion !== layerGradient.version) {
|
|
86
|
+
let textureResolution = 256;
|
|
87
|
+
if (layer.stepInterpolant) {
|
|
88
|
+
const sourceMaxZoom = sourceCache.getSource().maxzoom;
|
|
89
|
+
const potentialOverzoom = coord.canonical.z === sourceMaxZoom ?
|
|
90
|
+
Math.ceil(1 << (painter.transform.maxZoom - coord.canonical.z)) : 1;
|
|
91
|
+
const lineLength = bucket.maxLineLength / EXTENT;
|
|
92
|
+
// Logical pixel tile size is 512px, and 1024px right before current zoom + 1
|
|
93
|
+
const maxTilePixelSize = 1024;
|
|
94
|
+
// Maximum possible texture coverage heuristic, bound by hardware max texture size
|
|
95
|
+
const maxTextureCoverage = lineLength * maxTilePixelSize * potentialOverzoom;
|
|
96
|
+
textureResolution = clamp(nextPowerOfTwo(maxTextureCoverage), 256, context.maxTextureSize);
|
|
97
|
+
}
|
|
98
|
+
layerGradient.gradient = renderColorRamp({
|
|
99
|
+
expression: layer.gradientExpression(),
|
|
100
|
+
evaluationKey: 'lineProgress',
|
|
101
|
+
resolution: textureResolution,
|
|
102
|
+
image: layerGradient.gradient || undefined,
|
|
103
|
+
clips: bucket.lineClipsArray
|
|
104
|
+
});
|
|
105
|
+
if (layerGradient.texture) {
|
|
106
|
+
layerGradient.texture.update(layerGradient.gradient);
|
|
107
|
+
} else {
|
|
108
|
+
layerGradient.texture = new Texture(context, layerGradient.gradient, gl.RGBA);
|
|
109
|
+
}
|
|
110
|
+
layerGradient.version = layer.gradientVersion;
|
|
111
|
+
gradientTexture = layerGradient.texture;
|
|
112
|
+
}
|
|
113
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
114
|
+
gradientTexture.bind(layer.stepInterpolant ? gl.NEAREST : gl.LINEAR, gl.CLAMP_TO_EDGE);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
program.draw(context, gl.TRIANGLES, depthMode,
|
|
118
|
+
painter.stencilModeForClipping(coord), colorMode, CullFaceMode.disabled, uniformValues,
|
|
119
|
+
layer.id, bucket.layoutVertexBuffer, bucket.indexBuffer, bucket.segments,
|
|
120
|
+
layer.paint, painter.transform.zoom, programConfiguration, bucket.layoutVertexBuffer2);
|
|
121
|
+
|
|
122
|
+
firstTile = false;
|
|
123
|
+
// once refactored so that bound texture state is managed, we'll also be able to remove this firstTile/programChanged logic
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import {clamp} from '../util/util';
|
|
4
|
+
|
|
5
|
+
import ImageSource from '../source/image_source';
|
|
6
|
+
import browser from '../util/browser';
|
|
7
|
+
import StencilMode from '../gl/stencil_mode';
|
|
8
|
+
import DepthMode from '../gl/depth_mode';
|
|
9
|
+
import CullFaceMode from '../gl/cull_face_mode';
|
|
10
|
+
import {rasterUniformValues} from './program/raster_program';
|
|
11
|
+
|
|
12
|
+
import type Painter from './painter';
|
|
13
|
+
import type SourceCache from '../source/source_cache';
|
|
14
|
+
import type RasterStyleLayer from '../style/style_layer/raster_style_layer';
|
|
15
|
+
import type {OverscaledTileID} from '../source/tile_id';
|
|
16
|
+
|
|
17
|
+
export default drawRaster;
|
|
18
|
+
|
|
19
|
+
function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterStyleLayer, tileIDs: Array<OverscaledTileID>) {
|
|
20
|
+
if (painter.renderPass !== 'translucent') return;
|
|
21
|
+
if (layer.paint.get('raster-opacity') === 0) return;
|
|
22
|
+
if (!tileIDs.length) return;
|
|
23
|
+
|
|
24
|
+
const context = painter.context;
|
|
25
|
+
const gl = context.gl;
|
|
26
|
+
const source = sourceCache.getSource();
|
|
27
|
+
const program = painter.useProgram('raster');
|
|
28
|
+
|
|
29
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
30
|
+
|
|
31
|
+
const [stencilModes, coords] = source instanceof ImageSource ? [{}, tileIDs] :
|
|
32
|
+
painter.stencilConfigForOverlap(tileIDs);
|
|
33
|
+
|
|
34
|
+
const minTileZ = coords[coords.length - 1].overscaledZ;
|
|
35
|
+
|
|
36
|
+
const align = !painter.options.moving;
|
|
37
|
+
for (const coord of coords) {
|
|
38
|
+
// Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers
|
|
39
|
+
// Use gl.LESS to prevent double drawing in areas where tiles overlap.
|
|
40
|
+
const depthMode = painter.depthModeForSublayer(coord.overscaledZ - minTileZ,
|
|
41
|
+
layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);
|
|
42
|
+
|
|
43
|
+
const tile = sourceCache.getTile(coord);
|
|
44
|
+
const posMatrix = painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);
|
|
45
|
+
|
|
46
|
+
tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));
|
|
47
|
+
|
|
48
|
+
const parentTile = sourceCache.findLoadedParent(coord, 0),
|
|
49
|
+
fade = getFadeValues(tile, parentTile, sourceCache, layer, painter.transform);
|
|
50
|
+
|
|
51
|
+
let parentScaleBy, parentTL;
|
|
52
|
+
|
|
53
|
+
const textureFilter = layer.paint.get('raster-resampling') === 'nearest' ? gl.NEAREST : gl.LINEAR;
|
|
54
|
+
|
|
55
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
56
|
+
tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
57
|
+
|
|
58
|
+
context.activeTexture.set(gl.TEXTURE1);
|
|
59
|
+
|
|
60
|
+
if (parentTile) {
|
|
61
|
+
parentTile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
62
|
+
parentScaleBy = Math.pow(2, parentTile.tileID.overscaledZ - tile.tileID.overscaledZ);
|
|
63
|
+
parentTL = [tile.tileID.canonical.x * parentScaleBy % 1, tile.tileID.canonical.y * parentScaleBy % 1];
|
|
64
|
+
|
|
65
|
+
} else {
|
|
66
|
+
tile.texture.bind(textureFilter, gl.CLAMP_TO_EDGE, gl.LINEAR_MIPMAP_NEAREST);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const uniformValues = rasterUniformValues(posMatrix, parentTL || [0, 0], parentScaleBy || 1, fade, layer);
|
|
70
|
+
|
|
71
|
+
if (source instanceof ImageSource) {
|
|
72
|
+
program.draw(context, gl.TRIANGLES, depthMode, StencilMode.disabled, colorMode, CullFaceMode.disabled,
|
|
73
|
+
uniformValues, layer.id, source.boundsBuffer,
|
|
74
|
+
painter.quadTriangleIndexBuffer, source.boundsSegments);
|
|
75
|
+
} else {
|
|
76
|
+
program.draw(context, gl.TRIANGLES, depthMode, stencilModes[coord.overscaledZ], colorMode, CullFaceMode.disabled,
|
|
77
|
+
uniformValues, layer.id, painter.rasterBoundsBuffer,
|
|
78
|
+
painter.quadTriangleIndexBuffer, painter.rasterBoundsSegments);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getFadeValues(tile, parentTile, sourceCache, layer, transform) {
|
|
84
|
+
const fadeDuration = layer.paint.get('raster-fade-duration');
|
|
85
|
+
|
|
86
|
+
if (fadeDuration > 0) {
|
|
87
|
+
const now = browser.now();
|
|
88
|
+
const sinceTile = (now - tile.timeAdded) / fadeDuration;
|
|
89
|
+
const sinceParent = parentTile ? (now - parentTile.timeAdded) / fadeDuration : -1;
|
|
90
|
+
|
|
91
|
+
const source = sourceCache.getSource();
|
|
92
|
+
const idealZ = transform.coveringZoomLevel({
|
|
93
|
+
tileSize: source.tileSize,
|
|
94
|
+
roundZoom: source.roundZoom
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// if no parent or parent is older, fade in; if parent is younger, fade out
|
|
98
|
+
const fadeIn = !parentTile || Math.abs(parentTile.tileID.overscaledZ - idealZ) > Math.abs(tile.tileID.overscaledZ - idealZ);
|
|
99
|
+
|
|
100
|
+
const childOpacity = (fadeIn && tile.refreshedUponExpiration) ? 1 : clamp(fadeIn ? sinceTile : 1 - sinceParent, 0, 1);
|
|
101
|
+
|
|
102
|
+
// we don't crossfade tiles that were just refreshed upon expiring:
|
|
103
|
+
// once they're old enough to pass the crossfading threshold
|
|
104
|
+
// (fadeDuration), unset the `refreshedUponExpiration` flag so we don't
|
|
105
|
+
// incorrectly fail to crossfade them when zooming
|
|
106
|
+
if (tile.refreshedUponExpiration && sinceTile >= 1) tile.refreshedUponExpiration = false;
|
|
107
|
+
|
|
108
|
+
if (parentTile) {
|
|
109
|
+
return {
|
|
110
|
+
opacity: 1,
|
|
111
|
+
mix: 1 - childOpacity
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
return {
|
|
115
|
+
opacity: childOpacity,
|
|
116
|
+
mix: 0
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
return {
|
|
121
|
+
opacity: 1,
|
|
122
|
+
mix: 0
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
import Point from '@mapbox/point-geometry';
|
|
4
|
+
import drawCollisionDebug from './draw_collision_debug';
|
|
5
|
+
|
|
6
|
+
import SegmentVector from '../data/segment';
|
|
7
|
+
import pixelsToTileUnits from '../source/pixels_to_tile_units';
|
|
8
|
+
import * as symbolProjection from '../symbol/projection';
|
|
9
|
+
import * as symbolSize from '../symbol/symbol_size';
|
|
10
|
+
import {mat4} from 'gl-matrix';
|
|
11
|
+
const identityMat4 = mat4.identity(new Float32Array(16));
|
|
12
|
+
import StencilMode from '../gl/stencil_mode';
|
|
13
|
+
import DepthMode from '../gl/depth_mode';
|
|
14
|
+
import CullFaceMode from '../gl/cull_face_mode';
|
|
15
|
+
import {addDynamicAttributes} from '../data/bucket/symbol_bucket';
|
|
16
|
+
|
|
17
|
+
import {getAnchorAlignment, WritingMode} from '../symbol/shaping';
|
|
18
|
+
import ONE_EM from '../symbol/one_em';
|
|
19
|
+
import {evaluateVariableOffset} from '../symbol/symbol_layout';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
symbolIconUniformValues,
|
|
23
|
+
symbolSDFUniformValues,
|
|
24
|
+
symbolTextAndIconUniformValues
|
|
25
|
+
} from './program/symbol_program';
|
|
26
|
+
|
|
27
|
+
import type Painter from './painter';
|
|
28
|
+
import type SourceCache from '../source/source_cache';
|
|
29
|
+
import type SymbolStyleLayer from '../style/style_layer/symbol_style_layer';
|
|
30
|
+
import type SymbolBucket, {SymbolBuffers} from '../data/bucket/symbol_bucket';
|
|
31
|
+
import type Texture from '../render/texture';
|
|
32
|
+
import type {OverscaledTileID} from '../source/tile_id';
|
|
33
|
+
import type {UniformValues} from './uniform_binding';
|
|
34
|
+
import type {SymbolSDFUniformsType} from '../render/program/symbol_program';
|
|
35
|
+
import type {CrossTileID, VariableOffset} from '../symbol/placement';
|
|
36
|
+
|
|
37
|
+
export default drawSymbols;
|
|
38
|
+
|
|
39
|
+
type SymbolTileRenderState = {
|
|
40
|
+
segments: SegmentVector,
|
|
41
|
+
sortKey: number,
|
|
42
|
+
state: {
|
|
43
|
+
program: any,
|
|
44
|
+
buffers: SymbolBuffers,
|
|
45
|
+
uniformValues: any,
|
|
46
|
+
atlasTexture: Texture,
|
|
47
|
+
atlasTextureIcon: Texture | null,
|
|
48
|
+
atlasInterpolation: any,
|
|
49
|
+
atlasInterpolationIcon: any,
|
|
50
|
+
isSDF: boolean,
|
|
51
|
+
hasHalo: boolean
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: SymbolStyleLayer, coords: Array<OverscaledTileID>, variableOffsets: {[_: CrossTileID]: VariableOffset}) {
|
|
56
|
+
if (painter.renderPass !== 'translucent') return;
|
|
57
|
+
|
|
58
|
+
// Disable the stencil test so that labels aren't clipped to tile boundaries.
|
|
59
|
+
const stencilMode = StencilMode.disabled;
|
|
60
|
+
const colorMode = painter.colorModeForRenderPass();
|
|
61
|
+
const variablePlacement = layer.layout.get('text-variable-anchor');
|
|
62
|
+
|
|
63
|
+
//Compute variable-offsets before painting since icons and text data positioning
|
|
64
|
+
//depend on each other in this case.
|
|
65
|
+
if (variablePlacement) {
|
|
66
|
+
updateVariableAnchors(coords, painter, layer, sourceCache,
|
|
67
|
+
layer.layout.get('text-rotation-alignment'),
|
|
68
|
+
layer.layout.get('text-pitch-alignment'),
|
|
69
|
+
variableOffsets
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (layer.paint.get('icon-opacity').constantOr(1) !== 0) {
|
|
74
|
+
drawLayerSymbols(painter, sourceCache, layer, coords, false,
|
|
75
|
+
layer.paint.get('icon-translate'),
|
|
76
|
+
layer.paint.get('icon-translate-anchor'),
|
|
77
|
+
layer.layout.get('icon-rotation-alignment'),
|
|
78
|
+
layer.layout.get('icon-pitch-alignment'),
|
|
79
|
+
layer.layout.get('icon-keep-upright'),
|
|
80
|
+
stencilMode, colorMode
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (layer.paint.get('text-opacity').constantOr(1) !== 0) {
|
|
85
|
+
drawLayerSymbols(painter, sourceCache, layer, coords, true,
|
|
86
|
+
layer.paint.get('text-translate'),
|
|
87
|
+
layer.paint.get('text-translate-anchor'),
|
|
88
|
+
layer.layout.get('text-rotation-alignment'),
|
|
89
|
+
layer.layout.get('text-pitch-alignment'),
|
|
90
|
+
layer.layout.get('text-keep-upright'),
|
|
91
|
+
stencilMode, colorMode
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (sourceCache.map.showCollisionBoxes) {
|
|
96
|
+
drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('text-translate'),
|
|
97
|
+
layer.paint.get('text-translate-anchor'), true);
|
|
98
|
+
drawCollisionDebug(painter, sourceCache, layer, coords, layer.paint.get('icon-translate'),
|
|
99
|
+
layer.paint.get('icon-translate-anchor'), false);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function calculateVariableRenderShift(anchor, width, height, textOffset, textBoxScale, renderTextSize): Point {
|
|
104
|
+
const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);
|
|
105
|
+
const shiftX = -(horizontalAlign - 0.5) * width;
|
|
106
|
+
const shiftY = -(verticalAlign - 0.5) * height;
|
|
107
|
+
const variableOffset = evaluateVariableOffset(anchor, textOffset);
|
|
108
|
+
return new Point(
|
|
109
|
+
(shiftX / textBoxScale + variableOffset[0]) * renderTextSize,
|
|
110
|
+
(shiftY / textBoxScale + variableOffset[1]) * renderTextSize
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function updateVariableAnchors(coords, painter, layer, sourceCache, rotationAlignment, pitchAlignment, variableOffsets) {
|
|
115
|
+
const tr = painter.transform;
|
|
116
|
+
const rotateWithMap = rotationAlignment === 'map';
|
|
117
|
+
const pitchWithMap = pitchAlignment === 'map';
|
|
118
|
+
|
|
119
|
+
for (const coord of coords) {
|
|
120
|
+
const tile = sourceCache.getTile(coord);
|
|
121
|
+
const bucket: SymbolBucket = (tile.getBucket(layer): any);
|
|
122
|
+
if (!bucket || !bucket.text || !bucket.text.segments.get().length) continue;
|
|
123
|
+
|
|
124
|
+
const sizeData = bucket.textSizeData;
|
|
125
|
+
const size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom);
|
|
126
|
+
|
|
127
|
+
const pixelToTileScale = pixelsToTileUnits(tile, 1, painter.transform.zoom);
|
|
128
|
+
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, pixelToTileScale);
|
|
129
|
+
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' && bucket.hasIconData();
|
|
130
|
+
|
|
131
|
+
if (size) {
|
|
132
|
+
const tileScale = Math.pow(2, tr.zoom - tile.tileID.overscaledZ);
|
|
133
|
+
updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, symbolSize,
|
|
134
|
+
tr, labelPlaneMatrix, coord.posMatrix, tileScale, size, updateTextFitIcon);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function updateVariableAnchorsForBucket(bucket, rotateWithMap, pitchWithMap, variableOffsets, symbolSize,
|
|
140
|
+
transform, labelPlaneMatrix, posMatrix, tileScale, size, updateTextFitIcon) {
|
|
141
|
+
const placedSymbols = bucket.text.placedSymbolArray;
|
|
142
|
+
const dynamicTextLayoutVertexArray = bucket.text.dynamicLayoutVertexArray;
|
|
143
|
+
const dynamicIconLayoutVertexArray = bucket.icon.dynamicLayoutVertexArray;
|
|
144
|
+
const placedTextShifts = {};
|
|
145
|
+
|
|
146
|
+
dynamicTextLayoutVertexArray.clear();
|
|
147
|
+
for (let s = 0; s < placedSymbols.length; s++) {
|
|
148
|
+
const symbol: any = placedSymbols.get(s);
|
|
149
|
+
const skipOrientation = bucket.allowVerticalPlacement && !symbol.placedOrientation;
|
|
150
|
+
const variableOffset = (!symbol.hidden && symbol.crossTileID && !skipOrientation) ? variableOffsets[symbol.crossTileID] : null;
|
|
151
|
+
|
|
152
|
+
if (!variableOffset) {
|
|
153
|
+
// These symbols are from a justification that is not being used, or a label that wasn't placed
|
|
154
|
+
// so we don't need to do the extra math to figure out what incremental shift to apply.
|
|
155
|
+
symbolProjection.hideGlyphs(symbol.numGlyphs, dynamicTextLayoutVertexArray);
|
|
156
|
+
} else {
|
|
157
|
+
const tileAnchor = new Point(symbol.anchorX, symbol.anchorY);
|
|
158
|
+
const projectedAnchor = symbolProjection.project(tileAnchor, pitchWithMap ? posMatrix : labelPlaneMatrix);
|
|
159
|
+
const perspectiveRatio = symbolProjection.getPerspectiveRatio(transform.cameraToCenterDistance, projectedAnchor.signedDistanceFromCamera);
|
|
160
|
+
let renderTextSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, size, symbol) * perspectiveRatio / ONE_EM;
|
|
161
|
+
if (pitchWithMap) {
|
|
162
|
+
// Go from size in pixels to equivalent size in tile units
|
|
163
|
+
renderTextSize *= bucket.tilePixelRatio / tileScale;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const {width, height, anchor, textOffset, textBoxScale} = variableOffset;
|
|
167
|
+
|
|
168
|
+
const shift = calculateVariableRenderShift(
|
|
169
|
+
anchor, width, height, textOffset, textBoxScale, renderTextSize);
|
|
170
|
+
|
|
171
|
+
// Usual case is that we take the projected anchor and add the pixel-based shift
|
|
172
|
+
// calculated above. In the (somewhat weird) case of pitch-aligned text, we add an equivalent
|
|
173
|
+
// tile-unit based shift to the anchor before projecting to the label plane.
|
|
174
|
+
const shiftedAnchor = pitchWithMap ?
|
|
175
|
+
symbolProjection.project(tileAnchor.add(shift), labelPlaneMatrix).point :
|
|
176
|
+
projectedAnchor.point.add(rotateWithMap ?
|
|
177
|
+
shift.rotate(-transform.angle) :
|
|
178
|
+
shift);
|
|
179
|
+
|
|
180
|
+
const angle = (bucket.allowVerticalPlacement && symbol.placedOrientation === WritingMode.vertical) ? Math.PI / 2 : 0;
|
|
181
|
+
for (let g = 0; g < symbol.numGlyphs; g++) {
|
|
182
|
+
addDynamicAttributes(dynamicTextLayoutVertexArray, shiftedAnchor, angle);
|
|
183
|
+
}
|
|
184
|
+
//Only offset horizontal text icons
|
|
185
|
+
if (updateTextFitIcon && symbol.associatedIconIndex >= 0) {
|
|
186
|
+
placedTextShifts[symbol.associatedIconIndex] = {shiftedAnchor, angle};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (updateTextFitIcon) {
|
|
192
|
+
dynamicIconLayoutVertexArray.clear();
|
|
193
|
+
const placedIcons = bucket.icon.placedSymbolArray;
|
|
194
|
+
for (let i = 0; i < placedIcons.length; i++) {
|
|
195
|
+
const placedIcon = placedIcons.get(i);
|
|
196
|
+
if (placedIcon.hidden) {
|
|
197
|
+
symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);
|
|
198
|
+
} else {
|
|
199
|
+
const shift = placedTextShifts[i];
|
|
200
|
+
if (!shift) {
|
|
201
|
+
symbolProjection.hideGlyphs(placedIcon.numGlyphs, dynamicIconLayoutVertexArray);
|
|
202
|
+
} else {
|
|
203
|
+
for (let g = 0; g < placedIcon.numGlyphs; g++) {
|
|
204
|
+
addDynamicAttributes(dynamicIconLayoutVertexArray, shift.shiftedAnchor, shift.angle);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
bucket.icon.dynamicLayoutVertexBuffer.updateData(dynamicIconLayoutVertexArray);
|
|
210
|
+
}
|
|
211
|
+
bucket.text.dynamicLayoutVertexBuffer.updateData(dynamicTextLayoutVertexArray);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getSymbolProgramName(isSDF: boolean, isText: boolean, bucket: SymbolBucket) {
|
|
215
|
+
if (bucket.iconsInText && isText) {
|
|
216
|
+
return 'symbolTextAndIcon';
|
|
217
|
+
} else if (isSDF) {
|
|
218
|
+
return 'symbolSDF';
|
|
219
|
+
} else {
|
|
220
|
+
return 'symbolIcon';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function drawLayerSymbols(painter, sourceCache, layer, coords, isText, translate, translateAnchor,
|
|
225
|
+
rotationAlignment, pitchAlignment, keepUpright, stencilMode, colorMode) {
|
|
226
|
+
|
|
227
|
+
const context = painter.context;
|
|
228
|
+
const gl = context.gl;
|
|
229
|
+
const tr = painter.transform;
|
|
230
|
+
|
|
231
|
+
const rotateWithMap = rotationAlignment === 'map';
|
|
232
|
+
const pitchWithMap = pitchAlignment === 'map';
|
|
233
|
+
const alongLine = rotateWithMap && layer.layout.get('symbol-placement') !== 'point';
|
|
234
|
+
// Line label rotation happens in `updateLineLabels`
|
|
235
|
+
// Pitched point labels are automatically rotated by the labelPlaneMatrix projection
|
|
236
|
+
// Unpitched point labels need to have their rotation applied after projection
|
|
237
|
+
const rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;
|
|
238
|
+
|
|
239
|
+
const hasSortKey = layer.layout.get('symbol-sort-key').constantOr(1) !== undefined;
|
|
240
|
+
let sortFeaturesByKey = false;
|
|
241
|
+
|
|
242
|
+
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
243
|
+
|
|
244
|
+
const variablePlacement = layer.layout.get('text-variable-anchor');
|
|
245
|
+
|
|
246
|
+
const tileRenderState: Array<SymbolTileRenderState> = [];
|
|
247
|
+
|
|
248
|
+
for (const coord of coords) {
|
|
249
|
+
const tile = sourceCache.getTile(coord);
|
|
250
|
+
const bucket: SymbolBucket = (tile.getBucket(layer): any);
|
|
251
|
+
if (!bucket) continue;
|
|
252
|
+
const buffers = isText ? bucket.text : bucket.icon;
|
|
253
|
+
if (!buffers || !buffers.segments.get().length) continue;
|
|
254
|
+
const programConfiguration = buffers.programConfigurations.get(layer.id);
|
|
255
|
+
|
|
256
|
+
const isSDF = isText || bucket.sdfIcons;
|
|
257
|
+
|
|
258
|
+
const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;
|
|
259
|
+
const transformed = pitchWithMap || tr.pitch !== 0;
|
|
260
|
+
|
|
261
|
+
const program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);
|
|
262
|
+
const size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom);
|
|
263
|
+
|
|
264
|
+
let texSize: [number, number];
|
|
265
|
+
let texSizeIcon: [number, number] = [0, 0];
|
|
266
|
+
let atlasTexture;
|
|
267
|
+
let atlasInterpolation;
|
|
268
|
+
let atlasTextureIcon = null;
|
|
269
|
+
let atlasInterpolationIcon;
|
|
270
|
+
if (isText) {
|
|
271
|
+
atlasTexture = tile.glyphAtlasTexture;
|
|
272
|
+
atlasInterpolation = gl.LINEAR;
|
|
273
|
+
texSize = tile.glyphAtlasTexture.size;
|
|
274
|
+
if (bucket.iconsInText) {
|
|
275
|
+
texSizeIcon = tile.imageAtlasTexture.size;
|
|
276
|
+
atlasTextureIcon = tile.imageAtlasTexture;
|
|
277
|
+
const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';
|
|
278
|
+
atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;
|
|
282
|
+
atlasTexture = tile.imageAtlasTexture;
|
|
283
|
+
atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?
|
|
284
|
+
gl.LINEAR :
|
|
285
|
+
gl.NEAREST;
|
|
286
|
+
texSize = tile.imageAtlasTexture.size;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);
|
|
290
|
+
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
291
|
+
const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
292
|
+
|
|
293
|
+
const hasVariableAnchors = variablePlacement && bucket.hasTextData();
|
|
294
|
+
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&
|
|
295
|
+
hasVariableAnchors &&
|
|
296
|
+
bucket.hasIconData();
|
|
297
|
+
|
|
298
|
+
if (alongLine) {
|
|
299
|
+
symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),
|
|
303
|
+
uLabelPlaneMatrix = (alongLine || (isText && variablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,
|
|
304
|
+
uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);
|
|
305
|
+
|
|
306
|
+
const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
|
|
307
|
+
|
|
308
|
+
let uniformValues;
|
|
309
|
+
if (isSDF) {
|
|
310
|
+
if (!bucket.iconsInText) {
|
|
311
|
+
uniformValues = symbolSDFUniformValues(sizeData.kind,
|
|
312
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
313
|
+
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);
|
|
314
|
+
} else {
|
|
315
|
+
uniformValues = symbolTextAndIconUniformValues(sizeData.kind,
|
|
316
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
317
|
+
uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
uniformValues = symbolIconUniformValues(sizeData.kind,
|
|
321
|
+
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
322
|
+
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const state = {
|
|
326
|
+
program,
|
|
327
|
+
buffers,
|
|
328
|
+
uniformValues,
|
|
329
|
+
atlasTexture,
|
|
330
|
+
atlasTextureIcon,
|
|
331
|
+
atlasInterpolation,
|
|
332
|
+
atlasInterpolationIcon,
|
|
333
|
+
isSDF,
|
|
334
|
+
hasHalo
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
if (hasSortKey && bucket.canOverlap) {
|
|
338
|
+
sortFeaturesByKey = true;
|
|
339
|
+
const oldSegments = buffers.segments.get();
|
|
340
|
+
for (const segment of oldSegments) {
|
|
341
|
+
tileRenderState.push({
|
|
342
|
+
segments: new SegmentVector([segment]),
|
|
343
|
+
sortKey: ((segment.sortKey: any): number),
|
|
344
|
+
state
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
tileRenderState.push({
|
|
349
|
+
segments: buffers.segments,
|
|
350
|
+
sortKey: 0,
|
|
351
|
+
state
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (sortFeaturesByKey) {
|
|
357
|
+
tileRenderState.sort((a, b) => a.sortKey - b.sortKey);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
for (const segmentState of tileRenderState) {
|
|
361
|
+
const state = segmentState.state;
|
|
362
|
+
|
|
363
|
+
context.activeTexture.set(gl.TEXTURE0);
|
|
364
|
+
state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);
|
|
365
|
+
if (state.atlasTextureIcon) {
|
|
366
|
+
context.activeTexture.set(gl.TEXTURE1);
|
|
367
|
+
if (state.atlasTextureIcon) {
|
|
368
|
+
state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if (state.isSDF) {
|
|
373
|
+
const uniformValues = ((state.uniformValues: any): UniformValues<SymbolSDFUniformsType>);
|
|
374
|
+
if (state.hasHalo) {
|
|
375
|
+
uniformValues['u_is_halo'] = 1;
|
|
376
|
+
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues);
|
|
377
|
+
}
|
|
378
|
+
uniformValues['u_is_halo'] = 0;
|
|
379
|
+
}
|
|
380
|
+
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function drawSymbolElements(buffers, segments, layer, painter, program, depthMode, stencilMode, colorMode, uniformValues) {
|
|
385
|
+
const context = painter.context;
|
|
386
|
+
const gl = context.gl;
|
|
387
|
+
program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,
|
|
388
|
+
uniformValues, layer.id, buffers.layoutVertexBuffer,
|
|
389
|
+
buffers.indexBuffer, segments, layer.paint,
|
|
390
|
+
painter.transform.zoom, buffers.programConfigurations.get(layer.id),
|
|
391
|
+
buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);
|
|
392
|
+
}
|