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

Side by Side Diff: tests/GpuColorFilterTest.cpp

Issue 699943003: Move GrInvariantOutput out of GrProcessor and into its own class. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanup Created 6 years, 1 month 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/GLProgramsTest.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 #if SK_SUPPORT_GPU 9 #if SK_SUPPORT_GPU
10 10
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrContextFactory.h" 12 #include "GrContextFactory.h"
13 #include "GrFragmentProcessor.h" 13 #include "GrFragmentProcessor.h"
14 #include "GrInvariantOutput.h"
14 #include "SkColorFilter.h" 15 #include "SkColorFilter.h"
15 #include "SkGr.h" 16 #include "SkGr.h"
16 #include "Test.h" 17 #include "Test.h"
17 18
18 static GrColor filterColor(const GrColor& color, uint32_t flags) { 19 static GrColor filterColor(const GrColor& color, uint32_t flags) {
19 uint32_t mask = 0; 20 uint32_t mask = 0;
20 if (flags & kR_GrColorComponentFlag) { 21 if (flags & kR_GrColorComponentFlag) {
21 mask = 0xFF << GrColor_SHIFT_R; 22 mask = 0xFF << GrColor_SHIFT_R;
22 } 23 }
23 if (flags & kG_GrColorComponentFlag) { 24 if (flags & kG_GrColorComponentFlag) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black}, 93 { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode:: kDstOver_Mode, 0 , gr_black},
93 94
94 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha. 95 // An unknown color with known alpha and red component filtered with Mul tiply produces an unknown color with known red and alpha.
95 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } 96 { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkXfermode: :kModulate_Mode, kR|kA, GrColorPackRGBA(50, 0, 0, 64) }
96 }; 97 };
97 98
98 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { 99 for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) {
99 const GetConstantComponentTestCase& test = filterTests[i]; 100 const GetConstantComponentTestCase& test = filterTests[i];
100 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt erColor, test.filterMode)); 101 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(test.filt erColor, test.filterMode));
101 SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grConte xt)); 102 SkAutoTUnref<GrFragmentProcessor> effect(cf->asFragmentProcessor(grConte xt));
102 GrProcessor::InvariantOutput inout; 103 GrInvariantOutput inout(test.inputColor,
103 inout.setToOther(test.inputComponents, test.inputColor, 104 static_cast<GrColorComponentFlags>(test.inputCom ponents),
104 GrProcessor::InvariantOutput::kWill_ReadInput); 105 false);
105 effect->computeInvariantOutput(&inout); 106 effect->computeInvariantOutput(&inout);
106 107
107 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor); 108 REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == test.outputColor);
108 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); 109 REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags());
109 } 110 }
110 } 111 }
111 112
112 DEF_GPUTEST(GpuColorFilter, reporter, factory) { 113 DEF_GPUTEST(GpuColorFilter, reporter, factory) {
113 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { 114 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
114 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type); 115 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G LContextType>(type);
115 116
116 GrContext* grContext = factory->get(glType); 117 GrContext* grContext = factory->get(glType);
117 if (NULL == grContext) { 118 if (NULL == grContext) {
118 continue; 119 continue;
119 } 120 }
120 121
121 test_getConstantColorComponents(reporter, grContext); 122 test_getConstantColorComponents(reporter, grContext);
122 } 123 }
123 } 124 }
124 125
125 #endif 126 #endif
OLDNEW
« no previous file with comments | « tests/GLProgramsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698