Chromium Code Reviews| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 bench->getName(), config.name, FLAGS_maxMs, loopsPerIte r)); | 586 bench->getName(), config.name, FLAGS_maxMs, loopsPerIte r)); |
| 587 break; | 587 break; |
| 588 } | 588 } |
| 589 | 589 |
| 590 if ((benchMode == kRecord_BenchMode || benchMode == kPictureReco rd_BenchMode)) { | 590 if ((benchMode == kRecord_BenchMode || benchMode == kPictureReco rd_BenchMode)) { |
| 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 if (NULL != canvas) { | |
| 597 canvas->save(); | |
| 598 } | |
| 599 | |
| 600 // Inner loop that allows us to break the run into smaller | 596 // Inner loop that allows us to break the run into smaller |
| 601 // chunks (e.g. frames). This is especially useful for the GPU | 597 // chunks (e.g. frames). This is especially useful for the GPU |
| 602 // 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 |
| 603 // queuing up too much work. | 599 // queuing up too much work. |
| 604 for (int loopCount = loopsPerIter; loopCount > 0; ) { | 600 for (int loopCount = loopsPerIter; loopCount > 0; ) { |
| 601 if (NULL != canvas) { | |
|
reed1
2013/10/14 13:18:04
We have SkAutoCanvasRestore. One if its smarts is
| |
| 602 canvas->save(); | |
| 603 } | |
| 605 if (frameIntervalComputed && loopCount > loopsPerFrame) { | 604 if (frameIntervalComputed && loopCount > loopsPerFrame) { |
| 606 bench->setLoops(loopsPerFrame); | 605 bench->setLoops(loopsPerFrame); |
| 607 loopCount -= loopsPerFrame; | 606 loopCount -= loopsPerFrame; |
| 608 } else { | 607 } else { |
| 609 bench->setLoops(loopCount); | 608 bench->setLoops(loopCount); |
| 610 loopCount = 0; | 609 loopCount = 0; |
| 611 } | 610 } |
| 612 | 611 |
| 613 if (benchMode == kPictureRecord_BenchMode) { | 612 if (benchMode == kPictureRecord_BenchMode) { |
| 614 recordFrom.draw(canvas); | 613 recordFrom.draw(canvas); |
| 615 } else { | 614 } else { |
| 616 bench->draw(canvas); | 615 bench->draw(canvas); |
| 617 } | 616 } |
| 618 | 617 |
| 619 if (kDeferredSilent_BenchMode == benchMode) { | 618 if (kDeferredSilent_BenchMode == benchMode) { |
| 620 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus h(); | 619 static_cast<SkDeferredCanvas*>(canvas.get())->silentFlus h(); |
| 621 } else if (NULL != canvas) { | 620 } else if (NULL != canvas) { |
| 622 canvas->flush(); | 621 canvas->flush(); |
| 623 } | 622 } |
| 624 | 623 |
| 625 #if SK_SUPPORT_GPU | 624 #if SK_SUPPORT_GPU |
| 626 // swap drawing buffers on each frame to prevent the GPU | 625 // swap drawing buffers on each frame to prevent the GPU |
| 627 // from queuing up too much work | 626 // from queuing up too much work |
| 628 if (NULL != glContext) { | 627 if (NULL != glContext) { |
| 629 glContext->swapBuffers(); | 628 glContext->swapBuffers(); |
| 630 } | 629 } |
| 631 #endif | 630 #endif |
| 632 } | 631 if (NULL != canvas) { |
| 633 | 632 canvas->restore(); |
| 634 if (NULL != canvas) { | 633 } |
| 635 canvas->restore(); | |
| 636 } | 634 } |
| 637 | 635 |
| 638 | 636 |
| 637 | |
| 639 // Stop truncated timers before GL calls complete, and stop the full timers after. | 638 // Stop truncated timers before GL calls complete, and stop the full timers after. |
| 640 timer.truncatedEnd(); | 639 timer.truncatedEnd(); |
| 641 #if SK_SUPPORT_GPU | 640 #if SK_SUPPORT_GPU |
| 642 if (NULL != glContext) { | 641 if (NULL != glContext) { |
| 643 context->flush(); | 642 context->flush(); |
| 644 SK_GL(*glContext, Finish()); | 643 SK_GL(*glContext, Finish()); |
| 645 } | 644 } |
| 646 #endif | 645 #endif |
| 647 timer.end(); | 646 timer.end(); |
| 648 | 647 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 gContextFactory.destroyContexts(); | 710 gContextFactory.destroyContexts(); |
| 712 #endif | 711 #endif |
| 713 return 0; | 712 return 0; |
| 714 } | 713 } |
| 715 | 714 |
| 716 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 715 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 717 int main(int argc, char * const argv[]) { | 716 int main(int argc, char * const argv[]) { |
| 718 return tool_main(argc, (char**) argv); | 717 return tool_main(argc, (char**) argv); |
| 719 } | 718 } |
| 720 #endif | 719 #endif |
| OLD | NEW |