summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/painter_clipping.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/renderer/painter_clipping.cpp')
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index 6994650412..aed4c45869 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -1,36 +1,39 @@
#include <mbgl/renderer/painter.hpp>
-#include <mbgl/map/source.hpp>
+#include <mbgl/source/source.hpp>
#include <mbgl/shader/plain_shader.hpp>
#include <mbgl/util/clip_id.hpp>
#include <mbgl/gl/debugging.hpp>
using namespace mbgl;
-void Painter::drawClippingMasks(const std::set<Source*>& sources) {
+
+void Painter::drawClippingMasks(const std::map<TileID, ClipID>& stencils) {
MBGL_DEBUG_GROUP("clipping masks");
- config.program = plainShader->program;
+ mat4 matrix;
+ const GLuint mask = 0b11111111;
+
+ config.program = plainShader->getID();
config.stencilOp.reset();
config.stencilTest = GL_TRUE;
- config.depthFunc.reset();
- config.depthTest = GL_TRUE;
+ config.depthTest = GL_FALSE;
config.depthMask = GL_FALSE;
config.colorMask = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
- config.depthRange = { 1.0f, 1.0f };
+ config.stencilMask = mask;
- coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET_0);
+ coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET_0, glObjectStore);
- for (const auto& source : sources) {
- source->drawClippingMasks(*this);
- }
-}
+ for (const auto& stencil : stencils) {
+ const auto& id = stencil.first;
+ const auto& clip = stencil.second;
-void Painter::drawClippingMask(const mat4& matrix, const ClipID &clip) {
- plainShader->u_matrix = matrix;
+ MBGL_DEBUG_GROUP(std::string{ "mask: " } + std::string(id));
+ state.matrixFor(matrix, id, id.z);
+ matrix::multiply(matrix, projMatrix, matrix);
+ plainShader->u_matrix = matrix;
- const GLint ref = (GLint)(clip.reference.to_ulong());
- const GLuint mask = (GLuint)(clip.mask.to_ulong());
- config.stencilFunc = { GL_ALWAYS, ref, mask };
- config.stencilMask = mask;
- MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
+ const GLint ref = (GLint)(clip.reference.to_ulong());
+ config.stencilFunc = { GL_ALWAYS, ref, mask };
+ MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
+ }
}