diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-07 20:48:56 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-07 20:48:56 +0000 |
commit | 5f97114fd28e03e8c4c1c22c924d383b45cdced1 (patch) | |
tree | 7a6287e1cb446c4b454512e753b458161077f97d /debugger | |
parent | c6b3e48cb3a22d83ba3f4b9a614a5a35b05958a0 (diff) |
Make debugger profiling honor deleted commands
https://codereview.appspot.com/6906043/
git-svn-id: http://skia.googlecode.com/svn/trunk@6713 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger')
-rw-r--r-- | debugger/QT/SkDebuggerGUI.cpp | 43 | ||||
-rw-r--r-- | debugger/QT/SkDebuggerGUI.h | 1 |
2 files changed, 36 insertions, 8 deletions
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index 25e0c57a4d..b301fcef66 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -141,11 +141,13 @@ class SkTimedPicturePlayback : public SkPicturePlayback { public: SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info, bool* isValid, SkSerializationHelpers::DecodeBitmap decoder, - const SkTDArray<size_t>& offsets) + const SkTDArray<size_t>& offsets, + const SkTDArray<bool>& deletedCommands) : INHERITED(stream, info, isValid, decoder) , fTot(0.0) , fCurCommand(0) - , fOffsets(offsets) { + , fOffsets(offsets) + , fSkipCommands(deletedCommands) { fTimes.setCount(fOffsets.count()); fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1); this->resetTimes(); @@ -172,6 +174,7 @@ public: protected: BenchSysTimer fTimer; SkTDArray<size_t> fOffsets; // offset in the SkPicture for each command + SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI? SkTDArray<double> fTimes; // sum of time consumed for each command SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath) double fTot; // total of all times in 'fTimes' @@ -179,7 +182,7 @@ protected: int fCurType; int fCurCommand; // the current command being executed/timed - virtual void preDraw(size_t offset, int type) { + virtual size_t preDraw(size_t offset, int type) SK_OVERRIDE { // This search isn't as bad as it seems. In normal playback mode, the // base class steps through the commands in order and can only skip ahead // a bit on a clip. This class is only used during profiling so we @@ -189,6 +192,17 @@ protected: SkASSERT(i <= fOffsets.count()); // should always find the offset in the list } + if (fSkipCommands[fCurCommand]) { + while (fCurCommand < fSkipCommands.count() && fSkipCommands[fCurCommand]) { + ++fCurCommand; + } + if (fCurCommand == fSkipCommands.count()) { + // Signal SkPicturePlayback to stop playing back + return SK_MaxU32; + } + return fOffsets[fCurCommand]; + } + fCurOffset = offset; fCurType = type; // The SkDebugCanvas doesn't recognize these types. This class needs to @@ -206,9 +220,11 @@ protected: #else fTimer.startCpu(); #endif + + return 0; } - virtual void postDraw(size_t offset) { + virtual void postDraw(size_t offset) SK_OVERRIDE { #if defined(SK_BUILD_FOR_WIN32) // CPU timer doesn't work well on Windows double time = fTimer.endWall(); @@ -234,7 +250,8 @@ public: explicit SkTimedPicture(SkStream* stream, bool* success, SkSerializationHelpers::DecodeBitmap decoder, - const SkTDArray<size_t>& offsets) { + const SkTDArray<size_t>& offsets, + const SkTDArray<bool>& deletedCommands) { if (success) { *success = false; } @@ -254,7 +271,7 @@ public: if (stream->readBool()) { bool isValid = false; fPlayback = SkNEW_ARGS(SkTimedPicturePlayback, - (stream, info, &isValid, decoder, offsets)); + (stream, info, &isValid, decoder, offsets, deletedCommands)); if (!isValid) { SkDELETE(fPlayback); fPlayback = NULL; @@ -341,7 +358,8 @@ void SkDebuggerGUI::actionProfile() { } bool success = false; - SkTimedPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream, fOffsets); + SkTimedPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream, + fOffsets, fSkipCommands); if (!success) { return; } @@ -407,6 +425,7 @@ void SkDebuggerGUI::actionClearDeletes() { QListWidgetItem* item = fListWidget.item(row); item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); fDebugger.setCommandVisible(row, true); + fSkipCommands[row] = false; } if (fPause) { fCanvasWidget.drawTo(fPausedRow); @@ -435,9 +454,11 @@ void SkDebuggerGUI::actionDelete() { if (fDebugger.isCommandVisible(currentRow)) { item->setData(Qt::UserRole + 2, QPixmap(":/delete.png")); fDebugger.setCommandVisible(currentRow, false); + fSkipCommands[currentRow] = true; } else { item->setData(Qt::UserRole + 2, QPixmap(":/blank.png")); fDebugger.setCommandVisible(currentRow, true); + fSkipCommands[currentRow] = false; } if (fPause) { @@ -882,8 +903,9 @@ public: protected: SkTDArray<size_t> fOffsets; - virtual void preDraw(size_t offset, int type) { + virtual size_t preDraw(size_t offset, int type) SK_OVERRIDE { *fOffsets.append() = offset; + return 0; } private: @@ -956,6 +978,11 @@ void SkDebuggerGUI::loadPicture(const SkString& fileName) { fOffsets = picture->offsets(); + fSkipCommands.setCount(fOffsets.count()); + for (int i = 0; i < fOffsets.count(); ++i) { + fSkipCommands[i] = false; + } + SkSafeUnref(stream); SkSafeUnref(picture); diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h index aed40721fe..75d3f28561 100644 --- a/debugger/QT/SkDebuggerGUI.h +++ b/debugger/QT/SkDebuggerGUI.h @@ -260,6 +260,7 @@ private: QString fPath; SkString fFileName; SkTDArray<size_t> fOffsets; // the offset of each command in the SkPicture + SkTDArray<bool> fSkipCommands; // has a specific command been deleted? bool fDirectoryWidgetActive; QMenuBar fMenuBar; |