| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkDebugCanvas.h" | 8 #include "SkDebugCanvas.h" |
| 9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 debugCanvas.setBounds(inPicture->width(), inPicture->height()); | 529 debugCanvas.setBounds(inPicture->width(), inPicture->height()); |
| 530 inPicture->draw(&debugCanvas); | 530 inPicture->draw(&debugCanvas); |
| 531 | 531 |
| 532 // delete the initial save and restore since replaying the commands will | 532 // delete the initial save and restore since replaying the commands will |
| 533 // re-add them | 533 // re-add them |
| 534 if (debugCanvas.getSize() > 1) { | 534 if (debugCanvas.getSize() > 1) { |
| 535 debugCanvas.deleteDrawCommandAt(0); | 535 debugCanvas.deleteDrawCommandAt(0); |
| 536 debugCanvas.deleteDrawCommandAt(debugCanvas.getSize()-1); | 536 debugCanvas.deleteDrawCommandAt(debugCanvas.getSize()-1); |
| 537 } | 537 } |
| 538 | 538 |
| 539 for (int i = 0; i < debugCanvas.getSize(); ++i) { | 539 bool changed = true; |
| 540 for (size_t opt = 0; opt < SK_ARRAY_COUNT(gOptTable); ++opt) { | 540 |
| 541 if ((*gOptTable[opt].fCheck)(&debugCanvas, i)) { | 541 while (changed) { |
| 542 (*gOptTable[opt].fApply)(&debugCanvas, i); | 542 changed = false; |
| 543 ++gOptTable[opt].fNumTimesApplied; | 543 for (int i = 0; i < debugCanvas.getSize(); ++i) { |
| 544 ++localCount[opt]; | 544 for (size_t opt = 0; opt < SK_ARRAY_COUNT(gOptTable); ++opt) { |
| 545 if ((*gOptTable[opt].fCheck)(&debugCanvas, i)) { |
| 546 (*gOptTable[opt].fApply)(&debugCanvas, i); |
| 547 |
| 548 ++gOptTable[opt].fNumTimesApplied; |
| 549 ++localCount[opt]; |
| 550 |
| 551 if (debugCanvas.getSize() == i) { |
| 552 // the optimization removed all the remaining operations |
| 553 break; |
| 554 } |
| 555 |
| 556 opt = 0; // try all the opts all over again |
| 557 changed = true; |
| 558 } |
| 545 } | 559 } |
| 546 } | 560 } |
| 547 } | 561 } |
| 548 | 562 |
| 549 if (!outFile.isEmpty()) { | 563 if (!outFile.isEmpty()) { |
| 550 SkPicture outPicture; | 564 SkPicture outPicture; |
| 551 | 565 |
| 552 SkCanvas* canvas = outPicture.beginRecording(inPicture->width(), inPictu
re->height()); | 566 SkCanvas* canvas = outPicture.beginRecording(inPicture->width(), inPictu
re->height()); |
| 553 debugCanvas.draw(canvas); | 567 debugCanvas.draw(canvas); |
| 554 outPicture.endRecording(); | 568 outPicture.endRecording(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 678 |
| 665 SkGraphics::Term(); | 679 SkGraphics::Term(); |
| 666 return 0; | 680 return 0; |
| 667 } | 681 } |
| 668 | 682 |
| 669 #if !defined SK_BUILD_FOR_IOS | 683 #if !defined SK_BUILD_FOR_IOS |
| 670 int main(int argc, char * const argv[]) { | 684 int main(int argc, char * const argv[]) { |
| 671 return tool_main(argc, (char**) argv); | 685 return tool_main(argc, (char**) argv); |
| 672 } | 686 } |
| 673 #endif | 687 #endif |
| OLD | NEW |