| 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 "SkBenchLogger.h" | 9 #include "SkBenchLogger.h" |
| 10 #include "SkBenchmark.h" | 10 #include "SkBenchmark.h" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 | 509 |
| 510 switch(benchMode) { | 510 switch(benchMode) { |
| 511 case kDeferredSilent_BenchMode: | 511 case kDeferredSilent_BenchMode: |
| 512 case kDeferred_BenchMode: | 512 case kDeferred_BenchMode: |
| 513 canvas.reset(SkDeferredCanvas::Create(device.get())); | 513 canvas.reset(SkDeferredCanvas::Create(device.get())); |
| 514 break; | 514 break; |
| 515 case kRecord_BenchMode: | 515 case kRecord_BenchMode: |
| 516 canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.f
Y, kRecordFlags))); | 516 canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.f
Y, kRecordFlags))); |
| 517 break; | 517 break; |
| 518 case kPictureRecord_BenchMode: | 518 case kPictureRecord_BenchMode: |
| 519 bench->draw(recordFrom.beginRecording(dim.fX, dim.fY, kR
ecordFlags)); | 519 bench->draw(1, recordFrom.beginRecording(dim.fX, dim.fY,
kRecordFlags)); |
| 520 recordFrom.endRecording(); | 520 recordFrom.endRecording(); |
| 521 canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.f
Y, kRecordFlags))); | 521 canvas.reset(SkRef(recordTo.beginRecording(dim.fX, dim.f
Y, kRecordFlags))); |
| 522 break; | 522 break; |
| 523 case kNormal_BenchMode: | 523 case kNormal_BenchMode: |
| 524 canvas.reset(new SkCanvas(device.get())); | 524 canvas.reset(new SkCanvas(device.get())); |
| 525 break; | 525 break; |
| 526 default: | 526 default: |
| 527 SkASSERT(false); | 527 SkASSERT(false); |
| 528 } | 528 } |
| 529 } | 529 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 584 |
| 585 timer.start(); | 585 timer.start(); |
| 586 // Inner loop that allows us to break the run into smaller | 586 // Inner loop that allows us to break the run into smaller |
| 587 // chunks (e.g. frames). This is especially useful for the GPU | 587 // chunks (e.g. frames). This is especially useful for the GPU |
| 588 // as we can flush and/or swap buffers to keep the GPU from | 588 // as we can flush and/or swap buffers to keep the GPU from |
| 589 // queuing up too much work. | 589 // queuing up too much work. |
| 590 for (int loopCount = loopsPerIter; loopCount > 0; ) { | 590 for (int loopCount = loopsPerIter; loopCount > 0; ) { |
| 591 // Save and restore around each call to draw() to guarantee
a pristine canvas. | 591 // Save and restore around each call to draw() to guarantee
a pristine canvas. |
| 592 SkAutoCanvasRestore saveRestore(canvas, true/*also save*/); | 592 SkAutoCanvasRestore saveRestore(canvas, true/*also save*/); |
| 593 | 593 |
| 594 int loops; |
| 594 if (frameIntervalComputed && loopCount > loopsPerFrame) { | 595 if (frameIntervalComputed && loopCount > loopsPerFrame) { |
| 595 bench->setLoops(loopsPerFrame); | 596 loops = loopsPerFrame; |
| 596 loopCount -= loopsPerFrame; | 597 loopCount -= loopsPerFrame; |
| 597 } else { | 598 } else { |
| 598 bench->setLoops(loopCount); | 599 loops = loopCount; |
| 599 loopCount = 0; | 600 loopCount = 0; |
| 600 } | 601 } |
| 601 | 602 |
| 602 if (benchMode == kPictureRecord_BenchMode) { | 603 if (benchMode == kPictureRecord_BenchMode) { |
| 603 recordFrom.draw(canvas); | 604 recordFrom.draw(canvas); |
| 604 } else { | 605 } else { |
| 605 bench->draw(canvas); | 606 bench->draw(loops, canvas); |
| 606 } | 607 } |
| 607 | 608 |
| 608 if (kDeferredSilent_BenchMode == benchMode) { | 609 if (kDeferredSilent_BenchMode == benchMode) { |
| 609 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus
h(); | 610 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus
h(); |
| 610 } else if (NULL != canvas) { | 611 } else if (NULL != canvas) { |
| 611 canvas->flush(); | 612 canvas->flush(); |
| 612 } | 613 } |
| 613 | 614 |
| 614 #if SK_SUPPORT_GPU | 615 #if SK_SUPPORT_GPU |
| 615 // swap drawing buffers on each frame to prevent the GPU | 616 // swap drawing buffers on each frame to prevent the GPU |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 gContextFactory.destroyContexts(); | 698 gContextFactory.destroyContexts(); |
| 698 #endif | 699 #endif |
| 699 return 0; | 700 return 0; |
| 700 } | 701 } |
| 701 | 702 |
| 702 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 703 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 703 int main(int argc, char * const argv[]) { | 704 int main(int argc, char * const argv[]) { |
| 704 return tool_main(argc, (char**) argv); | 705 return tool_main(argc, (char**) argv); |
| 705 } | 706 } |
| 706 #endif | 707 #endif |
| OLD | NEW |