| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkXfermode.h" | 8 #include "SkXfermode.h" |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 SkFAIL("Null context does not support dual source blending."); | 41 SkFAIL("Null context does not support dual source blending."); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 | 44 |
| 45 test_color_unknown_with_coverage(reporter, caps); | 45 test_color_unknown_with_coverage(reporter, caps); |
| 46 test_color_unknown_no_coverage(reporter, caps); | 46 test_color_unknown_no_coverage(reporter, caps); |
| 47 test_color_opaque_with_coverage(reporter, caps); | 47 test_color_opaque_with_coverage(reporter, caps); |
| 48 test_color_opaque_no_coverage(reporter, caps); | 48 test_color_opaque_no_coverage(reporter, caps); |
| 49 test_lcd_coverage(reporter, caps); | 49 test_lcd_coverage(reporter, caps); |
| 50 test_lcd_coverage_fallback_case(reporter, caps); | 50 test_lcd_coverage_fallback_case(reporter, caps); |
| 51 test_no_dual_source_blending(reporter); | 51 //test_no_dual_source_blending(reporter); |
| 52 } | 52 } |
| 53 | 53 |
| 54 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
| 55 | 55 |
| 56 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) | 56 #define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__) |
| 57 | 57 |
| 58 enum { | 58 enum { |
| 59 kNone_OutputType, | 59 kNone_OutputType, |
| 60 kCoverage_OutputType, | 60 kCoverage_OutputType, |
| 61 kModulate_OutputType, | 61 kModulate_OutputType, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 72 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag | 72 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 class GrPorterDuffTest { | 75 class GrPorterDuffTest { |
| 76 public: | 76 public: |
| 77 struct XPInfo { | 77 struct XPInfo { |
| 78 XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const Gr
Caps& caps, | 78 XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const Gr
Caps& caps, |
| 79 const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { | 79 const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { |
| 80 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode
)); | 80 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode
)); |
| 81 SkAutoTUnref<GrXferProcessor> xp( | 81 SkAutoTUnref<GrXferProcessor> xp( |
| 82 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps)
); | 82 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps,
nullptr)); |
| 83 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false))
; | 83 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false))
; |
| 84 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); | 84 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); |
| 85 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, c
aps); | 85 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, c
aps); |
| 86 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); | 86 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); |
| 87 xp->getBlendInfo(&fBlendInfo); | 87 xp->getBlendInfo(&fBlendInfo); |
| 88 TEST_ASSERT(!xp->willReadDstColor()); | 88 TEST_ASSERT(!xp->willReadDstColor()); |
| 89 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI
nfo.fDstBlend)); | 89 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI
nfo.fDstBlend)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 GrXPFactory::InvariantBlendedColor fBlendedColor; | 92 GrXPFactory::InvariantBlendedColor fBlendedColor; |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, nullptr, 0); | 1121 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, nullptr, 0); |
| 1122 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, nullptr, 0); | 1122 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, nullptr, 0); |
| 1123 | 1123 |
| 1124 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); | 1124 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |
| 1125 SkASSERT(covPOI.isFourChannelOutput()); | 1125 SkASSERT(covPOI.isFourChannelOutput()); |
| 1126 | 1126 |
| 1127 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); | 1127 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); |
| 1128 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); | 1128 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); |
| 1129 | 1129 |
| 1130 SkAutoTUnref<GrXferProcessor> xp( | 1130 SkAutoTUnref<GrXferProcessor> xp( |
| 1131 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps)); | 1131 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps, nullptr
)); |
| 1132 if (!xp) { | 1132 if (!xp) { |
| 1133 ERRORF(reporter, "Failed to create an XP with LCD coverage."); | 1133 ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 1134 return; | 1134 return; |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 GrXPFactory::InvariantBlendedColor blendedColor; | 1137 GrXPFactory::InvariantBlendedColor blendedColor; |
| 1138 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); | 1138 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); |
| 1139 TEST_ASSERT(blendedColor.fWillBlendWithDst); | 1139 TEST_ASSERT(blendedColor.fWillBlendWithDst); |
| 1140 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); | 1140 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
| 1141 | 1141 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 } else { | 1197 } else { |
| 1198 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), | 1198 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), |
| 1199 kRGBA_GrColorComponentFlags, true); | 1199 kRGBA_GrColorComponentFlags, true); |
| 1200 } | 1200 } |
| 1201 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 1201 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 1202 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 1202 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 1203 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); | 1203 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); |
| 1204 GrXferProcessor::DstTexture* dstTexture = | 1204 GrXferProcessor::DstTexture* dstTexture = |
| 1205 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa
keDstTexture : 0; | 1205 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa
keDstTexture : 0; |
| 1206 SkAutoTUnref<GrXferProcessor> xp( | 1206 SkAutoTUnref<GrXferProcessor> xp( |
| 1207 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture
, caps)); | 1207 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture
, caps, NULL)); |
| 1208 if (!xp) { | 1208 if (!xp) { |
| 1209 ERRORF(reporter, "Failed to create an XP without dual source
blending."); | 1209 ERRORF(reporter, "Failed to create an XP without dual source
blending."); |
| 1210 return; | 1210 return; |
| 1211 } | 1211 } |
| 1212 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1212 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1213 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); | 1213 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); |
| 1214 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1214 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1215 } | 1215 } |
| 1216 } | 1216 } |
| 1217 } | 1217 } |
| 1218 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1218 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
| 1219 } | 1219 } |
| 1220 | 1220 |
| 1221 #endif | 1221 #endif |
| 1222 | 1222 |
| OLD | NEW |