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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 "Device creation failure for config %s. Will skip.\n", c
onfig.name)); | 499 "Device creation failure for config %s. Will skip.\n", c
onfig.name)); |
500 continue; | 500 continue; |
501 } | 501 } |
502 | 502 |
503 switch(benchMode) { | 503 switch(benchMode) { |
504 case kDeferredSilent_BenchMode: | 504 case kDeferredSilent_BenchMode: |
505 case kDeferred_BenchMode: | 505 case kDeferred_BenchMode: |
506 canvas.reset(SkDeferredCanvas::Create(surface.get())); | 506 canvas.reset(SkDeferredCanvas::Create(surface.get())); |
507 break; | 507 break; |
508 case kRecord_BenchMode: | 508 case kRecord_BenchMode: |
509 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, kRecordFlags))); | 509 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, |
| 510 NULL, kReco
rdFlags))); |
510 break; | 511 break; |
511 case kPictureRecord_BenchMode: { | 512 case kPictureRecord_BenchMode: { |
512 SkPictureRecorder recorderFrom; | 513 SkPictureRecorder recorderFrom; |
513 bench->draw(1, recorderFrom.beginRecording(dim.fX, dim.f
Y, kRecordFlags)); | 514 bench->draw(1, recorderFrom.beginRecording(dim.fX, dim.f
Y, |
| 515 NULL, kRecord
Flags)); |
514 recordFrom.reset(recorderFrom.endRecording()); | 516 recordFrom.reset(recorderFrom.endRecording()); |
515 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, kRecordFlags))); | 517 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, |
| 518 NULL, kReco
rdFlags))); |
516 break; | 519 break; |
517 } | 520 } |
518 case kNormal_BenchMode: | 521 case kNormal_BenchMode: |
519 canvas.reset(SkRef(surface->getCanvas())); | 522 canvas.reset(SkRef(surface->getCanvas())); |
520 break; | 523 break; |
521 default: | 524 default: |
522 SkASSERT(false); | 525 SkASSERT(false); |
523 } | 526 } |
524 } | 527 } |
525 | 528 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // 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. ;) |
572 // "1B ought to be enough for anybody." | 575 // "1B ought to be enough for anybody." |
573 logger.logError(SkStringPrintf( | 576 logger.logError(SkStringPrintf( |
574 "\nCan't get %s %s to converge in %dms (%d loops)", | 577 "\nCan't get %s %s to converge in %dms (%d loops)", |
575 bench->getName(), config.name, FLAGS_maxMs, loopsPe
rIter)); | 578 bench->getName(), config.name, FLAGS_maxMs, loopsPe
rIter)); |
576 break; | 579 break; |
577 } | 580 } |
578 | 581 |
579 if ((benchMode == kRecord_BenchMode || benchMode == kPicture
Record_BenchMode)) { | 582 if ((benchMode == kRecord_BenchMode || benchMode == kPicture
Record_BenchMode)) { |
580 // Clear the recorded commands so that they do not accum
ulate. | 583 // Clear the recorded commands so that they do not accum
ulate. |
581 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, kRecordFlags))); | 584 canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim
.fY, |
| 585 NULL, kReco
rdFlags))); |
582 } | 586 } |
583 | 587 |
584 timer.start(); | 588 timer.start(); |
585 // Inner loop that allows us to break the run into smaller | 589 // Inner loop that allows us to break the run into smaller |
586 // chunks (e.g. frames). This is especially useful for the G
PU | 590 // chunks (e.g. frames). This is especially useful for the G
PU |
587 // as we can flush and/or swap buffers to keep the GPU from | 591 // as we can flush and/or swap buffers to keep the GPU from |
588 // queuing up too much work. | 592 // queuing up too much work. |
589 for (int loopCount = loopsPerIter; loopCount > 0; ) { | 593 for (int loopCount = loopsPerIter; loopCount > 0; ) { |
590 // Save and restore around each call to draw() to guaran
tee a pristine canvas. | 594 // Save and restore around each call to draw() to guaran
tee a pristine canvas. |
591 SkAutoCanvasRestore saveRestore(canvas, true/*also save*
/); | 595 SkAutoCanvasRestore saveRestore(canvas, true/*also save*
/); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 gContextFactory.destroyContexts(); | 697 gContextFactory.destroyContexts(); |
694 #endif | 698 #endif |
695 return 0; | 699 return 0; |
696 } | 700 } |
697 | 701 |
698 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 702 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
699 int main(int argc, char * const argv[]) { | 703 int main(int argc, char * const argv[]) { |
700 return tool_main(argc, (char**) argv); | 704 return tool_main(argc, (char**) argv); |
701 } | 705 } |
702 #endif | 706 #endif |
OLD | NEW |