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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 GrTexture*[]) { | 98 GrTexture*[]) { |
99 return BigKeyProcessor::Create(); | 99 return BigKeyProcessor::Create(); |
100 } | 100 } |
101 | 101 |
102 /* | 102 /* |
103 * Begin test code | 103 * Begin test code |
104 */ | 104 */ |
105 static const int kRenderTargetHeight = 1; | 105 static const int kRenderTargetHeight = 1; |
106 static const int kRenderTargetWidth = 1; | 106 static const int kRenderTargetWidth = 1; |
107 | 107 |
108 static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random
) { | 108 static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random
, |
| 109 const GrDrawTargetCaps* caps) { |
109 // setup render target | 110 // setup render target |
110 GrTextureParams params; | 111 GrTextureParams params; |
111 GrSurfaceDesc texDesc; | 112 GrSurfaceDesc texDesc; |
112 texDesc.fWidth = kRenderTargetWidth; | 113 texDesc.fWidth = kRenderTargetWidth; |
113 texDesc.fHeight = kRenderTargetHeight; | 114 texDesc.fHeight = kRenderTargetHeight; |
114 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 115 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
115 texDesc.fConfig = kRGBA_8888_GrPixelConfig; | 116 texDesc.fConfig = kRGBA_8888_GrPixelConfig; |
116 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : | 117 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : |
117 kBottomLeft_GrSurfaceOrigin; | 118 kBottomLeft_GrSurfaceOrigin; |
118 texDesc.fSampleCnt = random->nextBool() == true ? 4 : 0; | 119 texDesc.fSampleCnt = random->nextBool() == true ? SkTMin(4, caps->maxSampleC
ount()) : 0; |
119 | 120 |
120 GrUniqueKey key; | 121 GrUniqueKey key; |
121 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); | 122 static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain(); |
122 GrUniqueKey::Builder builder(&key, kDomain, 2); | 123 GrUniqueKey::Builder builder(&key, kDomain, 2); |
123 builder[0] = texDesc.fOrigin; | 124 builder[0] = texDesc.fOrigin; |
124 builder[1] = texDesc.fSampleCnt; | 125 builder[1] = texDesc.fSampleCnt; |
125 builder.finish(); | 126 builder.finish(); |
126 | 127 |
127 GrTexture* texture = context->textureProvider()->findAndRefTextureByUniqueKe
y(key); | 128 GrTexture* texture = context->textureProvider()->findAndRefTextureByUniqueKe
y(key); |
128 if (!texture) { | 129 if (!texture) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // dummy scissor state | 233 // dummy scissor state |
233 GrScissorState scissor; | 234 GrScissorState scissor; |
234 | 235 |
235 // wide open clip | 236 // wide open clip |
236 GrClip clip; | 237 GrClip clip; |
237 | 238 |
238 SkRandom random; | 239 SkRandom random; |
239 static const int NUM_TESTS = 2048; | 240 static const int NUM_TESTS = 2048; |
240 for (int t = 0; t < NUM_TESTS; t++) { | 241 for (int t = 0; t < NUM_TESTS; t++) { |
241 // setup random render target(can fail) | 242 // setup random render target(can fail) |
242 SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random))
; | 243 SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random,
this->caps())); |
243 if (!rt.get()) { | 244 if (!rt.get()) { |
244 SkDebugf("Could not allocate render target"); | 245 SkDebugf("Could not allocate render target"); |
245 return false; | 246 return false; |
246 } | 247 } |
247 | 248 |
248 GrPipelineBuilder pipelineBuilder; | 249 GrPipelineBuilder pipelineBuilder; |
249 pipelineBuilder.setRenderTarget(rt.get()); | 250 pipelineBuilder.setRenderTarget(rt.get()); |
250 pipelineBuilder.setClip(clip); | 251 pipelineBuilder.setClip(clip); |
251 | 252 |
252 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, fContext)); | 253 SkAutoTUnref<GrBatch> batch(GrRandomBatch(&random, fContext)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 313 } |
313 #endif | 314 #endif |
314 GrTestTarget target; | 315 GrTestTarget target; |
315 context->getTestTarget(&target); | 316 context->getTestTarget(&target); |
316 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); | 317 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); |
317 } | 318 } |
318 } | 319 } |
319 } | 320 } |
320 | 321 |
321 #endif | 322 #endif |
OLD | NEW |