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.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index 64368b9ef9..ad66523bcb 100644
--- a/include/gpu/GrColor.h
+++ b/include/gpu/GrColor.h
@@ -259,6 +259,15 @@ struct GrColor4f {
float a = fRGBA[3];
return GrColor4f(fRGBA[0] * a, fRGBA[1] * a, fRGBA[2] * a, a);
}
+
+ GrColor4f unpremul() const {
+ float a = fRGBA[3];
+ if (a <= 0.0f) {
+ return GrColor4f(0.0f, 0.0f, 0.0f, 0.0f);
+ }
+ float invAlpha = 1.0f / a;
+ return GrColor4f(fRGBA[0] * invAlpha, fRGBA[1] * invAlpha, fRGBA[2] * invAlpha, a);
+ }
};
/**