Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: debugger/QT/SkDebuggerGUI.cpp

Issue 377623002: Split SkPicturePlayback out of SkPictureData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add virtual dtor for SkPicturePlayback Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « debugger/QT/SkDebuggerGUI.h ('k') | gyp/core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkImageDecoder.h" 11 #include "SkImageDecoder.h"
12 #include <QListWidgetItem> 12 #include <QListWidgetItem>
13 #include "PictureRenderer.h" 13 #include "PictureRenderer.h"
14 #include "SkPicturePlayback.h"
14 #include "SkPictureRecord.h" 15 #include "SkPictureRecord.h"
15 #include "SkPictureData.h" 16 #include "SkPictureData.h"
16 17
17 __SK_FORCE_IMAGE_DECODER_LINKING; 18 __SK_FORCE_IMAGE_DECODER_LINKING;
18 19
19 #if defined(SK_BUILD_FOR_WIN32) 20 #if defined(SK_BUILD_FOR_WIN32)
20 #include "SysTimer_windows.h" 21 #include "SysTimer_windows.h"
21 #elif defined(SK_BUILD_FOR_MAC) 22 #elif defined(SK_BUILD_FOR_MAC)
22 #include "SysTimer_mach.h" 23 #include "SysTimer_mach.h"
23 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID) 24 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 fDeletesActivated = !fDeletesActivated; 152 fDeletesActivated = !fDeletesActivated;
152 for (int row = 0; row < fListWidget.count(); row++) { 153 for (int row = 0; row < fListWidget.count(); row++) {
153 QListWidgetItem *item = fListWidget.item(row); 154 QListWidgetItem *item = fListWidget.item(row);
154 item->setHidden(fDebugger.isCommandVisible(row) && fDeletesActivated); 155 item->setHidden(fDebugger.isCommandVisible(row) && fDeletesActivated);
155 } 156 }
156 } 157 }
157 158
158 // The timed picture playback uses the SkPictureData's profiling stubs 159 // The timed picture playback uses the SkPictureData's profiling stubs
159 // to time individual commands. The offsets are needed to map SkPicture 160 // to time individual commands. The offsets are needed to map SkPicture
160 // offsets to individual commands. 161 // offsets to individual commands.
161 class SkTimedPicturePlayback : public SkPictureData { 162 class SkTimedPicturePlayback : public SkPicturePlayback {
162 public: 163 public:
163 static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPi ctInfo& info,
164 SkPicture::InstallPixelRefPr oc proc,
165 const SkTDArray<bool>& delet edCommands) {
166 // Mimics SkPictureData::CreateFromStream
167 SkAutoTDelete<SkTimedPicturePlayback> playback(SkNEW_ARGS(SkTimedPicture Playback,
168 (deletedCommands, info)));
169 if (!playback->parseStream(stream, proc)) {
170 return NULL; // we're invalid
171 }
172 return playback.detach();
173 }
174 164
175 SkTimedPicturePlayback(const SkTDArray<bool>& deletedCommands, 165 SkTimedPicturePlayback(const SkPicture* picture, const SkTDArray<bool>& dele tedCommands)
176 const SkPictInfo& info) 166 : INHERITED(picture)
177 : INHERITED(info)
178 , fSkipCommands(deletedCommands) 167 , fSkipCommands(deletedCommands)
179 , fTot(0.0) 168 , fTot(0.0)
180 , fCurCommand(0) { 169 , fCurCommand(0) {
181 fTimes.setCount(deletedCommands.count()); 170 fTimes.setCount(deletedCommands.count());
182 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1); 171 fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1);
183 this->resetTimes(); 172 this->resetTimes();
184 } 173 }
185 174
186 void resetTimes() { 175 void resetTimes() {
187 for (int i = 0; i < fTimes.count(); ++i) { 176 for (int i = 0; i < fTimes.count(); ++i) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 SkASSERT(opIndex == fCurCommand); 238 SkASSERT(opIndex == fCurCommand);
250 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM); 239 SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM);
251 240
252 fTimes[fCurCommand] += time; 241 fTimes[fCurCommand] += time;
253 fTypeTimes[fCurType] += time; 242 fTypeTimes[fCurType] += time;
254 fTot += time; 243 fTot += time;
255 } 244 }
256 #endif 245 #endif
257 246
258 private: 247 private:
259 typedef SkPictureData INHERITED; 248 typedef SkPicturePlayback INHERITED;
260 }; 249 };
261 250
251 #if 0
262 // Wrap SkPicture to allow installation of an SkTimedPicturePlayback object 252 // Wrap SkPicture to allow installation of an SkTimedPicturePlayback object
263 class SkTimedPicture : public SkPicture { 253 class SkTimedPicture : public SkPicture {
264 public: 254 public:
265 static SkTimedPicture* CreateTimedPicture(SkStream* stream, 255 static SkTimedPicture* CreateTimedPicture(SkStream* stream,
266 SkPicture::InstallPixelRefProc pro c, 256 SkPicture::InstallPixelRefProc pro c,
267 const SkTDArray<bool>& deletedComm ands) { 257 const SkTDArray<bool>& deletedComm ands) {
268 SkPictInfo info; 258 SkPictInfo info;
269 if (!InternalOnly_StreamIsSKP(stream, &info)) { 259 if (!InternalOnly_StreamIsSKP(stream, &info)) {
270 return NULL; 260 return NULL;
271 } 261 }
(...skipping 29 matching lines...) Expand all
301 // disallow default ctor b.c. we don't have a good way to setup the fData pt r 291 // disallow default ctor b.c. we don't have a good way to setup the fData pt r
302 SkTimedPicture(); 292 SkTimedPicture();
303 // Private ctor only used by CreateTimedPicture, which has created the playb ack. 293 // Private ctor only used by CreateTimedPicture, which has created the playb ack.
304 SkTimedPicture(SkTimedPicturePlayback* playback, int width, int height) 294 SkTimedPicture(SkTimedPicturePlayback* playback, int width, int height)
305 : INHERITED(playback, width, height) {} 295 : INHERITED(playback, width, height) {}
306 // disallow the copy ctor - enabling would require copying code from SkPictu re 296 // disallow the copy ctor - enabling would require copying code from SkPictu re
307 SkTimedPicture(const SkTimedPicture& src); 297 SkTimedPicture(const SkTimedPicture& src);
308 298
309 typedef SkPicture INHERITED; 299 typedef SkPicture INHERITED;
310 }; 300 };
301 #endif
311 302
312 // This is a simplification of PictureBenchmark's run with the addition of 303 // This is a simplification of PictureBenchmark's run with the addition of
313 // clearing of the times after the first pass (in resetTimes) 304 // clearing of the times after the first pass (in resetTimes)
314 void SkDebuggerGUI::run(SkTimedPicture* pict, 305 void SkDebuggerGUI::run(const SkPicture* pict,
315 sk_tools::PictureRenderer* renderer, 306 sk_tools::PictureRenderer* renderer,
316 int repeats) { 307 int repeats) {
317 SkASSERT(pict); 308 SkASSERT(pict);
318 if (NULL == pict) { 309 if (NULL == pict) {
319 return; 310 return;
320 } 311 }
321 312
322 SkASSERT(renderer != NULL); 313 SkASSERT(renderer != NULL);
323 if (NULL == renderer) { 314 if (NULL == renderer) {
324 return; 315 return;
325 } 316 }
326 317
327 renderer->init(pict, NULL, NULL, NULL, false); 318 renderer->init(pict, NULL, NULL, NULL, false);
328 319
329 renderer->setup(); 320 renderer->setup();
330 renderer->render(); 321 renderer->render();
331 renderer->resetState(true); // flush, swapBuffers and Finish 322 renderer->resetState(true); // flush, swapBuffers and Finish
332 323
324 #if 0
333 // We throw this away the first batch of times to remove first time effects (such as paging in this program) 325 // We throw this away the first batch of times to remove first time effects (such as paging in this program)
334 pict->resetTimes(); 326 pict->resetTimes();
327 #endif
335 328
336 for (int i = 0; i < repeats; ++i) { 329 for (int i = 0; i < repeats; ++i) {
337 renderer->setup(); 330 renderer->setup();
338 renderer->render(); 331 renderer->render();
339 renderer->resetState(false); // flush & swapBuffers, but don't Finish 332 renderer->resetState(false); // flush & swapBuffers, but don't Finish
340 } 333 }
341 renderer->resetState(true); // flush, swapBuffers and Finish 334 renderer->resetState(true); // flush, swapBuffers and Finish
342 335
343 renderer->end(); 336 renderer->end();
344 } 337 }
345 338
346 void SkDebuggerGUI::actionProfile() { 339 void SkDebuggerGUI::actionProfile() {
347 // In order to profile we pass the command offsets (that were read-in 340 // In order to profile we pass the command offsets (that were read-in
348 // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture. 341 // in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture.
349 // The SkTimedPlaybackPicture in turn passes the offsets to an 342 // The SkTimedPlaybackPicture in turn passes the offsets to an
350 // SkTimedPicturePlayback object which uses them to track the performance 343 // SkTimedPicturePlayback object which uses them to track the performance
351 // of individual commands. 344 // of individual commands.
352 if (fFileName.isEmpty()) { 345 if (fFileName.isEmpty()) {
353 return; 346 return;
354 } 347 }
355 348
356 SkFILEStream inputStream; 349 SkFILEStream inputStream;
357 350
358 inputStream.setPath(fFileName.c_str()); 351 inputStream.setPath(fFileName.c_str());
359 if (!inputStream.isValid()) { 352 if (!inputStream.isValid()) {
360 return; 353 return;
361 } 354 }
362 355
363 SkAutoTUnref<SkTimedPicture> picture(SkTimedPicture::CreateTimedPicture(&inp utStream, 356 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream,
364 &SkImageDecoder::DecodeMemory, fSkipCom mands)); 357 &SkImageDecoder::DecodeMemory)); // , fS kipCommands));
365 if (NULL == picture.get()) { 358 if (NULL == picture.get()) {
366 return; 359 return;
367 } 360 }
368 361
362
363 #if 0
364
369 // For now this #if allows switching between tiled and simple rendering 365 // For now this #if allows switching between tiled and simple rendering
370 // modes. Eventually this will be accomplished via the GUI 366 // modes. Eventually this will be accomplished via the GUI
371 #if 0 367 #if 0
372 // With the current batch of SysTimers, profiling in tiled mode 368 // With the current batch of SysTimers, profiling in tiled mode
373 // gets swamped by the timing overhead: 369 // gets swamped by the timing overhead:
374 // 370 //
375 // tile mode simple mode 371 // tile mode simple mode
376 // debugger 64.2ms 12.8ms 372 // debugger 64.2ms 12.8ms
377 // bench_pictures 16.9ms 12.4ms 373 // bench_pictures 16.9ms 12.4ms
378 // 374 //
(...skipping 28 matching lines...) Expand all
407 for (int i = 0; i < picture->count(); ++i) { 403 for (int i = 0; i < picture->count(); ++i) {
408 double temp = picture->time(i); 404 double temp = picture->time(i);
409 405
410 QListWidgetItem* item = fListWidget.item(i); 406 QListWidgetItem* item = fListWidget.item(i);
411 407
412 item->setData(Qt::UserRole + 4, 100.0*temp); 408 item->setData(Qt::UserRole + 4, 100.0*temp);
413 } 409 }
414 410
415 setupOverviewText(picture->typeTimes(), picture->totTime(), kNumRepeats); 411 setupOverviewText(picture->typeTimes(), picture->totTime(), kNumRepeats);
416 setupClipStackText(); 412 setupClipStackText();
413
414 #endif
417 } 415 }
418 416
419 void SkDebuggerGUI::actionCancel() { 417 void SkDebuggerGUI::actionCancel() {
420 for (int row = 0; row < fListWidget.count(); row++) { 418 for (int row = 0; row < fListWidget.count(); row++) {
421 fListWidget.item(row)->setHidden(false); 419 fListWidget.item(row)->setHidden(false);
422 } 420 }
423 } 421 }
424 422
425 void SkDebuggerGUI::actionClearBreakpoints() { 423 void SkDebuggerGUI::actionClearBreakpoints() {
426 for (int row = 0; row < fListWidget.count(); row++) { 424 for (int row = 0; row < fListWidget.count(); row++) {
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 } 1067 }
1070 1068
1071 // NOTE(chudy): Makes first item unselectable. 1069 // NOTE(chudy): Makes first item unselectable.
1072 QStandardItemModel* model = qobject_cast<QStandardItemModel*>( 1070 QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
1073 fFilter.model()); 1071 fFilter.model());
1074 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(), 1072 QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
1075 fFilter.rootModelIndex()); 1073 fFilter.rootModelIndex());
1076 QStandardItem* firstItem = model->itemFromIndex(firstIndex); 1074 QStandardItem* firstItem = model->itemFromIndex(firstIndex);
1077 firstItem->setSelectable(false); 1075 firstItem->setSelectable(false);
1078 } 1076 }
OLDNEW
« no previous file with comments | « debugger/QT/SkDebuggerGUI.h ('k') | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698