diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-18 10:23:37 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-19 09:31:07 -0700 |
commit | 5d997ae08e099948dc99181967368a617e03282d (patch) | |
tree | 3ba2b9727c736fc100cf4a2605fa85ffe4b0c527 /src/mbgl/renderer/layers | |
parent | 356bba9e3be9ba9940d163020ec1369779487135 (diff) | |
download | qtlocation-mapboxgl-5d997ae08e099948dc99181967368a617e03282d.tar.gz |
[core] Inline Painter::renderFillExtrusion
Diffstat (limited to 'src/mbgl/renderer/layers')
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp | 85 |
1 files changed, 77 insertions, 8 deletions
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 4a28b3b752..f33a039981 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -2,6 +2,10 @@ #include <mbgl/renderer/buckets/fill_extrusion_bucket.hpp> #include <mbgl/renderer/painter.hpp> #include <mbgl/renderer/render_tile.hpp> +#include <mbgl/renderer/paint_parameters.hpp> +#include <mbgl/renderer/image_manager.hpp> +#include <mbgl/programs/programs.hpp> +#include <mbgl/programs/fill_extrusion_program.hpp> #include <mbgl/tile/tile.hpp> #include <mbgl/style/layers/fill_extrusion_layer_impl.hpp> #include <mbgl/geometry/feature_index.hpp> @@ -10,6 +14,8 @@ namespace mbgl { +using namespace style; + RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl) : RenderLayer(style::LayerType::FillExtrusion, _impl), unevaluated(impl().paint.untransitioned()) { @@ -39,14 +45,77 @@ bool RenderFillExtrusionLayer::hasTransition() const { } void RenderFillExtrusionLayer::render(Painter& painter, PaintParameters& parameters, RenderSource*) { - for (const RenderTile& tile : renderTiles) { - Bucket* bucket = tile.tile.getBucket(*baseImpl); - assert(dynamic_cast<FillExtrusionBucket*>(bucket)); - painter.renderFillExtrusion( - parameters, - *reinterpret_cast<FillExtrusionBucket*>(bucket), - *this, - tile); + if (painter.pass == RenderPass::Opaque) { + return; + } + + if (evaluated.get<FillExtrusionPattern>().from.empty()) { + for (const RenderTile& tile : renderTiles) { + assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl))); + FillExtrusionBucket& bucket = *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)); + + parameters.programs.fillExtrusion.get(evaluated).draw( + painter.context, + gl::Triangles(), + painter.depthModeForSublayer(0, gl::DepthMode::ReadWrite), + gl::StencilMode::disabled(), + painter.colorModeForRenderPass(), + FillExtrusionUniforms::values( + tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), + evaluated.get<FillExtrusionTranslateAnchor>(), + painter.state), + painter.state, + painter.evaluatedLight + ), + *bucket.vertexBuffer, + *bucket.indexBuffer, + bucket.triangleSegments, + bucket.paintPropertyBinders.at(getID()), + evaluated, + painter.state.getZoom(), + getID()); + } + } else { + optional<ImagePosition> imagePosA = painter.imageManager->getPattern(evaluated.get<FillExtrusionPattern>().from); + optional<ImagePosition> imagePosB = painter.imageManager->getPattern(evaluated.get<FillExtrusionPattern>().to); + + if (!imagePosA || !imagePosB) { + return; + } + + painter.imageManager->bind(painter.context, 0); + + for (const RenderTile& tile : renderTiles) { + assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl))); + FillExtrusionBucket& bucket = *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)); + + parameters.programs.fillExtrusionPattern.get(evaluated).draw( + painter.context, + gl::Triangles(), + painter.depthModeForSublayer(0, gl::DepthMode::ReadWrite), + gl::StencilMode::disabled(), + painter.colorModeForRenderPass(), + FillExtrusionPatternUniforms::values( + tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(), + evaluated.get<FillExtrusionTranslateAnchor>(), + painter.state), + painter.imageManager->getPixelSize(), + *imagePosA, + *imagePosB, + evaluated.get<FillExtrusionPattern>(), + tile.id, + painter.state, + -std::pow(2, tile.id.canonical.z) / util::tileSize / 8.0f, + painter.evaluatedLight + ), + *bucket.vertexBuffer, + *bucket.indexBuffer, + bucket.triangleSegments, + bucket.paintPropertyBinders.at(getID()), + evaluated, + painter.state.getZoom(), + getID()); + } } } |