| 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 "SkDebuggerGUI.h" | 8 #include "SkDebuggerGUI.h" |
| 9 #include "SkForceLinking.h" | 9 #include "SkForceLinking.h" |
| 10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 item->setHidden(fDebugger.isCommandVisible(row) | 140 item->setHidden(fDebugger.isCommandVisible(row) |
| 141 && fDeletesActivated); | 141 && fDeletesActivated); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 // The timed picture playback uses the SkPicturePlayback's profiling stubs | 145 // The timed picture playback uses the SkPicturePlayback's profiling stubs |
| 146 // to time individual commands. The offsets are needed to map SkPicture | 146 // to time individual commands. The offsets are needed to map SkPicture |
| 147 // offsets to individual commands. | 147 // offsets to individual commands. |
| 148 class SkTimedPicturePlayback : public SkPicturePlayback { | 148 class SkTimedPicturePlayback : public SkPicturePlayback { |
| 149 public: | 149 public: |
| 150 SkTimedPicturePlayback(SkStream* stream, const SkPictInfo& info, | 150 static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPi
ctInfo& info, |
| 151 SkPicture::InstallPixelRefProc proc, | 151 SkPicture::InstallPixelRefPr
oc proc, |
| 152 const SkTDArray<bool>& deletedCommands) | 152 const SkTDArray<bool>& delet
edCommands) { |
| 153 : INHERITED(stream, info, proc) | 153 // Mimics SkPicturePlayback::CreateFromStream |
| 154 SkAutoTDelete<SkTimedPicturePlayback> playback(SkNEW_ARGS(SkTimedPicture
Playback, |
| 155 (deletedComman
ds))); |
| 156 if (!playback->parseStream(stream, info, proc)) { |
| 157 return NULL; // we're invalid |
| 158 } |
| 159 return playback.detach(); |
| 160 } |
| 161 |
| 162 SkTimedPicturePlayback(const SkTDArray<bool>& deletedCommands) |
| 163 : INHERITED() |
| 154 , fSkipCommands(deletedCommands) | 164 , fSkipCommands(deletedCommands) |
| 155 , fTot(0.0) | 165 , fTot(0.0) |
| 156 , fCurCommand(0) { | 166 , fCurCommand(0) { |
| 157 fTimes.setCount(deletedCommands.count()); | 167 fTimes.setCount(deletedCommands.count()); |
| 158 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1); | 168 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1); |
| 159 this->resetTimes(); | 169 this->resetTimes(); |
| 160 } | 170 } |
| 161 | 171 |
| 162 void resetTimes() { | 172 void resetTimes() { |
| 163 for (int i = 0; i < fTimes.count(); ++i) { | 173 for (int i = 0; i < fTimes.count(); ++i) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 SkASSERT(opIndex == fCurCommand); | 235 SkASSERT(opIndex == fCurCommand); |
| 226 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM); | 236 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM); |
| 227 | 237 |
| 228 fTimes[fCurCommand] += time; | 238 fTimes[fCurCommand] += time; |
| 229 fTypeTimes[fCurType] += time; | 239 fTypeTimes[fCurType] += time; |
| 230 fTot += time; | 240 fTot += time; |
| 231 } | 241 } |
| 232 #endif | 242 #endif |
| 233 | 243 |
| 234 private: | 244 private: |
| 245 // SkPicturePlayback::parseStream is protected, so it can be |
| 246 // called here, but not by our static factory function. This |
| 247 // allows the factory function to call it. |
| 248 bool parseStream(SkStream* stream, const SkPictInfo& info, |
| 249 SkPicture::InstallPixelRefProc proc) { |
| 250 return this->INHERITED::parseStream(stream, info, proc); |
| 251 } |
| 252 |
| 235 typedef SkPicturePlayback INHERITED; | 253 typedef SkPicturePlayback INHERITED; |
| 236 }; | 254 }; |
| 237 | 255 |
| 238 // Wrap SkPicture to allow installation of an SkTimedPicturePlayback object | 256 // Wrap SkPicture to allow installation of an SkTimedPicturePlayback object |
| 239 class SkTimedPicture : public SkPicture { | 257 class SkTimedPicture : public SkPicture { |
| 240 public: | 258 public: |
| 241 static SkTimedPicture* CreateTimedPicture(SkStream* stream, | 259 static SkTimedPicture* CreateTimedPicture(SkStream* stream, |
| 242 SkPicture::InstallPixelRefProc pro
c, | 260 SkPicture::InstallPixelRefProc pro
c, |
| 243 const SkTDArray<bool>& deletedComm
ands) { | 261 const SkTDArray<bool>& deletedComm
ands) { |
| 244 SkPictInfo info; | 262 SkPictInfo info; |
| 245 if (!StreamIsSKP(stream, &info)) { | 263 if (!StreamIsSKP(stream, &info)) { |
| 246 return NULL; | 264 return NULL; |
| 247 } | 265 } |
| 248 | 266 |
| 249 SkTimedPicturePlayback* playback; | 267 SkTimedPicturePlayback* playback; |
| 250 // Check to see if there is a playback to recreate. | 268 // Check to see if there is a playback to recreate. |
| 251 if (stream->readBool()) { | 269 if (stream->readBool()) { |
| 252 playback = SkNEW_ARGS(SkTimedPicturePlayback, | 270 playback = SkTimedPicturePlayback::CreateFromStream(stream, info, pr
oc, |
| 253 (stream, info, proc, deletedCommands)); | 271 deletedCommands)
; |
| 272 if (NULL == playback) { |
| 273 return NULL; |
| 274 } |
| 254 } else { | 275 } else { |
| 255 playback = NULL; | 276 playback = NULL; |
| 256 } | 277 } |
| 257 | 278 |
| 258 return SkNEW_ARGS(SkTimedPicture, (playback, info.fWidth, info.fHeight))
; | 279 return SkNEW_ARGS(SkTimedPicture, (playback, info.fWidth, info.fHeight))
; |
| 259 } | 280 } |
| 260 | 281 |
| 261 void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); } | 282 void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); } |
| 262 | 283 |
| 263 int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); } | 284 int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); } |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 } | 1028 } |
| 1008 | 1029 |
| 1009 // NOTE(chudy): Makes first item unselectable. | 1030 // NOTE(chudy): Makes first item unselectable. |
| 1010 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( | 1031 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( |
| 1011 fFilter.model()); | 1032 fFilter.model()); |
| 1012 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), | 1033 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), |
| 1013 fFilter.rootModelIndex()); | 1034 fFilter.rootModelIndex()); |
| 1014 QStandardItem* firstItem = model->itemFromIndex(firstIndex); | 1035 QStandardItem* firstItem = model->itemFromIndex(firstIndex); |
| 1015 firstItem->setSelectable(false); | 1036 firstItem->setSelectable(false); |
| 1016 } | 1037 } |
| OLD | NEW |