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

Side by Side Diff: src/effects/SkColorMatrixFilter.cpp

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkColorFilterImageFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | 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 9
10 static SkScalar byte_to_scale(U8CPU byte) { 10 static SkScalar byte_to_scale(U8CPU byte) {
11 if (0xFF == byte) { 11 if (0xFF == byte) {
12 // want to get this exact 12 // want to get this exact
13 return 1; 13 return 1;
14 } else { 14 } else {
15 return byte * 0.00392156862745f; 15 return byte * 0.00392156862745f;
16 } 16 }
17 } 17 }
18 18
19 SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor ad d) { 19 sk_sp<SkColorFilter> SkColorMatrixFilter::MakeLightingFilter(SkColor mul, SkColo r add) {
20 SkColorMatrix matrix; 20 SkColorMatrix matrix;
21 matrix.setScale(byte_to_scale(SkColorGetR(mul)), 21 matrix.setScale(byte_to_scale(SkColorGetR(mul)),
22 byte_to_scale(SkColorGetG(mul)), 22 byte_to_scale(SkColorGetG(mul)),
23 byte_to_scale(SkColorGetB(mul)), 23 byte_to_scale(SkColorGetB(mul)),
24 1); 24 1);
25 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), 25 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
26 SkIntToScalar(SkColorGetG(add)), 26 SkIntToScalar(SkColorGetG(add)),
27 SkIntToScalar(SkColorGetB(add)), 27 SkIntToScalar(SkColorGetB(add)),
28 0); 28 0);
29 return SkColorMatrixFilter::Create(matrix); 29 return SkColorFilter::MakeMatrixFilterRowMajor255(matrix.fMat);
30 } 30 }
OLDNEW
« no previous file with comments | « src/effects/SkColorFilterImageFilter.cpp ('k') | src/effects/SkDropShadowImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698