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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, | 69 kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag, |
70 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, | 70 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
71 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, | 71 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, |
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 GrPipelineOptimizations& optimizations) { |
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(optimizations, false, nullptr, caps)); |
83 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false))
; | 83 TEST_ASSERT(!xpf->willNeedDstTexture(caps, optimizations, false)); |
84 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); | 84 xpf->getInvariantBlendedColor(optimizations.fColorPOI, &fBlendedColo
r); |
85 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, c
aps); | 85 fOptFlags = xp->getOptimizations(optimizations, false, nullptr, caps
); |
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; |
93 int fOptFlags; | 93 int fOptFlags; |
94 int fPrimaryOutputType; | 94 int fPrimaryOutputType; |
95 int fSecondaryOutputType; | 95 int fSecondaryOutputType; |
96 GrXferProcessor::BlendInfo fBlendInfo; | 96 GrXferProcessor::BlendInfo fBlendInfo; |
97 }; | 97 }; |
98 | 98 |
99 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { | 99 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int
* outSecondary) { |
100 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); | 100 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary
); |
101 } | 101 } |
102 }; | 102 }; |
103 | 103 |
104 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ | 104 static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps)
{ |
105 GrProcOptInfo colorPOI, covPOI; | 105 GrPipelineOptimizations opt; |
106 colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, fals
e); | 106 opt.fColorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags,
false); |
107 // Setting 2nd to last value to false and last to true will force covPOI to
LCD coverage. | 107 // Setting 2nd to last value to false and last to true will force covPOI to
LCD coverage. |
108 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false,
true); | 108 opt.fCoveragePOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFla
gs, false, true); |
109 | 109 |
110 SkASSERT(!colorPOI.isOpaque()); | 110 SkASSERT(!opt.fColorPOI.isOpaque()); |
111 SkASSERT(!colorPOI.isSolidWhite()); | 111 SkASSERT(!opt.fColorPOI.isSolidWhite()); |
112 SkASSERT(!covPOI.isSolidWhite()); | 112 SkASSERT(!opt.fCoveragePOI.isSolidWhite()); |
113 SkASSERT(covPOI.isFourChannelOutput()); | 113 SkASSERT(opt.fCoveragePOI.isFourChannelOutput()); |
114 | 114 |
115 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 115 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
116 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 116 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
117 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 117 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt); |
118 | 118 |
119 switch (xfermode) { | 119 switch (xfermode) { |
120 case SkXfermode::kClear_Mode: | 120 case SkXfermode::kClear_Mode: |
121 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 121 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
122 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 122 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
123 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 123 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
124 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); | 124 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
125 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); | 125 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
126 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 126 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
127 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); | 127 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); | 286 TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend); |
287 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 287 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
288 break; | 288 break; |
289 default: | 289 default: |
290 ERRORF(reporter, "Invalid xfermode."); | 290 ERRORF(reporter, "Invalid xfermode."); |
291 break; | 291 break; |
292 } | 292 } |
293 } | 293 } |
294 } | 294 } |
295 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 295 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
296 GrProcOptInfo colorPOI, covPOI; | 296 GrPipelineOptimizations optimizations; |
297 colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, f
alse); | 297 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCo
mponentFlags, |
298 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru
e); | 298 false); |
| 299 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
| 300 true); |
299 | 301 |
300 SkASSERT(!colorPOI.isOpaque()); | 302 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
301 SkASSERT(!colorPOI.isSolidWhite()); | 303 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
302 SkASSERT(!covPOI.isSolidWhite()); | 304 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
303 SkASSERT(!covPOI.isFourChannelOutput()); | 305 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
304 | 306 |
305 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 307 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
306 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 308 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
307 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 309 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
308 | 310 |
309 | 311 |
310 switch (xfermode) { | 312 switch (xfermode) { |
311 case SkXfermode::kClear_Mode: | 313 case SkXfermode::kClear_Mode: |
312 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 314 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
313 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 315 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
314 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 316 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
315 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); | 317 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
316 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); | 318 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
317 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 319 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 480 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
479 break; | 481 break; |
480 default: | 482 default: |
481 ERRORF(reporter, "Invalid xfermode."); | 483 ERRORF(reporter, "Invalid xfermode."); |
482 break; | 484 break; |
483 } | 485 } |
484 } | 486 } |
485 } | 487 } |
486 | 488 |
487 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { | 489 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G
rCaps& caps) { |
488 GrProcOptInfo colorPOI, covPOI; | 490 GrPipelineOptimizations optimizations; |
489 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0), | 491 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(22
9, 0, 154, 0), |
490 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); | 492 kR_GrColorComponentFlag | kB_GrColorComponent
Flag, false); |
491 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorCo
mponentFlags, true); | 493 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
| 494 kRGBA_GrColorComponentFlags
, true); |
492 | 495 |
493 SkASSERT(!colorPOI.isOpaque()); | 496 SkASSERT(!optimizations.fColorPOI.isOpaque()); |
494 SkASSERT(!colorPOI.isSolidWhite()); | 497 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
495 SkASSERT(covPOI.isSolidWhite()); | 498 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
496 SkASSERT(!covPOI.isFourChannelOutput()); | 499 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
497 | 500 |
498 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 501 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
499 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 502 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
500 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 503 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
501 | 504 |
502 switch (xfermode) { | 505 switch (xfermode) { |
503 case SkXfermode::kClear_Mode: | 506 case SkXfermode::kClear_Mode: |
504 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 507 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
505 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 508 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
506 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 509 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
507 TEST_ASSERT((kIgnoreColor_OptFlag | | 510 TEST_ASSERT((kIgnoreColor_OptFlag | |
508 kIgnoreCoverage_OptFlag) == xpi.fOptFlags); | 511 kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
509 TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); | 512 TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
510 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 513 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 684 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
682 break; | 685 break; |
683 default: | 686 default: |
684 ERRORF(reporter, "Invalid xfermode."); | 687 ERRORF(reporter, "Invalid xfermode."); |
685 break; | 688 break; |
686 } | 689 } |
687 } | 690 } |
688 } | 691 } |
689 | 692 |
690 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { | 693 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const
GrCaps& caps) { |
691 GrProcOptInfo colorPOI, covPOI; | 694 GrPipelineOptimizations optimizations; |
692 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kA_GrColorCom
ponentFlag, false); | 695 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255)
, |
693 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru
e); | 696 kA_GrColorComponentFlag, false
); |
| 697 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColo
rComponentFlags, |
| 698 true); |
694 | 699 |
695 SkASSERT(colorPOI.isOpaque()); | 700 SkASSERT(optimizations.fColorPOI.isOpaque()); |
696 SkASSERT(!colorPOI.isSolidWhite()); | 701 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
697 SkASSERT(!covPOI.isSolidWhite()); | 702 SkASSERT(!optimizations.fCoveragePOI.isSolidWhite()); |
698 SkASSERT(!covPOI.isFourChannelOutput()); | 703 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
699 | 704 |
700 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 705 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
701 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 706 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
702 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 707 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
703 | 708 |
704 switch (xfermode) { | 709 switch (xfermode) { |
705 case SkXfermode::kClear_Mode: | 710 case SkXfermode::kClear_Mode: |
706 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 711 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
707 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 712 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
708 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 713 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
709 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); | 714 TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); |
710 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); | 715 TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); |
711 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 716 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
712 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); | 717 TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.f
Equation); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); | 883 TEST_ASSERT(xpi.fBlendInfo.fWriteColor); |
879 break; | 884 break; |
880 default: | 885 default: |
881 ERRORF(reporter, "Invalid xfermode."); | 886 ERRORF(reporter, "Invalid xfermode."); |
882 break; | 887 break; |
883 } | 888 } |
884 } | 889 } |
885 } | 890 } |
886 | 891 |
887 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { | 892 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr
Caps& caps) { |
888 GrProcOptInfo colorPOI, covPOI; | 893 GrPipelineOptimizations optimizations; |
889 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255), | 894 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0,
82, 0, 255), |
890 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); | 895 kG_GrColorComponentFlag | kA_GrColorComponent
Flag, false); |
891 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorCo
mponentFlags, true); | 896 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(2
55), |
| 897 kRGBA_GrColorComponentFlags
, true); |
892 | 898 |
893 SkASSERT(colorPOI.isOpaque()); | 899 SkASSERT(optimizations.fColorPOI.isOpaque()); |
894 SkASSERT(!colorPOI.isSolidWhite()); | 900 SkASSERT(!optimizations.fColorPOI.isSolidWhite()); |
895 SkASSERT(covPOI.isSolidWhite()); | 901 SkASSERT(optimizations.fCoveragePOI.isSolidWhite()); |
896 SkASSERT(!covPOI.isFourChannelOutput()); | 902 SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput()); |
897 | 903 |
898 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 904 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
899 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 905 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
900 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c
ovPOI); | 906 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizatio
ns); |
901 | 907 |
902 switch (xfermode) { | 908 switch (xfermode) { |
903 case SkXfermode::kClear_Mode: | 909 case SkXfermode::kClear_Mode: |
904 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); | 910 TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); |
905 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); | 911 TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); |
906 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); | 912 TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKn
ownColorFlags); |
907 TEST_ASSERT((kIgnoreColor_OptFlag | | 913 TEST_ASSERT((kIgnoreColor_OptFlag | |
908 kIgnoreCoverage_OptFlag) == xpi.fOptFlags); | 914 kIgnoreCoverage_OptFlag) == xpi.fOptFlags); |
909 TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); | 915 TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); |
910 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); | 916 TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 | 1125 |
1120 GrPipelineOptimizations opts; | 1126 GrPipelineOptimizations opts; |
1121 testLCDCoverageBatch.getPipelineOptimizations(&opts); | 1127 testLCDCoverageBatch.getPipelineOptimizations(&opts); |
1122 GrProcOptInfo colorPOI = opts.fColorPOI; | 1128 GrProcOptInfo colorPOI = opts.fColorPOI; |
1123 GrProcOptInfo covPOI = opts.fCoveragePOI; | 1129 GrProcOptInfo covPOI = opts.fCoveragePOI; |
1124 | 1130 |
1125 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); | 1131 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |
1126 SkASSERT(covPOI.isFourChannelOutput()); | 1132 SkASSERT(covPOI.isFourChannelOutput()); |
1127 | 1133 |
1128 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); | 1134 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); |
1129 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); | 1135 TEST_ASSERT(!xpf->willNeedDstTexture(caps, opts, false)); |
1130 | 1136 |
1131 SkAutoTUnref<GrXferProcessor> xp( | 1137 SkAutoTUnref<GrXferProcessor> xp( |
1132 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps)); | 1138 xpf->createXferProcessor(opts, false, nullptr, caps)); |
1133 if (!xp) { | 1139 if (!xp) { |
1134 ERRORF(reporter, "Failed to create an XP with LCD coverage."); | 1140 ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
1135 return; | 1141 return; |
1136 } | 1142 } |
1137 | 1143 |
1138 GrXPFactory::InvariantBlendedColor blendedColor; | 1144 GrXPFactory::InvariantBlendedColor blendedColor; |
1139 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); | 1145 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); |
1140 TEST_ASSERT(blendedColor.fWillBlendWithDst); | 1146 TEST_ASSERT(blendedColor.fWillBlendWithDst); |
1141 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); | 1147 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
1142 | 1148 |
1143 GrColor overrideColor; | 1149 GrColor overrideColor; |
1144 xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps); | 1150 xp->getOptimizations(opts, false, &overrideColor, caps); |
1145 | 1151 |
1146 GrXferProcessor::BlendInfo blendInfo; | 1152 GrXferProcessor::BlendInfo blendInfo; |
1147 xp->getBlendInfo(&blendInfo); | 1153 xp->getBlendInfo(&blendInfo); |
1148 TEST_ASSERT(blendInfo.fWriteColor); | 1154 TEST_ASSERT(blendInfo.fWriteColor); |
1149 } | 1155 } |
1150 | 1156 |
1151 static void test_no_dual_source_blending(skiatest::Reporter* reporter) { | 1157 static void test_no_dual_source_blending(skiatest::Reporter* reporter) { |
1152 GrContextOptions opts; | 1158 GrContextOptions opts; |
1153 opts.fSuppressDualSourceBlending = true; | 1159 opts.fSuppressDualSourceBlending = true; |
1154 GrContextFactory factory(opts); | 1160 GrContextFactory factory(opts); |
(...skipping 27 matching lines...) Expand all Loading... |
1182 GrColorPackA4(255) | 1188 GrColorPackA4(255) |
1183 }; | 1189 }; |
1184 static const GrColorComponentFlags testColorFlags[] = { | 1190 static const GrColorComponentFlags testColorFlags[] = { |
1185 kNone_GrColorComponentFlags, | 1191 kNone_GrColorComponentFlags, |
1186 kG_GrColorComponentFlag | kA_GrColorComponentFlag, | 1192 kG_GrColorComponentFlag | kA_GrColorComponentFlag, |
1187 kRGBA_GrColorComponentFlags | 1193 kRGBA_GrColorComponentFlags |
1188 }; | 1194 }; |
1189 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); | 1195 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags
)); |
1190 | 1196 |
1191 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { | 1197 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { |
1192 GrProcOptInfo colorPOI; | 1198 GrPipelineOptimizations optimizations; |
1193 colorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags
[c], false); | 1199 optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c],
testColorFlags[c], |
| 1200 false); |
1194 for (int f = 0; f <= 1; f++) { | 1201 for (int f = 0; f <= 1; f++) { |
1195 GrProcOptInfo covPOI; | |
1196 if (!f) { | 1202 if (!f) { |
1197 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCompone
ntFlags, true); | 1203 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, |
| 1204 kNone_GrColorCo
mponentFlags, true); |
1198 } else { | 1205 } else { |
1199 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), | 1206 optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrC
olorPackA4(255), |
1200 kRGBA_GrColorComponentFlags, true); | 1207 kRGBA_GrColorCo
mponentFlags, true); |
1201 } | 1208 } |
1202 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 1209 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
1203 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 1210 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
1204 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); | 1211 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); |
1205 GrXferProcessor::DstTexture* dstTexture = | 1212 GrXferProcessor::DstTexture* dstTexture = |
1206 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa
keDstTexture : 0; | 1213 xpf->willNeedDstTexture(caps, optimizations, false) ? &fakeD
stTexture : 0; |
1207 SkAutoTUnref<GrXferProcessor> xp( | 1214 SkAutoTUnref<GrXferProcessor> xp( |
1208 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture
, caps)); | 1215 xpf->createXferProcessor(optimizations, false, dstTexture, c
aps)); |
1209 if (!xp) { | 1216 if (!xp) { |
1210 ERRORF(reporter, "Failed to create an XP without dual source
blending."); | 1217 ERRORF(reporter, "Failed to create an XP without dual source
blending."); |
1211 return; | 1218 return; |
1212 } | 1219 } |
1213 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1220 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1214 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); | 1221 xp->getOptimizations(optimizations, false, 0, caps); |
1215 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1222 TEST_ASSERT(!xp->hasSecondaryOutput()); |
1216 } | 1223 } |
1217 } | 1224 } |
1218 } | 1225 } |
1219 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); | 1226 ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex); |
1220 } | 1227 } |
1221 | 1228 |
1222 #endif | 1229 #endif |
1223 | 1230 |
OLD | NEW |