cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 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 | |
| 8 | #include "SkXfermode.h" |
| 9 | #include "Test.h" |
| 10 | |
| 11 | #if SK_SUPPORT_GPU |
| 12 | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 13 | #include "GrContextFactory.h" |
| 14 | #include "GrContextOptions.h" |
| 15 | #include "GrGpu.h" |
| 16 | #include "GrResourceProvider.h" |
| 17 | #include "GrXferProcessor.h" |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 18 | #include "batches/GrVertexBatch.h" |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 19 | #include "effects/GrPorterDuffXferProcessor.h" |
| 20 | #include "gl/GrGLCaps.h" |
| 21 | |
| 22 | //////////////////////////////////////////////////////////////////////////////// |
| 23 | |
| 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 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 GrCaps& caps); |
| 28 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 29 | static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 30 | static void test_no_dual_source_blending(skiatest::Reporter* reporter); |
| 31 | |
| 32 | DEF_GPUTEST(GrPorterDuff, reporter, factory) { |
| 33 | GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); |
| 34 | if (!ctx) { |
| 35 | SkFAIL("Failed to create null context."); |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | const GrCaps& caps = *ctx->getGpu()->caps(); |
| 40 | if (!caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 41 | SkFAIL("Null context does not support dual source blending."); |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | test_color_unknown_with_coverage(reporter, caps); |
| 46 | test_color_unknown_no_coverage(reporter, caps); |
| 47 | test_color_opaque_with_coverage(reporter, caps); |
| 48 | test_color_opaque_no_coverage(reporter, caps); |
| 49 | test_lcd_coverage(reporter, caps); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 50 | test_lcd_coverage_fallback_case(reporter, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 51 | test_no_dual_source_blending(reporter); |
| 52 | } |
| 53 | |
| 54 | //////////////////////////////////////////////////////////////////////////////// |
| 55 | |
| 56 | #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) |
| 57 | |
| 58 | enum { |
| 59 | kNone_OutputType, |
| 60 | kCoverage_OutputType, |
| 61 | kModulate_OutputType, |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 62 | kSAModulate_OutputType, |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 63 | kISAModulate_OutputType, |
| 64 | kISCModulate_OutputType |
| 65 | }; |
| 66 | |
| 67 | enum { |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 68 | kNone_OptFlags = GrXferProcessor::kNone_OptFlags, |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 69 | kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, |
| 70 | kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
| 71 | kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag, |
| 72 | kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag |
| 73 | }; |
| 74 | |
| 75 | class GrPorterDuffTest { |
| 76 | public: |
| 77 | struct XPInfo { |
| 78 | XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const GrCaps& caps, |
| 79 | const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame^] | 80 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 81 | SkAutoTUnref<GrXferProcessor> xp( |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 82 | xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 83 | TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 84 | xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 85 | fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 86 | GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); |
| 87 | xp->getBlendInfo(&fBlendInfo); |
| 88 | TEST_ASSERT(!xp->willReadDstColor()); |
| 89 | TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend)); |
| 90 | } |
| 91 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 92 | GrXPFactory::InvariantBlendedColor fBlendedColor; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 93 | int fOptFlags; |
| 94 | int fPrimaryOutputType; |
| 95 | int fSecondaryOutputType; |
| 96 | GrXferProcessor::BlendInfo fBlendInfo; |
| 97 | }; |
| 98 | |
| 99 | static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) { |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame^] | 100 | GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 101 | } |
| 102 | }; |
| 103 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 104 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 105 | GrProcOptInfo colorPOI, covPOI; |
| 106 | colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false); |
| 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, covPOI); |
| 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.fKnownColorFlags); |
| 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.fEquation); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fEquation); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fKnownColorFlags); |
| 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.fEquation); |
| 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.fKnownColorFlags); |
| 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 | } |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 295 | static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 296 | GrProcOptInfo colorPOI, covPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 297 | colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, false); |
| 298 | covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 299 | |
| 300 | SkASSERT(!colorPOI.isOpaque()); |
| 301 | SkASSERT(!colorPOI.isSolidWhite()); |
| 302 | SkASSERT(!covPOI.isSolidWhite()); |
| 303 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 304 | |
| 305 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 306 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 307 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 308 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 309 | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 310 | switch (xfermode) { |
| 311 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 312 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 313 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 314 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 315 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 316 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 317 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 318 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 319 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 320 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 321 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 322 | break; |
| 323 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 324 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 325 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 326 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 327 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 328 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 329 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 330 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 331 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 332 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 333 | break; |
| 334 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 335 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 336 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 337 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 338 | kIgnoreColor_OptFlag | |
| 339 | kIgnoreCoverage_OptFlag | |
| 340 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 341 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 342 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 343 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 344 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 345 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 346 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 347 | break; |
| 348 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 349 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 350 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 351 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 352 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 353 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 354 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 355 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 356 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 357 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 358 | break; |
| 359 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 360 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 361 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 362 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 363 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 364 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 365 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 366 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 367 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 368 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 369 | break; |
| 370 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 371 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 372 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 373 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 374 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 375 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 376 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 377 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 378 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 379 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 380 | break; |
| 381 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 382 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 383 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 384 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 385 | TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 386 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 387 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 388 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 389 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 390 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 391 | break; |
| 392 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 393 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 394 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 395 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 396 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 397 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 398 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 399 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 400 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 401 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 402 | break; |
| 403 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 404 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 405 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 406 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 407 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 408 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 409 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 410 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 411 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 412 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 413 | break; |
| 414 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 415 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 416 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 417 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 418 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 419 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 420 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 421 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 422 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 423 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 424 | break; |
| 425 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 426 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 427 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 428 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 429 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 430 | TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); |
| 431 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 432 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 433 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 434 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 435 | break; |
| 436 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 437 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 438 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 439 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 440 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 441 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 442 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 443 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 444 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 445 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 446 | break; |
| 447 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 448 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 449 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 450 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 451 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 452 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 453 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 454 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 455 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 456 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 457 | break; |
| 458 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 459 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 460 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 461 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 462 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 463 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 464 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 465 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 466 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 467 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 468 | break; |
| 469 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 470 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 471 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 472 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 473 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 474 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 475 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 476 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 477 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 478 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 479 | break; |
| 480 | default: |
| 481 | ERRORF(reporter, "Invalid xfermode."); |
| 482 | break; |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 488 | GrProcOptInfo colorPOI, covPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 489 | colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0), |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 490 | kR_GrColorComponentFlag | kB_GrColorComponentFlag, false); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 491 | covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 492 | |
| 493 | SkASSERT(!colorPOI.isOpaque()); |
| 494 | SkASSERT(!colorPOI.isSolidWhite()); |
| 495 | SkASSERT(covPOI.isSolidWhite()); |
| 496 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 497 | |
| 498 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 499 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 500 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 501 | |
| 502 | switch (xfermode) { |
| 503 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 504 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 505 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 506 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 507 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 508 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 509 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 510 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 511 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 512 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 513 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 514 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 515 | break; |
| 516 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 517 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 518 | TEST_ASSERT(229 == GrColorUnpackR(xpi.fBlendedColor.fKnownColor)); |
| 519 | TEST_ASSERT(154 == GrColorUnpackB(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 520 | TEST_ASSERT((kR_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 521 | kB_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 522 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 523 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 524 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 525 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 526 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 527 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 528 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 529 | break; |
| 530 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 531 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 532 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 533 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 534 | kIgnoreColor_OptFlag | |
| 535 | kIgnoreCoverage_OptFlag | |
| 536 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 537 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 538 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 539 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 540 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 541 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 542 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 543 | break; |
| 544 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 545 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 546 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 547 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 548 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 549 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 550 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 551 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 552 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 553 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 554 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 555 | break; |
| 556 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 557 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 558 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 559 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 560 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 561 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 562 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 563 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 564 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 565 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 566 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 567 | break; |
| 568 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 569 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 570 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 571 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 572 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 573 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 574 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 575 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 576 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 577 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 578 | break; |
| 579 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 580 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 581 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 582 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 583 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 584 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 585 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 586 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 587 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 588 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 589 | break; |
| 590 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 591 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 592 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 593 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 594 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 595 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 596 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 597 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 598 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 599 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 600 | break; |
| 601 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 602 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 603 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 604 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 605 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 606 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 607 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 608 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 609 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 610 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 611 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 612 | break; |
| 613 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 614 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 615 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 616 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 617 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 618 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 619 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 620 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 621 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 622 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 623 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 624 | break; |
| 625 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 626 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 627 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 628 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 629 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 630 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 631 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 632 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 633 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 634 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 635 | break; |
| 636 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 637 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 638 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 639 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 640 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 641 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 642 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 643 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 644 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 645 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 646 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 647 | break; |
| 648 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 649 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 650 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 651 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 652 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 653 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 654 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 655 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 656 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 657 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 658 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 659 | break; |
| 660 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 661 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 662 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 663 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 664 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 665 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 666 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 667 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 668 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 669 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 670 | break; |
| 671 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 672 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 673 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 674 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 675 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 676 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 677 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 678 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 679 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 680 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 681 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 682 | break; |
| 683 | default: |
| 684 | ERRORF(reporter, "Invalid xfermode."); |
| 685 | break; |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 691 | GrProcOptInfo colorPOI, covPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 692 | colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kA_GrColorComponentFlag, false); |
| 693 | covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 694 | |
| 695 | SkASSERT(colorPOI.isOpaque()); |
| 696 | SkASSERT(!colorPOI.isSolidWhite()); |
| 697 | SkASSERT(!covPOI.isSolidWhite()); |
| 698 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 699 | |
| 700 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 701 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 702 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 703 | |
| 704 | switch (xfermode) { |
| 705 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 706 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 707 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 708 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 709 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 710 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 711 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 712 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 713 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 714 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 715 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 716 | break; |
| 717 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 718 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 719 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
| 720 | TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 721 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 722 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 723 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 724 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 725 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 726 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 727 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 728 | break; |
| 729 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 730 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 731 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 732 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 733 | kIgnoreColor_OptFlag | |
| 734 | kIgnoreCoverage_OptFlag | |
| 735 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 736 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 737 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 738 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 739 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 740 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 741 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 742 | break; |
| 743 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 744 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 745 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
| 746 | TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 747 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 748 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 749 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 750 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 751 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 752 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 753 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 754 | break; |
| 755 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 756 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 757 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 758 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 759 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 760 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 761 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 762 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 763 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 764 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 765 | break; |
| 766 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 767 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 768 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 769 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 770 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 771 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 772 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 773 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 774 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 775 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 776 | break; |
| 777 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 778 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 779 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 780 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 781 | kIgnoreColor_OptFlag | |
| 782 | kIgnoreCoverage_OptFlag | |
| 783 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 784 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 785 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 786 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 787 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 788 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 789 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 790 | break; |
| 791 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 792 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 793 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 794 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 795 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 796 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 797 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 798 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 799 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 800 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 801 | break; |
| 802 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 803 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 804 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 805 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 806 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 807 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 808 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 809 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 810 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 811 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 812 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 813 | break; |
| 814 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 815 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 816 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 817 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 818 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 819 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 820 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 821 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 822 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 823 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 824 | break; |
| 825 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 826 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 827 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 828 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 829 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 830 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 831 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 832 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 833 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 834 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 835 | break; |
| 836 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 837 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 838 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 839 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 840 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 841 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 842 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 843 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 844 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 845 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 846 | break; |
| 847 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 848 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 849 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 850 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 851 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 852 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 853 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 854 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 855 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 856 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 857 | break; |
| 858 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 859 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 860 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 861 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 862 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 863 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 864 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 865 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 866 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 867 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 868 | break; |
| 869 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 870 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 871 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 872 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 873 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 874 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 875 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 876 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 877 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 878 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 879 | break; |
| 880 | default: |
| 881 | ERRORF(reporter, "Invalid xfermode."); |
| 882 | break; |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 888 | GrProcOptInfo colorPOI, covPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 889 | colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255), |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 890 | kG_GrColorComponentFlag | kA_GrColorComponentFlag, false); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 891 | covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 892 | |
| 893 | SkASSERT(colorPOI.isOpaque()); |
| 894 | SkASSERT(!colorPOI.isSolidWhite()); |
| 895 | SkASSERT(covPOI.isSolidWhite()); |
| 896 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 897 | |
| 898 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 899 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 900 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 901 | |
| 902 | switch (xfermode) { |
| 903 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 904 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 905 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 906 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 907 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 908 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 909 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 910 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 911 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 912 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 913 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 914 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 915 | break; |
| 916 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 917 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 918 | TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor)); |
| 919 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 920 | TEST_ASSERT((kG_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 921 | kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 922 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 923 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 924 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 925 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 926 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 927 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 928 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 929 | break; |
| 930 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 931 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 932 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 933 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 934 | kIgnoreColor_OptFlag | |
| 935 | kIgnoreCoverage_OptFlag | |
| 936 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 937 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 938 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 939 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 940 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 941 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 942 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 943 | break; |
| 944 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 945 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 946 | TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor)); |
| 947 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 948 | TEST_ASSERT((kG_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 949 | kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 950 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 951 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 952 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 953 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 954 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 955 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 956 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 957 | break; |
| 958 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 959 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 960 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 961 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 962 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 963 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 964 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 965 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 966 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 967 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 968 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 969 | break; |
| 970 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 971 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 972 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 973 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 974 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 975 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 976 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 977 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 978 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 979 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 980 | break; |
| 981 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 982 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 983 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 984 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 985 | kIgnoreColor_OptFlag | |
| 986 | kIgnoreCoverage_OptFlag | |
| 987 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 988 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 989 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 990 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 991 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 992 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 993 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 994 | break; |
| 995 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 996 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 997 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 998 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 999 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1000 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1001 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1002 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1003 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1004 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1005 | break; |
| 1006 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1007 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 1008 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 1009 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1010 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 1011 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 1012 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 1013 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1014 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1015 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1016 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1017 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1018 | break; |
| 1019 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1020 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1021 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1022 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 1023 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1024 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1025 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1026 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1027 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1028 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1029 | break; |
| 1030 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1031 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1032 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1033 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 1034 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 1035 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1036 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1037 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1038 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1039 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1040 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1041 | break; |
| 1042 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1043 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1044 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1045 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 1046 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1047 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1048 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1049 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1050 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1051 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1052 | break; |
| 1053 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1054 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1055 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1056 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 1057 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 1058 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1059 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1060 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1061 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1062 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1063 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1064 | break; |
| 1065 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1066 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1067 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1068 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 1069 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1070 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1071 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1072 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1073 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1074 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1075 | break; |
| 1076 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1077 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 1078 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1079 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 1080 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 1081 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1082 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1083 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1084 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1085 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1086 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1087 | break; |
| 1088 | default: |
| 1089 | ERRORF(reporter, "Invalid xfermode."); |
| 1090 | break; |
| 1091 | } |
| 1092 | } |
| 1093 | } |
| 1094 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 1095 | static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps) { |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 1096 | class TestLCDCoverageBatch: public GrVertexBatch { |
| 1097 | public: |
| 1098 | DEFINE_BATCH_CLASS_ID |
| 1099 | |
| 1100 | TestLCDCoverageBatch() : INHERITED(ClassID()) {} |
| 1101 | |
| 1102 | private: |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1103 | void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 1104 | out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); |
| 1105 | } |
| 1106 | |
| 1107 | void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 1108 | out->setUnknownFourComponents(); |
| 1109 | out->setUsingLCDCoverage(); |
| 1110 | } |
| 1111 | |
| 1112 | const char* name() const override { return "Test LCD Text Batch"; } |
bsalomon | 91d844d | 2015-08-10 10:47:29 -0700 | [diff] [blame] | 1113 | void initBatchTracker(const GrPipelineOptimizations&) override {} |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 1114 | bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; } |
bsalomon | 7539856 | 2015-08-17 12:55:38 -0700 | [diff] [blame] | 1115 | void onPrepareDraws(Target*) override {}; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1116 | |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 1117 | typedef GrVertexBatch INHERITED; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1118 | } testLCDCoverageBatch; |
| 1119 | |
| 1120 | GrProcOptInfo colorPOI, covPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1121 | colorPOI.calcColorWithBatch(&testLCDCoverageBatch, nullptr, 0); |
| 1122 | covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, nullptr, 0); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1123 | |
| 1124 | SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |
| 1125 | SkASSERT(covPOI.isFourChannelOutput()); |
| 1126 | |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame^] | 1127 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 1128 | TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1129 | |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 1130 | SkAutoTUnref<GrXferProcessor> xp( |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1131 | xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1132 | if (!xp) { |
| 1133 | ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 1134 | return; |
| 1135 | } |
| 1136 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 1137 | GrXPFactory::InvariantBlendedColor blendedColor; |
| 1138 | xpf->getInvariantBlendedColor(colorPOI, &blendedColor); |
| 1139 | TEST_ASSERT(blendedColor.fWillBlendWithDst); |
| 1140 | TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1141 | |
| 1142 | GrColor overrideColor; |
| 1143 | xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps); |
| 1144 | |
| 1145 | GrXferProcessor::BlendInfo blendInfo; |
| 1146 | xp->getBlendInfo(&blendInfo); |
| 1147 | TEST_ASSERT(blendInfo.fWriteColor); |
| 1148 | } |
| 1149 | |
| 1150 | static void test_no_dual_source_blending(skiatest::Reporter* reporter) { |
| 1151 | GrContextOptions opts; |
| 1152 | opts.fSuppressDualSourceBlending = true; |
| 1153 | GrContextFactory factory(opts); |
| 1154 | factory.get(GrContextFactory::kNull_GLContextType); |
| 1155 | GrContext* ctx = factory.get(GrContextFactory::kNull_GLContextType); |
| 1156 | if (!ctx) { |
| 1157 | SkFAIL("Failed to create null context without ARB_blend_func_extended."); |
| 1158 | return; |
| 1159 | } |
| 1160 | |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 1161 | const GrCaps& caps = *ctx->caps(); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1162 | if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 1163 | SkFAIL("Null context failed to honor request for no ARB_blend_func_extended."); |
| 1164 | return; |
| 1165 | } |
| 1166 | |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1167 | GrBackendObject backendTex = |
| 1168 | ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1169 | GrBackendTextureDesc fakeDesc; |
| 1170 | fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 1171 | fakeDesc.fWidth = fakeDesc.fHeight = 100; |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1172 | fakeDesc.fTextureHandle = backendTex; |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 1173 | SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTexture(fakeDesc, |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 1174 | kBorrow_GrWrapOwnership)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1175 | GrXferProcessor::DstTexture fakeDstTexture; |
| 1176 | fakeDstTexture.setTexture(fakeTexture); |
| 1177 | |
| 1178 | static const GrColor testColors[] = { |
| 1179 | 0, |
| 1180 | GrColorPackRGBA(0, 82, 0, 255), |
| 1181 | GrColorPackA4(255) |
| 1182 | }; |
| 1183 | static const GrColorComponentFlags testColorFlags[] = { |
| 1184 | kNone_GrColorComponentFlags, |
| 1185 | kG_GrColorComponentFlag | kA_GrColorComponentFlag, |
| 1186 | kRGBA_GrColorComponentFlags |
| 1187 | }; |
| 1188 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags)); |
| 1189 | |
| 1190 | for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { |
| 1191 | GrProcOptInfo colorPOI; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1192 | colorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags[c], false); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1193 | for (int f = 0; f <= 1; f++) { |
| 1194 | GrProcOptInfo covPOI; |
| 1195 | if (!f) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1196 | covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1197 | } else { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 1198 | covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1199 | kRGBA_GrColorComponentFlags, true); |
| 1200 | } |
| 1201 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 1202 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame^] | 1203 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 1204 | GrXferProcessor::DstTexture* dstTexture = |
| 1205 | xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fakeDstTexture : 0; |
| 1206 | SkAutoTUnref<GrXferProcessor> xp( |
| 1207 | xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1208 | if (!xp) { |
| 1209 | ERRORF(reporter, "Failed to create an XP without dual source blending."); |
| 1210 | return; |
| 1211 | } |
| 1212 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1213 | xp->getOptimizations(colorPOI, covPOI, false, 0, caps); |
| 1214 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1215 | } |
| 1216 | } |
| 1217 | } |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1218 | ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1219 | } |
| 1220 | |
| 1221 | #endif |
| 1222 | |