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 | kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 61 | kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag |
| 62 | }; |
| 63 | |
| 64 | class GrPorterDuffTest { |
| 65 | public: |
| 66 | struct XPInfo { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 67 | XPInfo(skiatest::Reporter* reporter, SkBlendMode xfermode, const GrCaps& caps, |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 68 | const GrProcessorSet::FragmentProcessorAnalysis& analysis) { |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 69 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 70 | // The GrXPFactory query assumes no coverage. |
| 71 | fCanCombineOverlappedStencilAndCover = |
| 72 | !analysis.hasCoverage() && GrXPFactory::CanCombineOverlappedStencilAndCover( |
| 73 | xpf, analysis.isOutputColorOpaque()); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 74 | sk_sp<GrXferProcessor> xp(xpf->createXferProcessor(analysis, false, nullptr, caps)); |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 75 | TEST_ASSERT(!GrXPFactory::WillNeedDstTexture(xpf, caps, analysis)); |
Brian Salomon | 1c10fdd | 2017-03-03 14:30:15 -0500 | [diff] [blame] | 76 | fOptFlags = xp->getOptimizations(analysis); |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 77 | GetXPOutputTypes(xp.get(), &fPrimaryOutputType, &fSecondaryOutputType); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 78 | xp->getBlendInfo(&fBlendInfo); |
| 79 | TEST_ASSERT(!xp->willReadDstColor()); |
| 80 | TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend)); |
| 81 | } |
| 82 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 83 | bool fCanCombineOverlappedStencilAndCover; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 84 | int fOptFlags; |
| 85 | int fPrimaryOutputType; |
| 86 | int fSecondaryOutputType; |
| 87 | GrXferProcessor::BlendInfo fBlendInfo; |
| 88 | }; |
| 89 | |
| 90 | static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) { |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame] | 91 | GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 92 | } |
| 93 | }; |
| 94 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 95 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 96 | GrPipelineInput lcdInput; |
| 97 | lcdInput.setToLCDCoverage(); |
| 98 | GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput(), lcdInput, caps); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 99 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 100 | SkASSERT(!analysis.isOutputColorOpaque()); |
| 101 | SkASSERT(!analysis.hasKnownOutputColor()); |
| 102 | SkASSERT(analysis.hasLCDCoverage()); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 103 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 104 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 105 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 106 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 107 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 108 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 109 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 110 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 111 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 112 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 113 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 114 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 115 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 116 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 117 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 118 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 119 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 120 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 121 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 122 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 123 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 124 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 125 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 126 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 127 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 128 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 129 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 130 | TEST_ASSERT((kIgnoreColor_OptFlag | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 131 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 132 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 133 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 134 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 135 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 136 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 137 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 138 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 139 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 140 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 141 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 142 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 143 | TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 144 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 145 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 146 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 147 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 148 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 149 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 150 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 151 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 152 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 153 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 154 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 155 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 156 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 157 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 158 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 159 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 160 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 161 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 162 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 163 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 164 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 165 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 166 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 167 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 168 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 169 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 170 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 171 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 172 | TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 173 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 174 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 175 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 176 | TEST_ASSERT(kOne_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::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 180 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 181 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 182 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 183 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 184 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 185 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 186 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 187 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 188 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 189 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 190 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 191 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 192 | TEST_ASSERT(kSAModulate_OutputType == xpi.fPrimaryOutputType); |
| 193 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 194 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 195 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 196 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 197 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 198 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 199 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 200 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 201 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 202 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 203 | TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 204 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 205 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 206 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 207 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 208 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 209 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 210 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 211 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 212 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 213 | TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); |
| 214 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 215 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 216 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 217 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 218 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 219 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 220 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 221 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 222 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 223 | TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 224 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 225 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 226 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 227 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 228 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 229 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 230 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 231 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 232 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 233 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 234 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 235 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 236 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 237 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 238 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 239 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 240 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 241 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 242 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 243 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 244 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 245 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 246 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 247 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 248 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 249 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 250 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 251 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
| 252 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 253 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 254 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 255 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 256 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 257 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 258 | break; |
| 259 | default: |
| 260 | ERRORF(reporter, "Invalid xfermode."); |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | } |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 265 | static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 266 | GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput(), GrPipelineInput(), caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 267 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 268 | SkASSERT(!analysis.isOutputColorOpaque()); |
| 269 | SkASSERT(!analysis.hasKnownOutputColor()); |
| 270 | SkASSERT(!analysis.hasLCDCoverage()); |
| 271 | SkASSERT(analysis.hasCoverage()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 272 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 273 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 274 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 275 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 276 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 277 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 278 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 279 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 280 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 281 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 282 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 283 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 284 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 285 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 286 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 287 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 288 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 289 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 290 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 291 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 292 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 293 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 294 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 295 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 296 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 297 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 298 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 299 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 300 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 301 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 302 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 303 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 304 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 305 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 306 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 307 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 308 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 309 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 310 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 311 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 312 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 313 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 314 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 315 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 316 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 317 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 318 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 319 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 320 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 321 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 322 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 323 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 324 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 325 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 326 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 327 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 328 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 329 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 330 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 331 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 332 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 333 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 334 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 335 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 336 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 337 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 338 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 339 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 340 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 341 | TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 342 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 343 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 344 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 345 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 346 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 347 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 348 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 349 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 350 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 351 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 352 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 353 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 354 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 355 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 356 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 357 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 358 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 359 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 360 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 361 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 362 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 363 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 364 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 365 | TEST_ASSERT(kISA_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::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 369 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 370 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 371 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 372 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 373 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 374 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 375 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 376 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 377 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 378 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 379 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 380 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 381 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 382 | TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); |
| 383 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 384 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 385 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 386 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 387 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 388 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 389 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 390 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 391 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 392 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 393 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 394 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 395 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 396 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 397 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 398 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 399 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 400 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 401 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 402 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 403 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 404 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 405 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 406 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 407 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 408 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 409 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 410 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 411 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 412 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 413 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 414 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 415 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 416 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 417 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 418 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 419 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 420 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 421 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 422 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 423 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 424 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 425 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 426 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 427 | break; |
| 428 | default: |
| 429 | ERRORF(reporter, "Invalid xfermode."); |
| 430 | break; |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 436 | GrProcessorSet::FragmentProcessorAnalysis analysis(GrColorPackRGBA(229, 0, 154, 240), |
| 437 | GrColorPackA4(255), caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 438 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 439 | SkASSERT(!analysis.isOutputColorOpaque()); |
| 440 | SkASSERT(analysis.hasKnownOutputColor()); |
| 441 | SkASSERT(!analysis.hasCoverage()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 442 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 443 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 444 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 445 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 446 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 447 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 448 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 449 | TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 450 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 451 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 452 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 453 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 454 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 455 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 456 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 457 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 458 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 459 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 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(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 465 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 466 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 467 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 468 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 469 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 470 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 471 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 472 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 473 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 474 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 475 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 476 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 477 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 478 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 479 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 480 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 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(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 486 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 487 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 488 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 489 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 490 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 491 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 492 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 493 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 494 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 495 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 496 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 497 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 498 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 499 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 500 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 501 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 502 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 503 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 504 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 505 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 506 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 507 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 508 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 509 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
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(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 515 | TEST_ASSERT(kSA_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::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 519 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 520 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 521 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 522 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 523 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 524 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 525 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 526 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 527 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 528 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 529 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 530 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 531 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 532 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 533 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 534 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 535 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 536 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 537 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 538 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 539 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 540 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 541 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 542 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 543 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 544 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 545 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 546 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 547 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 548 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 549 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 550 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 551 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 552 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 553 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 554 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 555 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 556 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 557 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 558 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 559 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 560 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 561 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 562 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 563 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 564 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 565 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 566 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 567 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 568 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 569 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 570 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 571 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 572 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 573 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 574 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 575 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 576 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 577 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 578 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 579 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 580 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 581 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 582 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 583 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 584 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 585 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 586 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 587 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 588 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 589 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 590 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 591 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 592 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 593 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 594 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 595 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 596 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 597 | break; |
| 598 | default: |
| 599 | ERRORF(reporter, "Invalid xfermode."); |
| 600 | break; |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 606 | GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput::Opaque::kYes, |
| 607 | GrPipelineInput(), caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 608 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 609 | SkASSERT(analysis.isOutputColorOpaque()); |
| 610 | SkASSERT(!analysis.hasKnownOutputColor()); |
| 611 | SkASSERT(analysis.hasCoverage()); |
| 612 | SkASSERT(!analysis.hasLCDCoverage()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 613 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 614 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 615 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 616 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 617 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 618 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 619 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 620 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 621 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 622 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 623 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 624 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 625 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 626 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 627 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 628 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 629 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 630 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 631 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 632 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 633 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 634 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 635 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 636 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 637 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 638 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 639 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 640 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 641 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 642 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 643 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 644 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 645 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 646 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 647 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 648 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 649 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 650 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 651 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 652 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 653 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 654 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 655 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 656 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 657 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 658 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 659 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 660 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 661 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 662 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 663 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 664 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 665 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 666 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 667 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 668 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 669 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 670 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 671 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 672 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 673 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 674 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 675 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 676 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 677 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 678 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 679 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 680 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 681 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 682 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 683 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 684 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 685 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 686 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 687 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 688 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 689 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 690 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 691 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 692 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 693 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 694 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 695 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 696 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 697 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 698 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 699 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 700 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 701 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 702 | TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
| 703 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 704 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 705 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 706 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 707 | TEST_ASSERT(kOne_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::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 711 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 712 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 713 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 714 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 715 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 716 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 717 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 718 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 719 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 720 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 721 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 722 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 723 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 724 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 725 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 726 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 727 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 728 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 729 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 730 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 731 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 732 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 733 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 734 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 735 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 736 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 737 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 738 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 739 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 740 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 741 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 742 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 743 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 744 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 745 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 746 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 747 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 748 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 749 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 750 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 751 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
bsalomon | 7765a47 | 2015-07-08 11:26:37 -0700 | [diff] [blame] | 752 | TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 753 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 754 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 755 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 756 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 757 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 758 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 759 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 760 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 761 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 762 | TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 763 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 764 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 765 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 766 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 767 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 768 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 769 | break; |
| 770 | default: |
| 771 | ERRORF(reporter, "Invalid xfermode."); |
| 772 | break; |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 778 | GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput::Opaque::kYes, |
| 779 | GrColorPackA4(255), caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 780 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 781 | SkASSERT(analysis.isOutputColorOpaque()); |
| 782 | SkASSERT(!analysis.hasKnownOutputColor()); |
| 783 | SkASSERT(!analysis.hasCoverage()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 784 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 785 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 786 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 787 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 788 | |
| 789 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 790 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 791 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 792 | TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 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(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 798 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 799 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 800 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 801 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 802 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 803 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 804 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 805 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 806 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 807 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 808 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 809 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 810 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 811 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 812 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 813 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 814 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 815 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 816 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 817 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 818 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 819 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 820 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 821 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 822 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 823 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 824 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 825 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 826 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 827 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 828 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 829 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 830 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 831 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 832 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 833 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 834 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 835 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 836 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 837 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 838 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 839 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 840 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 841 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 842 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 843 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 844 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 845 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 846 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 847 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 848 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 849 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 850 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 851 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 852 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 02baee9 | 2017-02-24 10:37:15 -0500 | [diff] [blame] | 853 | TEST_ASSERT((kIgnoreColor_OptFlag | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 854 | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); |
| 855 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 856 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 857 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 858 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 859 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 860 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 861 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 862 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 863 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 864 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 865 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 866 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 867 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 868 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 869 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 870 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 871 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 872 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 873 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 874 | TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 875 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 876 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 877 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 878 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 879 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 880 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 881 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 882 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 883 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 884 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 885 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 886 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 887 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 888 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 889 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 890 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 891 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 892 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 893 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 894 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 895 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 896 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 897 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 898 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 899 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 900 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 901 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 902 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 903 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 904 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 905 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 906 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 907 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 908 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 909 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 910 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 911 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 912 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 913 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 914 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 915 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 916 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 917 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 918 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 919 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 920 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 921 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 922 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 923 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 924 | TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 925 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 926 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 927 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 928 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 929 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 930 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 931 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 932 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 933 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 8c852be | 2017-01-04 10:44:42 -0500 | [diff] [blame] | 934 | TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 935 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 936 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 937 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 938 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 939 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 940 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 941 | break; |
| 942 | default: |
| 943 | ERRORF(reporter, "Invalid xfermode."); |
| 944 | break; |
| 945 | } |
| 946 | } |
| 947 | } |
| 948 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 949 | 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] | 950 | class TestLCDCoverageOp : public GrMeshDrawOp { |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 951 | public: |
Brian Salomon | 25a8809 | 2016-12-01 09:36:50 -0500 | [diff] [blame] | 952 | DEFINE_OP_CLASS_ID |
reed | 1b55a96 | 2015-09-17 20:16:13 -0700 | [diff] [blame] | 953 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 954 | TestLCDCoverageOp() : INHERITED(ClassID()) {} |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 955 | |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 956 | const char* name() const override { return "Test LCD Text Op"; } |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 957 | |
| 958 | private: |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 959 | void getFragmentProcessorAnalysisInputs( |
| 960 | FragmentProcessorAnalysisInputs* input) const override { |
| 961 | input->colorInput()->setToConstant(GrColorPackRGBA(123, 45, 67, 221)); |
| 962 | input->coverageInput()->setToLCDCoverage(); |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | void applyPipelineOptimizations(const GrPipelineOptimizations&) override {} |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 966 | bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; } |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 967 | void onPrepareDraws(Target*) const override {} |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 968 | |
Brian Salomon | dad2923 | 2016-12-01 16:40:24 -0500 | [diff] [blame] | 969 | typedef GrMeshDrawOp INHERITED; |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 970 | } testLCDCoverageOp; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 971 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 972 | GrProcessorSet::FragmentProcessorAnalysis analysis; |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame^] | 973 | testLCDCoverageOp.analyzeProcessors(&analysis, GrProcessorSet(GrPaint()), nullptr, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 974 | |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 975 | SkASSERT(analysis.hasKnownOutputColor()); |
| 976 | SkASSERT(analysis.hasLCDCoverage()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 977 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 978 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(SkBlendMode::kSrcOver); |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 979 | TEST_ASSERT(!GrXPFactory::WillNeedDstTexture(xpf, caps, analysis)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 980 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 981 | sk_sp<GrXferProcessor> xp(xpf->createXferProcessor(analysis, false, nullptr, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 982 | if (!xp) { |
| 983 | ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 984 | return; |
| 985 | } |
| 986 | |
Brian Salomon | 1c10fdd | 2017-03-03 14:30:15 -0500 | [diff] [blame] | 987 | xp->getOptimizations(analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 988 | |
| 989 | GrXferProcessor::BlendInfo blendInfo; |
| 990 | xp->getBlendInfo(&blendInfo); |
| 991 | TEST_ASSERT(blendInfo.fWriteColor); |
| 992 | } |
| 993 | |
kkinnunen | 1530283 | 2015-12-01 04:35:26 -0800 | [diff] [blame] | 994 | DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 995 | GrContextOptions opts; |
| 996 | opts.fSuppressDualSourceBlending = true; |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 997 | sk_gpu_test::GrContextFactory mockFactory(opts); |
bsalomon | 85b4b53 | 2016-04-05 11:06:27 -0700 | [diff] [blame] | 998 | GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNullGL_ContextType); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 999 | if (!ctx) { |
| 1000 | SkFAIL("Failed to create null context without ARB_blend_func_extended."); |
| 1001 | return; |
| 1002 | } |
| 1003 | |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 1004 | const GrCaps& caps = *ctx->caps(); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1005 | if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 1006 | SkFAIL("Null context failed to honor request for no ARB_blend_func_extended."); |
| 1007 | return; |
| 1008 | } |
| 1009 | |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1010 | GrBackendObject backendTex = |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 1011 | ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1012 | GrBackendTextureDesc fakeDesc; |
| 1013 | fakeDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 1014 | fakeDesc.fWidth = fakeDesc.fHeight = 100; |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1015 | fakeDesc.fTextureHandle = backendTex; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1016 | GrXferProcessor::DstTexture fakeDstTexture; |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 1017 | fakeDstTexture.setTexture( |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 1018 | ctx->resourceProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1019 | |
Brian Salomon | c6b7146 | 2017-02-14 11:33:01 -0500 | [diff] [blame] | 1020 | static const GrPipelineInput colorInputs[] = {GrPipelineInput(), |
| 1021 | GrPipelineInput(GrPipelineInput::Opaque::kYes), |
| 1022 | GrPipelineInput(GrColorPackRGBA(0, 82, 17, 100)), |
| 1023 | GrPipelineInput(GrColorPackRGBA(0, 82, 17, 255))}; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1024 | |
Brian Salomon | c6b7146 | 2017-02-14 11:33:01 -0500 | [diff] [blame] | 1025 | for (const auto& colorInput : colorInputs) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 1026 | GrProcessorSet::FragmentProcessorAnalysis analysis; |
Brian Salomon | c6b7146 | 2017-02-14 11:33:01 -0500 | [diff] [blame] | 1027 | for (bool fractionalCoverage : {true, false}) { |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 1028 | if (fractionalCoverage) { |
| 1029 | analysis = GrProcessorSet::FragmentProcessorAnalysis(colorInput, GrPipelineInput(), |
| 1030 | caps); |
| 1031 | } else { |
| 1032 | analysis = GrProcessorSet::FragmentProcessorAnalysis(colorInput, GrColorPackA4(255), |
| 1033 | caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1034 | } |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 1035 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 1036 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 1037 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 1038 | GrXferProcessor::DstTexture* dstTexture = |
Brian Salomon | 5298dc8 | 2017-02-22 11:52:03 -0500 | [diff] [blame] | 1039 | GrXPFactory::WillNeedDstTexture(xpf, caps, analysis) ? &fakeDstTexture : 0; |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 1040 | sk_sp<GrXferProcessor> xp( |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 1041 | xpf->createXferProcessor(analysis, false, dstTexture, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1042 | if (!xp) { |
| 1043 | ERRORF(reporter, "Failed to create an XP without dual source blending."); |
| 1044 | return; |
| 1045 | } |
| 1046 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
Brian Salomon | 1c10fdd | 2017-03-03 14:30:15 -0500 | [diff] [blame] | 1047 | xp->getOptimizations(analysis); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1048 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1049 | } |
| 1050 | } |
| 1051 | } |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 1052 | ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | #endif |