OLD | NEW |
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 #include "BenchTimer.h" | 8 #include "BenchTimer.h" |
9 #include "ResultsWriter.h" | 9 #include "ResultsWriter.h" |
10 #include "SkBenchLogger.h" | 10 #include "SkBenchLogger.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 483 } |
484 glContext = gContextFactory.getGLContext(config.contextType); | 484 glContext = gContextFactory.getGLContext(config.contextType); |
485 } | 485 } |
486 #endif | 486 #endif |
487 | 487 |
488 SkAutoTUnref<SkCanvas> canvas; | 488 SkAutoTUnref<SkCanvas> canvas; |
489 SkAutoTUnref<SkPicture> recordFrom; | 489 SkAutoTUnref<SkPicture> recordFrom; |
490 SkPictureRecorder recorderTo; | 490 SkPictureRecorder recorderTo; |
491 const SkIPoint dim = bench->getSize(); | 491 const SkIPoint dim = bench->getSize(); |
492 | 492 |
493 const SkPicture::RecordingFlags kRecordFlags = | |
494 SkPicture::kUsePathBoundsForClip_RecordingFlag; | |
495 | |
496 SkAutoTUnref<SkSurface> surface; | 493 SkAutoTUnref<SkSurface> surface; |
497 if (SkBenchmark::kNonRendering_Backend != config.backend) { | 494 if (SkBenchmark::kNonRendering_Backend != config.backend) { |
498 surface.reset(make_surface(config.fColorType, | 495 surface.reset(make_surface(config.fColorType, |
499 dim, | 496 dim, |
500 config.backend, | 497 config.backend, |
501 config.sampleCount, | 498 config.sampleCount, |
502 context)); | 499 context)); |
503 if (!surface.get()) { | 500 if (!surface.get()) { |
504 logger.logError(SkStringPrintf( | 501 logger.logError(SkStringPrintf( |
505 "Device creation failure for config %s. Will skip.\n", c
onfig.name)); | 502 "Device creation failure for config %s. Will skip.\n", c
onfig.name)); |
506 continue; | 503 continue; |
507 } | 504 } |
508 | 505 |
509 switch(benchMode) { | 506 switch(benchMode) { |
510 case kDeferredSilent_BenchMode: | 507 case kDeferredSilent_BenchMode: |
511 case kDeferred_BenchMode: | 508 case kDeferred_BenchMode: |
512 canvas.reset(SkDeferredCanvas::Create(surface.get())); | 509 canvas.reset(SkDeferredCanvas::Create(surface.get())); |
513 break; | 510 break; |
514 case kRecord_BenchMode: | 511 case kRecord_BenchMode: |
515 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, | 512 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY))); |
516 NULL, kReco
rdFlags))); | |
517 break; | 513 break; |
518 case kPictureRecord_BenchMode: { | 514 case kPictureRecord_BenchMode: { |
519 SkPictureRecorder recorderFrom; | 515 SkPictureRecorder recorderFrom; |
520 bench->draw(1, recorderFrom.beginRecording(dim.fX, dim.f
Y, | 516 bench->draw(1, recorderFrom.beginRecording(dim.fX, dim.f
Y)); |
521 NULL, kRecord
Flags)); | |
522 recordFrom.reset(recorderFrom.endRecording()); | 517 recordFrom.reset(recorderFrom.endRecording()); |
523 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, | 518 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY))); |
524 NULL, kReco
rdFlags))); | |
525 break; | 519 break; |
526 } | 520 } |
527 case kNormal_BenchMode: | 521 case kNormal_BenchMode: |
528 canvas.reset(SkRef(surface->getCanvas())); | 522 canvas.reset(SkRef(surface->getCanvas())); |
529 break; | 523 break; |
530 default: | 524 default: |
531 SkASSERT(false); | 525 SkASSERT(false); |
532 } | 526 } |
533 } | 527 } |
534 | 528 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 // you've got a computer clocked at several THz or have
a broken benchmark. ;) | 574 // you've got a computer clocked at several THz or have
a broken benchmark. ;) |
581 // "1B ought to be enough for anybody." | 575 // "1B ought to be enough for anybody." |
582 logger.logError(SkStringPrintf( | 576 logger.logError(SkStringPrintf( |
583 "\nCan't get %s %s to converge in %dms (%d loops)", | 577 "\nCan't get %s %s to converge in %dms (%d loops)", |
584 bench->getName(), config.name, FLAGS_maxMs, loopsPe
rIter)); | 578 bench->getName(), config.name, FLAGS_maxMs, loopsPe
rIter)); |
585 break; | 579 break; |
586 } | 580 } |
587 | 581 |
588 if ((benchMode == kRecord_BenchMode || benchMode == kPicture
Record_BenchMode)) { | 582 if ((benchMode == kRecord_BenchMode || benchMode == kPicture
Record_BenchMode)) { |
589 // Clear the recorded commands so that they do not accum
ulate. | 583 // Clear the recorded commands so that they do not accum
ulate. |
590 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, | 584 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY))); |
591 NULL, kReco
rdFlags))); | |
592 } | 585 } |
593 | 586 |
594 timer.start(); | 587 timer.start(); |
595 // Inner loop that allows us to break the run into smaller | 588 // Inner loop that allows us to break the run into smaller |
596 // chunks (e.g. frames). This is especially useful for the G
PU | 589 // chunks (e.g. frames). This is especially useful for the G
PU |
597 // as we can flush and/or swap buffers to keep the GPU from | 590 // as we can flush and/or swap buffers to keep the GPU from |
598 // queuing up too much work. | 591 // queuing up too much work. |
599 for (int loopCount = loopsPerIter; loopCount > 0; ) { | 592 for (int loopCount = loopsPerIter; loopCount > 0; ) { |
600 // Save and restore around each call to draw() to guaran
tee a pristine canvas. | 593 // Save and restore around each call to draw() to guaran
tee a pristine canvas. |
601 SkAutoCanvasRestore saveRestore(canvas, true/*also save*
/); | 594 SkAutoCanvasRestore saveRestore(canvas, true/*also save*
/); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 gContextFactory.destroyContexts(); | 696 gContextFactory.destroyContexts(); |
704 #endif | 697 #endif |
705 return 0; | 698 return 0; |
706 } | 699 } |
707 | 700 |
708 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 701 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
709 int main(int argc, char * const argv[]) { | 702 int main(int argc, char * const argv[]) { |
710 return tool_main(argc, (char**) argv); | 703 return tool_main(argc, (char**) argv); |
711 } | 704 } |
712 #endif | 705 #endif |
OLD | NEW |