summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/painter_fill.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-05-24 17:57:08 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-05-25 21:37:58 -0700
commitc568a8ad77320c869d8e7c23b86426c094aceb6c (patch)
tree24b821b4cd8f374344feaba4d3be51e9cc37d1a8 /src/mbgl/renderer/painter_fill.cpp
parentd7a477b16586d830d9b0862f732302c4ae06aca5 (diff)
downloadqtlocation-mapboxgl-c568a8ad77320c869d8e7c23b86426c094aceb6c.tar.gz
[core] Port "separate u_opacity from u_color"
https://github.com/mapbox/mapbox-gl-shaders/commit/0d3412519618a3a1672db9fa21f96f90070cf84c https://github.com/mapbox/mapbox-gl-js/commit/1f5afa7db08a2bdcc492a46e500ff5d020e6f4a2
Diffstat (limited to 'src/mbgl/renderer/painter_fill.cpp')
-rw-r--r--src/mbgl/renderer/painter_fill.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp
index 1ac90a2806..ed0b3eec53 100644
--- a/src/mbgl/renderer/painter_fill.cpp
+++ b/src/mbgl/renderer/painter_fill.cpp
@@ -18,19 +18,11 @@ void Painter::renderFill(FillBucket& bucket,
translatedMatrix(matrix, properties.fillTranslate, tileID, properties.fillTranslateAnchor);
Color fill_color = properties.fillColor;
- fill_color[0] *= properties.fillOpacity;
- fill_color[1] *= properties.fillOpacity;
- fill_color[2] *= properties.fillOpacity;
- fill_color[3] *= properties.fillOpacity;
+ float opacity = properties.fillOpacity;
Color stroke_color = properties.fillOutlineColor;
if (stroke_color[3] < 0) {
stroke_color = fill_color;
- } else {
- stroke_color[0] *= properties.fillOpacity;
- stroke_color[1] *= properties.fillOpacity;
- stroke_color[2] *= properties.fillOpacity;
- stroke_color[3] *= properties.fillOpacity;
}
bool pattern = !properties.fillPattern.value.from.empty();
@@ -41,6 +33,7 @@ void Painter::renderFill(FillBucket& bucket,
if (wireframe) {
fill_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
stroke_color = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
+ opacity = 1.0f;
pattern = false;
outline = true;
fringeline = true;
@@ -60,6 +53,7 @@ void Painter::renderFill(FillBucket& bucket,
config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!
outlineShader->u_color = stroke_color;
+ outlineShader->u_opacity = opacity;
// Draw the entire line
outlineShader->u_world = {{
@@ -164,7 +158,7 @@ void Painter::renderFill(FillBucket& bucket,
}
} else if (!wireframe) {
// No image fill.
- if ((fill_color[3] >= 1.0f) == (pass == RenderPass::Opaque)) {
+ if ((fill_color[3] >= 1.0f && opacity >= 1.0f) == (pass == RenderPass::Opaque)) {
// Only draw the fill when it's either opaque and we're drawing opaque
// fragments or when it's translucent and we're drawing translucent
// fragments
@@ -172,6 +166,7 @@ void Painter::renderFill(FillBucket& bucket,
config.program = plainShader->getID();
plainShader->u_matrix = vtxMatrix;
plainShader->u_color = fill_color;
+ plainShader->u_opacity = opacity;
// Draw the actual triangles into the color & stencil buffer.
setDepthSublayer(1);
@@ -187,7 +182,8 @@ void Painter::renderFill(FillBucket& bucket,
config.lineWidth = 2.0f; // This is always fixed and does not depend on the pixelRatio!
outlineShader->u_color = fill_color;
-
+ outlineShader->u_opacity = opacity;
+
// Draw the entire line
outlineShader->u_world = {{
static_cast<float>(frame.framebufferSize[0]),