summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-12-07 19:44:48 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-09 12:10:23 -0800
commit45c7b472adb78600ab9f9c8f82082d6b0af21ba2 (patch)
tree8c484a132031d19e76cdf6a4b8582876302deb74 /src
parent249966a9d7c5ca5acda7a57222bf119c5cbc2a97 (diff)
downloadqtlocation-mapboxgl-45c7b472adb78600ab9f9c8f82082d6b0af21ba2.tar.gz
[core] Ensure GL state is set to necessary values in more places
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/painter.cpp33
-rw-r--r--src/mbgl/renderer/painter_circle.cpp4
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp4
-rw-r--r--src/mbgl/renderer/painter_fill.cpp3
-rw-r--r--src/mbgl/renderer/painter_raster.cpp1
5 files changed, 26 insertions, 19 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index b0421a3931..819338091f 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -215,22 +215,28 @@ void Painter::renderPass(RenderPass pass_,
pass == RenderPass::Opaque ? "opaque" : "translucent");
}
- if (pass == RenderPass::Translucent) {
- config.blendFunc.reset();
- config.blend = GL_TRUE;
- } else {
- config.blend = GL_FALSE;
- }
-
for (; it != end; ++it, i += increment) {
currentLayer = i;
const auto& item = *it;
+
+ if (!item.layer.hasRenderPass(pass))
+ continue;
+
+ if (pass == RenderPass::Translucent) {
+ config.blendFunc.reset();
+ config.blend = GL_TRUE;
+ } else {
+ config.blend = GL_FALSE;
+ }
+
+ config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+ config.stencilMask = 0x0;
+ config.viewport = { 0, 0, frame.framebufferSize[0], frame.framebufferSize[1] };
+
if (item.bucket && item.tile) {
- if (item.layer.hasRenderPass(pass)) {
- MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
- prepareTile(*item.tile);
- item.bucket->render(*this, item.layer, item.tile->id, item.tile->matrix);
- }
+ MBGL_DEBUG_GROUP(item.layer.id + " - " + std::string(item.tile->id));
+ prepareTile(*item.tile);
+ item.bucket->render(*this, item.layer, item.tile->id, item.tile->matrix);
} else {
MBGL_DEBUG_GROUP("background");
renderBackground(*item.layer.template as<BackgroundLayer>());
@@ -251,7 +257,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
mapbox::util::optional<SpriteAtlasPosition> imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true);
mapbox::util::optional<SpriteAtlasPosition> imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true);
- if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque) || !imagePosA || !imagePosB)
+ if (!imagePosA || !imagePosB)
return;
float zoomFraction = state.getZoomFraction();
@@ -309,6 +315,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
config.stencilTest = GL_FALSE;
config.depthFunc.reset();
config.depthTest = GL_TRUE;
+ config.depthMask = GL_FALSE;
config.depthRange = { 1.0f, 1.0f };
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4));
diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp
index 67c23f8615..9518cf9e39 100644
--- a/src/mbgl/renderer/painter_circle.cpp
+++ b/src/mbgl/renderer/painter_circle.cpp
@@ -18,6 +18,10 @@ void Painter::renderCircle(CircleBucket& bucket,
if (pass == RenderPass::Opaque) return;
config.stencilTest = GL_FALSE;
+ config.depthFunc.reset();
+ config.depthTest = GL_TRUE;
+ config.depthMask = GL_FALSE;
+ setDepthSublayer(0);
const CirclePaintProperties& properties = layer.paint;
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index 4ac3271dd6..6994650412 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -23,10 +23,6 @@ void Painter::drawClippingMasks(const std::set<Source*>& sources) {
for (const auto& source : sources) {
source->drawClippingMasks(*this);
}
-
- config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
- config.depthMask = GL_TRUE;
- config.stencilMask = 0x0;
}
void Painter::drawClippingMask(const mat4& matrix, const ClipID &clip) {
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index beebdfcf83..9976d9f6f0 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -39,6 +39,7 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
config.stencilTest = GL_TRUE;
config.depthFunc.reset();
config.depthTest = GL_TRUE;
+ config.depthMask = GL_TRUE;
// Because we're drawing top-to-bottom, and we update the stencil mask
// befrom, we have to draw the outline first (!)
@@ -93,7 +94,6 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
spriteAtlas->bind(true);
// Draw the actual triangles into the color & stencil buffer.
- config.depthMask = GL_TRUE;
setDepthSublayer(0);
bucket.drawElements(*patternShader);
}
@@ -110,7 +110,6 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
plainShader->u_color = fill_color;
// Draw the actual triangles into the color & stencil buffer.
- config.depthMask = GL_TRUE;
setDepthSublayer(1);
bucket.drawElements(*plainShader);
}
diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp
index 9672d6f0d6..3fd953fcd6 100644
--- a/src/mbgl/renderer/painter_raster.cpp
+++ b/src/mbgl/renderer/painter_raster.cpp
@@ -26,6 +26,7 @@ void Painter::renderRaster(RasterBucket& bucket, const RasterLayer& layer, const
config.stencilTest = GL_TRUE;
config.depthFunc.reset();
config.depthTest = GL_TRUE;
+ config.depthMask = GL_FALSE;
setDepthSublayer(0);
bucket.drawRaster(*rasterShader, tileStencilBuffer, coveringRasterArray);
}