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