diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-28 15:30:14 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-05-28 16:16:42 +0300 |
commit | 2f97a2660ada44cd18f2e02b4de4eb42cfcb07b1 (patch) | |
tree | d59193e56225fed08050add86b618d21da2e87ed | |
parent | 43966f1611c52fef9b7fc344410c3a5235e07765 (diff) | |
download | qtlocation-mapboxgl-2f97a2660ada44cd18f2e02b4de4eb42cfcb07b1.tar.gz |
[core] RenderTile returns textures by const reference
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_layer.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_line_layer.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/renderer/render_tile.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/renderer/render_tile.hpp | 4 |
6 files changed, 19 insertions, 17 deletions
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 1a2e623dd5..88c2edc1c2 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -179,7 +179,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), evaluated.get<FillExtrusionTranslateAnchor>(), parameters.state), - tile.getIconAtlasTexture()->size, + tile.getIconAtlasTexture().size, crossfade, tile.id, parameters.state, @@ -191,7 +191,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { patternPosA, patternPosB, FillExtrusionPatternProgram::TextureBindings{ - textures::image::Value{ tile.getIconAtlasTexture()->getResource(), gfx::TextureFilterType::Linear }, + textures::image::Value{ tile.getIconAtlasTexture().getResource(), gfx::TextureFilterType::Linear }, } ); } diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 64e0f0bba1..c549b338df 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -190,7 +190,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { evaluated.get<FillTranslateAnchor>(), parameters.state), parameters.backend.getDefaultRenderable().getSize(), - tile.getIconAtlasTexture()->size, + tile.getIconAtlasTexture().size, crossfade, tile.id, parameters.state, @@ -232,7 +232,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { *bucket.triangleIndexBuffer, bucket.triangleSegments, FillPatternProgram::TextureBindings{ - textures::image::Value{ tile.getIconAtlasTexture()->getResource(), gfx::TextureFilterType::Linear }, + textures::image::Value{ tile.getIconAtlasTexture().getResource(), gfx::TextureFilterType::Linear }, }); } if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined()) { @@ -242,7 +242,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { *bucket.lineIndexBuffer, bucket.lineSegments, FillOutlinePatternProgram::TextureBindings{ - textures::image::Value{ tile.getIconAtlasTexture()->getResource(), gfx::TextureFilterType::Linear }, + textures::image::Value{ tile.getIconAtlasTexture().getResource(), gfx::TextureFilterType::Linear }, }); } } diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 2520386df8..5b20e4667c 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -170,7 +170,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { } else if (!unevaluated.get<LinePattern>().isUndefined()) { const auto& linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<std::basic_string<char>>{ "", ""}); - const Size& texsize = tile.getIconAtlasTexture()->size; + const Size& texsize = tile.getIconAtlasTexture().size; optional<ImagePosition> posA = tile.getPattern(linePatternValue.from); optional<ImagePosition> posB = tile.getPattern(linePatternValue.to); @@ -187,7 +187,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { posA, posB, LinePatternProgram::TextureBindings{ - textures::image::Value{ tile.getIconAtlasTexture()->getResource(), gfx::TextureFilterType::Linear }, + textures::image::Value{ tile.getIconAtlasTexture().getResource(), gfx::TextureFilterType::Linear }, }); } else if (!unevaluated.get<LineGradient>().getValue().isUndefined()) { assert(colorRampTexture); diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 11469f27cc..a77f26088a 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -123,14 +123,14 @@ void drawIcon(const DrawFn& draw, const bool iconScaled = layout.get<IconSize>().constantOr(1.0) != 1.0 || bucket.iconsNeedLinear; const bool iconTransformed = values.rotationAlignment == AlignmentType::Map || parameters.state.getPitch() != 0; - const gfx::TextureBinding textureBinding{ tile.getIconAtlasTexture()->getResource(), + const gfx::TextureBinding textureBinding{ tile.getIconAtlasTexture().getResource(), bucket.sdfIcons || parameters.state.isChanging() || iconScaled || iconTransformed ? gfx::TextureFilterType::Linear : gfx::TextureFilterType::Nearest }; - const Size& iconSize = tile.getIconAtlasTexture()->size; + const Size& iconSize = tile.getIconAtlasTexture().size; if (bucket.sdfIcons) { if (values.hasHalo) { @@ -189,7 +189,7 @@ void drawText(const DrawFn& draw, const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties); const auto& layout = bucket.layout; - const gfx::TextureBinding textureBinding{ tile.getGlyphAtlasTexture()->getResource(), + const gfx::TextureBinding textureBinding{ tile.getGlyphAtlasTexture().getResource(), gfx::TextureFilterType::Linear }; auto values = textPropertyValues(evaluated, layout); @@ -198,7 +198,7 @@ void drawText(const DrawFn& draw, const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point && layout.get<TextRotationAlignment>() == AlignmentType::Map; - const Size& texsize = tile.getGlyphAtlasTexture()->size; + const Size& texsize = tile.getGlyphAtlasTexture().size; if (values.hasHalo) { draw(parameters.programs.getSymbolLayerPrograms().symbolGlyph, diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index a640a96776..b8fb4b2a11 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -77,14 +77,16 @@ optional<ImagePosition> RenderTile::getPattern(const std::string& pattern) const return static_cast<const GeometryTile&>(tile).getPattern(pattern); } -const optional<gfx::Texture>& RenderTile::getGlyphAtlasTexture() const { +const gfx::Texture& RenderTile::getGlyphAtlasTexture() const { assert(tile.kind == Tile::Kind::Geometry); - return static_cast<const GeometryTile&>(tile).glyphAtlasTexture; + assert(static_cast<const GeometryTile&>(tile).glyphAtlasTexture); + return *(static_cast<const GeometryTile&>(tile).glyphAtlasTexture); } -const optional<gfx::Texture>& RenderTile::getIconAtlasTexture() const { +const gfx::Texture& RenderTile::getIconAtlasTexture() const { assert(tile.kind == Tile::Kind::Geometry); - return static_cast<const GeometryTile&>(tile).iconAtlasTexture; + assert(static_cast<const GeometryTile&>(tile).iconAtlasTexture); + return *(static_cast<const GeometryTile&>(tile).iconAtlasTexture); } std::shared_ptr<FeatureIndex> RenderTile::getFeatureIndex() const { diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp index aaeef88db0..9725744ace 100644 --- a/src/mbgl/renderer/render_tile.hpp +++ b/src/mbgl/renderer/render_tile.hpp @@ -57,8 +57,8 @@ public: Bucket* getBucket(const style::Layer::Impl&) const; const LayerRenderData* getLayerRenderData(const style::Layer::Impl&) const; optional<ImagePosition> getPattern(const std::string& pattern) const; - const optional<gfx::Texture>& getGlyphAtlasTexture() const; - const optional<gfx::Texture>& getIconAtlasTexture() const; + const gfx::Texture& getGlyphAtlasTexture() const; + const gfx::Texture& getIconAtlasTexture() const; std::shared_ptr<FeatureIndex> getFeatureIndex() const; void setMask(TileMask&&); |