Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: tests/GrPorterDuffTest.cpp

Issue 1164973002: Add mixed samples support to XPs (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLXferProcessor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode )); 77 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode ));
78 SkAutoTUnref<GrXferProcessor> xp(xpf->createXferProcessor(colorPOI, covPOI, 0, caps)); 78 SkAutoTUnref<GrXferProcessor> xp(
79 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI)); 79 xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps));
80 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)) ;
80 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); 81 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor);
81 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, 0, caps); 82 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, NULL, caps );
82 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); 83 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType);
83 xp->getBlendInfo(&fBlendInfo); 84 xp->getBlendInfo(&fBlendInfo);
84 TEST_ASSERT(!xp->willReadDstColor()); 85 TEST_ASSERT(!xp->willReadDstColor());
85 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI nfo.fDstBlend)); 86 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI nfo.fDstBlend));
86 } 87 }
87 88
88 GrXPFactory::InvariantBlendedColor fBlendedColor; 89 GrXPFactory::InvariantBlendedColor fBlendedColor;
89 int fOptFlags; 90 int fOptFlags;
90 int fPrimaryOutputType; 91 int fPrimaryOutputType;
91 int fSecondaryOutputType; 92 int fSecondaryOutputType;
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 } testLCDCoverageBatch; 916 } testLCDCoverageBatch;
916 917
917 GrProcOptInfo colorPOI, covPOI; 918 GrProcOptInfo colorPOI, covPOI;
918 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0); 919 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0);
919 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0); 920 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0);
920 921
921 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); 922 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
922 SkASSERT(covPOI.isFourChannelOutput()); 923 SkASSERT(covPOI.isFourChannelOutput());
923 924
924 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc Over_Mode)); 925 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc Over_Mode));
925 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI)); 926 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false));
926 927
927 SkAutoTUnref<GrXferProcessor> xp(xpf->createXferProcessor(colorPOI, covPOI, 0, caps)); 928 SkAutoTUnref<GrXferProcessor> xp(
929 xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps));
928 if (!xp) { 930 if (!xp) {
929 ERRORF(reporter, "Failed to create an XP with LCD coverage."); 931 ERRORF(reporter, "Failed to create an XP with LCD coverage.");
930 return; 932 return;
931 } 933 }
932 934
933 GrXPFactory::InvariantBlendedColor blendedColor; 935 GrXPFactory::InvariantBlendedColor blendedColor;
934 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); 936 xpf->getInvariantBlendedColor(colorPOI, &blendedColor);
935 TEST_ASSERT(blendedColor.fWillBlendWithDst); 937 TEST_ASSERT(blendedColor.fWillBlendWithDst);
936 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); 938 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags);
937 939
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 GrProcOptInfo covPOI; 989 GrProcOptInfo covPOI;
988 if (!f) { 990 if (!f) {
989 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentF lags, true); 991 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentF lags, true);
990 } else { 992 } else {
991 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), 993 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255),
992 kRGBA_GrColorComponentFlags, true); 994 kRGBA_GrColorComponentFlags, true);
993 } 995 }
994 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 996 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
995 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 997 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
996 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer mode)); 998 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer mode));
997 SkAutoTUnref<GrXferProcessor> xp; 999 GrXferProcessor::DstTexture* dstTexture =
998 if (xpf->willNeedDstTexture(caps, colorPOI, covPOI)) { 1000 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa keDstTexture : 0;
999 xp.reset(xpf->createXferProcessor(colorPOI, covPOI, &fakeDst Texture, caps)); 1001 SkAutoTUnref<GrXferProcessor> xp(
1000 } else { 1002 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture , caps));
1001 xp.reset(xpf->createXferProcessor(colorPOI, covPOI, NULL, ca ps));
1002 }
1003 if (!xp) { 1003 if (!xp) {
1004 ERRORF(reporter, "Failed to create an XP without dual source blending."); 1004 ERRORF(reporter, "Failed to create an XP without dual source blending.");
1005 return; 1005 return;
1006 } 1006 }
1007 TEST_ASSERT(!xp->hasSecondaryOutput()); 1007 TEST_ASSERT(!xp->hasSecondaryOutput());
1008 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); 1008 xp->getOptimizations(colorPOI, covPOI, false, 0, caps);
1009 TEST_ASSERT(!xp->hasSecondaryOutput()); 1009 TEST_ASSERT(!xp->hasSecondaryOutput());
1010 } 1010 }
1011 } 1011 }
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 #endif 1015 #endif
1016 1016
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLXferProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698