OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 #include "SkDebugger.h" | 9 #include "SkDebugger.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 SkSafeUnref(fDebugCanvas); | 24 SkSafeUnref(fDebugCanvas); |
25 SkSafeUnref(fPicture); | 25 SkSafeUnref(fPicture); |
26 } | 26 } |
27 | 27 |
28 void SkDebugger::loadPicture(SkPicture* picture) { | 28 void SkDebugger::loadPicture(SkPicture* picture) { |
29 fPictureWidth = picture->width(); | 29 fPictureWidth = picture->width(); |
30 fPictureHeight = picture->height(); | 30 fPictureHeight = picture->height(); |
31 delete fDebugCanvas; | 31 delete fDebugCanvas; |
32 fDebugCanvas = new SkDebugCanvas(fPictureWidth, fPictureHeight); | 32 fDebugCanvas = new SkDebugCanvas(fPictureWidth, fPictureHeight); |
33 fDebugCanvas->setBounds(fPictureWidth, fPictureHeight); | 33 fDebugCanvas->setBounds(fPictureWidth, fPictureHeight); |
| 34 fDebugCanvas->setPicture(picture); |
34 picture->draw(fDebugCanvas); | 35 picture->draw(fDebugCanvas); |
| 36 fDebugCanvas->setPicture(NULL); |
35 fIndex = fDebugCanvas->getSize() - 1; | 37 fIndex = fDebugCanvas->getSize() - 1; |
36 SkRefCnt_SafeAssign(fPicture, picture); | 38 SkRefCnt_SafeAssign(fPicture, picture); |
37 } | 39 } |
38 | 40 |
39 SkPicture* SkDebugger::copyPicture() { | 41 SkPicture* SkDebugger::copyPicture() { |
40 // We can't just call clone here since we want to removed the "deleted" | 42 // We can't just call clone here since we want to removed the "deleted" |
41 // commands. Playing back will strip those out. | 43 // commands. Playing back will strip those out. |
42 SkPicture* newPicture = new SkPicture; | 44 SkPicture* newPicture = new SkPicture; |
43 SkCanvas* canvas = newPicture->beginRecording(fPictureWidth, fPictureHeight)
; | 45 SkCanvas* canvas = newPicture->beginRecording(fPictureWidth, fPictureHeight)
; |
| 46 |
| 47 bool vizMode = fDebugCanvas->getMegaVizMode(); |
| 48 fDebugCanvas->setMegaVizMode(false); |
| 49 bool overDraw = fDebugCanvas->getOverdrawViz(); |
| 50 fDebugCanvas->setOverdrawViz(false); |
| 51 int saveCount = fDebugCanvas->getOutstandingSaveCount(); |
| 52 fDebugCanvas->setOutstandingSaveCount(0); |
| 53 |
44 fDebugCanvas->draw(canvas); | 54 fDebugCanvas->draw(canvas); |
| 55 |
| 56 int temp = fDebugCanvas->getOutstandingSaveCount(); |
| 57 for (int i = 0; i < temp; ++i) { |
| 58 canvas->restore(); |
| 59 } |
| 60 |
| 61 fDebugCanvas->setMegaVizMode(vizMode); |
| 62 fDebugCanvas->setOverdrawViz(overDraw); |
| 63 fDebugCanvas->setOutstandingSaveCount(saveCount); |
| 64 |
45 newPicture->endRecording(); | 65 newPicture->endRecording(); |
46 return newPicture; | 66 return newPicture; |
47 } | 67 } |
48 | 68 |
49 void SkDebugger::getOverviewText(const SkTDArray<double>* typeTimes, | 69 void SkDebugger::getOverviewText(const SkTDArray<double>* typeTimes, |
50 double totTime, | 70 double totTime, |
51 SkString* overview, | 71 SkString* overview, |
52 int numRuns) { | 72 int numRuns) { |
53 const SkTDArray<SkDrawCommand*>& commands = this->getDrawCommands(); | 73 const SkTDArray<SkDrawCommand*>& commands = this->getDrawCommands(); |
54 | 74 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 overview->insert(0, totalStr); | 141 overview->insert(0, totalStr); |
122 | 142 |
123 overview->append("<br/>"); | 143 overview->append("<br/>"); |
124 overview->append("SkPicture Width: "); | 144 overview->append("SkPicture Width: "); |
125 overview->appendS32(pictureWidth()); | 145 overview->appendS32(pictureWidth()); |
126 overview->append("px<br/>"); | 146 overview->append("px<br/>"); |
127 overview->append("SkPicture Height: "); | 147 overview->append("SkPicture Height: "); |
128 overview->appendS32(pictureHeight()); | 148 overview->appendS32(pictureHeight()); |
129 overview->append("px"); | 149 overview->append("px"); |
130 } | 150 } |
OLD | NEW |