OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SkRandom rand; | 181 SkRandom rand; |
182 for (int i = 0; i < N; ++i) { | 182 for (int i = 0; i < N; ++i) { |
183 src4b[i] = SkPreMultiplyColor(rand.nextU()); | 183 src4b[i] = SkPreMultiplyColor(rand.nextU()); |
184 src4f[i] = SkPM4f::FromPMColor(src4b[i]); | 184 src4f[i] = SkPM4f::FromPMColor(src4b[i]); |
185 } | 185 } |
186 // confirm that our srcs are (nearly) equal | 186 // confirm that our srcs are (nearly) equal |
187 compare_spans(src4f, src4b, N, reporter); | 187 compare_spans(src4f, src4b, N, reporter); |
188 | 188 |
189 for (const auto& rec : recs) { | 189 for (const auto& rec : recs) { |
190 SkAutoTUnref<SkColorFilter> filter(rec.fFact()); | 190 SkAutoTUnref<SkColorFilter> filter(rec.fFact()); |
191 REPORTER_ASSERT(reporter, filter->supports4f() == rec.fSupports4f); | 191 SkPMColor dst4b[N]; |
192 if (filter->supports4f()) { | 192 filter->filterSpan(src4b, N, dst4b); |
193 SkPMColor dst4b[N]; | 193 SkPM4f dst4f[N]; |
194 filter->filterSpan(src4b, N, dst4b); | 194 filter->filterSpan4f(src4f, N, dst4f); |
195 SkPM4f dst4f[N]; | 195 compare_spans(dst4f, dst4b, N, reporter); |
196 filter->filterSpan4f(src4f, N, dst4f); | |
197 compare_spans(dst4f, dst4b, N, reporter); | |
198 } | |
199 } | 196 } |
200 } | 197 } |
201 | 198 |
202 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 199 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
203 | 200 |
204 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); | 201 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); |
205 | 202 |
206 static bool compare_procs(SkXfermodeProc proc32, SkXfermodeProc4f proc4f) { | 203 static bool compare_procs(SkXfermodeProc proc32, SkXfermodeProc4f proc4f) { |
207 const float kTolerance = 1.0f / 255; | 204 const float kTolerance = 1.0f / 255; |
208 | 205 |
(...skipping 24 matching lines...) Expand all Loading... |
233 // | 230 // |
234 DEF_TEST(Color4f_xfermode_proc4f, reporter) { | 231 DEF_TEST(Color4f_xfermode_proc4f, reporter) { |
235 // TODO: extend xfermodes so that all cases can be tested. | 232 // TODO: extend xfermodes so that all cases can be tested. |
236 // | 233 // |
237 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { | 234 for (int mode = SkXfermode::kClear_Mode; mode <= SkXfermode::kScreen_Mode; +
+mode) { |
238 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); | 235 SkXfermodeProc proc32 = SkXfermode::GetProc((SkXfermode::Mode)mode); |
239 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); | 236 SkXfermodeProc4f proc4f = SkXfermode::GetProc4f((SkXfermode::Mode)mode); |
240 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); | 237 REPORTER_ASSERT(reporter, compare_procs(proc32, proc4f)); |
241 } | 238 } |
242 } | 239 } |
OLD | NEW |