| 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 : fPicture(NULL) | 15 : fPicture(nullptr) |
| 16 , fIndex(-1) { | 16 , fIndex(-1) { |
| 17 // Create this some other dynamic way? | 17 // Create this some other dynamic way? |
| 18 fDebugCanvas = new SkDebugCanvas(0, 0); | 18 fDebugCanvas = new SkDebugCanvas(0, 0); |
| 19 } | 19 } |
| 20 | 20 |
| 21 SkDebugger::~SkDebugger() { | 21 SkDebugger::~SkDebugger() { |
| 22 // 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 |
| 23 SkSafeUnref(fDebugCanvas); | 23 SkSafeUnref(fDebugCanvas); |
| 24 SkSafeUnref(fPicture); | 24 SkSafeUnref(fPicture); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void SkDebugger::loadPicture(SkPicture* picture) { | 27 void SkDebugger::loadPicture(SkPicture* picture) { |
| 28 SkRefCnt_SafeAssign(fPicture, picture); | 28 SkRefCnt_SafeAssign(fPicture, picture); |
| 29 | 29 |
| 30 delete fDebugCanvas; | 30 delete fDebugCanvas; |
| 31 fDebugCanvas = new SkDebugCanvas(SkScalarCeilToInt(this->pictureCull().width
()), | 31 fDebugCanvas = new SkDebugCanvas(SkScalarCeilToInt(this->pictureCull().width
()), |
| 32 SkScalarCeilToInt(this->pictureCull().heigh
t())); | 32 SkScalarCeilToInt(this->pictureCull().heigh
t())); |
| 33 fDebugCanvas->setPicture(picture); | 33 fDebugCanvas->setPicture(picture); |
| 34 picture->playback(fDebugCanvas); | 34 picture->playback(fDebugCanvas); |
| 35 fDebugCanvas->setPicture(NULL); | 35 fDebugCanvas->setPicture(nullptr); |
| 36 fIndex = fDebugCanvas->getSize() - 1; | 36 fIndex = fDebugCanvas->getSize() - 1; |
| 37 } | 37 } |
| 38 | 38 |
| 39 SkPicture* SkDebugger::copyPicture() { | 39 SkPicture* SkDebugger::copyPicture() { |
| 40 // 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" |
| 41 // commands. Playing back will strip those out. | 41 // commands. Playing back will strip those out. |
| 42 SkPictureRecorder recorder; | 42 SkPictureRecorder recorder; |
| 43 SkCanvas* canvas = recorder.beginRecording(this->pictureCull().width(), | 43 SkCanvas* canvas = recorder.beginRecording(this->pictureCull().width(), |
| 44 this->pictureCull().height()); | 44 this->pictureCull().height()); |
| 45 | 45 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 overview->reset(); | 78 overview->reset(); |
| 79 int total = 0; | 79 int total = 0; |
| 80 #ifdef SK_DEBUG | 80 #ifdef SK_DEBUG |
| 81 double totPercent = 0, tempSum = 0; | 81 double totPercent = 0, tempSum = 0; |
| 82 #endif | 82 #endif |
| 83 for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) { | 83 for (int i = 0; i < SkDrawCommand::kOpTypeCount; ++i) { |
| 84 if (0 == counts[i]) { | 84 if (0 == counts[i]) { |
| 85 // if there were no commands of this type then they should've consum
ed no time | 85 // if there were no commands of this type then they should've consum
ed no time |
| 86 SkASSERT(NULL == typeTimes || 0.0 == (*typeTimes)[i]); | 86 SkASSERT(nullptr == typeTimes || 0.0 == (*typeTimes)[i]); |
| 87 continue; | 87 continue; |
| 88 } | 88 } |
| 89 | 89 |
| 90 overview->append(SkDrawCommand::GetCommandString((SkDrawCommand::OpType)
i)); | 90 overview->append(SkDrawCommand::GetCommandString((SkDrawCommand::OpType)
i)); |
| 91 overview->append(": "); | 91 overview->append(": "); |
| 92 overview->appendS32(counts[i]); | 92 overview->appendS32(counts[i]); |
| 93 if (typeTimes && totTime >= 0.0) { | 93 if (typeTimes && totTime >= 0.0) { |
| 94 overview->append(" - "); | 94 overview->append(" - "); |
| 95 overview->appendf("%.2f", (*typeTimes)[i]/(float)numRuns); | 95 overview->appendf("%.2f", (*typeTimes)[i]/(float)numRuns); |
| 96 overview->append("ms"); | 96 overview->append("ms"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 overview->append(" R: "); | 140 overview->append(" R: "); |
| 141 overview->appendScalar(this->pictureCull().fRight); | 141 overview->appendScalar(this->pictureCull().fRight); |
| 142 overview->append(" B: "); | 142 overview->append(" B: "); |
| 143 overview->appendScalar(this->pictureCull().fBottom); | 143 overview->appendScalar(this->pictureCull().fBottom); |
| 144 overview->append("<br/>"); | 144 overview->append("<br/>"); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void SkDebugger::getClipStackText(SkString* clipStack) { | 147 void SkDebugger::getClipStackText(SkString* clipStack) { |
| 148 clipStack->set(fDebugCanvas->clipStackData()); | 148 clipStack->set(fDebugCanvas->clipStackData()); |
| 149 } | 149 } |
| OLD | NEW |