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

Side by Side Diff: tests/GLProgramsTest.cpp

Issue 1918003003: Bring sk_sp to GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // This is a GPU-backend specific test. It relies on static intializers to work 8 // This is a GPU-backend specific test. It relies on static intializers to work
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // dummy scissor state 327 // dummy scissor state
328 GrScissorState scissor; 328 GrScissorState scissor;
329 329
330 // wide open clip 330 // wide open clip
331 GrClip clip; 331 GrClip clip;
332 332
333 SkRandom random; 333 SkRandom random;
334 static const int NUM_TESTS = 1024; 334 static const int NUM_TESTS = 1024;
335 for (int t = 0; t < NUM_TESTS; t++) { 335 for (int t = 0; t < NUM_TESTS; t++) {
336 // setup random render target(can fail) 336 // setup random render target(can fail)
337 SkAutoTUnref<GrRenderTarget> rt(random_render_target( 337 sk_sp<GrRenderTarget> rt(random_render_target(
338 context->textureProvider(), &random, context->caps())); 338 context->textureProvider(), &random, context->caps()));
339 if (!rt.get()) { 339 if (!rt.get()) {
340 SkDebugf("Could not allocate render target"); 340 SkDebugf("Could not allocate render target");
341 return false; 341 return false;
342 } 342 }
343 343
344 GrPipelineBuilder pipelineBuilder; 344 GrPipelineBuilder pipelineBuilder;
345 pipelineBuilder.setRenderTarget(rt.get()); 345 pipelineBuilder.setRenderTarget(rt.get());
346 pipelineBuilder.setClip(clip); 346 pipelineBuilder.setClip(clip);
347 347
348 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)); 348 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context));
349 SkASSERT(batch); 349 SkASSERT(batch);
350 350
351 GrProcessorTestData ptd(&random, context, context->caps(), rt, dummyText ures); 351 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dum myTextures);
352 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages); 352 set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages);
353 set_random_xpf(&pipelineBuilder, &ptd); 353 set_random_xpf(&pipelineBuilder, &ptd);
354 set_random_state(&pipelineBuilder, &random); 354 set_random_state(&pipelineBuilder, &random);
355 set_random_stencil(&pipelineBuilder, &random); 355 set_random_stencil(&pipelineBuilder, &random);
356 356
357 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); 357 sk_sp<GrDrawContext> drawContext(context->drawContext(rt));
358 if (!drawContext) { 358 if (!drawContext) {
359 SkDebugf("Could not allocate drawContext"); 359 SkDebugf("Could not allocate drawContext");
360 return false; 360 return false;
361 } 361 }
362 362
363 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, ba tch); 363 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBuilder, ba tch);
364 } 364 }
365 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes) 365 // Flush everything, test passes if flush is successful(ie, no asserts are h it, no crashes)
366 drawingManager->flush(); 366 drawingManager->flush();
367 367
368 // Validate that GrFPs work correctly without an input. 368 // Validate that GrFPs work correctly without an input.
369 GrSurfaceDesc rtDesc; 369 GrSurfaceDesc rtDesc;
370 rtDesc.fWidth = kRenderTargetWidth; 370 rtDesc.fWidth = kRenderTargetWidth;
371 rtDesc.fHeight = kRenderTargetHeight; 371 rtDesc.fHeight = kRenderTargetHeight;
372 rtDesc.fFlags = kRenderTarget_GrSurfaceFlag; 372 rtDesc.fFlags = kRenderTarget_GrSurfaceFlag;
373 rtDesc.fConfig = kRGBA_8888_GrPixelConfig; 373 rtDesc.fConfig = kRGBA_8888_GrPixelConfig;
374 SkAutoTUnref<GrRenderTarget> rt( 374 sk_sp<GrRenderTarget> rt(
375 context->textureProvider()->createTexture(rtDesc, SkBudgeted::kNo)->asRe nderTarget()); 375 context->textureProvider()->createTexture(rtDesc, SkBudgeted::kNo)->asRe nderTarget());
376 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count(); 376 int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count();
377 for (int i = 0; i < fpFactoryCnt; ++i) { 377 for (int i = 0; i < fpFactoryCnt; ++i) {
378 // Since FP factories internally randomize, call each 10 times. 378 // Since FP factories internally randomize, call each 10 times.
379 for (int j = 0; j < 10; ++j) { 379 for (int j = 0; j < 10; ++j) {
380 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)) ; 380 SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context)) ;
381 SkASSERT(batch); 381 SkASSERT(batch);
382 GrProcessorTestData ptd(&random, context, context->caps(), rt, dummy Textures); 382 GrProcessorTestData ptd(&random, context, context->caps(), rt.get(), dummyTextures);
383 GrPipelineBuilder builder; 383 GrPipelineBuilder builder;
384 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_ Mode))->unref(); 384 builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_ Mode))->unref();
385 builder.setRenderTarget(rt); 385 builder.setRenderTarget(rt.get());
386 builder.setClip(clip); 386 builder.setClip(clip);
387 387
388 SkAutoTUnref<const GrFragmentProcessor> fp( 388 SkAutoTUnref<const GrFragmentProcessor> fp(
389 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd)) ; 389 GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd)) ;
390 SkAutoTUnref<const GrFragmentProcessor> blockFP( 390 SkAutoTUnref<const GrFragmentProcessor> blockFP(
391 BlockInputFragmentProcessor::Create(fp)); 391 BlockInputFragmentProcessor::Create(fp));
392 builder.addColorFragmentProcessor(blockFP); 392 builder.addColorFragmentProcessor(blockFP);
393 393
394 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); 394 sk_sp<GrDrawContext> drawContext(context->drawContext(rt));
395 if (!drawContext) { 395 if (!drawContext) {
396 SkDebugf("Could not allocate a drawcontext"); 396 SkDebugf("Could not allocate a drawcontext");
397 return false; 397 return false;
398 } 398 }
399 399
400 drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch) ; 400 drawContext->drawContextPriv().testingOnly_drawBatch(builder, batch) ;
401 drawingManager->flush(); 401 drawingManager->flush();
402 } 402 }
403 } 403 }
404 404
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 GrContextOptions opts; 469 GrContextOptions opts;
470 opts.fSuppressPrints = true; 470 opts.fSuppressPrints = true;
471 sk_gpu_test::GrContextFactory debugFactory(opts); 471 sk_gpu_test::GrContextFactory debugFactory(opts);
472 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type, 472 skiatest::RunWithGPUTestContexts(test_glprograms_native, &is_native_gl_conte xt_type,
473 reporter, &debugFactory); 473 reporter, &debugFactory);
474 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts, 474 skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts,
475 &is_other_rendering_gl_context_type, report er, &debugFactory); 475 &is_other_rendering_gl_context_type, report er, &debugFactory);
476 } 476 }
477 477
478 #endif 478 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698