summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-18 10:28:43 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-19 09:31:07 -0700
commit0d951f39b6ca815780605d973e744e5aab3b1129 (patch)
treefe1ad65602d2a5abecd5d574fb227982c5d62ac7 /src
parent5d997ae08e099948dc99181967368a617e03282d (diff)
downloadqtlocation-mapboxgl-0d951f39b6ca815780605d973e744e5aab3b1129.tar.gz
[core] Inline Painter::renderLine
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp85
-rw-r--r--src/mbgl/renderer/painter.hpp3
-rw-r--r--src/mbgl/renderer/painters/painter_line.cpp92
3 files changed, 78 insertions, 102 deletions
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 68b4eaeaef..b40066f4c4 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -2,6 +2,11 @@
#include <mbgl/renderer/buckets/line_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/line_program.hpp>
+#include <mbgl/geometry/line_atlas.hpp>
#include <mbgl/tile/tile.hpp>
#include <mbgl/style/layers/line_layer_impl.hpp>
#include <mbgl/geometry/feature_index.hpp>
@@ -10,6 +15,8 @@
namespace mbgl {
+using namespace style;
+
RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl)
: RenderLayer(style::LayerType::Line, _impl),
unevaluated(impl().paint.untransitioned()) {
@@ -47,14 +54,78 @@ bool RenderLineLayer::hasTransition() const {
}
void RenderLineLayer::render(Painter& painter, PaintParameters& parameters, RenderSource*) {
+ if (painter.pass == RenderPass::Opaque) {
+ return;
+ }
+
for (const RenderTile& tile : renderTiles) {
- Bucket* bucket = tile.tile.getBucket(*baseImpl);
- assert(dynamic_cast<LineBucket*>(bucket));
- painter.renderLine(
- parameters,
- *reinterpret_cast<LineBucket*>(bucket),
- *this,
- tile);
+ assert(dynamic_cast<LineBucket*>(tile.tile.getBucket(*baseImpl)));
+ LineBucket& bucket = *reinterpret_cast<LineBucket*>(tile.tile.getBucket(*baseImpl));
+
+ auto draw = [&] (auto& program, auto&& uniformValues) {
+ program.get(evaluated).draw(
+ painter.context,
+ gl::Triangles(),
+ painter.depthModeForSublayer(0, gl::DepthMode::ReadOnly),
+ painter.stencilModeForClipping(tile.clip),
+ painter.colorModeForRenderPass(),
+ std::move(uniformValues),
+ *bucket.vertexBuffer,
+ *bucket.indexBuffer,
+ bucket.segments,
+ bucket.paintPropertyBinders.at(getID()),
+ evaluated,
+ painter.state.getZoom(),
+ getID()
+ );
+ };
+
+ if (!evaluated.get<LineDasharray>().from.empty()) {
+ const LinePatternCap cap = bucket.layout.get<LineCap>() == LineCapType::Round
+ ? LinePatternCap::Round : LinePatternCap::Square;
+ LinePatternPos posA = painter.lineAtlas->getDashPosition(evaluated.get<LineDasharray>().from, cap);
+ LinePatternPos posB = painter.lineAtlas->getDashPosition(evaluated.get<LineDasharray>().to, cap);
+
+ painter.lineAtlas->bind(painter.context, 0);
+
+ draw(parameters.programs.lineSDF,
+ LineSDFProgram::uniformValues(
+ evaluated,
+ painter.frame.pixelRatio,
+ tile,
+ painter.state,
+ painter.pixelsToGLUnits,
+ posA,
+ posB,
+ painter.lineAtlas->getSize().width));
+
+ } else if (!evaluated.get<LinePattern>().from.empty()) {
+ optional<ImagePosition> posA = painter.imageManager->getPattern(evaluated.get<LinePattern>().from);
+ optional<ImagePosition> posB = painter.imageManager->getPattern(evaluated.get<LinePattern>().to);
+
+ if (!posA || !posB)
+ return;
+
+ painter.imageManager->bind(painter.context, 0);
+
+ draw(parameters.programs.linePattern,
+ LinePatternProgram::uniformValues(
+ evaluated,
+ tile,
+ painter.state,
+ painter.pixelsToGLUnits,
+ painter.imageManager->getPixelSize(),
+ *posA,
+ *posB));
+
+ } else {
+ draw(parameters.programs.line,
+ LineProgram::uniformValues(
+ evaluated,
+ tile,
+ painter.state,
+ painter.pixelsToGLUnits));
+ }
}
}
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index 9b90b37fa3..60b03a16a9 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -39,11 +39,9 @@ struct FrameData;
class Tile;
class DebugBucket;
-class LineBucket;
class SymbolBucket;
class RasterBucket;
-class RenderLineLayer;
class RenderSymbolLayer;
class RenderRasterLayer;
@@ -75,7 +73,6 @@ public:
void renderClippingMask(const UnwrappedTileID&, const ClipID&);
void renderTileDebug(const RenderTile&);
void renderTileDebug(const mat4& matrix);
- void renderLine(PaintParameters&, LineBucket&, const RenderLineLayer&, const RenderTile&);
void renderSymbol(PaintParameters&, SymbolBucket&, const RenderSymbolLayer&, const RenderTile&);
void renderRaster(PaintParameters&, RasterBucket&, const RenderRasterLayer&, const mat4&, bool useBucketBuffers /* = false */);
diff --git a/src/mbgl/renderer/painters/painter_line.cpp b/src/mbgl/renderer/painters/painter_line.cpp
deleted file mode 100644
index 667e19283d..0000000000
--- a/src/mbgl/renderer/painters/painter_line.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <mbgl/renderer/painter.hpp>
-#include <mbgl/renderer/paint_parameters.hpp>
-#include <mbgl/renderer/buckets/line_bucket.hpp>
-#include <mbgl/renderer/render_tile.hpp>
-#include <mbgl/renderer/layers/render_line_layer.hpp>
-#include <mbgl/renderer/image_manager.hpp>
-#include <mbgl/style/layers/line_layer_impl.hpp>
-#include <mbgl/programs/programs.hpp>
-#include <mbgl/programs/line_program.hpp>
-#include <mbgl/geometry/line_atlas.hpp>
-
-namespace mbgl {
-
-using namespace style;
-
-void Painter::renderLine(PaintParameters& parameters,
- LineBucket& bucket,
- const RenderLineLayer& layer,
- const RenderTile& tile) {
- if (pass == RenderPass::Opaque) {
- return;
- }
-
- const RenderLinePaintProperties::PossiblyEvaluated& properties = layer.evaluated;
-
- auto draw = [&] (auto& program, auto&& uniformValues) {
- program.get(properties).draw(
- context,
- gl::Triangles(),
- depthModeForSublayer(0, gl::DepthMode::ReadOnly),
- stencilModeForClipping(tile.clip),
- colorModeForRenderPass(),
- std::move(uniformValues),
- *bucket.vertexBuffer,
- *bucket.indexBuffer,
- bucket.segments,
- bucket.paintPropertyBinders.at(layer.getID()),
- properties,
- state.getZoom(),
- layer.getID()
- );
- };
-
- if (!properties.get<LineDasharray>().from.empty()) {
- const LinePatternCap cap = bucket.layout.get<LineCap>() == LineCapType::Round
- ? LinePatternCap::Round : LinePatternCap::Square;
- LinePatternPos posA = lineAtlas->getDashPosition(properties.get<LineDasharray>().from, cap);
- LinePatternPos posB = lineAtlas->getDashPosition(properties.get<LineDasharray>().to, cap);
-
- lineAtlas->bind(context, 0);
-
- draw(parameters.programs.lineSDF,
- LineSDFProgram::uniformValues(
- properties,
- frame.pixelRatio,
- tile,
- state,
- pixelsToGLUnits,
- posA,
- posB,
- lineAtlas->getSize().width));
-
- } else if (!properties.get<LinePattern>().from.empty()) {
- optional<ImagePosition> posA = imageManager->getPattern(properties.get<LinePattern>().from);
- optional<ImagePosition> posB = imageManager->getPattern(properties.get<LinePattern>().to);
-
- if (!posA || !posB)
- return;
-
- imageManager->bind(context, 0);
-
- draw(parameters.programs.linePattern,
- LinePatternProgram::uniformValues(
- properties,
- tile,
- state,
- pixelsToGLUnits,
- imageManager->getPixelSize(),
- *posA,
- *posB));
-
- } else {
- draw(parameters.programs.line,
- LineProgram::uniformValues(
- properties,
- tile,
- state,
- pixelsToGLUnits));
- }
-}
-
-} // namespace mbgl