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