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

Unified Diff: src/effects/SkColorMatrixFilter.cpp

Issue 1574023002: move declaration of CreateLightingFilter into SkColorMatrixFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: don't remove old impl yet Created 4 years, 11 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
« no previous file with comments | « src/effects/SkColorFilters.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkColorMatrixFilter.cpp
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 3cc6e2c0c0e20cab72ed9a470c4215d48ee89fcc..f24670e4bc2bdedf634b62cff7a6030658265c8c 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -338,3 +338,32 @@ void SkColorMatrixFilter::toString(SkString* str) const {
str->append(")");
}
#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
+static SkScalar byte_to_scale(U8CPU byte) {
+ if (0xFF == byte) {
+ // want to get this exact
+ return 1;
+ } else {
+ return byte * 0.00392156862745f;
+ }
+}
+
+SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
+ SkColorMatrix matrix;
+ matrix.setScale(byte_to_scale(SkColorGetR(mul)),
+ byte_to_scale(SkColorGetG(mul)),
+ byte_to_scale(SkColorGetB(mul)),
+ 1);
+ matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
+ SkIntToScalar(SkColorGetG(add)),
+ SkIntToScalar(SkColorGetB(add)),
+ 0);
+ return SkColorMatrixFilter::Create(matrix);
+}
+
+// DEPRECTED -- remove this when chrome/android stop calling it
+SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
+ return SkColorMatrixFilter::CreateLightingFilter(mul, add);
+}
« no previous file with comments | « src/effects/SkColorFilters.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698