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 "SkXfermode.h" | 8 #include "SkXfermode.h" |
9 #include "Test.h" | 9 #include "Test.h" |
10 | 10 |
11 #if SK_SUPPORT_GPU | 11 #if SK_SUPPORT_GPU |
12 | 12 |
13 #include "GrContextFactory.h" | 13 #include "GrContextFactory.h" |
14 #include "GrContextOptions.h" | 14 #include "GrContextOptions.h" |
15 #include "GrGpu.h" | 15 #include "GrGpu.h" |
16 #include "GrResourceProvider.h" | 16 #include "GrResourceProvider.h" |
17 #include "GrXferProcessor.h" | 17 #include "GrXferProcessor.h" |
18 #include "batches/GrVertexBatch.h" | 18 #include "batches/GrVertexBatch.h" |
19 #include "effects/GrPorterDuffXferProcessor.h" | 19 #include "effects/GrPorterDuffXferProcessor.h" |
20 #include "gl/GrGLCaps.h" | 20 #include "gl/GrGLCaps.h" |
21 | 21 |
22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
23 | 23 |
24 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps); | 24 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps); |
25 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps); | 25 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps); |
26 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps); | 26 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps); |
27 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps); | 27 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps); |
28 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps); | 28 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
| 29 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
GrCaps& caps); |
29 static void test_no_dual_source_blending(skiatest::Reporter* reporter); | 30 static void test_no_dual_source_blending(skiatest::Reporter* reporter); |
30 | 31 |
31 DEF_GPUTEST(GrPorterDuff, reporter, factory) { | 32 DEF_GPUTEST(GrPorterDuff, reporter, factory) { |
32 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); | 33 GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); |
33 if (!ctx) { | 34 if (!ctx) { |
34 SkFAIL("Failed to create null context."); | 35 SkFAIL("Failed to create null context."); |
35 return; | 36 return; |
36 } | 37 } |
37 | 38 |
38 const GrCaps& caps = *ctx->getGpu()->caps(); | 39 const GrCaps& caps = *ctx->getGpu()->caps(); |
39 if (!caps.shaderCaps()->dualSourceBlendingSupport()) { | 40 if (!caps.shaderCaps()->dualSourceBlendingSupport()) { |
40 SkFAIL("Null context does not support dual source blending."); | 41 SkFAIL("Null context does not support dual source blending."); |
41 return; | 42 return; |
42 } | 43 } |
43 | 44 |
44 test_color_unknown_with_coverage(reporter, caps); | 45 test_color_unknown_with_coverage(reporter, caps); |
45 test_color_unknown_no_coverage(reporter, caps); | 46 test_color_unknown_no_coverage(reporter, caps); |
46 test_color_opaque_with_coverage(reporter, caps); | 47 test_color_opaque_with_coverage(reporter, caps); |
47 test_color_opaque_no_coverage(reporter, caps); | 48 test_color_opaque_no_coverage(reporter, caps); |
48 test_lcd_coverage(reporter, caps); | 49 test_lcd_coverage(reporter, caps); |
| 50 test_lcd_coverage_fallback_case(reporter, caps); |
49 test_no_dual_source_blending(reporter); | 51 test_no_dual_source_blending(reporter); |
50 } | 52 } |
51 | 53 |
52 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
53 | 55 |
54 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) | 56 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) |
55 | 57 |
56 enum { | 58 enum { |
57 kNone_OutputType, | 59 kNone_OutputType, |
58 kCoverage_OutputType, | 60 kCoverage_OutputType, |
59 kModulate_OutputType, | 61 kModulate_OutputType, |
| 62 kSAModulate_OutputType, |
60 kISAModulate_OutputType, | 63 kISAModulate_OutputType, |
61 kISCModulate_OutputType | 64 kISCModulate_OutputType |
62 }; | 65 }; |
63 | 66 |
64 enum { | 67 enum { |
65 kNone_OptFlags = GrXferProcessor::kNone_OptFlags, | 68 kNone_OptFlags = GrXferProcessor::kNone_OptFlags, |
66 kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, | 69 kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, |
67 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, | 70 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
68 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, | 71 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, |
69 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag | 72 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag |
(...skipping 21 matching lines...) Expand all Loading... |
91 int fPrimaryOutputType; | 94 int fPrimaryOutputType; |
92 int fSecondaryOutputType; | 95 int fSecondaryOutputType; |
93 GrXferProcessor::BlendInfo fBlendInfo; | 96 GrXferProcessor::BlendInfo fBlendInfo; |
94 }; | 97 }; |
95 | 98 |
96 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { | 99 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { |
97 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); | 100 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); |
98 } | 101 } |
99 }; | 102 }; |
100 | 103 |
| 104 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ |
| 105 GrProcOptInfo colorPOI, covPOI; |
| 106 colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, fals
e); |
| 107 // Setting 2nd to last value to false and last to true will force covPOI to
LCD coverage. |
| 108 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false,
true); |
| 109 |
| 110 SkASSERT(!colorPOI.isOpaque()); |
| 111 SkASSERT(!colorPOI.isSolidWhite()); |
| 112 SkASSERT(!covPOI.isSolidWhite()); |
| 113 SkASSERT(covPOI.isFourChannelOutput()); |
| 114 |
| 115 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 116 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 117 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); |
| 118 |
| 119 switch (xfermode) { |
| 120 case SkXfermode::kClear_Mode: |
| 121 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 122 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 123 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 124 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 125 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 126 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 127 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
| 128 TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 129 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 130 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 131 break; |
| 132 case SkXfermode::kSrc_Mode: |
| 133 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 134 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 135 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 136 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 137 TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 138 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 139 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 140 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 141 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 142 break; |
| 143 case SkXfermode::kDst_Mode: |
| 144 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 145 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 146 TEST_ASSERT((kSkipDraw_OptFlag | |
| 147 kIgnoreColor_OptFlag | |
| 148 kIgnoreCoverage_OptFlag | |
| 149 kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags
); |
| 150 TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 151 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 152 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 153 TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 154 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 155 TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 156 break; |
| 157 case SkXfermode::kSrcOver_Mode: |
| 158 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 159 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 160 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 161 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 162 TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 163 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 164 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 165 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 166 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 167 break; |
| 168 case SkXfermode::kDstOver_Mode: |
| 169 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 170 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 171 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 172 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 173 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 174 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 175 TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 176 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 177 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 178 break; |
| 179 case SkXfermode::kSrcIn_Mode: |
| 180 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 181 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 182 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 183 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 184 TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 185 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 186 TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 187 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 188 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 189 break; |
| 190 case SkXfermode::kDstIn_Mode: |
| 191 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 192 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 193 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 194 TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 195 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 196 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
| 197 TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 198 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 199 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 200 break; |
| 201 case SkXfermode::kSrcOut_Mode: |
| 202 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 203 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 204 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 205 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 206 TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 207 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 208 TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 209 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 210 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 211 break; |
| 212 case SkXfermode::kDstOut_Mode: |
| 213 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 214 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 215 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 216 TEST_ASSERT(kSAModulate_OutputType == xpi.fPrimaryOutputType); |
| 217 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 218 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 219 TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 220 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 221 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 222 break; |
| 223 case SkXfermode::kSrcATop_Mode: |
| 224 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 225 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 226 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 227 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 228 TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 229 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 230 TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 231 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 232 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 233 break; |
| 234 case SkXfermode::kDstATop_Mode: |
| 235 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 236 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 237 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 238 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 239 TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType)
; |
| 240 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 241 TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 242 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 243 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 244 break; |
| 245 case SkXfermode::kXor_Mode: |
| 246 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 247 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 248 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 249 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 250 TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 251 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 252 TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 253 TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 254 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 255 break; |
| 256 case SkXfermode::kPlus_Mode: |
| 257 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 258 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 259 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 260 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 261 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 262 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 263 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 264 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 265 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 266 break; |
| 267 case SkXfermode::kModulate_Mode: |
| 268 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 269 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 270 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 271 TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 272 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 273 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
| 274 TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 275 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 276 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 277 break; |
| 278 case SkXfermode::kScreen_Mode: |
| 279 TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 280 TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
| 281 TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 282 TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 283 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 284 TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 285 TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 286 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 287 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 288 break; |
| 289 default: |
| 290 ERRORF(reporter, "Invalid xfermode."); |
| 291 break; |
| 292 } |
| 293 } |
| 294 } |
101 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 295 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
102 GrProcOptInfo colorPOI, covPOI; | 296 GrProcOptInfo colorPOI, covPOI; |
103 colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, f
alse); | 297 colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, f
alse); |
104 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru
e); | 298 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru
e); |
105 | 299 |
106 SkASSERT(!colorPOI.isOpaque()); | 300 SkASSERT(!colorPOI.isOpaque()); |
107 SkASSERT(!colorPOI.isSolidWhite()); | 301 SkASSERT(!colorPOI.isSolidWhite()); |
108 SkASSERT(!covPOI.isSolidWhite()); | 302 SkASSERT(!covPOI.isSolidWhite()); |
109 SkASSERT(!covPOI.isFourChannelOutput()); | 303 SkASSERT(!covPOI.isFourChannelOutput()); |
110 | 304 |
111 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 305 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
112 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 306 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
113 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 307 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); |
114 | 308 |
| 309 |
115 switch (xfermode) { | 310 switch (xfermode) { |
116 case SkXfermode::kClear_Mode: | 311 case SkXfermode::kClear_Mode: |
117 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 312 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
118 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 313 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
119 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 314 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
120 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); | 315 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
121 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); | 316 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
122 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 317 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
123 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); | 318 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
124 TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); | 319 TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); | 1085 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
891 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 1086 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
892 break; | 1087 break; |
893 default: | 1088 default: |
894 ERRORF(reporter, "Invalid xfermode."); | 1089 ERRORF(reporter, "Invalid xfermode."); |
895 break; | 1090 break; |
896 } | 1091 } |
897 } | 1092 } |
898 } | 1093 } |
899 | 1094 |
900 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ | 1095 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
GrCaps& caps) { |
901 class : public GrVertexBatch { | 1096 class : public GrVertexBatch { |
902 void getInvariantOutputColor(GrInitInvariantOutput* out) const override
{ | 1097 void getInvariantOutputColor(GrInitInvariantOutput* out) const override
{ |
903 out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); | 1098 out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); |
904 } | 1099 } |
905 | 1100 |
906 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const overri
de { | 1101 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const overri
de { |
907 out->setUnknownFourComponents(); | 1102 out->setUnknownFourComponents(); |
908 out->setUsingLCDCoverage(); | 1103 out->setUsingLCDCoverage(); |
909 } | 1104 } |
910 | 1105 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1203 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1009 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); | 1204 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); |
1010 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1205 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1011 } | 1206 } |
1012 } | 1207 } |
1013 } | 1208 } |
1014 } | 1209 } |
1015 | 1210 |
1016 #endif | 1211 #endif |
1017 | 1212 |
OLD | NEW |