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

Side by Side Diff: tests/BlendTest.cpp

Issue 1228333003: Replace buggy_blend_modes GM with an exhaustive test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « include/core/SkColorPriv.h ('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 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include "Test.h" 8 #include "Test.h"
2 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkColorPriv.h"
11 #include "SkTaskGroup.h"
12 #include "SkXfermode.h"
3 13
4 #define ASSERT(x) REPORTER_ASSERT(r, x) 14 #define ASSERT(x) REPORTER_ASSERT(r, x)
5 15
6 static uint8_t double_to_u8(double d) { 16 static uint8_t double_to_u8(double d) {
7 SkASSERT(d >= 0); 17 SkASSERT(d >= 0);
8 SkASSERT(d < 256); 18 SkASSERT(d < 256);
9 return uint8_t(d); 19 return uint8_t(d);
10 } 20 }
11 21
12 // All algorithms we're testing have this interface. 22 // All algorithms we're testing have this interface.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // blend_perfect 259 // blend_perfect
250 // GOOD ENOUGH 260 // GOOD ENOUGH
251 // blend_double_trunc 261 // blend_double_trunc
252 // blend_float_trunc 262 // blend_float_trunc
253 // blend_256_round 263 // blend_256_round
254 // blend_256_round_alt 264 // blend_256_round_alt
255 // NOT GOOD ENOUGH 265 // NOT GOOD ENOUGH
256 // all others 266 // all others
257 // 267 //
258 // Algorithms that make sense to use in Skia: blend_256_round, blend_256_round_ alt, blend_perfect 268 // Algorithms that make sense to use in Skia: blend_256_round, blend_256_round_ alt, blend_perfect
269
270 DEF_TEST(Blend_premul_begets_premul, r) {
271 // This test is quite slow, even if you have enough cores to run each mode i n parallel.
272 if (!r->allowExtendedTest()) {
273 return;
274 }
275
276 // No matter what xfermode we use, premul inputs should create premul output s.
277 auto test_mode = [&](int m) {
278 SkXfermode::Mode mode = (SkXfermode::Mode)m;
279 if (mode == SkXfermode::kSrcOver_Mode) {
280 return; // TODO: can't create a SrcOver xfermode.
281 }
282 SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(mode));
283 SkASSERT(xfermode);
284 // We'll test all alphas and legal color values, assuming all colors wor k the same.
285 // This is not true for non-separable blend modes, but this test still c an't hurt.
286 for (int sa = 0; sa <= 255; sa++) {
287 for (int da = 0; da <= 255; da++) {
288 for (int s = 0; s <= sa; s++) {
289 for (int d = 0; d <= da; d++) {
290 SkPMColor src = SkPackARGB32(sa, s, s, s),
291 dst = SkPackARGB32(da, d, d, d);
292 xfermode->xfer32(&dst, &src, 1, nullptr); // To keep it simple, no AA.
293 if (!SkPMColorValid(dst)) {
294 ERRORF(r, "%08x is not premul using %s", dst, SkXfermode::ModeNa me(mode));
295 }
296 }}}}
297 };
298
299 // Parallelism helps speed things up on my desktop from ~725s to ~50s.
300 sk_parallel_for(SkXfermode::kLastMode, test_mode);
301 }
OLDNEW
« no previous file with comments | « include/core/SkColorPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698