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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { | 91 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { |
92 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); | 92 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); |
93 } | 93 } |
94 }; | 94 }; |
95 | 95 |
96 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ | 96 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ |
97 GrPipelineOptimizations opt; | 97 GrPipelineOptimizations opt; |
98 opt.fColorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags,
false); | 98 opt.fColorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags,
false); |
99 // Setting 2nd to last value to false and last to true will force covPOI to
LCD coverage. | 99 // Setting 2nd to last value to false and last to true will force covPOI to
LCD coverage. |
100 opt.fCoveragePOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFla
gs, false, true); | 100 opt.fCoveragePOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFla
gs, false, true); |
| 101 opt.fOverrides.fUsePLSDstRead = false; |
101 | 102 |
102 SkASSERT(!opt.fColorPOI.isOpaque()); | 103 SkASSERT(!opt.fColorPOI.isOpaque()); |
103 SkASSERT(!opt.fColorPOI.isSolidWhite()); | 104 SkASSERT(!opt.fColorPOI.isSolidWhite()); |
104 SkASSERT(!opt.fCoveragePOI.isSolidWhite()); | 105 SkASSERT(!opt.fCoveragePOI.isSolidWhite()); |
105 SkASSERT(opt.fCoveragePOI.isFourChannelOutput()); | 106 SkASSERT(opt.fCoveragePOI.isFourChannelOutput()); |
106 | 107 |
107 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 108 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
108 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 109 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
109 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt); | 110 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt); |
110 | 111 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 break; | 284 break; |
284 } | 285 } |
285 } | 286 } |
286 } | 287 } |
287 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 288 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
288 GrPipelineOptimizations optimizations; | 289 GrPipelineOptimizations optimizations; |
289 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, | 290 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, |
290 false); | 291 false); |
291 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 292 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
292 true); | 293 true); |
| 294 optimizations.fOverrides.fUsePLSDstRead = false; |
293 | 295 |
294 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 296 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
295 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 297 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
296 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 298 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
297 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 299 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
298 | 300 |
299 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 301 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
300 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 302 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
301 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 303 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
302 | 304 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 } | 479 } |
478 } | 480 } |
479 } | 481 } |
480 | 482 |
481 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { | 483 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { |
482 GrPipelineOptimizations optimizations; | 484 GrPipelineOptimizations optimizations; |
483 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), | 485 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), |
484 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); | 486 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); |
485 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 487 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
486 kRGBA_GrColorComponentFlags
, true); | 488 kRGBA_GrColorComponentFlags
, true); |
| 489 optimizations.fOverrides.fUsePLSDstRead = false; |
487 | 490 |
488 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 491 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
489 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 492 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
490 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 493 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
491 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 494 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
492 | 495 |
493 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 496 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
494 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 497 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
495 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 498 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
496 | 499 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 } | 684 } |
682 } | 685 } |
683 } | 686 } |
684 | 687 |
685 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 688 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
686 GrPipelineOptimizations optimizations; | 689 GrPipelineOptimizations optimizations; |
687 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, | 690 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, |
688 kA_GrColorComponentFlag, false
); | 691 kA_GrColorComponentFlag, false
); |
689 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 692 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
690 true); | 693 true); |
| 694 optimizations.fOverrides.fUsePLSDstRead = false; |
691 | 695 |
692 SkASSERT(optimizations.fColorPOI.isOpaque()); | 696 SkASSERT(optimizations.fColorPOI.isOpaque()); |
693 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 697 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
694 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 698 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
695 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 699 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
696 | 700 |
697 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 701 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
698 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 702 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
699 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 703 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
700 | 704 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 } | 884 } |
881 } | 885 } |
882 } | 886 } |
883 | 887 |
884 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { | 888 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { |
885 GrPipelineOptimizations optimizations; | 889 GrPipelineOptimizations optimizations; |
886 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), | 890 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), |
887 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); | 891 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); |
888 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 892 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
889 kRGBA_GrColorComponentFlags
, true); | 893 kRGBA_GrColorComponentFlags
, true); |
| 894 optimizations.fOverrides.fUsePLSDstRead = false; |
890 | 895 |
891 SkASSERT(optimizations.fColorPOI.isOpaque()); | 896 SkASSERT(optimizations.fColorPOI.isOpaque()); |
892 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 897 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
893 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 898 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
894 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 899 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
895 | 900 |
896 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 901 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
897 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 902 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
898 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 903 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
899 | 904 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 DEFINE_BATCH_CLASS_ID | 1101 DEFINE_BATCH_CLASS_ID |
1097 | 1102 |
1098 TestLCDCoverageBatch() : INHERITED(ClassID()) {} | 1103 TestLCDCoverageBatch() : INHERITED(ClassID()) {} |
1099 | 1104 |
1100 private: | 1105 private: |
1101 void computePipelineOptimizations(GrInitInvariantOutput* color, | 1106 void computePipelineOptimizations(GrInitInvariantOutput* color, |
1102 GrInitInvariantOutput* coverage, | 1107 GrInitInvariantOutput* coverage, |
1103 GrBatchToXPOverrides* overrides) const
override { | 1108 GrBatchToXPOverrides* overrides) const
override { |
1104 color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); | 1109 color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221)); |
1105 coverage->setUnknownFourComponents(); | 1110 coverage->setUnknownFourComponents(); |
1106 coverage->setUsingLCDCoverage(); | 1111 coverage->setUsingLCDCoverage(); } |
1107 overrides->fUsePLSDstRead = false; | |
1108 } | |
1109 | 1112 |
1110 const char* name() const override { return "Test LCD Text Batch"; } | 1113 const char* name() const override { return "Test LCD Text Batch"; } |
1111 void initBatchTracker(const GrXPOverridesForBatch&) override {} | 1114 void initBatchTracker(const GrXPOverridesForBatch&) override {} |
1112 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal
se; } | 1115 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal
se; } |
1113 void onPrepareDraws(Target*) const override {}; | 1116 void onPrepareDraws(Target*) const override {}; |
1114 | 1117 |
1115 typedef GrVertexBatch INHERITED; | 1118 typedef GrVertexBatch INHERITED; |
1116 } testLCDCoverageBatch; | 1119 } testLCDCoverageBatch; |
1117 | 1120 |
1118 GrPipelineOptimizations opts; | 1121 GrPipelineOptimizations opts; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 xp->getOptimizations(optimizations, false, 0, caps); | 1216 xp->getOptimizations(optimizations, false, 0, caps); |
1214 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1217 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1215 } | 1218 } |
1216 } | 1219 } |
1217 } | 1220 } |
1218 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1221 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
1219 } | 1222 } |
1220 | 1223 |
1221 #endif | 1224 #endif |
1222 | 1225 |
OLD | NEW |