Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: src/core/SkColor.cpp

Issue 1664663003: extend compose-colorfilter to 4f (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkColor.cpp
diff --git a/src/core/SkColor.cpp b/src/core/SkColor.cpp
index 865fe0de62820e106625cc6068c998f463fc26c8..87e3a9d60e2f18dfa449bd16f2033036a34ba1d0 100644
--- a/src/core/SkColor.cpp
+++ b/src/core/SkColor.cpp
@@ -111,6 +111,16 @@ SkPM4f SkPM4f::FromPMColor(SkPMColor c) {
return c4;
}
+SkColor4f SkPM4f::unpremul() const {
+ float alpha = fVec[A];
+ if (0 == alpha) {
+ return { 0, 0, 0, 0 };
+ } else {
+ float invAlpha = 1 / alpha;
+ return { alpha, fVec[R] * invAlpha, fVec[G] * invAlpha, fVec[B] * invAlpha };
+ }
+}
+
SkColor4f SkColor4f::FromColor(SkColor c) {
Sk4f value = SkNx_shuffle<3,2,1,0>(SkNx_cast<float>(Sk4b::Load(&c)));
SkColor4f c4;

Powered by Google App Engine
This is Rietveld 408576698