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