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; | |
102 | 101 |
103 SkASSERT(!opt.fColorPOI.isOpaque()); | 102 SkASSERT(!opt.fColorPOI.isOpaque()); |
104 SkASSERT(!opt.fColorPOI.isSolidWhite()); | 103 SkASSERT(!opt.fColorPOI.isSolidWhite()); |
105 SkASSERT(!opt.fCoveragePOI.isSolidWhite()); | 104 SkASSERT(!opt.fCoveragePOI.isSolidWhite()); |
106 SkASSERT(opt.fCoveragePOI.isFourChannelOutput()); | 105 SkASSERT(opt.fCoveragePOI.isFourChannelOutput()); |
107 | 106 |
108 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 107 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
109 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 108 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
110 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt); | 109 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt); |
111 | 110 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 break; | 283 break; |
285 } | 284 } |
286 } | 285 } |
287 } | 286 } |
288 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) { |
289 GrPipelineOptimizations optimizations; | 288 GrPipelineOptimizations optimizations; |
290 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, | 289 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, |
291 false); | 290 false); |
292 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 291 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
293 true); | 292 true); |
294 optimizations.fOverrides.fUsePLSDstRead = false; | |
295 | 293 |
296 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 294 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
297 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 295 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
298 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 296 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
299 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 297 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
300 | 298 |
301 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 299 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
302 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 300 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
303 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 301 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
304 | 302 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 477 } |
480 } | 478 } |
481 } | 479 } |
482 | 480 |
483 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) { |
484 GrPipelineOptimizations optimizations; | 482 GrPipelineOptimizations optimizations; |
485 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), | 483 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), |
486 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); | 484 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); |
487 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 485 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
488 kRGBA_GrColorComponentFlags
, true); | 486 kRGBA_GrColorComponentFlags
, true); |
489 optimizations.fOverrides.fUsePLSDstRead = false; | |
490 | 487 |
491 SkASSERT(!optimizations.fColorPOI.isOpaque()); | 488 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
492 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 489 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
493 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 490 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
494 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 491 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
495 | 492 |
496 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 493 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
497 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 494 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
498 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 495 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
499 | 496 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 681 } |
685 } | 682 } |
686 } | 683 } |
687 | 684 |
688 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) { |
689 GrPipelineOptimizations optimizations; | 686 GrPipelineOptimizations optimizations; |
690 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, | 687 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, |
691 kA_GrColorComponentFlag, false
); | 688 kA_GrColorComponentFlag, false
); |
692 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, | 689 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
693 true); | 690 true); |
694 optimizations.fOverrides.fUsePLSDstRead = false; | |
695 | 691 |
696 SkASSERT(optimizations.fColorPOI.isOpaque()); | 692 SkASSERT(optimizations.fColorPOI.isOpaque()); |
697 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 693 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
698 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); | 694 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
699 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 695 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
700 | 696 |
701 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 697 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
702 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 698 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
703 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 699 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
704 | 700 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 } | 880 } |
885 } | 881 } |
886 } | 882 } |
887 | 883 |
888 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) { |
889 GrPipelineOptimizations optimizations; | 885 GrPipelineOptimizations optimizations; |
890 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), | 886 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), |
891 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); | 887 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); |
892 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), | 888 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
893 kRGBA_GrColorComponentFlags
, true); | 889 kRGBA_GrColorComponentFlags
, true); |
894 optimizations.fOverrides.fUsePLSDstRead = false; | |
895 | 890 |
896 SkASSERT(optimizations.fColorPOI.isOpaque()); | 891 SkASSERT(optimizations.fColorPOI.isOpaque()); |
897 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); | 892 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
898 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); | 893 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
899 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); | 894 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
900 | 895 |
901 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 896 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
902 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 897 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
903 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); | 898 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
904 | 899 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 kNone_GrColorComponentFlags, | 1181 kNone_GrColorComponentFlags, |
1187 kG_GrColorComponentFlag | kA_GrColorComponentFlag, | 1182 kG_GrColorComponentFlag | kA_GrColorComponentFlag, |
1188 kRGBA_GrColorComponentFlags | 1183 kRGBA_GrColorComponentFlags |
1189 }; | 1184 }; |
1190 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); | 1185 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); |
1191 | 1186 |
1192 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { | 1187 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { |
1193 GrPipelineOptimizations optimizations; | 1188 GrPipelineOptimizations optimizations; |
1194 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c],
testColorFlags[c], | 1189 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c],
testColorFlags[c], |
1195 false); | 1190 false); |
1196 optimizations.fOverrides.fUsePLSDstRead = false; | |
1197 for (int f = 0; f <= 1; f++) { | 1191 for (int f = 0; f <= 1; f++) { |
1198 if (!f) { | 1192 if (!f) { |
1199 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, | 1193 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, |
1200 kNone_GrColorCo
mponentFlags, true); | 1194 kNone_GrColorCo
mponentFlags, true); |
1201 } else { | 1195 } else { |
1202 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrC
olorPackA4(255), | 1196 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrC
olorPackA4(255), |
1203 kRGBA_GrColorCo
mponentFlags, true); | 1197 kRGBA_GrColorCo
mponentFlags, true); |
1204 } | 1198 } |
1205 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 1199 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
1206 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 1200 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
(...skipping 10 matching lines...) Expand all Loading... |
1217 xp->getOptimizations(optimizations, false, 0, caps); | 1211 xp->getOptimizations(optimizations, false, 0, caps); |
1218 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1212 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1219 } | 1213 } |
1220 } | 1214 } |
1221 } | 1215 } |
1222 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1216 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
1223 } | 1217 } |
1224 | 1218 |
1225 #endif | 1219 #endif |
1226 | 1220 |
OLD | NEW |