Commit Graph

4245 Commits

Author SHA1 Message Date
Mikhail Pozdnyakov
3ea459233a [core] Fix GeoJSONVTData ownership and life cycle
Before this change, the `GeoJSONVTData` instance was retained at the scheduled
lambda, which run on the worker thread represented by the `GeoJSONVTData::scheduler`
class member:

```
        std::weak_ptr<GeoJSONVTData> weak = shared_from_this();
        scheduler->scheduleAndReplyValue(
            [id, weak, this]() -> TileFeatures {
                if (auto self = weak.lock()) {
                    return impl.getTile(id.z, id.x, id.y).features;
                }
                return {};
            },
            fn);
```

It caused program termination in case `self` turned to be the last reference to `this`,
as the `std::thread` destructor was called from the thread it represented.

Now, only the `GeoJSONVTData::impl` class member is retained.
2020-01-09 16:52:13 +02:00
Peng Liu
236afc0395 [android][core] Add Map::latLngBoundsForCameraUnwrapped and jni binding for getVisibleCoordinateBounds. (#16069)
* [android] Add getVisibleCoordinateBounds method.
* Fix Map::latLngBoundsForCamera, add Android binding for getVisibleRegionBounds.
* Add unit tests for CameraToLatLngBoundsWithRotation and CameraToLatLngBoundsCrossDateLine.
* Move API breaking changes to a new method name latLngBoundsForCameraUnwrapped.
2020-01-09 15:53:23 +02:00
Mikhail Pozdnyakov
0379615388 [core] Introduce CollisionIndex::getProjectedCollisionBoundaries()
In order to remove the repeated code.
2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
141e4e7935 [core] Introduce CollisionBoundaries and use it in CollisionIndex 2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
cf2946c8ff [core] Use only the first variable anchor for the symbols intersecting tile borders
Do not try the following variable anchors, if the first variable anchor placement failed.
2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
1debf4e05b [core] Fix CollisionIndex::featureIntersectsTileBorders() implementation 2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
c25fbe9a94 [core] Performance fix for placement in tile mode 2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
2040d4d6f5 [core] In tile mode, place labels from tile borders first 2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
7e5dc5608a [core] Pre-defined variable anchor at tile borders
In tile mode, stick to the first variable anchor if the label intersects tile borders.
2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
07194f7fa5 [core] Add CollisionIndex::featureIntersectsTileBorders() 2020-01-08 12:43:26 +02:00
Mikhail Pozdnyakov
2125548a6e [core] Consolidate more logic in calculateVariableLayoutOffset() 2020-01-08 12:43:26 +02:00
Dane Springmeyer
d009ce88e0 remove unused code (#16077) 2019-12-19 14:39:38 -06:00
Mikhail Pozdnyakov
cc684df736 [core] Handle zero text size
The style specification stipulates that `text-size` values must be positive
(https://docs.mapbox.com/mapbox-gl-js/style-spec/#layout-symbol-text-size).

However, a zero value could be passed to the engine (e.g. as a result of
an expression) this patch handles it and avoids assertion hit in `shaping.cpp`.
2019-12-19 18:09:33 +02:00
Aleksandar Stojiljkovic
2fd9d4a1fe Include padding when testing camera scale in cameraForLatLngBounds
Repurpose LatLngBoundsToCameraWithBearingAndPitch to test scaling and camera setup, both with and without padding.
This adds testing of path not covered in mapbox/mapbox-gl-native-ios#59.
2019-12-17 16:19:33 +02:00
Romain Quidet
5693f3be02 correct insets camera management - see https://github.com/mapbox/mapbox-gl-native-ios/issues/59 2019-12-17 16:19:33 +02:00
Ansis Brammanis
aa543e43e5 [core] Fix really overscaled lines #16018 2019-12-17 15:46:10 +02:00
Andrew Hay Kurtz
da4eb01bc7 [core] Enable 'line-sort-key' and 'fill-sort-key' layout properties (#15839)
- Generate style code for 'line-sort-key' and 'symbol-sort-key'

- Add new layout properties to FillLayer::Impl, FillBucket, and FillLayerFactory

- Fix consistency of paint and layout properties type alias usage in FillBucket, LineBucket

- Add optional feature sorting to fill and line Layout creation

- Enable node render tests for fill-sort-key and line-sort-key

- Fix FillBucket test construction

- Prefer emplace_back to push_back for PatternFeature container

- Fix buggy static_cast for PatternFeature indices

- Maintain sort of features as they are created

- Switch pattern layout features container to list from vector for better insert performance

- Fix formatting expected by sanity check

- Use subclass PatternLayoutSorted to work around lack of template functions

- Fix to retain source order for features with equivalent sort keys during sorting

- [core] Fix clang-format

- [core] Address review comments

- [core] Pass inserting strategy class at compile time

- [core] Use sorted strategy only if sort key is defined in layout

- [core] Update style generator

- [core] Merge PatternLayout and PatternLayoutSorted classes

  - Use static methods for inserter strategies
  - Merge PatternLayout and PatternLayoutSorted classes
2019-12-17 14:25:19 +02:00
Mikhail Pozdnyakov
9901167936 [core] Add style::Layer(Impl) constructor 2019-12-13 15:34:06 +02:00
Thiago Marcos P. Santos
3bbea2e30c [core] Fix -Wshadow when using GCC 4.9 2019-12-12 17:44:11 +02:00
Mikhail Pozdnyakov
1829fb5e40 [core] Placement::commit() handles absence of previuos placement 2019-12-09 17:32:49 +02:00
Mikhail Pozdnyakov
ffd378c68e [core] Simplify placement code path for still and tile modes 2019-12-09 17:32:49 +02:00
Alexander Shalamov
89665326c2 [core] Add unit test for calculateTileDistances 2019-12-09 17:26:13 +02:00
Alexander Shalamov
d36958997b [core] Add unit test for getAnchors and remove unused field 2019-12-09 17:26:13 +02:00
Alexander Shalamov
b6b077d73a [core] Don't use signed int type for anchor segment 2019-12-09 17:26:13 +02:00
Ansis Brammanis
cdee5b8249 [core] increase padding in CollisionIndex for MapMode::Tile (#15880)
* [core] fix cutoff cross-tile labels in MapMode::Tile

Increase the CollisionIndex's padding so that more of a tile's data gets
considered when checking for collisions. This should fix clipped
variable placement text labels.
2019-12-06 18:11:25 -05:00
zmiao
9f3a384296 [core] Refactoring transform state (#15956)
* [core] Refactoring transform state class

* [core] update matrix in transform, Fix precision

* [core] Make matrix mutable so that we only update them when needed

* [core] Add getters for matrices
2019-12-05 18:58:48 +02:00
Bruno de Oliveira Abinader
1e2cd1e086 [core] Remove Map::cycleDebugOptions 2019-12-04 11:50:05 +02:00
Mikhail Pozdnyakov
684000fc26 [core] Merge style::Layer::set{Layout,Paint}Property 2019-12-03 14:20:17 +02:00
Alexander Shalamov
84ec379477 [core] Turn off clang format for generated shaded code 2019-12-02 17:11:49 +02:00
Alexander Shalamov
72e9388a61 [core] Add unit tests for Formatted class 2019-12-02 17:11:49 +02:00
Alexander Shalamov
614000256b [core] Shape images in labels at bucket zoom level 2019-12-02 17:11:49 +02:00
Alexander Shalamov
33ba4052b6 [core] Use linear filtering for icons in text for zoom dependent text-size 2019-12-02 17:11:49 +02:00
Alexander Shalamov
26bf566f53 [core] Use new 'SymbolTextAndIcon' program to draw icons in text 2019-12-02 17:11:49 +02:00
Alexander Shalamov
2c49c4374c [core] Store 'sdf' flag in vertex attribute 2019-12-02 17:11:49 +02:00
Alexander Shalamov
2bb2a40b6d [core] Shape images in labels and create image quads 2019-12-02 17:11:49 +02:00
Alexander Shalamov
f4f652063d [core] Calculate line width and line breaks for images 2019-12-02 17:11:49 +02:00
Alexander Shalamov
34a9bc08ce [core] Pass images and evaluated layout text size to shaping 2019-12-02 17:11:49 +02:00
Alexander Shalamov
a9c3b5a389 [core] Add evaluated images to styled text sections 2019-12-02 17:11:49 +02:00
Alexander Shalamov
a01ecc92a0 [core] Add image sections to format expression 2019-12-02 17:11:49 +02:00
Mikhail Pozdnyakov
7bacf5696c [core] Introduce Pass<> class and use it for Scheduler
Thus we enforce client to retain the returned `Scheduler` objects.
2019-12-02 14:12:18 +02:00
Alexander Shalamov
00d133239e [core] Blacklist VAO extension for Adreno (TM) 4xx GPUs
Blacklist in order to avoid crashes in a driver.
2019-12-02 11:03:16 +02:00
Mikhail Pozdnyakov
3947d5fa98 [core] Retain thread pool in GeoJSONSource
Otherwise, the construction of the `Immutable<Source::Impl>` in background thread might never yeld.
2019-11-29 15:37:49 +02:00
Mikhail Pozdnyakov
597757df6a [core] GeoJSONVTData uses Scheduler::GetSequenced() 2019-11-29 11:12:55 +02:00
Mikhail Pozdnyakov
06c80cae3c [core] Introduce GeometryTile::reset()
The newly introduced `GeometryTile::reset()` is
used while GeoJSON tile update in order to prevent from the
parsing of the new data with the stale layers or vice verse.
2019-11-29 11:12:55 +02:00
Mikhail Pozdnyakov
6419cd0ab2 [core] Calculate GeoJSON tile geometries in a background thread
Call `mapbox::geojsonvt::GeoJSONVT::getTile()` in a background
thread, so that the rendering thread is not blocked.
2019-11-29 11:12:55 +02:00
Mikhail Pozdnyakov
ab5572b0bc [core] Fix supercluster lambdas capturing 2019-11-29 09:53:28 +02:00
Mikhail Pozdnyakov
cd4136ed4b [core][android][darwin] Fix GeoJSONOptions handling
- share the `GeoJSONOptions` instances using `Immutable<GeoJSONOptions>` - avoid extra copying
- fix wrapping of the `GeoJSONOptions` instances in supercluster map/reduce lambdas.
  Previously, local variables were wrapped by reference.
2019-11-29 09:53:28 +02:00
Mikhail Pozdnyakov
b5794730b5 [core] Introduce Scheduler::GetSequenced() API
The newly introduced `Scheduler::GetSequenced()` returns
sequenced schedulers from the cache limited to 10 instances,
preventing from spawning too many threads.
2019-11-28 14:34:52 +02:00
Mikhail Pozdnyakov
b6fbd1221e [core] Clear tiles when GeoJSON data changes
In tile and static mode clear tiles when data changes
in order to avoid render tests being flaky.
2019-11-26 16:35:17 +02:00
Konstantin Käfer
3600dd8a1a [core] fix rendering of dashed lines with round caps
In https://github.com/mapbox/mapbox-gl-native/pull/15862, we introduced individual textures for line dash patterns to eliminate atlas overflows. Unfortunately, this broke dashed lines that had round caps (dashed lines with straight caps still rendered correctly). Line pattern textures for round caps were now using 256×15 pixel textures.

The OpenGL ES 2.0 spec, section 3.8.2 states:

    Calling a sampler from a fragment shader will return `(R,G,B,A) = (0,0,0,1)` if any of the following conditions are true:
    […]
    - A two-dimensional sampler is called, the corresponding texture image is a non-power-of-two image […], and either the texture wrap mode is not `CLAMP_TO_EDGE`, or the minification filter is neither `NEAREST` nor `LINEAR`.
    […]

This means that texture lookups won't work for NPOT textures unless they use `GL_CLAMP_TO_EDGE`. We're using `GL_CLAMP_TO_EDGE` for the vertical direction, but GL_REPEAT for the horizontal direction, which means that we need a power-of-two texture for our line dash patterns to work on OpenGL ES 2.0 conforming implementations. Fortunately, this just means changing the height from 15 to 16, and from 30 to 32, so we don't waste many pixels.
2019-11-22 16:36:17 +01:00