| 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 "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 | 12 |
| 13 | 13 |
| 14 SkDebugger::SkDebugger() { | 14 SkDebugger::SkDebugger() { |
| 15 // Create this some other dynamic way? | 15 // Create this some other dynamic way? |
| 16 fDebugCanvas = new SkDebugCanvas(100, 100); | 16 fDebugCanvas = new SkDebugCanvas(0, 0); |
| 17 fPicture = NULL; | 17 fPicture = NULL; |
| 18 fPictureWidth = 0; | |
| 19 fPictureHeight = 0; | |
| 20 fIndex = 0; | 18 fIndex = 0; |
| 21 } | 19 } |
| 22 | 20 |
| 23 SkDebugger::~SkDebugger() { | 21 SkDebugger::~SkDebugger() { |
| 24 // Need to inherit from SkRef object in order for following to work | 22 // Need to inherit from SkRef object in order for following to work |
| 25 SkSafeUnref(fDebugCanvas); | 23 SkSafeUnref(fDebugCanvas); |
| 26 SkSafeUnref(fPicture); | 24 SkSafeUnref(fPicture); |
| 27 } | 25 } |
| 28 | 26 |
| 29 void SkDebugger::loadPicture(SkPicture* picture) { | 27 void SkDebugger::loadPicture(SkPicture* picture) { |
| 30 fPictureWidth = picture->width(); | 28 SkRefCnt_SafeAssign(fPicture, picture); |
| 31 fPictureHeight = picture->height(); | 29 |
| 32 delete fDebugCanvas; | 30 delete fDebugCanvas; |
| 33 fDebugCanvas = new SkDebugCanvas(fPictureWidth, fPictureHeight); | 31 fDebugCanvas = new SkDebugCanvas(SkScalarCeilToInt(this->pictureCull().width
()), |
| 34 fDebugCanvas->setBounds(fPictureWidth, fPictureHeight); | 32 SkScalarCeilToInt(this->pictureCull().heigh
t())); |
| 35 fDebugCanvas->setPicture(picture); | 33 fDebugCanvas->setPicture(picture); |
| 36 picture->draw(fDebugCanvas); | 34 picture->draw(fDebugCanvas); |
| 37 fDebugCanvas->setPicture(NULL); | 35 fDebugCanvas->setPicture(NULL); |
| 38 fIndex = fDebugCanvas->getSize() - 1; | 36 fIndex = fDebugCanvas->getSize() - 1; |
| 39 SkRefCnt_SafeAssign(fPicture, picture); | |
| 40 } | 37 } |
| 41 | 38 |
| 42 SkPicture* SkDebugger::copyPicture() { | 39 SkPicture* SkDebugger::copyPicture() { |
| 43 // We can't just call clone here since we want to removed the "deleted" | 40 // We can't just call clone here since we want to removed the "deleted" |
| 44 // commands. Playing back will strip those out. | 41 // commands. Playing back will strip those out. |
| 45 SkPictureRecorder recorder; | 42 SkPictureRecorder recorder; |
| 46 SkCanvas* canvas = recorder.beginRecording(fPictureWidth, fPictureHeight, NU
LL, 0); | 43 SkCanvas* canvas = recorder.beginRecording(this->pictureCull().width(), |
| 44 this->pictureCull().height()); |
| 47 | 45 |
| 48 bool vizMode = fDebugCanvas->getMegaVizMode(); | 46 bool vizMode = fDebugCanvas->getMegaVizMode(); |
| 49 fDebugCanvas->setMegaVizMode(false); | 47 fDebugCanvas->setMegaVizMode(false); |
| 50 bool overDraw = fDebugCanvas->getOverdrawViz(); | 48 bool overDraw = fDebugCanvas->getOverdrawViz(); |
| 51 fDebugCanvas->setOverdrawViz(false); | 49 fDebugCanvas->setOverdrawViz(false); |
| 52 bool pathOps = fDebugCanvas->getAllowSimplifyClip(); | 50 bool pathOps = fDebugCanvas->getAllowSimplifyClip(); |
| 53 fDebugCanvas->setAllowSimplifyClip(false); | 51 fDebugCanvas->setAllowSimplifyClip(false); |
| 54 int saveCount = fDebugCanvas->getOutstandingSaveCount(); | 52 int saveCount = fDebugCanvas->getOutstandingSaveCount(); |
| 55 fDebugCanvas->setOutstandingSaveCount(0); | 53 fDebugCanvas->setOutstandingSaveCount(0); |
| 56 | 54 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 #endif | 134 #endif |
| 137 overview->append("<br/>"); | 135 overview->append("<br/>"); |
| 138 } | 136 } |
| 139 | 137 |
| 140 SkString totalStr; | 138 SkString totalStr; |
| 141 totalStr.append("Total Draw Commands: "); | 139 totalStr.append("Total Draw Commands: "); |
| 142 totalStr.appendScalar(SkDoubleToScalar(total)); | 140 totalStr.appendScalar(SkDoubleToScalar(total)); |
| 143 totalStr.append("<br/>"); | 141 totalStr.append("<br/>"); |
| 144 overview->insert(0, totalStr); | 142 overview->insert(0, totalStr); |
| 145 | 143 |
| 144 overview->append("<br/>SkPicture L: "); |
| 145 overview->appendScalar(this->pictureCull().fLeft); |
| 146 overview->append(" T: "); |
| 147 overview->appendScalar(this->pictureCull().fTop); |
| 148 overview->append(" R: "); |
| 149 overview->appendScalar(this->pictureCull().fRight); |
| 150 overview->append(" B: "); |
| 151 overview->appendScalar(this->pictureCull().fBottom); |
| 146 overview->append("<br/>"); | 152 overview->append("<br/>"); |
| 147 overview->append("SkPicture Width: "); | |
| 148 overview->appendS32(pictureWidth()); | |
| 149 overview->append("px<br/>"); | |
| 150 overview->append("SkPicture Height: "); | |
| 151 overview->appendS32(pictureHeight()); | |
| 152 overview->append("px"); | |
| 153 } | 153 } |
| 154 | 154 |
| 155 void SkDebugger::getClipStackText(SkString* clipStack) { | 155 void SkDebugger::getClipStackText(SkString* clipStack) { |
| 156 clipStack->set(fDebugCanvas->clipStackData()); | 156 clipStack->set(fDebugCanvas->clipStackData()); |
| 157 } | 157 } |
| OLD | NEW |