| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Test.h" | 8 #include "Test.h" |
| 9 #include "SkColor.h" | 9 #include "SkColor.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (!r->allowExtendedTest()) { | 73 if (!r->allowExtendedTest()) { |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // No matter what xfermode we use, premul inputs should create premul output
s. | 77 // No matter what xfermode we use, premul inputs should create premul output
s. |
| 78 auto test_mode = [&](int m) { | 78 auto test_mode = [&](int m) { |
| 79 SkXfermode::Mode mode = (SkXfermode::Mode)m; | 79 SkXfermode::Mode mode = (SkXfermode::Mode)m; |
| 80 if (mode == SkXfermode::kSrcOver_Mode) { | 80 if (mode == SkXfermode::kSrcOver_Mode) { |
| 81 return; // TODO: can't create a SrcOver xfermode. | 81 return; // TODO: can't create a SrcOver xfermode. |
| 82 } | 82 } |
| 83 SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(mode)); | 83 auto xfermode(SkXfermode::Make(mode)); |
| 84 SkASSERT(xfermode); | 84 SkASSERT(xfermode); |
| 85 // We'll test all alphas and legal color values, assuming all colors wor
k the same. | 85 // We'll test all alphas and legal color values, assuming all colors wor
k the same. |
| 86 // This is not true for non-separable blend modes, but this test still c
an't hurt. | 86 // This is not true for non-separable blend modes, but this test still c
an't hurt. |
| 87 for (int sa = 0; sa <= 255; sa++) { | 87 for (int sa = 0; sa <= 255; sa++) { |
| 88 for (int da = 0; da <= 255; da++) { | 88 for (int da = 0; da <= 255; da++) { |
| 89 for (int s = 0; s <= sa; s++) { | 89 for (int s = 0; s <= sa; s++) { |
| 90 for (int d = 0; d <= da; d++) { | 90 for (int d = 0; d <= da; d++) { |
| 91 SkPMColor src = SkPackARGB32(sa, s, s, s), | 91 SkPMColor src = SkPackARGB32(sa, s, s, s), |
| 92 dst = SkPackARGB32(da, d, d, d); | 92 dst = SkPackARGB32(da, d, d, d); |
| 93 xfermode->xfer32(&dst, &src, 1, nullptr); // To keep it simple, no
AA. | 93 xfermode->xfer32(&dst, &src, 1, nullptr); // To keep it simple, no
AA. |
| 94 if (!SkPMColorValid(dst)) { | 94 if (!SkPMColorValid(dst)) { |
| 95 ERRORF(r, "%08x is not premul using %s", dst, SkXfermode::ModeNa
me(mode)); | 95 ERRORF(r, "%08x is not premul using %s", dst, SkXfermode::ModeNa
me(mode)); |
| 96 } | 96 } |
| 97 }}}} | 97 }}}} |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 // Parallelism helps speed things up on my desktop from ~725s to ~50s. | 100 // Parallelism helps speed things up on my desktop from ~725s to ~50s. |
| 101 SkTaskGroup().batch(SkXfermode::kLastMode, test_mode); | 101 SkTaskGroup().batch(SkXfermode::kLastMode, test_mode); |
| 102 } | 102 } |
| OLD | NEW |