@mapgis/mapbox-gl 16.0.1 → 16.2.0
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/dist/mapbox-gl.js +3 -3
- package/dist/mapbox-gl.js.map +1 -1
- package/package.json +1 -1
- package/.flowconfig +0 -61
- package/LICENSE.txt +0 -84
- package/README.md +0 -34
- package/build/banner.js +0 -4
- package/build/check-bundle-size.js +0 -140
- package/build/generate-access-token-script.js +0 -11
- package/build/generate-flow-typed-style-spec.js +0 -188
- package/build/generate-release-list.js +0 -21
- package/build/generate-struct-arrays.js +0 -237
- package/build/generate-style-code.js +0 -159
- package/build/mapbox-gl.js.flow +0 -3
- package/build/print-release-url.js +0 -6
- package/build/rollup_plugin_minify_style_spec.js +0 -20
- package/build/rollup_plugins.js +0 -80
- package/build/run-node +0 -3
- package/build/run-tap +0 -8
- package/build/test/build-tape.js +0 -19
- package/flow-typed/gl.js +0 -5
- package/flow-typed/jsdom.js +0 -18
- package/flow-typed/mapbox-gl-supported.js +0 -9
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -25
- package/flow-typed/point-geometry.js +0 -44
- package/flow-typed/potpack.js +0 -12
- package/flow-typed/sinon.js +0 -28
- package/flow-typed/vector-tile.js +0 -41
- package/src/css/mapbox-gl.css +0 -798
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
- package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
- package/src/data/array_types.js +0 -1095
- package/src/data/bucket/circle_attributes.js +0 -9
- package/src/data/bucket/circle_bucket.js +0 -204
- package/src/data/bucket/fill_attributes.js +0 -9
- package/src/data/bucket/fill_bucket.js +0 -233
- package/src/data/bucket/fill_extrusion_attributes.js +0 -10
- package/src/data/bucket/fill_extrusion_bucket.js +0 -289
- package/src/data/bucket/heatmap_bucket.js +0 -17
- package/src/data/bucket/line_attributes.js +0 -10
- package/src/data/bucket/line_bucket.js +0 -556
- package/src/data/bucket/pattern_attributes.js +0 -10
- package/src/data/bucket/pattern_bucket_features.js +0 -60
- package/src/data/bucket/symbol_attributes.js +0 -117
- package/src/data/bucket/symbol_bucket.js +0 -972
- package/src/data/bucket.js +0 -123
- package/src/data/dem_data.js +0 -125
- package/src/data/extent.js +0 -18
- package/src/data/feature_index.js +0 -321
- package/src/data/feature_position_map.js +0 -125
- package/src/data/index_array_type.js +0 -16
- package/src/data/load_geometry.js +0 -48
- package/src/data/pos_attributes.js +0 -6
- package/src/data/program_configuration.js +0 -687
- package/src/data/raster_bounds_attributes.js +0 -7
- package/src/data/segment.js +0 -76
- package/src/geo/edge_insets.js +0 -102
- package/src/geo/lng_lat.js +0 -165
- package/src/geo/lng_lat_bounds.js +0 -267
- package/src/geo/mercator_coordinate.js +0 -153
- package/src/geo/transform.js +0 -864
- package/src/gl/color_mode.js +0 -34
- package/src/gl/context.js +0 -298
- package/src/gl/cull_face_mode.js +0 -26
- package/src/gl/depth_mode.js +0 -29
- package/src/gl/framebuffer.js +0 -44
- package/src/gl/index_buffer.js +0 -55
- package/src/gl/stencil_mode.js +0 -30
- package/src/gl/types.js +0 -84
- package/src/gl/value.js +0 -520
- package/src/gl/vertex_buffer.js +0 -119
- package/src/index.js +0 -201
- package/src/render/draw_background.js +0 -57
- package/src/render/draw_circle.js +0 -113
- package/src/render/draw_collision_debug.js +0 -49
- package/src/render/draw_custom.js +0 -49
- package/src/render/draw_debug.js +0 -127
- package/src/render/draw_fill.js +0 -126
- package/src/render/draw_fill_extrusion.js +0 -96
- package/src/render/draw_heatmap.js +0 -140
- package/src/render/draw_hillshade.js +0 -108
- package/src/render/draw_line.js +0 -98
- package/src/render/draw_raster.js +0 -125
- package/src/render/draw_symbol.js +0 -394
- package/src/render/glyph_atlas.js +0 -71
- package/src/render/glyph_manager.js +0 -182
- package/src/render/image_atlas.js +0 -149
- package/src/render/image_manager.js +0 -306
- package/src/render/line_atlas.js +0 -210
- package/src/render/painter.js +0 -653
- package/src/render/program/background_program.js +0 -103
- package/src/render/program/circle_program.js +0 -69
- package/src/render/program/clipping_mask_program.js +0 -20
- package/src/render/program/collision_program.js +0 -49
- package/src/render/program/debug_program.js +0 -35
- package/src/render/program/fill_extrusion_program.js +0 -122
- package/src/render/program/fill_program.js +0 -126
- package/src/render/program/heatmap_program.js +0 -83
- package/src/render/program/hillshade_program.js +0 -122
- package/src/render/program/line_program.js +0 -207
- package/src/render/program/pattern.js +0 -102
- package/src/render/program/program_uniforms.js +0 -42
- package/src/render/program/raster_program.js +0 -92
- package/src/render/program/symbol_program.js +0 -224
- package/src/render/program.js +0 -168
- package/src/render/texture.js +0 -122
- package/src/render/uniform_binding.js +0 -147
- package/src/render/vertex_array_object.js +0 -163
- package/src/shaders/README.md +0 -42
- package/src/shaders/_prelude.fragment.glsl +0 -17
- package/src/shaders/_prelude.vertex.glsl +0 -73
- package/src/shaders/background.fragment.glsl +0 -10
- package/src/shaders/background.vertex.glsl +0 -7
- package/src/shaders/background_pattern.fragment.glsl +0 -28
- package/src/shaders/background_pattern.vertex.glsl +0 -20
- package/src/shaders/circle.fragment.glsl +0 -39
- package/src/shaders/circle.vertex.glsl +0 -64
- package/src/shaders/clipping_mask.fragment.glsl +0 -3
- package/src/shaders/clipping_mask.vertex.glsl +0 -7
- package/src/shaders/collision_box.fragment.glsl +0 -21
- package/src/shaders/collision_box.vertex.glsl +0 -27
- package/src/shaders/collision_circle.fragment.glsl +0 -34
- package/src/shaders/collision_circle.vertex.glsl +0 -36
- package/src/shaders/debug.fragment.glsl +0 -9
- package/src/shaders/debug.vertex.glsl +0 -12
- package/src/shaders/encode_attribute.js +0 -17
- package/src/shaders/fill.fragment.glsl +0 -13
- package/src/shaders/fill.vertex.glsl +0 -13
- package/src/shaders/fill_extrusion.fragment.glsl +0 -9
- package/src/shaders/fill_extrusion.vertex.glsl +0 -66
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
- package/src/shaders/fill_outline.fragment.glsl +0 -17
- package/src/shaders/fill_outline.vertex.glsl +0 -17
- package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
- package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
- package/src/shaders/fill_pattern.fragment.glsl +0 -36
- package/src/shaders/fill_pattern.vertex.glsl +0 -39
- package/src/shaders/heatmap.fragment.glsl +0 -22
- package/src/shaders/heatmap.vertex.glsl +0 -54
- package/src/shaders/heatmap_texture.fragment.glsl +0 -14
- package/src/shaders/heatmap_texture.vertex.glsl +0 -11
- package/src/shaders/hillshade.fragment.glsl +0 -52
- package/src/shaders/hillshade.vertex.glsl +0 -11
- package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
- package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
- package/src/shaders/index.js +0 -20
- package/src/shaders/line.fragment.glsl +0 -30
- package/src/shaders/line.vertex.glsl +0 -85
- package/src/shaders/line_gradient.fragment.glsl +0 -34
- package/src/shaders/line_gradient.vertex.glsl +0 -87
- package/src/shaders/line_pattern.fragment.glsl +0 -74
- package/src/shaders/line_pattern.vertex.glsl +0 -99
- package/src/shaders/line_sdf.fragment.glsl +0 -45
- package/src/shaders/line_sdf.vertex.glsl +0 -98
- package/src/shaders/raster.fragment.glsl +0 -52
- package/src/shaders/raster.vertex.glsl +0 -21
- package/src/shaders/shaders.js +0 -180
- package/src/shaders/symbol_icon.fragment.glsl +0 -17
- package/src/shaders/symbol_icon.vertex.glsl +0 -94
- package/src/shaders/symbol_sdf.fragment.glsl +0 -52
- package/src/shaders/symbol_sdf.vertex.glsl +0 -115
- package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
- package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
- package/src/source/canvas_source.js +0 -238
- package/src/source/geojson_helper.js +0 -92
- package/src/source/geojson_source.js +0 -374
- package/src/source/geojson_worker_source.js +0 -357
- package/src/source/geojson_wrapper.js +0 -94
- package/src/source/image_source.js +0 -307
- package/src/source/load_tilejson.js +0 -39
- package/src/source/mbtiles_source.js +0 -115
- package/src/source/offline_database.js +0 -61
- package/src/source/offline_database_root.js +0 -62
- package/src/source/pixels_to_tile_units.js +0 -21
- package/src/source/query_features.js +0 -208
- package/src/source/raster_dem_tile_source.js +0 -138
- package/src/source/raster_dem_tile_worker_source.js +0 -62
- package/src/source/raster_tile_offline_source.js +0 -136
- package/src/source/raster_tile_source.js +0 -177
- package/src/source/rtl_text_plugin.js +0 -138
- package/src/source/source.js +0 -137
- package/src/source/source_cache.js +0 -957
- package/src/source/source_state.js +0 -159
- package/src/source/tile.js +0 -465
- package/src/source/tile_bounds.js +0 -38
- package/src/source/tile_cache.js +0 -212
- package/src/source/tile_id.js +0 -402
- package/src/source/vector_tile_source.js +0 -192
- package/src/source/vector_tile_worker_source.js +0 -216
- package/src/source/video_source.js +0 -203
- package/src/source/worker.js +0 -237
- package/src/source/worker_source.js +0 -106
- package/src/source/worker_tile.js +0 -224
- package/src/style/create_style_layer.js +0 -36
- package/src/style/evaluation_parameters.js +0 -62
- package/src/style/light.js +0 -130
- package/src/style/load_glyph_range.js +0 -38
- package/src/style/load_sprite.js +0 -67
- package/src/style/parse_glyph_pbf.js +0 -44
- package/src/style/pauseable_placement.js +0 -132
- package/src/style/properties.js +0 -753
- package/src/style/query_utils.js +0 -43
- package/src/style/style.js +0 -1361
- package/src/style/style_glyph.js +0 -17
- package/src/style/style_image.js +0 -137
- package/src/style/style_layer/background_style_layer.js +0 -21
- package/src/style/style_layer/background_style_layer_properties.js +0 -40
- package/src/style/style_layer/circle_style_layer.js +0 -98
- package/src/style/style_layer/circle_style_layer_properties.js +0 -63
- package/src/style/style_layer/custom_style_layer.js +0 -223
- package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
- package/src/style/style_layer/fill_style_layer.js +0 -67
- package/src/style/style_layer/fill_style_layer_properties.js +0 -55
- package/src/style/style_layer/heatmap_style_layer.js +0 -69
- package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
- package/src/style/style_layer/hillshade_style_layer.js +0 -25
- package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
- package/src/style/style_layer/layer_properties.js.ejs +0 -69
- package/src/style/style_layer/line_style_layer.js +0 -151
- package/src/style/style_layer/line_style_layer_properties.js +0 -71
- package/src/style/style_layer/raster_style_layer.js +0 -21
- package/src/style/style_layer/raster_style_layer_properties.js +0 -50
- package/src/style/style_layer/symbol_style_layer.js +0 -190
- package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
- package/src/style/style_layer/typed_style_layer.js +0 -17
- package/src/style/style_layer.js +0 -281
- package/src/style/style_layer_index.js +0 -80
- package/src/style/validate_style.js +0 -42
- package/src/style/zoom_history.js +0 -44
- package/src/style-spec/.eslintrc +0 -5
- package/src/style-spec/CHANGELOG.md +0 -438
- package/src/style-spec/README.md +0 -59
- package/src/style-spec/bin/gl-style-composite +0 -9
- package/src/style-spec/bin/gl-style-format +0 -22
- package/src/style-spec/bin/gl-style-migrate +0 -9
- package/src/style-spec/bin/gl-style-validate +0 -50
- package/src/style-spec/composite.js +0 -50
- package/src/style-spec/declass.js +0 -42
- package/src/style-spec/deref.js +0 -52
- package/src/style-spec/diff.js +0 -393
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/empty.js +0 -29
- package/src/style-spec/error/parsing_error.js +0 -16
- package/src/style-spec/error/validation_error.js +0 -18
- package/src/style-spec/expression/compound_expression.js +0 -162
- package/src/style-spec/expression/definitions/assertion.js +0 -130
- package/src/style-spec/expression/definitions/at.js +0 -70
- package/src/style-spec/expression/definitions/case.js +0 -85
- package/src/style-spec/expression/definitions/coalesce.js +0 -93
- package/src/style-spec/expression/definitions/coercion.js +0 -133
- package/src/style-spec/expression/definitions/collator.js +0 -78
- package/src/style-spec/expression/definitions/comparison.js +0 -184
- package/src/style-spec/expression/definitions/format.js +0 -144
- package/src/style-spec/expression/definitions/format_section_override.js +0 -54
- package/src/style-spec/expression/definitions/image.js +0 -52
- package/src/style-spec/expression/definitions/in.js +0 -92
- package/src/style-spec/expression/definitions/index.js +0 -561
- package/src/style-spec/expression/definitions/interpolate.js +0 -267
- package/src/style-spec/expression/definitions/length.js +0 -61
- package/src/style-spec/expression/definitions/let.js +0 -72
- package/src/style-spec/expression/definitions/literal.js +0 -77
- package/src/style-spec/expression/definitions/match.js +0 -158
- package/src/style-spec/expression/definitions/number_format.js +0 -142
- package/src/style-spec/expression/definitions/step.js +0 -120
- package/src/style-spec/expression/definitions/var.js +0 -46
- package/src/style-spec/expression/definitions/within.js +0 -333
- package/src/style-spec/expression/evaluation_context.js +0 -59
- package/src/style-spec/expression/expression.js +0 -27
- package/src/style-spec/expression/index.js +0 -392
- package/src/style-spec/expression/is_constant.js +0 -59
- package/src/style-spec/expression/parsing_context.js +0 -233
- package/src/style-spec/expression/parsing_error.js +0 -13
- package/src/style-spec/expression/runtime_error.js +0 -17
- package/src/style-spec/expression/scope.js +0 -36
- package/src/style-spec/expression/stops.js +0 -39
- package/src/style-spec/expression/types/collator.js +0 -61
- package/src/style-spec/expression/types/formatted.js +0 -73
- package/src/style-spec/expression/types/resolved_image.js +0 -29
- package/src/style-spec/expression/types.js +0 -106
- package/src/style-spec/expression/values.js +0 -123
- package/src/style-spec/feature_filter/README.md +0 -55
- package/src/style-spec/feature_filter/convert.js +0 -208
- package/src/style-spec/feature_filter/index.js +0 -165
- package/src/style-spec/format.js +0 -51
- package/src/style-spec/function/convert.js +0 -254
- package/src/style-spec/function/index.js +0 -262
- package/src/style-spec/group_by_layout.js +0 -75
- package/src/style-spec/migrate/expressions.js +0 -39
- package/src/style-spec/migrate/v8.js +0 -203
- package/src/style-spec/migrate/v9.js +0 -26
- package/src/style-spec/migrate.js +0 -36
- package/src/style-spec/package.json +0 -41
- package/src/style-spec/read_style.js +0 -14
- package/src/style-spec/reference/latest.js +0 -3
- package/src/style-spec/reference/v8.json +0 -5808
- package/src/style-spec/rollup.config.js +0 -45
- package/src/style-spec/style-spec.js +0 -122
- package/src/style-spec/types.js +0 -438
- package/src/style-spec/util/color.js +0 -95
- package/src/style-spec/util/color_spaces.js +0 -139
- package/src/style-spec/util/deep_equal.js +0 -28
- package/src/style-spec/util/extend.js +0 -10
- package/src/style-spec/util/get_type.js +0 -17
- package/src/style-spec/util/interpolate.js +0 -22
- package/src/style-spec/util/properties.js +0 -15
- package/src/style-spec/util/ref_properties.js +0 -2
- package/src/style-spec/util/result.js +0 -19
- package/src/style-spec/util/unbundle_jsonlint.js +0 -24
- package/src/style-spec/validate/latest.js +0 -11
- package/src/style-spec/validate/validate.js +0 -75
- package/src/style-spec/validate/validate_array.js +0 -52
- package/src/style-spec/validate/validate_boolean.js +0 -15
- package/src/style-spec/validate/validate_color.js +0 -20
- package/src/style-spec/validate/validate_constants.js +0 -13
- package/src/style-spec/validate/validate_enum.js +0 -21
- package/src/style-spec/validate/validate_expression.js +0 -43
- package/src/style-spec/validate/validate_filter.js +0 -111
- package/src/style-spec/validate/validate_formatted.js +0 -11
- package/src/style-spec/validate/validate_function.js +0 -207
- package/src/style-spec/validate/validate_glyphs_url.js +0 -21
- package/src/style-spec/validate/validate_image.js +0 -11
- package/src/style-spec/validate/validate_layer.js +0 -134
- package/src/style-spec/validate/validate_layout_property.js +0 -6
- package/src/style-spec/validate/validate_light.js +0 -47
- package/src/style-spec/validate/validate_number.js +0 -29
- package/src/style-spec/validate/validate_object.js +0 -61
- package/src/style-spec/validate/validate_paint_property.js +0 -6
- package/src/style-spec/validate/validate_property.js +0 -64
- package/src/style-spec/validate/validate_source.js +0 -111
- package/src/style-spec/validate/validate_string.js +0 -15
- package/src/style-spec/validate_mapbox_api_supported.js +0 -171
- package/src/style-spec/validate_style.js +0 -39
- package/src/style-spec/validate_style.min.js +0 -78
- package/src/style-spec/visit.js +0 -77
- package/src/symbol/anchor.js +0 -26
- package/src/symbol/check_max_angle.js +0 -81
- package/src/symbol/clip_line.js +0 -71
- package/src/symbol/collision_feature.js +0 -217
- package/src/symbol/collision_index.js +0 -372
- package/src/symbol/cross_tile_symbol_index.js +0 -301
- package/src/symbol/get_anchors.js +0 -167
- package/src/symbol/grid_index.js +0 -335
- package/src/symbol/mergelines.js +0 -82
- package/src/symbol/one_em.js +0 -4
- package/src/symbol/opacity_state.js +0 -27
- package/src/symbol/placement.js +0 -1062
- package/src/symbol/projection.js +0 -450
- package/src/symbol/quads.js +0 -334
- package/src/symbol/shaping.js +0 -816
- package/src/symbol/symbol_layout.js +0 -772
- package/src/symbol/symbol_size.js +0 -113
- package/src/symbol/transform_text.js +0 -29
- package/src/types/callback.js +0 -17
- package/src/types/cancelable.js +0 -3
- package/src/types/tilejson.js +0 -17
- package/src/types/transferable.js +0 -3
- package/src/types/window.js +0 -172
- package/src/ui/anchor.js +0 -32
- package/src/ui/bind_handlers.js +0 -202
- package/src/ui/camera.js +0 -1152
- package/src/ui/control/attribution_control.js +0 -189
- package/src/ui/control/fps_control.js +0 -185
- package/src/ui/control/fullscreen_control.js +0 -147
- package/src/ui/control/geolocate_control.js +0 -594
- package/src/ui/control/logo_control.js +0 -92
- package/src/ui/control/navigation_control.js +0 -148
- package/src/ui/control/scale_control.js +0 -142
- package/src/ui/crs.js +0 -64
- package/src/ui/default_locale.js +0 -20
- package/src/ui/events.js +0 -806
- package/src/ui/handler/box_zoom.js +0 -175
- package/src/ui/handler/dblclick_zoom.js +0 -139
- package/src/ui/handler/drag_pan.js +0 -416
- package/src/ui/handler/drag_rotate.js +0 -378
- package/src/ui/handler/keyboard.js +0 -161
- package/src/ui/handler/scroll_zoom.js +0 -333
- package/src/ui/handler/touch_zoom_rotate.js +0 -293
- package/src/ui/hash.js +0 -147
- package/src/ui/map.js +0 -2883
- package/src/ui/marker.js +0 -607
- package/src/ui/offline_map.js +0 -91
- package/src/ui/popup.js +0 -530
- package/src/util/actor.js +0 -212
- package/src/util/ajax.js +0 -371
- package/src/util/browser/web_worker.js +0 -10
- package/src/util/browser/window.js +0 -5
- package/src/util/browser.js +0 -70
- package/src/util/classify_rings.js +0 -52
- package/src/util/color_ramp.js +0 -28
- package/src/util/config.js +0 -30
- package/src/util/debug.js +0 -12
- package/src/util/dictionary_coder.js +0 -30
- package/src/util/dispatcher.js +0 -70
- package/src/util/dom.js +0 -144
- package/src/util/evented.js +0 -174
- package/src/util/find_pole_of_inaccessibility.js +0 -129
- package/src/util/global_worker_pool.js +0 -17
- package/src/util/image.js +0 -142
- package/src/util/intersection_tests.js +0 -208
- package/src/util/is_char_in_unicode_block.js +0 -311
- package/src/util/mapbox.js +0 -486
- package/src/util/offscreen_canvas_supported.js +0 -14
- package/src/util/performance.js +0 -112
- package/src/util/primitives.js +0 -145
- package/src/util/resolve_tokens.js +0 -16
- package/src/util/script_detection.js +0 -328
- package/src/util/sku_token.js +0 -42
- package/src/util/smart_wrap.js +0 -55
- package/src/util/struct_array.js +0 -243
- package/src/util/struct_array.js.ejs +0 -112
- package/src/util/struct_array_layout.js.ejs +0 -98
- package/src/util/task_queue.js +0 -68
- package/src/util/throttle.js +0 -28
- package/src/util/throttled_invoker.js +0 -46
- package/src/util/tile_cover.js +0 -101
- package/src/util/tile_request_cache.js +0 -172
- package/src/util/util.js +0 -504
- package/src/util/vectortile_to_geojson.js +0 -54
- package/src/util/verticalize_punctuation.js +0 -114
- package/src/util/web_worker.js +0 -91
- package/src/util/web_worker_transfer.js +0 -266
- package/src/util/webp_supported.js +0 -69
- package/src/util/window.js +0 -102
- package/src/util/worker_pool.js +0 -47
|
@@ -1,125 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,394 +0,0 @@
|
|
|
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 = 0.5 + 0.5 * (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 sortFeaturesByKey = layer.layout.get('symbol-sort-key').constantOr(1) !== undefined;
|
|
240
|
-
|
|
241
|
-
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
242
|
-
|
|
243
|
-
let program;
|
|
244
|
-
let size;
|
|
245
|
-
const variablePlacement = layer.layout.get('text-variable-anchor');
|
|
246
|
-
|
|
247
|
-
const tileRenderState: Array<SymbolTileRenderState> = [];
|
|
248
|
-
|
|
249
|
-
for (const coord of coords) {
|
|
250
|
-
const tile = sourceCache.getTile(coord);
|
|
251
|
-
const bucket: SymbolBucket = (tile.getBucket(layer): any);
|
|
252
|
-
if (!bucket) continue;
|
|
253
|
-
const buffers = isText ? bucket.text : bucket.icon;
|
|
254
|
-
if (!buffers || !buffers.segments.get().length) continue;
|
|
255
|
-
const programConfiguration = buffers.programConfigurations.get(layer.id);
|
|
256
|
-
|
|
257
|
-
const isSDF = isText || bucket.sdfIcons;
|
|
258
|
-
|
|
259
|
-
const sizeData = isText ? bucket.textSizeData : bucket.iconSizeData;
|
|
260
|
-
const transformed = pitchWithMap || tr.pitch !== 0;
|
|
261
|
-
|
|
262
|
-
if (!program) {
|
|
263
|
-
program = painter.useProgram(getSymbolProgramName(isSDF, isText, bucket), programConfiguration);
|
|
264
|
-
size = symbolSize.evaluateSizeForZoom(sizeData, tr.zoom);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
let texSize: [number, number];
|
|
268
|
-
let texSizeIcon: [number, number] = [0, 0];
|
|
269
|
-
let atlasTexture;
|
|
270
|
-
let atlasInterpolation;
|
|
271
|
-
let atlasTextureIcon = null;
|
|
272
|
-
let atlasInterpolationIcon;
|
|
273
|
-
if (isText) {
|
|
274
|
-
atlasTexture = tile.glyphAtlasTexture;
|
|
275
|
-
atlasInterpolation = gl.LINEAR;
|
|
276
|
-
texSize = tile.glyphAtlasTexture.size;
|
|
277
|
-
if (bucket.iconsInText) {
|
|
278
|
-
texSizeIcon = tile.imageAtlasTexture.size;
|
|
279
|
-
atlasTextureIcon = tile.imageAtlasTexture;
|
|
280
|
-
const zoomDependentSize = sizeData.kind === 'composite' || sizeData.kind === 'camera';
|
|
281
|
-
atlasInterpolationIcon = transformed || painter.options.rotating || painter.options.zooming || zoomDependentSize ? gl.LINEAR : gl.NEAREST;
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
const iconScaled = layer.layout.get('icon-size').constantOr(0) !== 1 || bucket.iconsNeedLinear;
|
|
285
|
-
atlasTexture = tile.imageAtlasTexture;
|
|
286
|
-
atlasInterpolation = isSDF || painter.options.rotating || painter.options.zooming || iconScaled || transformed ?
|
|
287
|
-
gl.LINEAR :
|
|
288
|
-
gl.NEAREST;
|
|
289
|
-
texSize = tile.imageAtlasTexture.size;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const s = pixelsToTileUnits(tile, 1, painter.transform.zoom);
|
|
293
|
-
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
294
|
-
const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
295
|
-
|
|
296
|
-
const hasVariableAnchors = variablePlacement && bucket.hasTextData();
|
|
297
|
-
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&
|
|
298
|
-
hasVariableAnchors &&
|
|
299
|
-
bucket.hasIconData();
|
|
300
|
-
|
|
301
|
-
if (alongLine) {
|
|
302
|
-
symbolProjection.updateLineLabels(bucket, coord.posMatrix, painter, isText, labelPlaneMatrix, glCoordMatrix, pitchWithMap, keepUpright);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),
|
|
306
|
-
uLabelPlaneMatrix = (alongLine || (isText && variablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,
|
|
307
|
-
uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);
|
|
308
|
-
|
|
309
|
-
const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
|
|
310
|
-
|
|
311
|
-
let uniformValues;
|
|
312
|
-
if (isSDF) {
|
|
313
|
-
if (!bucket.iconsInText) {
|
|
314
|
-
uniformValues = symbolSDFUniformValues(sizeData.kind,
|
|
315
|
-
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
316
|
-
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize, true);
|
|
317
|
-
} else {
|
|
318
|
-
uniformValues = symbolTextAndIconUniformValues(sizeData.kind,
|
|
319
|
-
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
320
|
-
uLabelPlaneMatrix, uglCoordMatrix, texSize, texSizeIcon);
|
|
321
|
-
}
|
|
322
|
-
} else {
|
|
323
|
-
uniformValues = symbolIconUniformValues(sizeData.kind,
|
|
324
|
-
size, rotateInShader, pitchWithMap, painter, matrix,
|
|
325
|
-
uLabelPlaneMatrix, uglCoordMatrix, isText, texSize);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const state = {
|
|
329
|
-
program,
|
|
330
|
-
buffers,
|
|
331
|
-
uniformValues,
|
|
332
|
-
atlasTexture,
|
|
333
|
-
atlasTextureIcon,
|
|
334
|
-
atlasInterpolation,
|
|
335
|
-
atlasInterpolationIcon,
|
|
336
|
-
isSDF,
|
|
337
|
-
hasHalo
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
if (sortFeaturesByKey) {
|
|
341
|
-
const oldSegments = buffers.segments.get();
|
|
342
|
-
for (const segment of oldSegments) {
|
|
343
|
-
tileRenderState.push({
|
|
344
|
-
segments: new SegmentVector([segment]),
|
|
345
|
-
sortKey: ((segment.sortKey: any): number),
|
|
346
|
-
state
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
tileRenderState.push({
|
|
351
|
-
segments: buffers.segments,
|
|
352
|
-
sortKey: 0,
|
|
353
|
-
state
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (sortFeaturesByKey) {
|
|
359
|
-
tileRenderState.sort((a, b) => a.sortKey - b.sortKey);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
for (const segmentState of tileRenderState) {
|
|
363
|
-
const state = segmentState.state;
|
|
364
|
-
|
|
365
|
-
context.activeTexture.set(gl.TEXTURE0);
|
|
366
|
-
state.atlasTexture.bind(state.atlasInterpolation, gl.CLAMP_TO_EDGE);
|
|
367
|
-
if (state.atlasTextureIcon) {
|
|
368
|
-
context.activeTexture.set(gl.TEXTURE1);
|
|
369
|
-
if (state.atlasTextureIcon) {
|
|
370
|
-
state.atlasTextureIcon.bind(state.atlasInterpolationIcon, gl.CLAMP_TO_EDGE);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (state.isSDF) {
|
|
375
|
-
const uniformValues = ((state.uniformValues: any): UniformValues<SymbolSDFUniformsType>);
|
|
376
|
-
if (state.hasHalo) {
|
|
377
|
-
uniformValues['u_is_halo'] = 1;
|
|
378
|
-
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, uniformValues);
|
|
379
|
-
}
|
|
380
|
-
uniformValues['u_is_halo'] = 0;
|
|
381
|
-
}
|
|
382
|
-
drawSymbolElements(state.buffers, segmentState.segments, layer, painter, state.program, depthMode, stencilMode, colorMode, state.uniformValues);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function drawSymbolElements(buffers, segments, layer, painter, program, depthMode, stencilMode, colorMode, uniformValues) {
|
|
387
|
-
const context = painter.context;
|
|
388
|
-
const gl = context.gl;
|
|
389
|
-
program.draw(context, gl.TRIANGLES, depthMode, stencilMode, colorMode, CullFaceMode.disabled,
|
|
390
|
-
uniformValues, layer.id, buffers.layoutVertexBuffer,
|
|
391
|
-
buffers.indexBuffer, segments, layer.paint,
|
|
392
|
-
painter.transform.zoom, buffers.programConfigurations.get(layer.id),
|
|
393
|
-
buffers.dynamicLayoutVertexBuffer, buffers.opacityVertexBuffer);
|
|
394
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {AlphaImage} from '../util/image';
|
|
4
|
-
import {register} from '../util/web_worker_transfer';
|
|
5
|
-
import potpack from 'potpack';
|
|
6
|
-
|
|
7
|
-
import type {GlyphMetrics, StyleGlyph} from '../style/style_glyph';
|
|
8
|
-
|
|
9
|
-
const padding = 1;
|
|
10
|
-
|
|
11
|
-
export type Rect = {
|
|
12
|
-
x: number,
|
|
13
|
-
y: number,
|
|
14
|
-
w: number,
|
|
15
|
-
h: number
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type GlyphPosition = {
|
|
19
|
-
rect: Rect,
|
|
20
|
-
metrics: GlyphMetrics
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type GlyphPositions = {[_: string]: {[_: number]: GlyphPosition } }
|
|
24
|
-
|
|
25
|
-
export default class GlyphAtlas {
|
|
26
|
-
image: AlphaImage;
|
|
27
|
-
positions: GlyphPositions;
|
|
28
|
-
|
|
29
|
-
constructor(stacks: {[_: string]: {[_: number]: ?StyleGlyph } }) {
|
|
30
|
-
const positions = {};
|
|
31
|
-
const bins = [];
|
|
32
|
-
|
|
33
|
-
for (const stack in stacks) {
|
|
34
|
-
const glyphs = stacks[stack];
|
|
35
|
-
const stackPositions = positions[stack] = {};
|
|
36
|
-
|
|
37
|
-
for (const id in glyphs) {
|
|
38
|
-
const src = glyphs[+id];
|
|
39
|
-
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
|
|
40
|
-
|
|
41
|
-
const bin = {
|
|
42
|
-
x: 0,
|
|
43
|
-
y: 0,
|
|
44
|
-
w: src.bitmap.width + 2 * padding,
|
|
45
|
-
h: src.bitmap.height + 2 * padding
|
|
46
|
-
};
|
|
47
|
-
bins.push(bin);
|
|
48
|
-
stackPositions[id] = {rect: bin, metrics: src.metrics};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const {w, h} = potpack(bins);
|
|
53
|
-
const image = new AlphaImage({width: w || 1, height: h || 1});
|
|
54
|
-
|
|
55
|
-
for (const stack in stacks) {
|
|
56
|
-
const glyphs = stacks[stack];
|
|
57
|
-
|
|
58
|
-
for (const id in glyphs) {
|
|
59
|
-
const src = glyphs[+id];
|
|
60
|
-
if (!src || src.bitmap.width === 0 || src.bitmap.height === 0) continue;
|
|
61
|
-
const bin = positions[stack][id].rect;
|
|
62
|
-
AlphaImage.copy(src.bitmap, image, {x: 0, y: 0}, {x: bin.x + padding, y: bin.y + padding}, src.bitmap);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
this.image = image;
|
|
67
|
-
this.positions = positions;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
register('GlyphAtlas', GlyphAtlas);
|