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 | |
| 13 | #include "GrBatch.h" |
| 14 | #include "GrContextFactory.h" |
| 15 | #include "GrContextOptions.h" |
| 16 | #include "GrGpu.h" |
| 17 | #include "GrResourceProvider.h" |
| 18 | #include "GrXferProcessor.h" |
| 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); |
| 29 | static void test_no_dual_source_blending(skiatest::Reporter* reporter); |
| 30 | |
| 31 | DEF_GPUTEST(GrPorterDuff, reporter, factory) { |
| 32 | GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType); |
| 33 | if (!ctx) { |
| 34 | SkFAIL("Failed to create null context."); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | const GrCaps& caps = *ctx->getGpu()->caps(); |
| 39 | if (!caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 40 | SkFAIL("Null context does not support dual source blending."); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | test_color_unknown_with_coverage(reporter, caps); |
| 45 | test_color_unknown_no_coverage(reporter, caps); |
| 46 | test_color_opaque_with_coverage(reporter, caps); |
| 47 | test_color_opaque_no_coverage(reporter, caps); |
| 48 | test_lcd_coverage(reporter, caps); |
| 49 | test_no_dual_source_blending(reporter); |
| 50 | } |
| 51 | |
| 52 | //////////////////////////////////////////////////////////////////////////////// |
| 53 | |
| 54 | #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) |
| 55 | |
| 56 | enum { |
| 57 | kNone_OutputType, |
| 58 | kCoverage_OutputType, |
| 59 | kModulate_OutputType, |
| 60 | kISAModulate_OutputType, |
| 61 | kISCModulate_OutputType |
| 62 | }; |
| 63 | |
| 64 | enum { |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 65 | kNone_OptFlags = GrXferProcessor::kNone_OptFlags, |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 66 | kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, |
| 67 | kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
| 68 | kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag, |
| 69 | kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag |
| 70 | }; |
| 71 | |
| 72 | class GrPorterDuffTest { |
| 73 | public: |
| 74 | struct XPInfo { |
| 75 | XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const GrCaps& caps, |
| 76 | const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { |
| 77 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 78 | SkAutoTUnref<GrXferProcessor> xp( |
| 79 | xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps)); |
| 80 | TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 81 | xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 82 | fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, NULL, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 83 | GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); |
| 84 | xp->getBlendInfo(&fBlendInfo); |
| 85 | TEST_ASSERT(!xp->willReadDstColor()); |
| 86 | TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend)); |
| 87 | } |
| 88 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 89 | GrXPFactory::InvariantBlendedColor fBlendedColor; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 90 | int fOptFlags; |
| 91 | int fPrimaryOutputType; |
| 92 | int fSecondaryOutputType; |
| 93 | GrXferProcessor::BlendInfo fBlendInfo; |
| 94 | }; |
| 95 | |
| 96 | static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) { |
| 97 | GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary); |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 102 | GrProcOptInfo colorPOI, covPOI; |
| 103 | colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false); |
| 104 | covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, true); |
| 105 | |
| 106 | SkASSERT(!colorPOI.isOpaque()); |
| 107 | SkASSERT(!colorPOI.isSolidWhite()); |
| 108 | SkASSERT(!covPOI.isSolidWhite()); |
| 109 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 110 | |
| 111 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 112 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 113 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 114 | |
| 115 | switch (xfermode) { |
| 116 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 117 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 118 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 119 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 120 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 121 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 122 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 123 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 124 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 125 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 126 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 127 | break; |
| 128 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 129 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 130 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 131 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 132 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 133 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 134 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 135 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 136 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 137 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 138 | break; |
| 139 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 140 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 141 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 142 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 143 | kIgnoreColor_OptFlag | |
| 144 | kIgnoreCoverage_OptFlag | |
| 145 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 146 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 147 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 148 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 149 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 150 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 151 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 152 | break; |
| 153 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 154 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 155 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 156 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 157 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 158 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 159 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 160 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 161 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 162 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 163 | break; |
| 164 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 165 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 166 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 167 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 168 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 169 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 170 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 171 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 172 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 173 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 174 | break; |
| 175 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 176 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 177 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 178 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 179 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 180 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 181 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 182 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 183 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 184 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 185 | break; |
| 186 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 187 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 188 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 189 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 190 | TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 191 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 192 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 193 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 194 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 195 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 196 | break; |
| 197 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 198 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 199 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 200 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 201 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 202 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 203 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 204 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 205 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 206 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 207 | break; |
| 208 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 209 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 210 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 211 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 212 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 213 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 214 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 215 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 216 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 217 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 218 | break; |
| 219 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 220 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 221 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 222 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 223 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 224 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 225 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 226 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 227 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 228 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 229 | break; |
| 230 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 231 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 232 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 233 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 234 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 235 | TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); |
| 236 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 237 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 238 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 239 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 240 | break; |
| 241 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 242 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 243 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 244 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 245 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 246 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 247 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 248 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 249 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 250 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 251 | break; |
| 252 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 253 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 254 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 255 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 256 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 257 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 258 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 259 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 260 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 261 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 262 | break; |
| 263 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 264 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 265 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 266 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 267 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 268 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 269 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 270 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 271 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 272 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 273 | break; |
| 274 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 275 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 276 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 277 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 278 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 279 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 280 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 281 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 282 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 283 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 284 | break; |
| 285 | default: |
| 286 | ERRORF(reporter, "Invalid xfermode."); |
| 287 | break; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 293 | GrProcOptInfo colorPOI, covPOI; |
| 294 | colorPOI.calcWithInitialValues(NULL, 0, GrColorPackRGBA(229, 0, 154, 0), |
| 295 | kR_GrColorComponentFlag | kB_GrColorComponentFlag, false); |
| 296 | covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true); |
| 297 | |
| 298 | SkASSERT(!colorPOI.isOpaque()); |
| 299 | SkASSERT(!colorPOI.isSolidWhite()); |
| 300 | SkASSERT(covPOI.isSolidWhite()); |
| 301 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 302 | |
| 303 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 304 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 305 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 306 | |
| 307 | switch (xfermode) { |
| 308 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 309 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 310 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 311 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 312 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 313 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 314 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 315 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 316 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 317 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 318 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 319 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 320 | break; |
| 321 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 322 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 323 | TEST_ASSERT(229 == GrColorUnpackR(xpi.fBlendedColor.fKnownColor)); |
| 324 | TEST_ASSERT(154 == GrColorUnpackB(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 325 | TEST_ASSERT((kR_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 326 | kB_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 327 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 328 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 329 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 330 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 331 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 332 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 333 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 334 | break; |
| 335 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 336 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 337 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 338 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 339 | kIgnoreColor_OptFlag | |
| 340 | kIgnoreCoverage_OptFlag | |
| 341 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 342 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 343 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 344 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 345 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 346 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 347 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 348 | break; |
| 349 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 350 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 351 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 352 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 353 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 354 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 355 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 356 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 357 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 358 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 359 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 360 | break; |
| 361 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 362 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 363 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 364 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 365 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 366 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 367 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 368 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 369 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 370 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 371 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 372 | break; |
| 373 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 374 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 375 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 376 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 377 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 378 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 379 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 380 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 381 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 382 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 383 | break; |
| 384 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 385 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 386 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 387 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 388 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 389 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 390 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 391 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 392 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 393 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 394 | break; |
| 395 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 396 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 397 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 398 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 399 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 400 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 401 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 402 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 403 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 404 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 405 | break; |
| 406 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 407 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 408 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 409 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 410 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 411 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 412 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 413 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 414 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 415 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 416 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 417 | break; |
| 418 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 419 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 420 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 421 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 422 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 423 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 424 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 425 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 426 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 427 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 428 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 429 | break; |
| 430 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 431 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 432 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 433 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 434 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 435 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 436 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 437 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 438 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 439 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 440 | break; |
| 441 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 442 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 443 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 444 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 445 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 446 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 447 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 448 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 449 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 450 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 451 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 452 | break; |
| 453 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 454 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 455 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 456 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 457 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 458 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 459 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 460 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 461 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 462 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 463 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 464 | break; |
| 465 | case SkXfermode::kModulate_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((kIgnoreCoverage_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(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 473 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 474 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 475 | break; |
| 476 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 477 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 478 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 479 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 480 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 481 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 482 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 483 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 484 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 485 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 486 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 487 | break; |
| 488 | default: |
| 489 | ERRORF(reporter, "Invalid xfermode."); |
| 490 | break; |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 496 | GrProcOptInfo colorPOI, covPOI; |
| 497 | colorPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kA_GrColorComponentFlag, false); |
| 498 | covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, true); |
| 499 | |
| 500 | SkASSERT(colorPOI.isOpaque()); |
| 501 | SkASSERT(!colorPOI.isSolidWhite()); |
| 502 | SkASSERT(!covPOI.isSolidWhite()); |
| 503 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 504 | |
| 505 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 506 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 507 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 508 | |
| 509 | switch (xfermode) { |
| 510 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 511 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 512 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 513 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 514 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 515 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 516 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 517 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 518 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 519 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 520 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 521 | break; |
| 522 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 523 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 524 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
| 525 | TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 526 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 527 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 528 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 529 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 530 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 531 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 532 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 533 | break; |
| 534 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 535 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 536 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 537 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 538 | kIgnoreColor_OptFlag | |
| 539 | kIgnoreCoverage_OptFlag | |
| 540 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 541 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 542 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 543 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 544 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 545 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 546 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 547 | break; |
| 548 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 549 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 550 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
| 551 | TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 552 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 553 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 554 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 555 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 556 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 557 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 558 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 559 | break; |
| 560 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 561 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 562 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 563 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 564 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 565 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 566 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 567 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 568 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 569 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 570 | break; |
| 571 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 572 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 573 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 574 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 575 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 576 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 577 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 578 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 579 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 580 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 581 | break; |
| 582 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 583 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 584 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 585 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 586 | kIgnoreColor_OptFlag | |
| 587 | kIgnoreCoverage_OptFlag | |
| 588 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 589 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 590 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 591 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 592 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 593 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 594 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 595 | break; |
| 596 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 597 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 598 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 599 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 600 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 601 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 602 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 603 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 604 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 605 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 606 | break; |
| 607 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 608 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 609 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 610 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 611 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 612 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 613 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 614 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 615 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 616 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 617 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 618 | break; |
| 619 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 620 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 621 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 622 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 623 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 624 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 625 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 626 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 627 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 628 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 629 | break; |
| 630 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 631 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 632 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 633 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 634 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 635 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 636 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 637 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 638 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 639 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 640 | break; |
| 641 | case SkXfermode::kXor_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 642 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 643 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 644 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 645 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 646 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 647 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 648 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 649 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 650 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 651 | break; |
| 652 | case SkXfermode::kPlus_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 653 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 654 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 655 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 656 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 657 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 658 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 659 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 660 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 661 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 662 | break; |
| 663 | case SkXfermode::kModulate_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 664 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 665 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame^] | 666 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 667 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 668 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 669 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 670 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 671 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 672 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 673 | break; |
| 674 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 675 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 676 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 677 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 678 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 679 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 680 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 681 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 682 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 683 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 684 | break; |
| 685 | default: |
| 686 | ERRORF(reporter, "Invalid xfermode."); |
| 687 | break; |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 693 | GrProcOptInfo colorPOI, covPOI; |
| 694 | colorPOI.calcWithInitialValues(NULL, 0, GrColorPackRGBA(0, 82, 0, 255), |
| 695 | kG_GrColorComponentFlag | kA_GrColorComponentFlag, false); |
| 696 | covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true); |
| 697 | |
| 698 | SkASSERT(colorPOI.isOpaque()); |
| 699 | SkASSERT(!colorPOI.isSolidWhite()); |
| 700 | SkASSERT(covPOI.isSolidWhite()); |
| 701 | SkASSERT(!covPOI.isFourChannelOutput()); |
| 702 | |
| 703 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 704 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 705 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI); |
| 706 | |
| 707 | switch (xfermode) { |
| 708 | case SkXfermode::kClear_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 709 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 710 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 711 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 712 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 713 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 714 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 715 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 716 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 717 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 718 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 719 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 720 | break; |
| 721 | case SkXfermode::kSrc_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 722 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 723 | TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor)); |
| 724 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 725 | TEST_ASSERT((kG_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 726 | kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 727 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 728 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 729 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 730 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 731 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 732 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 733 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 734 | break; |
| 735 | case SkXfermode::kDst_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 736 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 737 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 738 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 739 | kIgnoreColor_OptFlag | |
| 740 | kIgnoreCoverage_OptFlag | |
| 741 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 742 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 743 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 744 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 745 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 746 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 747 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 748 | break; |
| 749 | case SkXfermode::kSrcOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 750 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 751 | TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor)); |
| 752 | TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 753 | TEST_ASSERT((kG_GrColorComponentFlag | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 754 | kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 755 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 756 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 757 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 758 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 759 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 760 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 761 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 762 | break; |
| 763 | case SkXfermode::kDstOver_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 764 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 765 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 766 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 767 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 768 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 769 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 770 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 771 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 772 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 773 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 774 | break; |
| 775 | case SkXfermode::kSrcIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 776 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 777 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 778 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 779 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 780 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 781 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 782 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 783 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 784 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 785 | break; |
| 786 | case SkXfermode::kDstIn_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 787 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 788 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 789 | TEST_ASSERT((kSkipDraw_OptFlag | |
| 790 | kIgnoreColor_OptFlag | |
| 791 | kIgnoreCoverage_OptFlag | |
| 792 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 793 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 794 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 795 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 796 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 797 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 798 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 799 | break; |
| 800 | case SkXfermode::kSrcOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 801 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 802 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 803 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 804 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 805 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 806 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 807 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 808 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 809 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 810 | break; |
| 811 | case SkXfermode::kDstOut_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 812 | TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
| 813 | TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
| 814 | TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 815 | TEST_ASSERT((kIgnoreColor_OptFlag | |
| 816 | kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 817 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 818 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 819 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 820 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 821 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 822 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 823 | break; |
| 824 | case SkXfermode::kSrcATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 825 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 826 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 827 | TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
| 828 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 829 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 830 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 831 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 832 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 833 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 834 | break; |
| 835 | case SkXfermode::kDstATop_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 836 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 837 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 838 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 839 | 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(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 845 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 846 | break; |
| 847 | case SkXfermode::kXor_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((kIgnoreCoverage_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(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 855 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 856 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 857 | break; |
| 858 | case SkXfermode::kPlus_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); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 861 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 862 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 863 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 864 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 865 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 866 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 867 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 868 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 869 | break; |
| 870 | case SkXfermode::kModulate_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((kIgnoreCoverage_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(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 878 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 879 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 880 | break; |
| 881 | case SkXfermode::kScreen_Mode: |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 882 | TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); |
| 883 | TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 884 | TEST_ASSERT((kIgnoreCoverage_OptFlag | |
| 885 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 886 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 887 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 888 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 889 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 890 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 891 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 892 | break; |
| 893 | default: |
| 894 | ERRORF(reporter, "Invalid xfermode."); |
| 895 | break; |
| 896 | } |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
| 901 | class : public GrBatch { |
| 902 | void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 903 | out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); |
| 904 | } |
| 905 | |
| 906 | void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 907 | out->setUnknownFourComponents(); |
| 908 | out->setUsingLCDCoverage(); |
| 909 | } |
| 910 | |
| 911 | const char* name() const override { return "Test LCD Text Batch"; } |
| 912 | void initBatchTracker(const GrPipelineInfo&) override {} |
| 913 | bool onCombineIfPossible(GrBatch*) override { return false; } |
| 914 | void generateGeometry(GrBatchTarget*, const GrPipeline*) override {} |
| 915 | |
| 916 | } testLCDCoverageBatch; |
| 917 | |
| 918 | GrProcOptInfo colorPOI, covPOI; |
| 919 | colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0); |
| 920 | covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0); |
| 921 | |
| 922 | SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |
| 923 | SkASSERT(covPOI.isFourChannelOutput()); |
| 924 | |
| 925 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 926 | TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 927 | |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 928 | SkAutoTUnref<GrXferProcessor> xp( |
| 929 | xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 930 | if (!xp) { |
| 931 | ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 932 | return; |
| 933 | } |
| 934 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 935 | GrXPFactory::InvariantBlendedColor blendedColor; |
| 936 | xpf->getInvariantBlendedColor(colorPOI, &blendedColor); |
| 937 | TEST_ASSERT(blendedColor.fWillBlendWithDst); |
| 938 | TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 939 | |
| 940 | GrColor overrideColor; |
| 941 | xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps); |
| 942 | |
| 943 | GrXferProcessor::BlendInfo blendInfo; |
| 944 | xp->getBlendInfo(&blendInfo); |
| 945 | TEST_ASSERT(blendInfo.fWriteColor); |
| 946 | } |
| 947 | |
| 948 | static void test_no_dual_source_blending(skiatest::Reporter* reporter) { |
| 949 | GrContextOptions opts; |
| 950 | opts.fSuppressDualSourceBlending = true; |
| 951 | GrContextFactory factory(opts); |
| 952 | factory.get(GrContextFactory::kNull_GLContextType); |
| 953 | GrContext* ctx = factory.get(GrContextFactory::kNull_GLContextType); |
| 954 | if (!ctx) { |
| 955 | SkFAIL("Failed to create null context without ARB_blend_func_extended."); |
| 956 | return; |
| 957 | } |
| 958 | |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 959 | const GrCaps& caps = *ctx->caps(); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 960 | if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 961 | SkFAIL("Null context failed to honor request for no ARB_blend_func_extended."); |
| 962 | return; |
| 963 | } |
| 964 | |
| 965 | GrBackendTextureDesc fakeDesc; |
| 966 | fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 967 | fakeDesc.fWidth = fakeDesc.fHeight = 100; |
| 968 | fakeDesc.fTextureHandle = 1; |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 969 | SkAutoTUnref<GrTexture> fakeTexture(ctx->resourceProvider()->wrapBackendTexture(fakeDesc, |
| 970 | kBorrow_GrWrapOwnership)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 971 | GrXferProcessor::DstTexture fakeDstTexture; |
| 972 | fakeDstTexture.setTexture(fakeTexture); |
| 973 | |
| 974 | static const GrColor testColors[] = { |
| 975 | 0, |
| 976 | GrColorPackRGBA(0, 82, 0, 255), |
| 977 | GrColorPackA4(255) |
| 978 | }; |
| 979 | static const GrColorComponentFlags testColorFlags[] = { |
| 980 | kNone_GrColorComponentFlags, |
| 981 | kG_GrColorComponentFlag | kA_GrColorComponentFlag, |
| 982 | kRGBA_GrColorComponentFlags |
| 983 | }; |
| 984 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags)); |
| 985 | |
| 986 | for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { |
| 987 | GrProcOptInfo colorPOI; |
| 988 | colorPOI.calcWithInitialValues(NULL, 0, testColors[c], testColorFlags[c], false); |
| 989 | for (int f = 0; f <= 1; f++) { |
| 990 | GrProcOptInfo covPOI; |
| 991 | if (!f) { |
| 992 | covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, true); |
| 993 | } else { |
| 994 | covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), |
| 995 | kRGBA_GrColorComponentFlags, true); |
| 996 | } |
| 997 | for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 998 | SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 999 | SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode)); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 1000 | GrXferProcessor::DstTexture* dstTexture = |
| 1001 | xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fakeDstTexture : 0; |
| 1002 | SkAutoTUnref<GrXferProcessor> xp( |
| 1003 | xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1004 | if (!xp) { |
| 1005 | ERRORF(reporter, "Failed to create an XP without dual source blending."); |
| 1006 | return; |
| 1007 | } |
| 1008 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1009 | xp->getOptimizations(colorPOI, covPOI, false, 0, caps); |
| 1010 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | #endif |
| 1017 | |