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

Side by Side Diff: tests/SkColor4fTest.cpp

Issue 1782703002: sk_sp versions of newWithColorFilter and newWithLocalMatrix (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/core/SkLocalMatrixShader.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 2016 Google Inc. 2 * Copyright 2016 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 "SkColor.h" 8 #include "SkColor.h"
9 #include "SkColorMatrixFilter.h" 9 #include "SkColorMatrixFilter.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const SkColor colors[] { SK_ColorRED, SK_ColorBLUE }; 118 const SkColor colors[] { SK_ColorRED, SK_ColorBLUE };
119 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kCl amp_TileMode); 119 return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kCl amp_TileMode);
120 #else 120 #else
121 // TODO: need to convert new gradient code to enforce PM4f --> RGBA order 121 // TODO: need to convert new gradient code to enforce PM4f --> RGBA order
122 return make_color_sh(); 122 return make_color_sh();
123 #endif 123 #endif
124 } 124 }
125 125
126 static sk_sp<SkShader> make_cf_sh() { 126 static sk_sp<SkShader> make_cf_sh() {
127 SkAutoTUnref<SkColorFilter> filter(make_mx_cf()); 127 SkAutoTUnref<SkColorFilter> filter(make_mx_cf());
128 sk_sp<SkShader> shader(make_color_sh()); 128 return make_color_sh()->makeWithColorFilter(filter);
129 return sk_sp<SkShader>(shader->newWithColorFilter(filter));
130 } 129 }
131 130
132 static bool compare_spans(const SkPM4f span4f[], const SkPMColor span4b[], int c ount, 131 static bool compare_spans(const SkPM4f span4f[], const SkPMColor span4b[], int c ount,
133 float tolerance = 1.0f/255) { 132 float tolerance = 1.0f/255) {
134 for (int i = 0; i < count; ++i) { 133 for (int i = 0; i < count; ++i) {
135 SkPM4f c0 = SkPM4f::FromPMColor(span4b[i]); 134 SkPM4f c0 = SkPM4f::FromPMColor(span4b[i]);
136 SkPM4f c1 = span4f[i]; 135 SkPM4f c1 = span4f[i];
137 if (!nearly_equal(c0, c1, tolerance)) { 136 if (!nearly_equal(c0, c1, tolerance)) {
138 return false; 137 return false;
139 } 138 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // 243 //
245 DEF_TEST(Color4f_xfermode_proc4f, reporter) { 244 DEF_TEST(Color4f_xfermode_proc4f, reporter) {
246 // TODO: extend xfermodes so that all cases can be tested. 245 // TODO: extend xfermodes so that all cases can be tested.
247 // 246 //
248 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; + +mode) { 247 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; + +mode) {
249 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); 248 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode);
250 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); 249 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode);
251 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); 250 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f));
252 } 251 }
253 } 252 }
OLDNEW
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698