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