diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-01-19 21:28:59 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-01-22 14:30:26 +0200 |
commit | 4dac2f61c244b6ac3859510e21b2c80c83f25841 (patch) | |
tree | 681db888a5b82dc86cb973de1deee85308a4d519 /src/mbgl | |
parent | e6ddcf9beb8e0aad52d4185dac0c0b1d15205a16 (diff) | |
download | qtlocation-mapboxgl-4dac2f61c244b6ac3859510e21b2c80c83f25841.tar.gz |
[core] Simplify Placement::addLayer()
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/renderer/render_orchestrator.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/text/placement.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/text/placement.hpp | 3 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index edc7f3b9cf..8597f3b5df 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -210,6 +210,7 @@ public: void setLatLngZoom(const LatLng& latLng, double zoom); void constrain(double& scale, double& x, double& y) const; + const mat4& getProjectionMatrix() const; private: bool rotatedNorth() const; @@ -236,7 +237,7 @@ private: void updateMatricesIfNeeded() const; bool needsMatricesUpdate() const { return requestMatricesUpdate; } - const mat4& getProjectionMatrix() const; + const mat4& getCoordMatrix() const; const mat4& getInvertedMatrix() const; diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index 48e7b09812..79059164ae 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -400,7 +400,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree( for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) { const RenderLayer& layer = *it; usedSymbolLayers.insert(layer.getID()); - placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix); + placement->placeLayer(layer); } placement->commit(); @@ -422,8 +422,8 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree( Mutable<Placement> placement = makeMutable<Placement>(updateParameters); for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) { const RenderLayer& layer = *it; - crossTileSymbolIndex.addLayer(layer, longitude); - placement->placeLayer(layer, renderTreeParameters->transformParams.projMatrix); + crossTileSymbolIndex.addLayer(layer, updateParameters->transformState); + placement->placeLayer(layer); } placement->commit(); placementController.setPlacement(std::move(placement)); diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index dce1cb40dc..43d9713717 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -109,11 +109,11 @@ Placement::Placement(std::shared_ptr<const UpdateParameters> updateParameters_, Placement::Placement() : collisionIndex({}, MapMode::Static), collisionGroups(true) {} -void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix) { +void Placement::placeLayer(const RenderLayer& layer) { std::set<uint32_t> seenCrossTileIDs; for (const auto& item : layer.getPlacementData()) { Bucket& bucket = item.bucket; - BucketPlacementParameters params{item.tile, projMatrix, layer.baseImpl->source, item.featureIndex}; + BucketPlacementParameters params{item.tile, layer.baseImpl->source, item.featureIndex}; bucket.place(*this, params, seenCrossTileIDs); } } @@ -158,8 +158,9 @@ void Placement::placeBucket(const SymbolBucket& bucket, const bool pitchIconWithMap = layout.get<style::IconPitchAlignment>() == style::AlignmentType::Map; mat4 posMatrix; + const auto& projMatrix = state.getProjectionMatrix(); state.matrixFor(posMatrix, renderTile.id); - matrix::multiply(posMatrix, params.projMatrix, posMatrix); + matrix::multiply(posMatrix, projMatrix, posMatrix); mat4 textLabelPlaneMatrix = getLabelPlaneMatrix(posMatrix, pitchTextWithMap, rotateTextWithMap, state, pixelsToTileUnits); diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index 0d224f67de..46d560b673 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -89,7 +89,6 @@ private: class BucketPlacementParameters { public: const RenderTile& tile; - const mat4& projMatrix; std::string sourceId; std::shared_ptr<FeatureIndex> featureIndex; }; @@ -115,7 +114,7 @@ public: Placement(std::shared_ptr<const UpdateParameters>, optional<Immutable<Placement>> prevPlacement = nullopt); Placement(); - void placeLayer(const RenderLayer&, const mat4&); + void placeLayer(const RenderLayer&); void commit(); void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const; float symbolFadeChange(TimePoint now) const; |