| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 GrTexture*[]) { | 91 GrTexture*[]) { |
| 92 return BigKeyProcessor::Create(); | 92 return BigKeyProcessor::Create(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 /* | 95 /* |
| 96 * Begin test code | 96 * Begin test code |
| 97 */ | 97 */ |
| 98 static const int kRenderTargetHeight = 1; | 98 static const int kRenderTargetHeight = 1; |
| 99 static const int kRenderTargetWidth = 1; | 99 static const int kRenderTargetWidth = 1; |
| 100 | 100 |
| 101 static GrRenderTarget* random_render_target(GrContext* context, | 101 static GrRenderTarget* random_render_target(GrContext* context, SkRandom* random
) { |
| 102 const GrCacheID& cacheId, | |
| 103 SkRandom* random) { | |
| 104 // setup render target | 102 // setup render target |
| 105 GrTextureParams params; | 103 GrTextureParams params; |
| 106 GrSurfaceDesc texDesc; | 104 GrSurfaceDesc texDesc; |
| 107 texDesc.fWidth = kRenderTargetWidth; | 105 texDesc.fWidth = kRenderTargetWidth; |
| 108 texDesc.fHeight = kRenderTargetHeight; | 106 texDesc.fHeight = kRenderTargetHeight; |
| 109 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 107 texDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 110 texDesc.fConfig = kRGBA_8888_GrPixelConfig; | 108 texDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 111 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : | 109 texDesc.fOrigin = random->nextBool() == true ? kTopLeft_GrSurfaceOrigin : |
| 112 kBottomLeft_GrSurfaceOrigin; | 110 kBottomLeft_GrSurfaceOrigin; |
| 111 GrContentKey key; |
| 112 static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); |
| 113 GrContentKey::Builder builder(&key, kDomain, 1); |
| 114 builder[0] = texDesc.fOrigin; |
| 115 builder.finish(); |
| 113 | 116 |
| 114 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, cacheId,
¶ms)); | 117 SkAutoTUnref<GrTexture> texture(context->findAndRefTexture(texDesc, key, &pa
rams)); |
| 115 if (!texture) { | 118 if (!texture) { |
| 116 texture.reset(context->createTexture(¶ms, texDesc, cacheId, 0, 0)); | 119 texture.reset(context->createTexture(¶ms, texDesc, key, 0, 0)); |
| 117 if (!texture) { | 120 if (!texture) { |
| 118 return NULL; | 121 return NULL; |
| 119 } | 122 } |
| 120 } | 123 } |
| 121 return SkRef(texture->asRenderTarget()); | 124 return SkRef(texture->asRenderTarget()); |
| 122 } | 125 } |
| 123 | 126 |
| 124 static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, | 127 static void set_random_xpf(GrContext* context, const GrDrawTargetCaps& caps, |
| 125 GrPipelineBuilder* pipelineBuilder, SkRandom* random, | 128 GrPipelineBuilder* pipelineBuilder, SkRandom* random, |
| 126 GrTexture* dummyTextures[]) { | 129 GrTexture* dummyTextures[]) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if (!dummyTexture1 || ! dummyTexture2) { | 233 if (!dummyTexture1 || ! dummyTexture2) { |
| 231 SkDebugf("Could not allocate dummy textures"); | 234 SkDebugf("Could not allocate dummy textures"); |
| 232 return false; | 235 return false; |
| 233 } | 236 } |
| 234 | 237 |
| 235 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; | 238 GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()}; |
| 236 | 239 |
| 237 // dummy scissor state | 240 // dummy scissor state |
| 238 GrScissorState scissor; | 241 GrScissorState scissor; |
| 239 | 242 |
| 240 // Setup texture cache id key | |
| 241 const GrCacheID::Domain glProgramsDomain = GrCacheID::GenerateDomain(); | |
| 242 GrCacheID::Key key; | |
| 243 memset(&key, 0, sizeof(key)); | |
| 244 key.fData32[0] = kRenderTargetWidth; | |
| 245 key.fData32[1] = kRenderTargetHeight; | |
| 246 GrCacheID glProgramsCacheID(glProgramsDomain, key); | |
| 247 | |
| 248 // setup clip | 243 // setup clip |
| 249 SkRect screen = SkRect::MakeWH(SkIntToScalar(kRenderTargetWidth), | 244 SkRect screen = SkRect::MakeWH(SkIntToScalar(kRenderTargetWidth), |
| 250 SkIntToScalar(kRenderTargetHeight)); | 245 SkIntToScalar(kRenderTargetHeight)); |
| 251 | 246 |
| 252 SkClipStack stack; | 247 SkClipStack stack; |
| 253 stack.clipDevRect(screen, SkRegion::kReplace_Op, false); | 248 stack.clipDevRect(screen, SkRegion::kReplace_Op, false); |
| 254 | 249 |
| 255 // wrap the SkClipStack in a GrClipData | 250 // wrap the SkClipStack in a GrClipData |
| 256 GrClipData clipData; | 251 GrClipData clipData; |
| 257 clipData.fClipStack = &stack; | 252 clipData.fClipStack = &stack; |
| 258 this->setClip(&clipData); | 253 this->setClip(&clipData); |
| 259 | 254 |
| 260 SkRandom random; | 255 SkRandom random; |
| 261 static const int NUM_TESTS = 512; | 256 static const int NUM_TESTS = 512; |
| 262 for (int t = 0; t < NUM_TESTS;) { | 257 for (int t = 0; t < NUM_TESTS;) { |
| 263 // setup random render target(can fail) | 258 // setup random render target(can fail) |
| 264 SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, glProgram
sCacheID, &random)); | 259 SkAutoTUnref<GrRenderTarget> rt(random_render_target(fContext, &random))
; |
| 265 if (!rt.get()) { | 260 if (!rt.get()) { |
| 266 SkDebugf("Could not allocate render target"); | 261 SkDebugf("Could not allocate render target"); |
| 267 return false; | 262 return false; |
| 268 } | 263 } |
| 269 | 264 |
| 270 GrPipelineBuilder pipelineBuilder; | 265 GrPipelineBuilder pipelineBuilder; |
| 271 pipelineBuilder.setRenderTarget(rt.get()); | 266 pipelineBuilder.setRenderTarget(rt.get()); |
| 272 | 267 |
| 273 // if path rendering we have to setup a couple of things like the draw t
ype | 268 // if path rendering we have to setup a couple of things like the draw t
ype |
| 274 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n
extBool(); | 269 bool usePathRendering = gpu->glCaps().pathRenderingSupport() && random.n
extBool(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 358 } |
| 364 #endif | 359 #endif |
| 365 GrTestTarget target; | 360 GrTestTarget target; |
| 366 context->getTestTarget(&target); | 361 context->getTestTarget(&target); |
| 367 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); | 362 REPORTER_ASSERT(reporter, target.target()->programUnitTest(maxStages
)); |
| 368 } | 363 } |
| 369 } | 364 } |
| 370 } | 365 } |
| 371 | 366 |
| 372 #endif | 367 #endif |
| OLD | NEW |