| 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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 // Clear the recorded commands so that they do not accumulat
e. | 591 // Clear the recorded commands so that they do not accumulat
e. |
| 592 canvas.reset(recordTo.beginRecording(dim.fX, dim.fY, kRecord
Flags)); | 592 canvas.reset(recordTo.beginRecording(dim.fX, dim.fY, kRecord
Flags)); |
| 593 } | 593 } |
| 594 | 594 |
| 595 timer.start(); | 595 timer.start(); |
| 596 // Inner loop that allows us to break the run into smaller | 596 // Inner loop that allows us to break the run into smaller |
| 597 // chunks (e.g. frames). This is especially useful for the GPU | 597 // chunks (e.g. frames). This is especially useful for the GPU |
| 598 // as we can flush and/or swap buffers to keep the GPU from | 598 // as we can flush and/or swap buffers to keep the GPU from |
| 599 // queuing up too much work. | 599 // queuing up too much work. |
| 600 for (int loopCount = loopsPerIter; loopCount > 0; ) { | 600 for (int loopCount = loopsPerIter; loopCount > 0; ) { |
| 601 if (NULL != canvas) { | 601 // Save and restore around each call to draw() to guarantee
a pristine canvas. |
| 602 canvas->save(); | 602 SkAutoCanvasRestore saveRestore(canvas, true/*also save*/); |
| 603 } | 603 |
| 604 if (frameIntervalComputed && loopCount > loopsPerFrame) { | 604 if (frameIntervalComputed && loopCount > loopsPerFrame) { |
| 605 bench->setLoops(loopsPerFrame); | 605 bench->setLoops(loopsPerFrame); |
| 606 loopCount -= loopsPerFrame; | 606 loopCount -= loopsPerFrame; |
| 607 } else { | 607 } else { |
| 608 bench->setLoops(loopCount); | 608 bench->setLoops(loopCount); |
| 609 loopCount = 0; | 609 loopCount = 0; |
| 610 } | 610 } |
| 611 | 611 |
| 612 if (benchMode == kPictureRecord_BenchMode) { | 612 if (benchMode == kPictureRecord_BenchMode) { |
| 613 recordFrom.draw(canvas); | 613 recordFrom.draw(canvas); |
| 614 } else { | 614 } else { |
| 615 bench->draw(canvas); | 615 bench->draw(canvas); |
| 616 } | 616 } |
| 617 | 617 |
| 618 if (kDeferredSilent_BenchMode == benchMode) { | 618 if (kDeferredSilent_BenchMode == benchMode) { |
| 619 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus
h(); | 619 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus
h(); |
| 620 } else if (NULL != canvas) { | 620 } else if (NULL != canvas) { |
| 621 canvas->flush(); | 621 canvas->flush(); |
| 622 } | 622 } |
| 623 | 623 |
| 624 #if SK_SUPPORT_GPU | 624 #if SK_SUPPORT_GPU |
| 625 // swap drawing buffers on each frame to prevent the GPU | 625 // swap drawing buffers on each frame to prevent the GPU |
| 626 // from queuing up too much work | 626 // from queuing up too much work |
| 627 if (NULL != glContext) { | 627 if (NULL != glContext) { |
| 628 glContext->swapBuffers(); | 628 glContext->swapBuffers(); |
| 629 } | 629 } |
| 630 #endif | 630 #endif |
| 631 if (NULL != canvas) { | |
| 632 canvas->restore(); | |
| 633 } | |
| 634 } | 631 } |
| 635 | 632 |
| 636 | 633 |
| 637 | 634 |
| 638 // Stop truncated timers before GL calls complete, and stop the
full timers after. | 635 // Stop truncated timers before GL calls complete, and stop the
full timers after. |
| 639 timer.truncatedEnd(); | 636 timer.truncatedEnd(); |
| 640 #if SK_SUPPORT_GPU | 637 #if SK_SUPPORT_GPU |
| 641 if (NULL != glContext) { | 638 if (NULL != glContext) { |
| 642 context->flush(); | 639 context->flush(); |
| 643 SK_GL(*glContext, Finish()); | 640 SK_GL(*glContext, Finish()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 gContextFactory.destroyContexts(); | 707 gContextFactory.destroyContexts(); |
| 711 #endif | 708 #endif |
| 712 return 0; | 709 return 0; |
| 713 } | 710 } |
| 714 | 711 |
| 715 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 712 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 716 int main(int argc, char * const argv[]) { | 713 int main(int argc, char * const argv[]) { |
| 717 return tool_main(argc, (char**) argv); | 714 return tool_main(argc, (char**) argv); |
| 718 } | 715 } |
| 719 #endif | 716 #endif |
| OLD | NEW |