summaryrefslogtreecommitdiff
path: root/src/mbgl/style/expression
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-01-08 12:30:15 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-01-08 12:43:03 -0800
commitf108066ce8ffa4a56b0e76092e58af5f4640b93d (patch)
tree7956f4c8265850da47f5cea6ffc7377d7621504a /src/mbgl/style/expression
parentdcd7019e7deeff1cb2a7bcaa7748d0f80461a190 (diff)
downloadqtlocation-mapboxgl-upstream/fix-10604.tar.gz
[core] Fix alpha handling in rgba and to-rgba operatorsupstream/fix-10604
Diffstat (limited to 'src/mbgl/style/expression')
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp7
-rw-r--r--src/mbgl/style/expression/util.cpp4
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index 70bc6dfd95..e5f849144b 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -216,7 +216,12 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
);
});
define("to-rgba", [](const Color& color) -> Result<std::array<double, 4>> {
- return std::array<double, 4> {{ color.r, color.g, color.b, color.a }};
+ return std::array<double, 4> {{
+ 255 * color.r / color.a,
+ 255 * color.g / color.a,
+ 255 * color.b / color.a,
+ color.a
+ }};
});
define("rgba", rgba);
diff --git a/src/mbgl/style/expression/util.cpp b/src/mbgl/style/expression/util.cpp
index f198fb3e1b..ee680dab08 100644
--- a/src/mbgl/style/expression/util.cpp
+++ b/src/mbgl/style/expression/util.cpp
@@ -1,4 +1,3 @@
-
#include <mbgl/style/expression/util.hpp>
#include <mbgl/style/expression/value.hpp>
@@ -30,10 +29,9 @@ Result<Color> rgba(double r, double g, double b, double a) {
"]: 'a' must be between 0 and 1."
};
}
- return Color(r / 255, g / 255, b / 255, a);
+ return Color(r / 255 * a, g / 255 * a, b / 255 * a, a);
}
} // namespace expression
} // namespace style
} // namespace mbgl
-