From b9fbb4f80b19b069a87f4c17f3340624f1b239a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 1 Jul 2014 12:49:53 +0200 Subject: [PATCH] make text painter respect text-opacity --- src/renderer/painter_text.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/renderer/painter_text.cpp b/src/renderer/painter_text.cpp index 89c9d4107..d8639ad9c 100644 --- a/src/renderer/painter_text.cpp +++ b/src/renderer/painter_text.cpp @@ -95,7 +95,16 @@ void Painter::renderText(TextBucket& bucket, std::shared_ptr layer_d // TODO: Get rid of the 2.4 magic value. It is currently 24 / 10, with 24 being the font size // of the SDF glyphs. textShader->setGamma(properties.halo_blur * 2.4f / fontSize / map.getState().getPixelRatio()); - textShader->setColor(properties.halo_color); + if (properties.opacity < 1.0f) { + Color color = properties.halo_color; + color[0] *= properties.opacity; + color[1] *= properties.opacity; + color[2] *= properties.opacity; + color[3] *= properties.opacity; + textShader->setColor(color); + } else { + textShader->setColor(properties.halo_color); + } textShader->setBuffer(properties.halo_width); glDepthRange(strata, 1.0f); bucket.drawGlyphs(*textShader); @@ -106,7 +115,16 @@ void Painter::renderText(TextBucket& bucket, std::shared_ptr layer_d // TODO: Get rid of the 2.4 magic value. It is currently 24 / 10, with 24 being the font size // of the SDF glyphs. textShader->setGamma(2.4f / fontSize / map.getState().getPixelRatio()); - textShader->setColor(properties.color); + if (properties.opacity < 1.0f) { + Color color = properties.color; + color[0] *= properties.opacity; + color[1] *= properties.opacity; + color[2] *= properties.opacity; + color[3] *= properties.opacity; + textShader->setColor(color); + } else { + textShader->setColor(properties.color); + } textShader->setBuffer((256.0f - 64.0f) / 256.0f); glDepthRange(strata + strata_epsilon, 1.0f); bucket.drawGlyphs(*textShader);