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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 1213623022: fix up test create functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 5 years, 5 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/effects/GrTextureDomain.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 2011 Google Inc. 3 * Copyright 2011 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 // This is a GPU-backend specific test. It relies on static intializers to work 9 // This is a GPU-backend specific test. It relies on static intializers to work
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool onIsEqual(const GrFragmentProcessor&) const override { return true; } 86 bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
87 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { } 87 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { }
88 88
89 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 89 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
90 90
91 typedef GrFragmentProcessor INHERITED; 91 typedef GrFragmentProcessor INHERITED;
92 }; 92 };
93 93
94 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor); 94 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(BigKeyProcessor);
95 95
96 GrFragmentProcessor* BigKeyProcessor::TestCreate(SkRandom*, 96 GrFragmentProcessor* BigKeyProcessor::TestCreate(GrProcessorTestData*) {
97 GrContext*,
98 const GrCaps&,
99 GrTexture*[]) {
100 return BigKeyProcessor::Create(); 97 return BigKeyProcessor::Create();
101 } 98 }
102 99
103 /* 100 /*
104 * Begin test code 101 * Begin test code
105 */ 102 */
106 static const int kRenderTargetHeight = 1; 103 static const int kRenderTargetHeight = 1;
107 static const int kRenderTargetWidth = 1; 104 static const int kRenderTargetWidth = 1;
108 105
109 static GrRenderTarget* random_render_target(GrTextureProvider* textureProvider, SkRandom* random, 106 static GrRenderTarget* random_render_target(GrTextureProvider* textureProvider, SkRandom* random,
(...skipping 19 matching lines...) Expand all
129 GrTexture* texture = textureProvider->findAndRefTextureByUniqueKey(key); 126 GrTexture* texture = textureProvider->findAndRefTextureByUniqueKey(key);
130 if (!texture) { 127 if (!texture) {
131 texture = textureProvider->createTexture(texDesc, true); 128 texture = textureProvider->createTexture(texDesc, true);
132 if (texture) { 129 if (texture) {
133 textureProvider->assignUniqueKeyToTexture(key, texture); 130 textureProvider->assignUniqueKeyToTexture(key, texture);
134 } 131 }
135 } 132 }
136 return texture ? texture->asRenderTarget() : NULL; 133 return texture ? texture->asRenderTarget() : NULL;
137 } 134 }
138 135
139 static void set_random_xpf(GrContext* context, const GrCaps& caps, 136 static void set_random_xpf(GrPipelineBuilder* pipelineBuilder, GrProcessorTestDa ta* d) {
140 GrPipelineBuilder* pipelineBuilder, SkRandom* random, 137 SkAutoTUnref<const GrXPFactory> xpf(GrProcessorTestFactory<GrXPFactory>::Cre ateStage(d));
141 GrTexture* dummyTextures[]) {
142 SkAutoTUnref<const GrXPFactory> xpf(
143 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures));
144 SkASSERT(xpf); 138 SkASSERT(xpf);
145 pipelineBuilder->setXPFactory(xpf.get()); 139 pipelineBuilder->setXPFactory(xpf.get());
146 } 140 }
147 141
148 static void set_random_color_coverage_stages(GrGpu* gpu, 142 static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder,
149 GrPipelineBuilder* pipelineBuilder, 143 GrProcessorTestData* d, int maxStag es) {
150 int maxStages, 144 int numProcs = d->fRandom->nextULessThan(maxStages + 1);
151 SkRandom* random, 145 int numColorProcs = d->fRandom->nextULessThan(numProcs + 1);
152 GrTexture* dummyTextures[]) {
153 int numProcs = random->nextULessThan(maxStages + 1);
154 int numColorProcs = random->nextULessThan(numProcs + 1);
155 146
156 for (int s = 0; s < numProcs;) { 147 for (int s = 0; s < numProcs;) {
157 SkAutoTUnref<const GrFragmentProcessor> fp( 148 SkAutoTUnref<const GrFragmentProcessor> fp(
158 GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(random, 149 GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d));
159 gpu->ge tContext(),
160 *gpu->c aps(),
161 dummyTe xtures));
162 SkASSERT(fp); 150 SkASSERT(fp);
163 151
164 // finally add the stage to the correct pipeline in the drawstate 152 // finally add the stage to the correct pipeline in the drawstate
165 if (s < numColorProcs) { 153 if (s < numColorProcs) {
166 pipelineBuilder->addColorProcessor(fp); 154 pipelineBuilder->addColorProcessor(fp);
167 } else { 155 } else {
168 pipelineBuilder->addCoverageProcessor(fp); 156 pipelineBuilder->addCoverageProcessor(fp);
169 } 157 }
170 ++s; 158 ++s;
171 } 159 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return false; 237 return false;
250 } 238 }
251 239
252 GrPipelineBuilder pipelineBuilder; 240 GrPipelineBuilder pipelineBuilder;
253 pipelineBuilder.setRenderTarget(rt.get()); 241 pipelineBuilder.setRenderTarget(rt.get());
254 pipelineBuilder.setClip(clip); 242 pipelineBuilder.setClip(clip);
255 243
256 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, context)); 244 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, context));
257 SkASSERT(batch); 245 SkASSERT(batch);
258 246
259 set_random_color_coverage_stages(fGpu, 247 GrShaderDataManager shaderDataManager;
260 &pipelineBuilder, 248 GrProcessorTestData ptd(&random, context, &shaderDataManager, fGpu->caps (), dummyTextures);
261 maxStages, 249 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages);
262 &random, 250 set_random_xpf(&pipelineBuilder, &ptd);
263 dummyTextures);
264
265 // creates a random xfer processor factory on the draw state
266 set_random_xpf(context, *fGpu->caps(), &pipelineBuilder, &random, dummyT extures);
267
268 set_random_state(&pipelineBuilder, &random); 251 set_random_state(&pipelineBuilder, &random);
269 set_random_stencil(&pipelineBuilder, &random); 252 set_random_stencil(&pipelineBuilder, &random);
270 253
271 this->drawBatch(&pipelineBuilder, batch); 254 this->drawBatch(&pipelineBuilder, batch);
272 } 255 }
273 256
274 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) 257 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes)
275 this->flush(); 258 this->flush();
276 return true; 259 return true;
277 } 260 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 299 }
317 #endif 300 #endif
318 GrTestTarget target; 301 GrTestTarget target;
319 context->getTestTarget(&target); 302 context->getTestTarget(&target);
320 REPORTER_ASSERT(reporter, target.target()->programUnitTest(context, maxStages)); 303 REPORTER_ASSERT(reporter, target.target()->programUnitTest(context, maxStages));
321 } 304 }
322 } 305 }
323 } 306 }
324 307
325 #endif 308 #endif
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698