| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 279 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
| 280 break; | 280 break; |
| 281 default: | 281 default: |
| 282 ERRORF(reporter, "Invalid xfermode."); | 282 ERRORF(reporter, "Invalid xfermode."); |
| 283 break; | 283 break; |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 287 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
| 288 GrPipelineOptimizations optimizations; | 288 GrPipelineOptimizations optimizations; |
| 289 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, | 289 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, |
| 290 false); | 290 false); |
| 291 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 291 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
| 292 true); | 292 true); |
| 293 | 293 |
| 294 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 294 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
| 295 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 295 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
| 296 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 296 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
| 297 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 297 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
| 298 | 298 |
| 299 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 299 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 300 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 300 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 301 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 301 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 ERRORF(reporter, "Invalid xfermode."); | 475 ERRORF(reporter, "Invalid xfermode."); |
| 476 break; | 476 break; |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { | 481 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { |
| 482 GrPipelineOptimizations optimizations; | 482 GrPipelineOptimizations optimizations; |
| 483 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), | 483 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), |
| 484 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); | 484 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); |
| 485 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 485 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
| 486 kRGBA_GrColorComponentFlags
, true); | 486 kRGBA_GrColorComponentFlags
, true); |
| 487 | 487 |
| 488 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 488 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
| 489 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 489 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
| 490 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 490 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
| 491 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 491 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
| 492 | 492 |
| 493 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 493 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 494 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 494 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 495 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 495 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 break; | 677 break; |
| 678 default: | 678 default: |
| 679 ERRORF(reporter, "Invalid xfermode."); | 679 ERRORF(reporter, "Invalid xfermode."); |
| 680 break; | 680 break; |
| 681 } | 681 } |
| 682 } | 682 } |
| 683 } | 683 } |
| 684 | 684 |
| 685 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 685 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
| 686 GrPipelineOptimizations optimizations; | 686 GrPipelineOptimizations optimizations; |
| 687 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, | 687 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, |
| 688 kA_GrColorComponentFlag, false
); | 688 kA_GrColorComponentFlag, false
); |
| 689 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 689 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
| 690 true); | 690 true); |
| 691 | 691 |
| 692 SkASSERT(optimizations.fColorPOI.isOpaque()); | 692 SkASSERT(optimizations.fColorPOI.isOpaque()); |
| 693 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 693 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
| 694 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 694 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
| 695 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 695 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
| 696 | 696 |
| 697 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 697 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 698 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 698 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 699 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 699 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 ERRORF(reporter, "Invalid xfermode."); | 878 ERRORF(reporter, "Invalid xfermode."); |
| 879 break; | 879 break; |
| 880 } | 880 } |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 | 883 |
| 884 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { | 884 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { |
| 885 GrPipelineOptimizations optimizations; | 885 GrPipelineOptimizations optimizations; |
| 886 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), | 886 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), |
| 887 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); | 887 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); |
| 888 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 888 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
| 889 kRGBA_GrColorComponentFlags
, true); | 889 kRGBA_GrColorComponentFlags
, true); |
| 890 | 890 |
| 891 SkASSERT(optimizations.fColorPOI.isOpaque()); | 891 SkASSERT(optimizations.fColorPOI.isOpaque()); |
| 892 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 892 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
| 893 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 893 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
| 894 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 894 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
| 895 | 895 |
| 896 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 896 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 897 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 897 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 898 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 898 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
GrCaps& caps) { | 1093 static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
GrCaps& caps) { |
| 1094 class TestLCDCoverageBatch: public GrVertexBatch { | 1094 class TestLCDCoverageBatch: public GrVertexBatch { |
| 1095 public: | 1095 public: |
| 1096 DEFINE_BATCH_CLASS_ID | 1096 DEFINE_BATCH_CLASS_ID |
| 1097 | 1097 |
| 1098 TestLCDCoverageBatch() : INHERITED(ClassID()) {} | 1098 TestLCDCoverageBatch() : INHERITED(ClassID()) {} |
| 1099 | 1099 |
| 1100 private: | 1100 private: |
| 1101 void computePipelineOptimizations(GrInitInvariantOutput* color, | 1101 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 1102 GrInitInvariantOutput* coverage, | 1102 GrInitInvariantOutput* coverage, |
| 1103 GrBatchToXPOverrides* overrides) const
override { | 1103 GrBatchToXPOverrides* overrides) const
override { |
| 1104 color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); | 1104 color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); |
| 1105 coverage->setUnknownFourComponents(); | 1105 coverage->setUnknownFourComponents(); |
| 1106 coverage->setUsingLCDCoverage(); } | 1106 coverage->setUsingLCDCoverage(); } |
| 1107 | 1107 |
| 1108 const char* name() const override { return "Test LCD Text Batch"; } | 1108 const char* name() const override { return "Test LCD Text Batch"; } |
| 1109 void initBatchTracker(const GrXPOverridesForBatch&) override {} | 1109 void initBatchTracker(const GrXPOverridesForBatch&) override {} |
| 1110 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal
se; } | 1110 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal
se; } |
| 1111 void onPrepareDraws(Target*) const override {}; | 1111 void onPrepareDraws(Target*) const override {}; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 }; | 1179 }; |
| 1180 static const GrColorComponentFlags testColorFlags[] = { | 1180 static const GrColorComponentFlags testColorFlags[] = { |
| 1181 kNone_GrColorComponentFlags, | 1181 kNone_GrColorComponentFlags, |
| 1182 kG_GrColorComponentFlag | kA_GrColorComponentFlag, | 1182 kG_GrColorComponentFlag | kA_GrColorComponentFlag, |
| 1183 kRGBA_GrColorComponentFlags | 1183 kRGBA_GrColorComponentFlags |
| 1184 }; | 1184 }; |
| 1185 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); | 1185 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); |
| 1186 | 1186 |
| 1187 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { | 1187 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { |
| 1188 GrPipelineOptimizations optimizations; | 1188 GrPipelineOptimizations optimizations; |
| 1189 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c],
testColorFlags[c], | 1189 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c],
testColorFlags[c], |
| 1190 false); | 1190 false); |
| 1191 for (int f = 0; f <= 1; f++) { | 1191 for (int f = 0; f <= 1; f++) { |
| 1192 if (!f) { | 1192 if (!f) { |
| 1193 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, | 1193 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, |
| 1194 kNone_GrColorCo
mponentFlags, true); | 1194 kNone_GrColorCo
mponentFlags, true); |
| 1195 } else { | 1195 } else { |
| 1196 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrC
olorPackA4(255), | 1196 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrC
olorPackA4(255), |
| 1197 kRGBA_GrColorCo
mponentFlags, true); | 1197 kRGBA_GrColorCo
mponentFlags, true); |
| 1198 } | 1198 } |
| 1199 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 1199 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 1200 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 1200 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 1201 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); | 1201 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); |
| 1202 GrXferProcessor::DstTexture* dstTexture = | 1202 GrXferProcessor::DstTexture* dstTexture = |
| 1203 xpf->willNeedDstTexture(caps, optimizations, false) ? &fakeD
stTexture : 0; | 1203 xpf->willNeedDstTexture(caps, optimizations, false) ? &fakeD
stTexture : 0; |
| 1204 SkAutoTUnref<GrXferProcessor> xp( | 1204 SkAutoTUnref<GrXferProcessor> xp( |
| 1205 xpf->createXferProcessor(optimizations, false, dstTexture, c
aps)); | 1205 xpf->createXferProcessor(optimizations, false, dstTexture, c
aps)); |
| 1206 if (!xp) { | 1206 if (!xp) { |
| 1207 ERRORF(reporter, "Failed to create an XP without dual source
blending."); | 1207 ERRORF(reporter, "Failed to create an XP without dual source
blending."); |
| 1208 return; | 1208 return; |
| 1209 } | 1209 } |
| 1210 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1210 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1211 xp->getOptimizations(optimizations, false, 0, caps); | 1211 xp->getOptimizations(optimizations, false, 0, caps); |
| 1212 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1212 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1213 } | 1213 } |
| 1214 } | 1214 } |
| 1215 } | 1215 } |
| 1216 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1216 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 #endif | 1219 #endif |
| 1220 | |
| OLD | NEW |