| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, | 67 kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag, |
| 68 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, | 68 kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag
, |
| 69 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag | 69 kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCovera
ge_OptFlag |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 class GrPorterDuffTest { | 72 class GrPorterDuffTest { |
| 73 public: | 73 public: |
| 74 struct XPInfo { | 74 struct XPInfo { |
| 75 XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const Gr
Caps& caps, | 75 XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const Gr
Caps& caps, |
| 76 const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { | 76 const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) { |
| 77 GrPipelineBuilder builder; |
| 77 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode
)); | 78 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode
)); |
| 78 SkAutoTUnref<GrXferProcessor> xp(xpf->createXferProcessor(colorPOI,
covPOI, 0, caps)); | 79 SkAutoTUnref<GrXferProcessor> xp( |
| 79 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI)); | 80 xpf->createXferProcessor(builder, colorPOI, covPOI, NULL, caps))
; |
| 81 TEST_ASSERT(!xpf->willNeedDstTexture(caps, builder, colorPOI, covPOI
)); |
| 80 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); | 82 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); |
| 81 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, 0, caps); | 83 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, NULL, caps
); |
| 82 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); | 84 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); |
| 83 xp->getBlendInfo(&fBlendInfo); | 85 xp->getBlendInfo(&fBlendInfo); |
| 84 TEST_ASSERT(!xp->willReadDstColor()); | 86 TEST_ASSERT(!xp->willReadDstColor()); |
| 85 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI
nfo.fDstBlend)); | 87 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI
nfo.fDstBlend)); |
| 86 } | 88 } |
| 87 | 89 |
| 88 GrXPFactory::InvariantBlendedColor fBlendedColor; | 90 GrXPFactory::InvariantBlendedColor fBlendedColor; |
| 89 int fOptFlags; | 91 int fOptFlags; |
| 90 int fPrimaryOutputType; | 92 int fPrimaryOutputType; |
| 91 int fSecondaryOutputType; | 93 int fSecondaryOutputType; |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 out->setUsingLCDCoverage(); | 909 out->setUsingLCDCoverage(); |
| 908 } | 910 } |
| 909 | 911 |
| 910 const char* name() const override { return "Test LCD Text Batch"; } | 912 const char* name() const override { return "Test LCD Text Batch"; } |
| 911 void initBatchTracker(const GrPipelineInfo&) override {} | 913 void initBatchTracker(const GrPipelineInfo&) override {} |
| 912 bool onCombineIfPossible(GrBatch*) override { return false; } | 914 bool onCombineIfPossible(GrBatch*) override { return false; } |
| 913 void generateGeometry(GrBatchTarget*, const GrPipeline*) override {} | 915 void generateGeometry(GrBatchTarget*, const GrPipeline*) override {} |
| 914 | 916 |
| 915 } testLCDCoverageBatch; | 917 } testLCDCoverageBatch; |
| 916 | 918 |
| 919 GrPipelineBuilder builder; |
| 920 |
| 917 GrProcOptInfo colorPOI, covPOI; | 921 GrProcOptInfo colorPOI, covPOI; |
| 918 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0); | 922 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0); |
| 919 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0); | 923 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0); |
| 920 | 924 |
| 921 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); | 925 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |
| 922 SkASSERT(covPOI.isFourChannelOutput()); | 926 SkASSERT(covPOI.isFourChannelOutput()); |
| 923 | 927 |
| 924 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); | 928 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc
Over_Mode)); |
| 925 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI)); | 929 TEST_ASSERT(!xpf->willNeedDstTexture(caps, builder, colorPOI, covPOI)); |
| 926 | 930 |
| 927 SkAutoTUnref<GrXferProcessor> xp(xpf->createXferProcessor(colorPOI, covPOI,
0, caps)); | 931 SkAutoTUnref<GrXferProcessor> xp( |
| 932 xpf->createXferProcessor(builder, colorPOI, covPOI, NULL, caps)); |
| 928 if (!xp) { | 933 if (!xp) { |
| 929 ERRORF(reporter, "Failed to create an XP with LCD coverage."); | 934 ERRORF(reporter, "Failed to create an XP with LCD coverage."); |
| 930 return; | 935 return; |
| 931 } | 936 } |
| 932 | 937 |
| 933 GrXPFactory::InvariantBlendedColor blendedColor; | 938 GrXPFactory::InvariantBlendedColor blendedColor; |
| 934 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); | 939 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); |
| 935 TEST_ASSERT(blendedColor.fWillBlendWithDst); | 940 TEST_ASSERT(blendedColor.fWillBlendWithDst); |
| 936 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); | 941 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); |
| 937 | 942 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 for (int f = 0; f <= 1; f++) { | 991 for (int f = 0; f <= 1; f++) { |
| 987 GrProcOptInfo covPOI; | 992 GrProcOptInfo covPOI; |
| 988 if (!f) { | 993 if (!f) { |
| 989 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentF
lags, true); | 994 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentF
lags, true); |
| 990 } else { | 995 } else { |
| 991 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), | 996 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), |
| 992 kRGBA_GrColorComponentFlags, true); | 997 kRGBA_GrColorComponentFlags, true); |
| 993 } | 998 } |
| 994 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { | 999 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { |
| 995 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); | 1000 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); |
| 1001 GrPipelineBuilder builder; |
| 996 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); | 1002 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer
mode)); |
| 997 SkAutoTUnref<GrXferProcessor> xp; | 1003 GrXferProcessor::DstTexture* dstTexture = |
| 998 if (xpf->willNeedDstTexture(caps, colorPOI, covPOI)) { | 1004 xpf->willNeedDstTexture(caps, builder, colorPOI, covPOI) ? &
fakeDstTexture : 0; |
| 999 xp.reset(xpf->createXferProcessor(colorPOI, covPOI, &fakeDst
Texture, caps)); | 1005 SkAutoTUnref<GrXferProcessor> xp( |
| 1000 } else { | 1006 xpf->createXferProcessor(builder, colorPOI, covPOI, dstTextu
re, caps)); |
| 1001 xp.reset(xpf->createXferProcessor(colorPOI, covPOI, NULL, ca
ps)); | |
| 1002 } | |
| 1003 if (!xp) { | 1007 if (!xp) { |
| 1004 ERRORF(reporter, "Failed to create an XP without dual source
blending."); | 1008 ERRORF(reporter, "Failed to create an XP without dual source
blending."); |
| 1005 return; | 1009 return; |
| 1006 } | 1010 } |
| 1007 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1011 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1008 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); | 1012 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); |
| 1009 TEST_ASSERT(!xp->hasSecondaryOutput()); | 1013 TEST_ASSERT(!xp->hasSecondaryOutput()); |
| 1010 } | 1014 } |
| 1011 } | 1015 } |
| 1012 } | 1016 } |
| 1013 } | 1017 } |
| 1014 | 1018 |
| 1015 #endif | 1019 #endif |
| 1016 | 1020 |
| OLD | NEW |