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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/effects/SkColorFilters.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkColorMatrixFilter.h" 8 #include "SkColorMatrixFilter.h"
9 #include "SkColorMatrix.h" 9 #include "SkColorMatrix.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 str->append("matrix: ("); 331 str->append("matrix: (");
332 for (int i = 0; i < 20; ++i) { 332 for (int i = 0; i < 20; ++i) {
333 str->appendScalar(fMatrix.fMat[i]); 333 str->appendScalar(fMatrix.fMat[i]);
334 if (i < 19) { 334 if (i < 19) {
335 str->append(", "); 335 str->append(", ");
336 } 336 }
337 } 337 }
338 str->append(")"); 338 str->append(")");
339 } 339 }
340 #endif 340 #endif
341
342 ///////////////////////////////////////////////////////////////////////////////
343
344 static SkScalar byte_to_scale(U8CPU byte) {
345 if (0xFF == byte) {
346 // want to get this exact
347 return 1;
348 } else {
349 return byte * 0.00392156862745f;
350 }
351 }
352
353 SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor ad d) {
354 SkColorMatrix matrix;
355 matrix.setScale(byte_to_scale(SkColorGetR(mul)),
356 byte_to_scale(SkColorGetG(mul)),
357 byte_to_scale(SkColorGetB(mul)),
358 1);
359 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
360 SkIntToScalar(SkColorGetG(add)),
361 SkIntToScalar(SkColorGetB(add)),
362 0);
363 return SkColorMatrixFilter::Create(matrix);
364 }
365
366 // DEPRECTED -- remove this when chrome/android stop calling it
367 SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
368 return SkColorMatrixFilter::CreateLightingFilter(mul, add);
369 }
OLDNEW
« 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