summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-18 10:16:17 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-19 09:31:07 -0700
commit356bba9e3be9ba9940d163020ec1369779487135 (patch)
treec60dfb80ecf7ddd8f9ba4746dee7a7f84e64422a
parent23198d793562718589d0242efaa9185c5e881007 (diff)
downloadqtlocation-mapboxgl-356bba9e3be9ba9940d163020ec1369779487135.tar.gz
[core] Inline Painter::renderFill
-rw-r--r--cmake/core-files.cmake1
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp142
-rw-r--r--src/mbgl/renderer/painter.hpp3
-rw-r--r--src/mbgl/renderer/painters/painter_fill.cpp143
4 files changed, 134 insertions, 155 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 948ac2a733..0394663d51 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -247,7 +247,6 @@ set(MBGL_CORE_FILES
# renderer/painters
src/mbgl/renderer/painters/painter_clipping.cpp
src/mbgl/renderer/painters/painter_debug.cpp
- src/mbgl/renderer/painters/painter_fill.cpp
src/mbgl/renderer/painters/painter_fill_extrusion.cpp
src/mbgl/renderer/painters/painter_line.cpp
src/mbgl/renderer/painters/painter_raster.cpp
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index 3063da36be..973b08dd1f 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -2,6 +2,10 @@
#include <mbgl/renderer/buckets/fill_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_program.hpp>
#include <mbgl/tile/tile.hpp>
#include <mbgl/style/layers/fill_layer_impl.hpp>
#include <mbgl/geometry/feature_index.hpp>
@@ -10,6 +14,8 @@
namespace mbgl {
+using namespace style;
+
RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl)
: RenderLayer(style::LayerType::Fill, _impl),
unevaluated(impl().paint.untransitioned()) {
@@ -54,14 +60,134 @@ bool RenderFillLayer::hasTransition() const {
}
void RenderFillLayer::render(Painter& painter, PaintParameters& parameters, RenderSource*) {
- for (const RenderTile& tile : renderTiles) {
- Bucket* bucket = tile.tile.getBucket(*baseImpl);
- assert(dynamic_cast<FillBucket*>(bucket));
- painter.renderFill(
- parameters,
- *reinterpret_cast<FillBucket*>(bucket),
- *this,
- tile);
+ if (evaluated.get<FillPattern>().from.empty()) {
+ for (const RenderTile& tile : renderTiles) {
+ assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
+ FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+
+ auto draw = [&] (uint8_t sublayer,
+ auto& program,
+ const auto& drawMode,
+ const auto& indexBuffer,
+ const auto& segments) {
+ program.get(evaluated).draw(
+ painter.context,
+ drawMode,
+ painter.depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
+ painter.stencilModeForClipping(tile.clip),
+ painter.colorModeForRenderPass(),
+ FillProgram::UniformValues {
+ uniforms::u_matrix::Value{
+ tile.translatedMatrix(evaluated.get<FillTranslate>(),
+ evaluated.get<FillTranslateAnchor>(),
+ painter.state)
+ },
+ uniforms::u_world::Value{ painter.context.viewport.getCurrentValue().size },
+ },
+ *bucket.vertexBuffer,
+ indexBuffer,
+ segments,
+ bucket.paintPropertyBinders.at(getID()),
+ evaluated,
+ painter.state.getZoom(),
+ getID()
+ );
+ };
+
+ if (evaluated.get<FillAntialias>() && !unevaluated.get<FillOutlineColor>().isUndefined() && painter.pass == RenderPass::Translucent) {
+ draw(2,
+ parameters.programs.fillOutline,
+ gl::Lines { 2.0f },
+ *bucket.lineIndexBuffer,
+ bucket.lineSegments);
+ }
+
+ // Only draw the fill when it's opaque and we're drawing opaque fragments,
+ // or when it's translucent and we're drawing translucent fragments.
+ if ((evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f
+ && evaluated.get<FillOpacity>().constantOr(0) >= 1.0f) == (painter.pass == RenderPass::Opaque)) {
+ draw(1,
+ parameters.programs.fill,
+ gl::Triangles(),
+ *bucket.triangleIndexBuffer,
+ bucket.triangleSegments);
+ }
+
+ if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined() && painter.pass == RenderPass::Translucent) {
+ draw(2,
+ parameters.programs.fillOutline,
+ gl::Lines { 2.0f },
+ *bucket.lineIndexBuffer,
+ bucket.lineSegments);
+ }
+ }
+ } else {
+ if (painter.pass != RenderPass::Translucent) {
+ return;
+ }
+
+ optional<ImagePosition> imagePosA = painter.imageManager->getPattern(evaluated.get<FillPattern>().from);
+ optional<ImagePosition> imagePosB = painter.imageManager->getPattern(evaluated.get<FillPattern>().to);
+
+ if (!imagePosA || !imagePosB) {
+ return;
+ }
+
+ painter.imageManager->bind(painter.context, 0);
+
+ for (const RenderTile& tile : renderTiles) {
+ assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
+ FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+
+ auto draw = [&] (uint8_t sublayer,
+ auto& program,
+ const auto& drawMode,
+ const auto& indexBuffer,
+ const auto& segments) {
+ program.get(evaluated).draw(
+ painter.context,
+ drawMode,
+ painter.depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
+ painter.stencilModeForClipping(tile.clip),
+ painter.colorModeForRenderPass(),
+ FillPatternUniforms::values(
+ tile.translatedMatrix(evaluated.get<FillTranslate>(),
+ evaluated.get<FillTranslateAnchor>(),
+ painter.state),
+ painter.context.viewport.getCurrentValue().size,
+ painter.imageManager->getPixelSize(),
+ *imagePosA,
+ *imagePosB,
+ evaluated.get<FillPattern>(),
+ tile.id,
+ painter.state
+ ),
+ *bucket.vertexBuffer,
+ indexBuffer,
+ segments,
+ bucket.paintPropertyBinders.at(getID()),
+ evaluated,
+ painter.state.getZoom(),
+ getID()
+ );
+ };
+
+ draw(0,
+ parameters.programs.fillPattern,
+ gl::Triangles(),
+ *bucket.triangleIndexBuffer,
+ bucket.triangleSegments);
+
+ if (!evaluated.get<FillAntialias>() || !unevaluated.get<FillOutlineColor>().isUndefined()) {
+ continue;
+ }
+
+ draw(2,
+ parameters.programs.fillOutlinePattern,
+ gl::Lines { 2.0f },
+ *bucket.lineIndexBuffer,
+ bucket.lineSegments);
+ }
}
}
diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp
index 645ddfd3ab..aef315ba22 100644
--- a/src/mbgl/renderer/painter.hpp
+++ b/src/mbgl/renderer/painter.hpp
@@ -39,13 +39,11 @@ struct FrameData;
class Tile;
class DebugBucket;
-class FillBucket;
class FillExtrusionBucket;
class LineBucket;
class SymbolBucket;
class RasterBucket;
-class RenderFillLayer;
class RenderFillExtrusionLayer;
class RenderLineLayer;
class RenderSymbolLayer;
@@ -79,7 +77,6 @@ public:
void renderClippingMask(const UnwrappedTileID&, const ClipID&);
void renderTileDebug(const RenderTile&);
void renderTileDebug(const mat4& matrix);
- void renderFill(PaintParameters&, FillBucket&, const RenderFillLayer&, const RenderTile&);
void renderFillExtrusion(PaintParameters&, FillExtrusionBucket&, const RenderFillExtrusionLayer&, const RenderTile&);
void renderLine(PaintParameters&, LineBucket&, const RenderLineLayer&, const RenderTile&);
void renderSymbol(PaintParameters&, SymbolBucket&, const RenderSymbolLayer&, const RenderTile&);
diff --git a/src/mbgl/renderer/painters/painter_fill.cpp b/src/mbgl/renderer/painters/painter_fill.cpp
deleted file mode 100644
index 3ca3bdf6b8..0000000000
--- a/src/mbgl/renderer/painters/painter_fill.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include <mbgl/renderer/painter.hpp>
-#include <mbgl/renderer/paint_parameters.hpp>
-#include <mbgl/renderer/buckets/fill_bucket.hpp>
-#include <mbgl/renderer/render_tile.hpp>
-#include <mbgl/renderer/layers/render_fill_layer.hpp>
-#include <mbgl/renderer/image_manager.hpp>
-#include <mbgl/style/layers/fill_layer_impl.hpp>
-#include <mbgl/programs/programs.hpp>
-#include <mbgl/programs/fill_program.hpp>
-#include <mbgl/util/convert.hpp>
-
-namespace mbgl {
-
-using namespace style;
-
-void Painter::renderFill(PaintParameters& parameters,
- FillBucket& bucket,
- const RenderFillLayer& layer,
- const RenderTile& tile) {
- const FillPaintProperties::PossiblyEvaluated& properties = layer.evaluated;
-
- if (!properties.get<FillPattern>().from.empty()) {
- if (pass != RenderPass::Translucent) {
- return;
- }
-
- optional<ImagePosition> imagePosA = imageManager->getPattern(properties.get<FillPattern>().from);
- optional<ImagePosition> imagePosB = imageManager->getPattern(properties.get<FillPattern>().to);
-
- if (!imagePosA || !imagePosB) {
- return;
- }
-
- imageManager->bind(context, 0);
-
- auto draw = [&] (uint8_t sublayer,
- auto& program,
- const auto& drawMode,
- const auto& indexBuffer,
- const auto& segments) {
- program.get(properties).draw(
- context,
- drawMode,
- depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
- stencilModeForClipping(tile.clip),
- colorModeForRenderPass(),
- FillPatternUniforms::values(
- tile.translatedMatrix(properties.get<FillTranslate>(),
- properties.get<FillTranslateAnchor>(),
- state),
- context.viewport.getCurrentValue().size,
- imageManager->getPixelSize(),
- *imagePosA,
- *imagePosB,
- properties.get<FillPattern>(),
- tile.id,
- state
- ),
- *bucket.vertexBuffer,
- indexBuffer,
- segments,
- bucket.paintPropertyBinders.at(layer.getID()),
- properties,
- state.getZoom(),
- layer.getID()
- );
- };
-
- draw(0,
- parameters.programs.fillPattern,
- gl::Triangles(),
- *bucket.triangleIndexBuffer,
- bucket.triangleSegments);
-
- if (!properties.get<FillAntialias>() || !layer.unevaluated.get<FillOutlineColor>().isUndefined()) {
- return;
- }
-
- draw(2,
- parameters.programs.fillOutlinePattern,
- gl::Lines { 2.0f },
- *bucket.lineIndexBuffer,
- bucket.lineSegments);
- } else {
- auto draw = [&] (uint8_t sublayer,
- auto& program,
- const auto& drawMode,
- const auto& indexBuffer,
- const auto& segments) {
- program.get(properties).draw(
- context,
- drawMode,
- depthModeForSublayer(sublayer, gl::DepthMode::ReadWrite),
- stencilModeForClipping(tile.clip),
- colorModeForRenderPass(),
- FillProgram::UniformValues {
- uniforms::u_matrix::Value{
- tile.translatedMatrix(properties.get<FillTranslate>(),
- properties.get<FillTranslateAnchor>(),
- state)
- },
- uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
- },
- *bucket.vertexBuffer,
- indexBuffer,
- segments,
- bucket.paintPropertyBinders.at(layer.getID()),
- properties,
- state.getZoom(),
- layer.getID()
- );
- };
-
- if (properties.get<FillAntialias>() && !layer.unevaluated.get<FillOutlineColor>().isUndefined() && pass == RenderPass::Translucent) {
- draw(2,
- parameters.programs.fillOutline,
- gl::Lines { 2.0f },
- *bucket.lineIndexBuffer,
- bucket.lineSegments);
- }
-
- // Only draw the fill when it's opaque and we're drawing opaque fragments,
- // or when it's translucent and we're drawing translucent fragments.
- if ((properties.get<FillColor>().constantOr(Color()).a >= 1.0f
- && properties.get<FillOpacity>().constantOr(0) >= 1.0f) == (pass == RenderPass::Opaque)) {
- draw(1,
- parameters.programs.fill,
- gl::Triangles(),
- *bucket.triangleIndexBuffer,
- bucket.triangleSegments);
- }
-
- if (properties.get<FillAntialias>() && layer.unevaluated.get<FillOutlineColor>().isUndefined() && pass == RenderPass::Translucent) {
- draw(2,
- parameters.programs.fillOutline,
- gl::Lines { 2.0f },
- *bucket.lineIndexBuffer,
- bucket.lineSegments);
- }
- }
-}
-
-} // namespace mbgl