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

Side by Side Diff: tests/GrPorterDuffTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « tests/GrMemoryPoolTest.cpp ('k') | tests/GrSurfaceTest.cpp » ('j') | 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 78 SkAutoTUnref<GrXferProcessor> xp(
79 xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps)); 79 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps) );
80 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)) ; 80 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)) ;
81 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor); 81 xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor);
82 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, NULL, caps ); 82 fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, c aps);
83 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType); 83 GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType);
84 xp->getBlendInfo(&fBlendInfo); 84 xp->getBlendInfo(&fBlendInfo);
85 TEST_ASSERT(!xp->willReadDstColor()); 85 TEST_ASSERT(!xp->willReadDstColor());
86 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI nfo.fDstBlend)); 86 TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendI nfo.fDstBlend));
87 } 87 }
88 88
89 GrXPFactory::InvariantBlendedColor fBlendedColor; 89 GrXPFactory::InvariantBlendedColor fBlendedColor;
90 int fOptFlags; 90 int fOptFlags;
91 int fPrimaryOutputType; 91 int fPrimaryOutputType;
92 int fSecondaryOutputType; 92 int fSecondaryOutputType;
93 GrXferProcessor::BlendInfo fBlendInfo; 93 GrXferProcessor::BlendInfo fBlendInfo;
94 }; 94 };
95 95
96 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int * outSecondary) { 96 static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int * outSecondary) {
97 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary ); 97 GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary );
98 } 98 }
99 }; 99 };
100 100
101 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { 101 static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
102 GrProcOptInfo colorPOI, covPOI; 102 GrProcOptInfo colorPOI, covPOI;
103 colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, fals e); 103 colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, f alse);
104 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, true); 104 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru e);
105 105
106 SkASSERT(!colorPOI.isOpaque()); 106 SkASSERT(!colorPOI.isOpaque());
107 SkASSERT(!colorPOI.isSolidWhite()); 107 SkASSERT(!colorPOI.isSolidWhite());
108 SkASSERT(!covPOI.isSolidWhite()); 108 SkASSERT(!covPOI.isSolidWhite());
109 SkASSERT(!covPOI.isFourChannelOutput()); 109 SkASSERT(!covPOI.isFourChannelOutput());
110 110
111 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 111 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
112 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 112 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
113 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI); 113 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI);
114 114
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 break; 284 break;
285 default: 285 default:
286 ERRORF(reporter, "Invalid xfermode."); 286 ERRORF(reporter, "Invalid xfermode.");
287 break; 287 break;
288 } 288 }
289 } 289 }
290 } 290 }
291 291
292 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G rCaps& caps) { 292 static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G rCaps& caps) {
293 GrProcOptInfo colorPOI, covPOI; 293 GrProcOptInfo colorPOI, covPOI;
294 colorPOI.calcWithInitialValues(NULL, 0, GrColorPackRGBA(229, 0, 154, 0), 294 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0),
295 kR_GrColorComponentFlag | kB_GrColorComponent Flag, false); 295 kR_GrColorComponentFlag | kB_GrColorComponent Flag, false);
296 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kRGBA_GrColorCompo nentFlags, true); 296 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorCo mponentFlags, true);
297 297
298 SkASSERT(!colorPOI.isOpaque()); 298 SkASSERT(!colorPOI.isOpaque());
299 SkASSERT(!colorPOI.isSolidWhite()); 299 SkASSERT(!colorPOI.isSolidWhite());
300 SkASSERT(covPOI.isSolidWhite()); 300 SkASSERT(covPOI.isSolidWhite());
301 SkASSERT(!covPOI.isFourChannelOutput()); 301 SkASSERT(!covPOI.isFourChannelOutput());
302 302
303 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 303 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
304 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 304 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
305 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI); 305 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI);
306 306
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 break; 487 break;
488 default: 488 default:
489 ERRORF(reporter, "Invalid xfermode."); 489 ERRORF(reporter, "Invalid xfermode.");
490 break; 490 break;
491 } 491 }
492 } 492 }
493 } 493 }
494 494
495 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { 495 static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
496 GrProcOptInfo colorPOI, covPOI; 496 GrProcOptInfo colorPOI, covPOI;
497 colorPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kA_GrColorCompon entFlag, false); 497 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kA_GrColorCom ponentFlag, false);
498 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, true); 498 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, tru e);
499 499
500 SkASSERT(colorPOI.isOpaque()); 500 SkASSERT(colorPOI.isOpaque());
501 SkASSERT(!colorPOI.isSolidWhite()); 501 SkASSERT(!colorPOI.isSolidWhite());
502 SkASSERT(!covPOI.isSolidWhite()); 502 SkASSERT(!covPOI.isSolidWhite());
503 SkASSERT(!covPOI.isFourChannelOutput()); 503 SkASSERT(!covPOI.isFourChannelOutput());
504 504
505 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 505 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
506 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 506 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
507 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI); 507 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI);
508 508
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 break; 684 break;
685 default: 685 default:
686 ERRORF(reporter, "Invalid xfermode."); 686 ERRORF(reporter, "Invalid xfermode.");
687 break; 687 break;
688 } 688 }
689 } 689 }
690 } 690 }
691 691
692 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr Caps& caps) { 692 static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr Caps& caps) {
693 GrProcOptInfo colorPOI, covPOI; 693 GrProcOptInfo colorPOI, covPOI;
694 colorPOI.calcWithInitialValues(NULL, 0, GrColorPackRGBA(0, 82, 0, 255), 694 colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255),
695 kG_GrColorComponentFlag | kA_GrColorComponent Flag, false); 695 kG_GrColorComponentFlag | kA_GrColorComponent Flag, false);
696 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), kRGBA_GrColorCompo nentFlags, true); 696 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorCo mponentFlags, true);
697 697
698 SkASSERT(colorPOI.isOpaque()); 698 SkASSERT(colorPOI.isOpaque());
699 SkASSERT(!colorPOI.isSolidWhite()); 699 SkASSERT(!colorPOI.isSolidWhite());
700 SkASSERT(covPOI.isSolidWhite()); 700 SkASSERT(covPOI.isSolidWhite());
701 SkASSERT(!covPOI.isFourChannelOutput()); 701 SkASSERT(!covPOI.isFourChannelOutput());
702 702
703 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 703 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
704 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 704 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
705 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI); 705 const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, c ovPOI);
706 706
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 } 909 }
910 910
911 const char* name() const override { return "Test LCD Text Batch"; } 911 const char* name() const override { return "Test LCD Text Batch"; }
912 void initBatchTracker(const GrPipelineOptimizations&) override {} 912 void initBatchTracker(const GrPipelineOptimizations&) override {}
913 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal se; } 913 bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return fal se; }
914 void onPrepareDraws(Target*) override {}; 914 void onPrepareDraws(Target*) override {};
915 915
916 } testLCDCoverageBatch; 916 } testLCDCoverageBatch;
917 917
918 GrProcOptInfo colorPOI, covPOI; 918 GrProcOptInfo colorPOI, covPOI;
919 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, NULL, 0); 919 colorPOI.calcColorWithBatch(&testLCDCoverageBatch, nullptr, 0);
920 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, NULL, 0); 920 covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, nullptr, 0);
921 921
922 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); 922 SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
923 SkASSERT(covPOI.isFourChannelOutput()); 923 SkASSERT(covPOI.isFourChannelOutput());
924 924
925 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc Over_Mode)); 925 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrc Over_Mode));
926 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false)); 926 TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false));
927 927
928 SkAutoTUnref<GrXferProcessor> xp( 928 SkAutoTUnref<GrXferProcessor> xp(
929 xpf->createXferProcessor(colorPOI, covPOI, false, NULL, caps)); 929 xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps));
930 if (!xp) { 930 if (!xp) {
931 ERRORF(reporter, "Failed to create an XP with LCD coverage."); 931 ERRORF(reporter, "Failed to create an XP with LCD coverage.");
932 return; 932 return;
933 } 933 }
934 934
935 GrXPFactory::InvariantBlendedColor blendedColor; 935 GrXPFactory::InvariantBlendedColor blendedColor;
936 xpf->getInvariantBlendedColor(colorPOI, &blendedColor); 936 xpf->getInvariantBlendedColor(colorPOI, &blendedColor);
937 TEST_ASSERT(blendedColor.fWillBlendWithDst); 937 TEST_ASSERT(blendedColor.fWillBlendWithDst);
938 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); 938 TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags);
939 939
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 }; 978 };
979 static const GrColorComponentFlags testColorFlags[] = { 979 static const GrColorComponentFlags testColorFlags[] = {
980 kNone_GrColorComponentFlags, 980 kNone_GrColorComponentFlags,
981 kG_GrColorComponentFlag | kA_GrColorComponentFlag, 981 kG_GrColorComponentFlag | kA_GrColorComponentFlag,
982 kRGBA_GrColorComponentFlags 982 kRGBA_GrColorComponentFlags
983 }; 983 };
984 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags )); 984 GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags ));
985 985
986 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) { 986 for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) {
987 GrProcOptInfo colorPOI; 987 GrProcOptInfo colorPOI;
988 colorPOI.calcWithInitialValues(NULL, 0, testColors[c], testColorFlags[c] , false); 988 colorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags [c], false);
989 for (int f = 0; f <= 1; f++) { 989 for (int f = 0; f <= 1; f++) {
990 GrProcOptInfo covPOI; 990 GrProcOptInfo covPOI;
991 if (!f) { 991 if (!f) {
992 covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentF lags, true); 992 covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorCompone ntFlags, true);
993 } else { 993 } else {
994 covPOI.calcWithInitialValues(NULL, 0, GrColorPackA4(255), 994 covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
995 kRGBA_GrColorComponentFlags, true); 995 kRGBA_GrColorComponentFlags, true);
996 } 996 }
997 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) { 997 for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
998 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m); 998 SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
999 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer mode)); 999 SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfer mode));
1000 GrXferProcessor::DstTexture* dstTexture = 1000 GrXferProcessor::DstTexture* dstTexture =
1001 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa keDstTexture : 0; 1001 xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fa keDstTexture : 0;
1002 SkAutoTUnref<GrXferProcessor> xp( 1002 SkAutoTUnref<GrXferProcessor> xp(
1003 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture , caps)); 1003 xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture , caps));
1004 if (!xp) { 1004 if (!xp) {
1005 ERRORF(reporter, "Failed to create an XP without dual source blending."); 1005 ERRORF(reporter, "Failed to create an XP without dual source blending.");
1006 return; 1006 return;
1007 } 1007 }
1008 TEST_ASSERT(!xp->hasSecondaryOutput()); 1008 TEST_ASSERT(!xp->hasSecondaryOutput());
1009 xp->getOptimizations(colorPOI, covPOI, false, 0, caps); 1009 xp->getOptimizations(colorPOI, covPOI, false, 0, caps);
1010 TEST_ASSERT(!xp->hasSecondaryOutput()); 1010 TEST_ASSERT(!xp->hasSecondaryOutput());
1011 } 1011 }
1012 } 1012 }
1013 } 1013 }
1014 } 1014 }
1015 1015
1016 #endif 1016 #endif
1017 1017
OLDNEW
« no previous file with comments | « tests/GrMemoryPoolTest.cpp ('k') | tests/GrSurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698