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" |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 14 | #include "GrContextPriv.h" |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 15 | #include "GrGpu.h" |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 16 | #include "GrTest.h" |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 17 | #include "GrXferProcessor.h" |
| 18 | #include "effects/GrPorterDuffXferProcessor.h" |
| 19 | #include "gl/GrGLCaps.h" |
Brian Salomon | 8952743 | 2016-12-16 09:52:16 -0500 | [diff] [blame] | 20 | #include "ops/GrMeshDrawOp.h" |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 21 | |
| 22 | //////////////////////////////////////////////////////////////////////////////// |
| 23 | |
| 24 | static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 25 | static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 26 | static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
| 27 | static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
| 28 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 29 | static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 30 | |
bsalomon | 758586c | 2016-04-06 14:02:39 -0700 | [diff] [blame] | 31 | DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrPorterDuff, reporter, ctxInfo) { |
bsalomon | 8b7451a | 2016-05-11 06:33:06 -0700 | [diff] [blame] | 32 | const GrCaps& caps = *ctxInfo.grContext()->getGpu()->caps(); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 33 | if (!caps.shaderCaps()->dualSourceBlendingSupport()) { |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 34 | SK_ABORT("Null context does not support dual source blending."); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 35 | return; |
| 36 | } |
| 37 | |
| 38 | test_color_unknown_with_coverage(reporter, caps); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 39 | test_color_not_opaque_no_coverage(reporter, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 40 | test_color_opaque_with_coverage(reporter, caps); |
| 41 | test_color_opaque_no_coverage(reporter, caps); |
| 42 | test_lcd_coverage(reporter, caps); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 43 | test_lcd_coverage_fallback_case(reporter, caps); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | //////////////////////////////////////////////////////////////////////////////// |
| 47 | |
| 48 | #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) |
| 49 | |
| 50 | enum { |
| 51 | kNone_OutputType, |
| 52 | kCoverage_OutputType, |
| 53 | kModulate_OutputType, |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 54 | kSAModulate_OutputType, |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 55 | kISAModulate_OutputType, |
| 56 | kISCModulate_OutputType |
| 57 | }; |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 58 | static const int kInvalid_OutputType = -1; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 59 | |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 60 | static GrProcessorSet::Analysis do_analysis(const GrXPFactory* xpf, |
| 61 | const GrProcessorAnalysisColor& colorInput, |
| 62 | GrProcessorAnalysisCoverage coverageInput, |
| 63 | const GrCaps& caps) { |
| 64 | GrPaint paint; |
| 65 | paint.setXPFactory(xpf); |
| 66 | GrProcessorSet procs(std::move(paint)); |
| 67 | GrColor overrideColor; |
| 68 | GrProcessorSet::Analysis analysis = |
| 69 | procs.finalize(colorInput, coverageInput, nullptr, false, caps, &overrideColor); |
| 70 | return analysis; |
| 71 | } |
| 72 | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 73 | class GrPorterDuffTest { |
| 74 | public: |
| 75 | struct XPInfo { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 76 | XPInfo(skiatest::Reporter* reporter, SkBlendMode xfermode, const GrCaps& caps, |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 77 | GrProcessorAnalysisColor inputColor, GrProcessorAnalysisCoverage inputCoverage) { |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 78 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 79 | |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 80 | bool isLCD = GrProcessorAnalysisCoverage::kLCD == inputCoverage; |
| 81 | |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 82 | GrProcessorSet::Analysis analysis = do_analysis(xpf, inputColor, inputCoverage, caps); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 83 | fCompatibleWithCoverageAsAlpha = analysis.isCompatibleWithCoverageAsAlpha(); |
| 84 | fCanCombineOverlappedStencilAndCover = analysis.canCombineOverlappedStencilAndCover(); |
Brian Salomon | 48d1b4c | 2017-04-08 07:38:53 -0400 | [diff] [blame] | 85 | fIgnoresInputColor = analysis.inputColorIsIgnored(); |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 86 | sk_sp<const GrXferProcessor> xp( |
Brian Salomon | a076d87 | 2017-04-04 15:17:03 -0400 | [diff] [blame] | 87 | GrXPFactory::MakeXferProcessor(xpf, inputColor, inputCoverage, false, caps)); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 88 | TEST_ASSERT(!analysis.requiresDstTexture() || |
| 89 | (isLCD && |
| 90 | !caps.shaderCaps()->dstReadInShaderSupport() && |
| 91 | (SkBlendMode::kSrcOver != xfermode || |
| 92 | !inputColor.isOpaque()))); |
Hal Canary | 342b7ac | 2016-11-04 11:49:42 -0400 | [diff] [blame] | 93 | GetXPOutputTypes(xp.get(), &fPrimaryOutputType, &fSecondaryOutputType); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 94 | xp->getBlendInfo(&fBlendInfo); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 95 | TEST_ASSERT(!xp->willReadDstColor() || |
| 96 | (isLCD && (SkBlendMode::kSrcOver != xfermode || |
| 97 | !inputColor.isOpaque()))); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 98 | TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend)); |
| 99 | } |
| 100 | |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 101 | bool fCanCombineOverlappedStencilAndCover; |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 102 | bool fCompatibleWithCoverageAsAlpha; |
| 103 | bool fIgnoresInputColor; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 104 | int fPrimaryOutputType; |
| 105 | int fSecondaryOutputType; |
| 106 | GrXferProcessor::BlendInfo fBlendInfo; |
| 107 | }; |
| 108 | |
| 109 | static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) { |
egdaniel | f234272 | 2015-11-20 15:12:59 -0800 | [diff] [blame] | 110 | GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 111 | } |
| 112 | }; |
| 113 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 114 | static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 115 | GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes; |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 116 | GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kLCD; |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 117 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 118 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 119 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 120 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 121 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 122 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 123 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 124 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 125 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 126 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 127 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
| 128 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 129 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 130 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 131 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 132 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 133 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 134 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 135 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 136 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 137 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 138 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 139 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 140 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 141 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 142 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 143 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 144 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 145 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 146 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 147 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 148 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 149 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 150 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 151 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 152 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 153 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 154 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 155 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 156 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 157 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 158 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 159 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 160 | TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); |
| 161 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 162 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 163 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 164 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 165 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 166 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 167 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 168 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 169 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 170 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 171 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 172 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 173 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 174 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 175 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 176 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 177 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 178 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 179 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 180 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 181 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 182 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 183 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 184 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 185 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 186 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 187 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 188 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 189 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 190 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 191 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 192 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 193 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
| 194 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 195 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 196 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 197 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 198 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 199 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 200 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 201 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 202 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 203 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 204 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 205 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 206 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 207 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 208 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 209 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 210 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 211 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 212 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 213 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 214 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 215 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 216 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 217 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 218 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 219 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 220 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 221 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 222 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 223 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 224 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 225 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 226 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 227 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 228 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 229 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 230 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 231 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 232 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 233 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 234 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 235 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 236 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 237 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 238 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 239 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 240 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 241 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 242 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 243 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 244 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 245 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 246 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 247 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 248 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 249 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 250 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 251 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 252 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 253 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 254 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 255 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 256 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 257 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 258 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 259 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 260 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 261 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 262 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 263 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 264 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 265 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 266 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 267 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 268 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 269 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 270 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
| 271 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 272 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 273 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 274 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 275 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 276 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 277 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 278 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 279 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 280 | TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType); |
| 281 | TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 282 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 283 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
Greg Daniel | 79cdf28 | 2017-05-22 15:56:22 -0400 | [diff] [blame] | 284 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 285 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 286 | break; |
| 287 | default: |
| 288 | ERRORF(reporter, "Invalid xfermode."); |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | } |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 293 | static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 294 | GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kNo; |
| 295 | GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kSingleChannel; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 296 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 297 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 298 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 299 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 300 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 301 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 302 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 303 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 304 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 305 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 306 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 307 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 308 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 309 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 310 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 311 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 312 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 313 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 314 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 315 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 316 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 317 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 318 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 319 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 320 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 321 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 322 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 323 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 324 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 325 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 326 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 327 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 328 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 329 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 330 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 331 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 332 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 333 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 334 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 335 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 336 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 337 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 338 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 339 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 340 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 341 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 342 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 343 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 344 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 345 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 346 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 347 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 348 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 349 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 350 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 351 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 352 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 353 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 354 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 355 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 356 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 357 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 358 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 359 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 360 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 361 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 362 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 363 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 364 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 365 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 366 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 367 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 368 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 369 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 370 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 371 | TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); |
| 372 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 373 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 374 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 375 | TEST_ASSERT(kOne_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::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 379 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 380 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 381 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 382 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 383 | TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); |
| 384 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 385 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 386 | TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 387 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 388 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 389 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 390 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 391 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 392 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 393 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 394 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 395 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 396 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 397 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 398 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 399 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 400 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 401 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 402 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 403 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 404 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 405 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 406 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 407 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 408 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 409 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 410 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 411 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 412 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 413 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 414 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 415 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 416 | TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); |
| 417 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 418 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 419 | TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 420 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 421 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 422 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 423 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 424 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 425 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 426 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 427 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 428 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 429 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 430 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 431 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 432 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 433 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 434 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 435 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 436 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 437 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 438 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 439 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 440 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 441 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 442 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 443 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 444 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 445 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 446 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 447 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 448 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 449 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 450 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 451 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 452 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 453 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 454 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 455 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 456 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 457 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 458 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 459 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 460 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 461 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 462 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 463 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 464 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 465 | break; |
| 466 | default: |
| 467 | ERRORF(reporter, "Invalid xfermode."); |
| 468 | break; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 473 | static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 474 | GrProcessorAnalysisColor inputColor(GrColorPackRGBA(229, 0, 154, 240)); |
| 475 | GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kNone; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 476 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 477 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 478 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 479 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 480 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 481 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 482 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 483 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 484 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 485 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 486 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 487 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 488 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 489 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 490 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 491 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 492 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 493 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 494 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 495 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 496 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 497 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 498 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 499 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 500 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 501 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 502 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 503 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 504 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 505 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 506 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 507 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 508 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 509 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 510 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 511 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 512 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 513 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 514 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 515 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 516 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 517 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 518 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 519 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 520 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 521 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 522 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 523 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 524 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 525 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 526 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 527 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 528 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 529 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 530 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 531 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 532 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 533 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 534 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 535 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 536 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 537 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 538 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 539 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 540 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 541 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 542 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 543 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 544 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 545 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 546 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 547 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 548 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 549 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 550 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
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(kZero_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::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 559 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 560 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 561 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 562 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 563 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 564 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 565 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 566 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 567 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 568 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 569 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 570 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 571 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 572 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 573 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 574 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 575 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 576 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 577 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 578 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 579 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 580 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 581 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 582 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 583 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 584 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 585 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 586 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 587 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 588 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 589 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 590 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 591 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 592 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 593 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 594 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 595 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 596 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 597 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 598 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 599 | TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 600 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 601 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 602 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 603 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 604 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 605 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 606 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 607 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 608 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 609 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 610 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 611 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 612 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 613 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 614 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 615 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 616 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 617 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 618 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 619 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 620 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 621 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 622 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 623 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 624 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 625 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 626 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 627 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 628 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 629 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 630 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 631 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 632 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 633 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 634 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 635 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 636 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 637 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 638 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 639 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 640 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 641 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 642 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 643 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 644 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 645 | break; |
| 646 | default: |
| 647 | ERRORF(reporter, "Invalid xfermode."); |
| 648 | break; |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 654 | GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes; |
| 655 | GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kSingleChannel; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 656 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 657 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 658 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 659 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 660 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 661 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 662 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 663 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 664 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 665 | TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
| 666 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 667 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 668 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 669 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 670 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 671 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 672 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 673 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 674 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 675 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 676 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 677 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 678 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 679 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 680 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 681 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 682 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 683 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 684 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 685 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 686 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 687 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 688 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 689 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 690 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 691 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 692 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 693 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 694 | case SkBlendMode::kSrcOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 695 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 696 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 697 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 698 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 699 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 700 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 701 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 702 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 703 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 704 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 705 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 706 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 707 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 708 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 709 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 710 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 711 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 712 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 713 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 714 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 715 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 716 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 717 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 718 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 719 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 720 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 721 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 722 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 723 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 724 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 725 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 726 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 727 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 728 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 729 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 730 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 731 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 732 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 733 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 734 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 735 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 736 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 737 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 738 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 739 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 740 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 741 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 742 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 743 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 744 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 745 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 746 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 747 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 748 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 749 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 750 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 751 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 752 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 753 | TEST_ASSERT(kCoverage_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::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 761 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 762 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 763 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 764 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 765 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 766 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 767 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 768 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 769 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 770 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 771 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 772 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 773 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 774 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 775 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 776 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 777 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 778 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 779 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 780 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 781 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 782 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 783 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 784 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 785 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 786 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 787 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 788 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 789 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 790 | TEST_ASSERT(kISA_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::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 794 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 795 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 796 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 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(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 801 | TEST_ASSERT(kOne_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::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 805 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 806 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 807 | TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); |
| 808 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 809 | TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 810 | TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 811 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 812 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 813 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 814 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 815 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 816 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 817 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 818 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 819 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 820 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 821 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 822 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 823 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 824 | break; |
| 825 | default: |
| 826 | ERRORF(reporter, "Invalid xfermode."); |
| 827 | break; |
| 828 | } |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 833 | GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes; |
| 834 | GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kNone; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 835 | |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 836 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 837 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 838 | const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 839 | |
| 840 | switch (xfermode) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 841 | case SkBlendMode::kClear: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 842 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 843 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 844 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 845 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 846 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 847 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 848 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 849 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 850 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 851 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 852 | case SkBlendMode::kSrc: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 853 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 854 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 855 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 856 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 857 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 858 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 859 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 860 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 861 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 862 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 863 | case SkBlendMode::kDst: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 864 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 865 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 866 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 867 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 868 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 869 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 870 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 871 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 872 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 873 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 874 | case SkBlendMode::kSrcOver: |
Brian Salomon | 28207df | 2017-06-05 12:25:13 -0400 | [diff] [blame] | 875 | // We don't specialize opaque src-over. See note in GrPorterDuffXferProcessor.cpp |
| 876 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 877 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
Brian Salomon | 28207df | 2017-06-05 12:25:13 -0400 | [diff] [blame] | 878 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 879 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 880 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 881 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 882 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
Brian Salomon | 28207df | 2017-06-05 12:25:13 -0400 | [diff] [blame] | 883 | TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 884 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 885 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 886 | case SkBlendMode::kDstOver: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 887 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 888 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 889 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 890 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 891 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 892 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 893 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 894 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 895 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 896 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 897 | case SkBlendMode::kSrcIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 898 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 899 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 900 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 901 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 902 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 903 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 904 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 905 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 906 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 907 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 908 | case SkBlendMode::kDstIn: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 909 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 910 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 911 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 912 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 913 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 914 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 915 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 916 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 917 | TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); |
| 918 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 919 | case SkBlendMode::kSrcOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 920 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 921 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 922 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 923 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 924 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 925 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 926 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 927 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 928 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 929 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 930 | case SkBlendMode::kDstOut: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 931 | TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 932 | TEST_ASSERT(xpi.fIgnoresInputColor); |
| 933 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 934 | TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
| 935 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 936 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 937 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 938 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 939 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 940 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 941 | case SkBlendMode::kSrcATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 942 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 943 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 944 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 945 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 946 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 947 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 948 | TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 949 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 950 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 951 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 952 | case SkBlendMode::kDstATop: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 953 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 954 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 955 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 956 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 957 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 958 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 959 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 960 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 961 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 962 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 963 | case SkBlendMode::kXor: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 964 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 965 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 966 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 967 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 968 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 969 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 970 | TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 971 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 972 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 973 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 974 | case SkBlendMode::kPlus: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 975 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 976 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 977 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 978 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 979 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 980 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 981 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 982 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 983 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 984 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 985 | case SkBlendMode::kModulate: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 986 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 987 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 988 | TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 989 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 990 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 991 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 992 | TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 993 | TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 994 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 995 | break; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 996 | case SkBlendMode::kScreen: |
Brian Salomon | 54d212e | 2017-03-21 14:22:38 -0400 | [diff] [blame] | 997 | TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover); |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 998 | TEST_ASSERT(!xpi.fIgnoresInputColor); |
| 999 | TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1000 | TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); |
| 1001 | TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
| 1002 | TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation); |
| 1003 | TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend); |
| 1004 | TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
| 1005 | TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 1006 | break; |
| 1007 | default: |
| 1008 | ERRORF(reporter, "Invalid xfermode."); |
| 1009 | break; |
| 1010 | } |
| 1011 | } |
| 1012 | } |
| 1013 | |
egdaniel | 723b050 | 2015-09-15 09:31:40 -0700 | [diff] [blame] | 1014 | static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps) { |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 1015 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(SkBlendMode::kSrcOver); |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 1016 | GrProcessorAnalysisColor color = GrColorPackRGBA(123, 45, 67, 255); |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 1017 | GrProcessorAnalysisCoverage coverage = GrProcessorAnalysisCoverage::kLCD; |
Greg Daniel | 6ebe4b9 | 2017-05-19 10:56:46 -0400 | [diff] [blame] | 1018 | TEST_ASSERT(!(GrXPFactory::GetAnalysisProperties(xpf, color, coverage, caps) & |
| 1019 | GrXPFactory::AnalysisProperties::kRequiresDstTexture)); |
| 1020 | sk_sp<const GrXferProcessor> xp_opaque( |
| 1021 | GrXPFactory::MakeXferProcessor(xpf, color, coverage, false, caps)); |
| 1022 | if (!xp_opaque) { |
| 1023 | ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 1024 | return; |
| 1025 | } |
| 1026 | |
| 1027 | GrXferProcessor::BlendInfo blendInfo; |
| 1028 | xp_opaque->getBlendInfo(&blendInfo); |
| 1029 | TEST_ASSERT(blendInfo.fWriteColor); |
| 1030 | |
| 1031 | // Test with non-opaque alpha |
| 1032 | color = GrColorPackRGBA(123, 45, 67, 221); |
| 1033 | coverage = GrProcessorAnalysisCoverage::kLCD; |
Greg Daniel | d7b1159 | 2017-06-14 13:37:12 -0400 | [diff] [blame] | 1034 | TEST_ASSERT(!(GrXPFactory::GetAnalysisProperties(xpf, color, coverage, caps) & |
| 1035 | GrXPFactory::AnalysisProperties::kRequiresDstTexture)); |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 1036 | sk_sp<const GrXferProcessor> xp( |
| 1037 | GrXPFactory::MakeXferProcessor(xpf, color, coverage, false, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1038 | if (!xp) { |
| 1039 | ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 1040 | return; |
| 1041 | } |
| 1042 | |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1043 | xp->getBlendInfo(&blendInfo); |
| 1044 | TEST_ASSERT(blendInfo.fWriteColor); |
| 1045 | } |
| 1046 | |
kkinnunen | 1530283 | 2015-12-01 04:35:26 -0800 | [diff] [blame] | 1047 | DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1048 | GrContextOptions opts; |
| 1049 | opts.fSuppressDualSourceBlending = true; |
bsalomon | 3724e57 | 2016-03-30 18:56:19 -0700 | [diff] [blame] | 1050 | sk_gpu_test::GrContextFactory mockFactory(opts); |
bsalomon | 85b4b53 | 2016-04-05 11:06:27 -0700 | [diff] [blame] | 1051 | GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNullGL_ContextType); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1052 | if (!ctx) { |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 1053 | SK_ABORT("Failed to create null context without ARB_blend_func_extended."); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1054 | return; |
| 1055 | } |
| 1056 | |
bsalomon | 7622863 | 2015-05-29 08:02:10 -0700 | [diff] [blame] | 1057 | const GrCaps& caps = *ctx->caps(); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1058 | if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
Ben Wagner | b4aab9a | 2017-08-16 10:53:04 -0400 | [diff] [blame] | 1059 | SK_ABORT("Null context failed to honor request for no ARB_blend_func_extended."); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1060 | return; |
| 1061 | } |
| 1062 | |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 1063 | GrBackendObject backendTexHandle = |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 1064 | ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig); |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 1065 | GrBackendTexture backendTex = GrTest::CreateBackendTexture(ctx->contextPriv().getBackend(), |
| 1066 | 100, |
| 1067 | 100, |
| 1068 | kRGBA_8888_GrPixelConfig, |
| 1069 | backendTexHandle); |
| 1070 | |
Robert Phillips | bb581ce | 2017-05-29 15:05:15 -0400 | [diff] [blame] | 1071 | GrXferProcessor::DstProxy fakeDstProxy; |
| 1072 | { |
| 1073 | sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeWrappedBackend(ctx, backendTex, |
| 1074 | kTopLeft_GrSurfaceOrigin); |
| 1075 | fakeDstProxy.setProxy(std::move(proxy)); |
| 1076 | } |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1077 | |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 1078 | static const GrProcessorAnalysisColor colorInputs[] = { |
| 1079 | GrProcessorAnalysisColor::Opaque::kNo, GrProcessorAnalysisColor::Opaque::kYes, |
| 1080 | GrProcessorAnalysisColor(GrColorPackRGBA(0, 82, 17, 100)), |
| 1081 | GrProcessorAnalysisColor(GrColorPackRGBA(0, 82, 17, 255))}; |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1082 | |
Brian Salomon | c6b7146 | 2017-02-14 11:33:01 -0500 | [diff] [blame] | 1083 | for (const auto& colorInput : colorInputs) { |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 1084 | for (GrProcessorAnalysisCoverage coverageType : |
| 1085 | {GrProcessorAnalysisCoverage::kSingleChannel, GrProcessorAnalysisCoverage::kNone}) { |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 1086 | for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { |
| 1087 | SkBlendMode xfermode = static_cast<SkBlendMode>(m); |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 1088 | const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 1089 | sk_sp<const GrXferProcessor> xp( |
Brian Salomon | a076d87 | 2017-04-04 15:17:03 -0400 | [diff] [blame] | 1090 | GrXPFactory::MakeXferProcessor(xpf, colorInput, coverageType, false, caps)); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1091 | if (!xp) { |
| 1092 | ERRORF(reporter, "Failed to create an XP without dual source blending."); |
| 1093 | return; |
| 1094 | } |
| 1095 | TEST_ASSERT(!xp->hasSecondaryOutput()); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1096 | } |
| 1097 | } |
| 1098 | } |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 1099 | ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTexHandle); |
cdalton | 6fd158e | 2015-05-27 15:08:33 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | #endif |