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

Side by Side Diff: tests/GrGetCoeffBlendKnownComponentsTest.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
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 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 13 matching lines...) Expand all
24 // null means src-over 24 // null means src-over
25 skDst = SkPMSrcOver(skSrc, skDst); 25 skDst = SkPMSrcOver(skSrc, skDst);
26 } 26 }
27 return SkPMColorToGrColor(skDst); 27 return SkPMColorToGrColor(skDst);
28 } 28 }
29 29
30 DEF_TEST(GrGetCoeffBlendKnownComponents, reporter) { 30 DEF_TEST(GrGetCoeffBlendKnownComponents, reporter) {
31 SkRandom random; 31 SkRandom random;
32 for (int i = 0; i < SkXfermode::kLastCoeffMode; ++i) { 32 for (int i = 0; i < SkXfermode::kLastCoeffMode; ++i) {
33 SkXfermode::Mode mode = (SkXfermode::Mode)i; 33 SkXfermode::Mode mode = (SkXfermode::Mode)i;
34 SkAutoTUnref<SkXfermode> xm(SkXfermode::Create(mode)); 34 auto xm(SkXfermode::Make(mode));
35 SkXfermode::Coeff srcCoeff, dstCoeff; 35 SkXfermode::Coeff srcCoeff, dstCoeff;
36 SkAssertResult(SkXfermode::ModeAsCoeff(mode, &srcCoeff, &dstCoeff)); 36 SkAssertResult(SkXfermode::ModeAsCoeff(mode, &srcCoeff, &dstCoeff));
37 for (int j = 0; j < 1000; ++j) { 37 for (int j = 0; j < 1000; ++j) {
38 GrColor src = GrPremulColor(random.nextU()); 38 GrColor src = GrPremulColor(random.nextU());
39 GrColor dst = GrPremulColor(random.nextU()); 39 GrColor dst = GrPremulColor(random.nextU());
40 GrColor outColor; 40 GrColor outColor;
41 GrColorComponentFlags outFlags; 41 GrColorComponentFlags outFlags;
42 GrGetCoeffBlendKnownComponents(SkXfermodeCoeffToGrBlendCoeff(srcCoef f), 42 GrGetCoeffBlendKnownComponents(SkXfermodeCoeffToGrBlendCoeff(srcCoef f),
43 SkXfermodeCoeffToGrBlendCoeff(dstCoef f), 43 SkXfermodeCoeffToGrBlendCoeff(dstCoef f),
44 src, kRGBA_GrColorComponentFlags, 44 src, kRGBA_GrColorComponentFlags,
45 dst, kRGBA_GrColorComponentFlags, 45 dst, kRGBA_GrColorComponentFlags,
46 &outColor, &outFlags); 46 &outColor, &outFlags);
47 GrColor baselineColor = make_baseline_color(src, dst, xm); 47 GrColor baselineColor = make_baseline_color(src, dst, xm.get());
48 if (SkAbs32(GrColorUnpackA(baselineColor) - GrColorUnpackA(outColor) ) > 1 || 48 if (SkAbs32(GrColorUnpackA(baselineColor) - GrColorUnpackA(outColor) ) > 1 ||
49 SkAbs32(GrColorUnpackR(baselineColor) - GrColorUnpackR(outColor) ) > 1 || 49 SkAbs32(GrColorUnpackR(baselineColor) - GrColorUnpackR(outColor) ) > 1 ||
50 SkAbs32(GrColorUnpackG(baselineColor) - GrColorUnpackG(outColor) ) > 1 || 50 SkAbs32(GrColorUnpackG(baselineColor) - GrColorUnpackG(outColor) ) > 1 ||
51 SkAbs32(GrColorUnpackB(baselineColor) - GrColorUnpackB(outColor) ) > 1) { 51 SkAbs32(GrColorUnpackB(baselineColor) - GrColorUnpackB(outColor) ) > 1) {
52 ERRORF(reporter, "Blended color is 0x%08x, expected 0x%08x", out Color, 52 ERRORF(reporter, "Blended color is 0x%08x, expected 0x%08x", out Color,
53 baselineColor); 53 baselineColor);
54 } 54 }
55 GrColorIsPMAssert(outColor); 55 GrColorIsPMAssert(outColor);
56 } 56 }
57 } 57 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 kOne_GrBlendCoeff, kISA_GrBlendCoeff, 94 kOne_GrBlendCoeff, kISA_GrBlendCoeff,
95 0xFF808080, (kG_GrColorComponentFlag | kB_GrColorComponentFlag | kA_GrCo lorComponentFlag), 95 0xFF808080, (kG_GrColorComponentFlag | kB_GrColorComponentFlag | kA_GrCo lorComponentFlag),
96 0xFF606060, kRGBA_GrColorComponentFlags, 96 0xFF606060, kRGBA_GrColorComponentFlags,
97 &outColor, &outFlags); 97 &outColor, &outFlags);
98 REPORTER_ASSERT(reporter, 98 REPORTER_ASSERT(reporter,
99 (kG_GrColorComponentFlag | kB_GrColorComponentFlag | kA_GrCo lorComponentFlag) == outFlags && 99 (kG_GrColorComponentFlag | kB_GrColorComponentFlag | kA_GrCo lorComponentFlag) == outFlags &&
100 (outColor & 0xFFFFFF00) == 0xFF808000); 100 (outColor & 0xFFFFFF00) == 0xFF808000);
101 } 101 }
102 102
103 #endif 103 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698