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

Side by Side Diff: tests/GpuColorFilterTest.cpp

Issue 1368423003: Use child processors to implement compose color filter. (Closed) Base URL: https://skia.googlesource.com/skia.git@upm
Patch Set: Address comments Created 5 years, 2 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/SkGr.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 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // A color with unknown alpha filtered with DstOver produces an unknown color. 93 // A color with unknown alpha filtered with DstOver produces an unknown color.
94 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black}, 94 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black},
95 95
96 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha. 96 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha.
97 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } 97 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) }
98 }; 98 };
99 99
100 GrPaint paint; 100 GrPaint paint;
101 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { 101 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
102 const GetConstantComponentTestCase& test = filterTests[i]; 102 const GetConstantComponentTestCase& test = filterTests[i];
103 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt erColor, test.filterMode)); 103 SkAutoTUnref<SkColorFilter> cf(
104 SkTDArray<const GrFragmentProcessor*> array; 104 SkColorFilter::CreateModeFilter(test.filterColor, test.filterMode));
105 bool hasFrag = cf->asFragmentProcessors(grContext, paint.getProcessorDat aManager(), &array); 105 SkAutoTUnref<const GrFragmentProcessor> fp(
106 REPORTER_ASSERT(reporter, hasFrag); 106 cf->asFragmentProcessor(grContext, paint.getProcessorDataManager())) ;
107 REPORTER_ASSERT(reporter, 1 == array.count()); 107 REPORTER_ASSERT(reporter, fp);
108 GrInvariantOutput inout(test.inputColor, 108 GrInvariantOutput inout(test.inputColor,
109 static_cast<GrColorComponentFlags>(test.inputCom ponents), 109 static_cast<GrColorComponentFlags>(test.inputCom ponents),
110 false); 110 false);
111 array[0]->computeInvariantOutput(&inout); 111 fp->computeInvariantOutput(&inout);
112 112 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) ==
113 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor); 113 test.outputColor);
114 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); 114 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags());
115 array[0]->unref();
116 } 115 }
117 } 116 }
118 117
119 DEF_GPUTEST(GpuColorFilter, reporter, factory) { 118 DEF_GPUTEST(GpuColorFilter, reporter, factory) {
120 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 119 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
121 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 120 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
122 121
123 GrContext* grContext = factory->get(glType); 122 GrContext* grContext = factory->get(glType);
124 if (nullptr == grContext) { 123 if (nullptr == grContext) {
125 continue; 124 continue;
126 } 125 }
127 126
128 test_getConstantColorComponents(reporter, grContext); 127 test_getConstantColorComponents(reporter, grContext);
129 } 128 }
130 } 129 }
131 130
132 #endif 131 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698