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