aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrColor.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/gpu/GrColor.h')
-rw-r--r--include/gpu/GrColor.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index cebceea2d0..64368b9ef9 100644
--- a/include/gpu/GrColor.h
+++ b/include/gpu/GrColor.h
@@ -213,6 +213,17 @@ struct GrColor4f {
return GrColor4f(color.fR, color.fG, color.fB, color.fA);
}
+ GrColor4f modulate(const GrColor4f& x) const {
+ return GrColor4f(fRGBA[0] * x.fRGBA[0],
+ fRGBA[1] * x.fRGBA[1],
+ fRGBA[2] * x.fRGBA[2],
+ fRGBA[3] * x.fRGBA[3]);
+ }
+
+ GrColor4f mulByScalar(float x) const {
+ return GrColor4f(fRGBA[0] * x, fRGBA[1] * x, fRGBA[2] * x, fRGBA[3] * x);
+ }
+
bool operator==(const GrColor4f& other) const {
return
fRGBA[0] == other.fRGBA[0] &&
@@ -240,6 +251,10 @@ struct GrColor4f {
return GrColor4f(fRGBA[0], fRGBA[1], fRGBA[2], 1.0f);
}
+ bool isOpaque() const {
+ return fRGBA[3] >= 1.f; // just in case precision causes a superopaque value.
+ }
+
GrColor4f premul() const {
float a = fRGBA[3];
return GrColor4f(fRGBA[0] * a, fRGBA[1] * a, fRGBA[2] * a, a);