OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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, | |
141 GrTexture* dummyTextures[]) { | |
142 SkAutoTUnref<const GrXPFactory> xpf( | 137 SkAutoTUnref<const GrXPFactory> xpf( |
robertphillips
2015/07/08 20:51:32
Can this be one line now ?
| |
143 GrProcessorTestFactory<GrXPFactory>::CreateStage(random, context, caps, dummyTextures)); | 138 GrProcessorTestFactory<GrXPFactory>::CreateStage(d)); |
144 SkASSERT(xpf); | 139 SkASSERT(xpf); |
145 pipelineBuilder->setXPFactory(xpf.get()); | 140 pipelineBuilder->setXPFactory(xpf.get()); |
146 } | 141 } |
147 | 142 |
148 static void set_random_color_coverage_stages(GrGpu* gpu, | 143 static void set_random_color_coverage_stages(GrPipelineBuilder* pipelineBuilder, |
149 GrPipelineBuilder* pipelineBuilder, | 144 GrProcessorTestData* d, int maxStag es) { |
150 int maxStages, | 145 int numProcs = d->fRandom->nextULessThan(maxStages + 1); |
151 SkRandom* random, | 146 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 | 147 |
156 for (int s = 0; s < numProcs;) { | 148 for (int s = 0; s < numProcs;) { |
157 SkAutoTUnref<const GrFragmentProcessor> fp( | 149 SkAutoTUnref<const GrFragmentProcessor> fp( |
158 GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(random, | 150 GrProcessorTestFactory<GrFragmentProcessor>::CreateStage(d)); |
159 gpu->ge tContext(), | |
160 *gpu->c aps(), | |
161 dummyTe xtures)); | |
162 SkASSERT(fp); | 151 SkASSERT(fp); |
163 | 152 |
164 // finally add the stage to the correct pipeline in the drawstate | 153 // finally add the stage to the correct pipeline in the drawstate |
165 if (s < numColorProcs) { | 154 if (s < numColorProcs) { |
166 pipelineBuilder->addColorProcessor(fp); | 155 pipelineBuilder->addColorProcessor(fp); |
167 } else { | 156 } else { |
168 pipelineBuilder->addCoverageProcessor(fp); | 157 pipelineBuilder->addCoverageProcessor(fp); |
169 } | 158 } |
170 ++s; | 159 ++s; |
171 } | 160 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 return false; | 238 return false; |
250 } | 239 } |
251 | 240 |
252 GrPipelineBuilder pipelineBuilder; | 241 GrPipelineBuilder pipelineBuilder; |
253 pipelineBuilder.setRenderTarget(rt.get()); | 242 pipelineBuilder.setRenderTarget(rt.get()); |
254 pipelineBuilder.setClip(clip); | 243 pipelineBuilder.setClip(clip); |
255 | 244 |
256 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, context)); | 245 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, context)); |
257 SkASSERT(batch); | 246 SkASSERT(batch); |
258 | 247 |
259 set_random_color_coverage_stages(fGpu, | 248 GrShaderDataManager shaderDataManager; |
260 &pipelineBuilder, | 249 GrProcessorTestData ptd(&random, context, &shaderDataManager, fGpu->caps (), dummyTextures); |
261 maxStages, | 250 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); |
262 &random, | 251 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); | 252 set_random_state(&pipelineBuilder, &random); |
269 set_random_stencil(&pipelineBuilder, &random); | 253 set_random_stencil(&pipelineBuilder, &random); |
270 | 254 |
271 this->drawBatch(&pipelineBuilder, batch); | 255 this->drawBatch(&pipelineBuilder, batch); |
272 } | 256 } |
273 | 257 |
274 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) | 258 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) |
275 this->flush(); | 259 this->flush(); |
276 return true; | 260 return true; |
277 } | 261 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 } | 300 } |
317 #endif | 301 #endif |
318 GrTestTarget target; | 302 GrTestTarget target; |
319 context->getTestTarget(&target); | 303 context->getTestTarget(&target); |
320 REPORTER_ASSERT(reporter, target.target()->programUnitTest(context, maxStages)); | 304 REPORTER_ASSERT(reporter, target.target()->programUnitTest(context, maxStages)); |
321 } | 305 } |
322 } | 306 } |
323 } | 307 } |
324 | 308 |
325 #endif | 309 #endif |
OLD | NEW |