2012-06-29 14:21:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkDebuggerGUI.h"
|
2013-05-31 14:00:10 +00:00
|
|
|
#include "SkForceLinking.h"
|
2012-08-13 14:26:36 +00:00
|
|
|
#include "SkGraphics.h"
|
2012-11-06 23:10:09 +00:00
|
|
|
#include "SkImageDecoder.h"
|
2012-06-29 14:21:22 +00:00
|
|
|
#include <QListWidgetItem>
|
2012-11-15 14:57:57 +00:00
|
|
|
#include "PictureRenderer.h"
|
|
|
|
#include "SkPictureRecord.h"
|
|
|
|
#include "SkPicturePlayback.h"
|
2012-11-27 16:04:42 +00:00
|
|
|
|
2013-05-31 14:00:10 +00:00
|
|
|
__SK_FORCE_IMAGE_DECODER_LINKING;
|
|
|
|
|
2012-11-27 16:04:42 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
|
|
|
#include "BenchSysTimer_windows.h"
|
|
|
|
#elif defined(SK_BUILD_FOR_MAC)
|
|
|
|
#include "BenchSysTimer_mach.h"
|
|
|
|
#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
|
|
|
|
#include "BenchSysTimer_posix.h"
|
|
|
|
#else
|
|
|
|
#include "BenchSysTimer_c.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
|
2012-07-10 13:19:25 +00:00
|
|
|
QMainWindow(parent)
|
2012-07-31 12:49:52 +00:00
|
|
|
, fCentralWidget(this)
|
|
|
|
, fStatusBar(this)
|
|
|
|
, fToolBar(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionOpen(this)
|
|
|
|
, fActionBreakpoint(this)
|
2012-11-12 20:42:12 +00:00
|
|
|
, fActionProfile(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionCancel(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fActionClearBreakpoints(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionClearDeletes(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionClose(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionCreateBreakpoint(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionDelete(this)
|
|
|
|
, fActionDirectory(this)
|
|
|
|
, fActionGoToLine(this)
|
|
|
|
, fActionInspector(this)
|
2013-07-01 14:24:12 +00:00
|
|
|
, fActionSettings(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionPlay(this)
|
2012-07-16 18:35:23 +00:00
|
|
|
, fActionPause(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionRewind(this)
|
2012-07-28 20:16:11 +00:00
|
|
|
, fActionSave(this)
|
|
|
|
, fActionSaveAs(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fActionShowDeletes(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fActionStepBack(this)
|
|
|
|
, fActionStepForward(this)
|
2012-07-26 20:26:44 +00:00
|
|
|
, fActionZoomIn(this)
|
|
|
|
, fActionZoomOut(this)
|
|
|
|
, fMapper(this)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fListWidget(&fCentralWidget)
|
|
|
|
, fDirectoryWidget(&fCentralWidget)
|
2012-08-07 16:12:23 +00:00
|
|
|
, fCanvasWidget(this, &fDebugger)
|
2012-11-21 17:11:02 +00:00
|
|
|
, fImageWidget(&fDebugger)
|
2012-07-10 13:19:25 +00:00
|
|
|
, fMenuBar(this)
|
|
|
|
, fMenuFile(this)
|
|
|
|
, fMenuNavigate(this)
|
|
|
|
, fMenuView(this)
|
2012-07-17 15:40:51 +00:00
|
|
|
, fBreakpointsActivated(false)
|
|
|
|
, fDeletesActivated(false)
|
|
|
|
, fPause(false)
|
2012-07-19 13:41:27 +00:00
|
|
|
, fLoading(false)
|
2012-07-10 13:19:25 +00:00
|
|
|
{
|
2012-06-29 14:21:22 +00:00
|
|
|
setupUi(this);
|
2013-01-22 19:38:46 +00:00
|
|
|
fListWidget.setSelectionMode(QAbstractItemView::ExtendedSelection);
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
|
|
|
|
connect(&fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
|
|
|
|
connect(&fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
|
|
|
|
connect(&fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
|
|
|
|
connect(&fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
|
|
|
|
connect(&fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
|
2013-07-01 14:24:12 +00:00
|
|
|
connect(&fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
|
2012-11-12 20:42:12 +00:00
|
|
|
connect(&fActionProfile, SIGNAL(triggered()), this, SLOT(actionProfile()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
|
2012-07-17 15:40:51 +00:00
|
|
|
connect(&fActionClearBreakpoints, SIGNAL(triggered()), this, SLOT(actionClearBreakpoints()));
|
|
|
|
connect(&fActionClearDeletes, SIGNAL(triggered()), this, SLOT(actionClearDeletes()));
|
2012-07-10 13:19:25 +00:00
|
|
|
connect(&fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(fSettingsWidget.getVisibilityButton(), SIGNAL(toggled(bool)), this, SLOT(actionCommandFilter()));
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-08-02 13:59:50 +00:00
|
|
|
connect(&fSettingsWidget, SIGNAL(glSettingsChanged()), this, SLOT(actionGLWidget()));
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(fSettingsWidget.getRasterCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionRasterWidget(bool)));
|
2013-02-06 20:13:54 +00:00
|
|
|
connect(fSettingsWidget.getOverdrawVizCheckBox(), SIGNAL(toggled(bool)), this, SLOT(actionOverdrawVizWidget(bool)));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fActionPause, SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool)));
|
2012-07-16 18:35:23 +00:00
|
|
|
connect(&fActionCreateBreakpoint, SIGNAL(activated()), this, SLOT(toggleBreakpoint()));
|
2012-07-17 15:40:51 +00:00
|
|
|
connect(&fActionShowDeletes, SIGNAL(triggered()), this, SLOT(showDeletes()));
|
2012-07-26 19:38:22 +00:00
|
|
|
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), this, SLOT(selectCommand(int)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, SLOT(updateHit(int)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float)));
|
|
|
|
connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int)));
|
2012-07-28 20:16:11 +00:00
|
|
|
connect(&fActionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs()));
|
|
|
|
connect(&fActionSave, SIGNAL(triggered()), this, SLOT(actionSave()));
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2013-01-17 16:30:56 +00:00
|
|
|
fMapper.setMapping(&fActionZoomIn, SkCanvasWidget::kIn_ZoomCommand);
|
|
|
|
fMapper.setMapping(&fActionZoomOut, SkCanvasWidget::kOut_ZoomCommand);
|
2012-07-26 20:26:44 +00:00
|
|
|
|
|
|
|
connect(&fActionZoomIn, SIGNAL(triggered()), &fMapper, SLOT(map()));
|
|
|
|
connect(&fActionZoomOut, SIGNAL(triggered()), &fMapper, SLOT(map()));
|
2013-01-17 16:30:56 +00:00
|
|
|
connect(&fMapper, SIGNAL(mapped(int)), &fCanvasWidget, SLOT(zoom(int)));
|
2012-07-26 20:26:44 +00:00
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fInspectorWidget.setDisabled(true);
|
2012-07-19 13:41:27 +00:00
|
|
|
fMenuEdit.setDisabled(true);
|
|
|
|
fMenuNavigate.setDisabled(true);
|
|
|
|
fMenuView.setDisabled(true);
|
2012-08-13 14:26:36 +00:00
|
|
|
|
|
|
|
SkGraphics::Init();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-08-13 14:26:36 +00:00
|
|
|
SkDebuggerGUI::~SkDebuggerGUI() {
|
|
|
|
SkGraphics::Term();
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
void SkDebuggerGUI::actionBreakpoints() {
|
2012-07-17 15:40:51 +00:00
|
|
|
fBreakpointsActivated = !fBreakpointsActivated;
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
|
|
|
item->setHidden(item->checkState() == Qt::Unchecked && fBreakpointsActivated);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
void SkDebuggerGUI::showDeletes() {
|
|
|
|
fDeletesActivated = !fDeletesActivated;
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-08-07 16:12:23 +00:00
|
|
|
item->setHidden(fDebugger.isCommandVisible(row)
|
|
|
|
&& fDeletesActivated);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
// The timed picture playback uses the SkPicturePlayback's profiling stubs
|
|
|
|
// to time individual commands. The offsets are needed to map SkPicture
|
|
|
|
// offsets to individual commands.
|
|
|
|
class SkTimedPicturePlayback : public SkPicturePlayback {
|
|
|
|
public:
|
2013-10-01 15:30:46 +00:00
|
|
|
static SkTimedPicturePlayback* CreateFromStream(SkStream* stream, const SkPictInfo& info,
|
|
|
|
SkPicture::InstallPixelRefProc proc,
|
|
|
|
const SkTDArray<bool>& deletedCommands) {
|
|
|
|
// Mimics SkPicturePlayback::CreateFromStream
|
|
|
|
SkAutoTDelete<SkTimedPicturePlayback> playback(SkNEW_ARGS(SkTimedPicturePlayback,
|
|
|
|
(deletedCommands)));
|
|
|
|
if (!playback->parseStream(stream, info, proc)) {
|
|
|
|
return NULL; // we're invalid
|
|
|
|
}
|
|
|
|
return playback.detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkTimedPicturePlayback(const SkTDArray<bool>& deletedCommands)
|
|
|
|
: INHERITED()
|
2013-01-17 16:30:56 +00:00
|
|
|
, fSkipCommands(deletedCommands)
|
|
|
|
, fTot(0.0)
|
|
|
|
, fCurCommand(0) {
|
2013-05-23 13:21:18 +00:00
|
|
|
fTimes.setCount(deletedCommands.count());
|
2012-11-19 20:44:29 +00:00
|
|
|
fTypeTimes.setCount(LAST_DRAWTYPE_ENUM+1);
|
|
|
|
this->resetTimes();
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetTimes() {
|
2013-05-23 13:21:18 +00:00
|
|
|
for (int i = 0; i < fTimes.count(); ++i) {
|
2012-11-19 20:44:29 +00:00
|
|
|
fTimes[i] = 0.0;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
2012-11-19 20:44:29 +00:00
|
|
|
for (int i = 0; i < fTypeTimes.count(); ++i) {
|
|
|
|
fTypeTimes[i] = 0.0f;
|
|
|
|
}
|
|
|
|
fTot = 0.0;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int count() const { return fTimes.count(); }
|
|
|
|
|
|
|
|
double time(int index) const { return fTimes[index] / fTot; }
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
const SkTDArray<double>* typeTimes() const { return &fTypeTimes; }
|
|
|
|
|
|
|
|
double totTime() const { return fTot; }
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
protected:
|
2012-11-27 16:04:42 +00:00
|
|
|
BenchSysTimer fTimer;
|
2012-12-07 20:48:56 +00:00
|
|
|
SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI?
|
2012-11-15 14:57:57 +00:00
|
|
|
SkTDArray<double> fTimes; // sum of time consumed for each command
|
2012-11-19 20:44:29 +00:00
|
|
|
SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath)
|
2012-11-15 14:57:57 +00:00
|
|
|
double fTot; // total of all times in 'fTimes'
|
2012-11-19 20:44:29 +00:00
|
|
|
int fCurType;
|
2012-11-15 14:57:57 +00:00
|
|
|
int fCurCommand; // the current command being executed/timed
|
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
#ifdef SK_DEVELOPER
|
|
|
|
virtual bool preDraw(int opIndex, int type) SK_OVERRIDE {
|
|
|
|
fCurCommand = opIndex;
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-12-07 20:48:56 +00:00
|
|
|
if (fSkipCommands[fCurCommand]) {
|
2013-05-23 13:21:18 +00:00
|
|
|
return true;
|
2012-12-07 20:48:56 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
fCurType = type;
|
|
|
|
// The SkDebugCanvas doesn't recognize these types. This class needs to
|
|
|
|
// convert or else we'll wind up with a mismatch between the type counts
|
|
|
|
// the debugger displays and the profile times.
|
|
|
|
if (DRAW_POS_TEXT_TOP_BOTTOM == type) {
|
|
|
|
fCurType = DRAW_POS_TEXT;
|
|
|
|
} else if (DRAW_POS_TEXT_H_TOP_BOTTOM == type) {
|
|
|
|
fCurType = DRAW_POS_TEXT_H;
|
|
|
|
}
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-11-27 16:04:42 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
|
|
|
// CPU timer doesn't work well on Windows
|
|
|
|
fTimer.startWall();
|
|
|
|
#else
|
|
|
|
fTimer.startCpu();
|
|
|
|
#endif
|
2012-12-07 20:48:56 +00:00
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
return false;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
virtual void postDraw(int opIndex) SK_OVERRIDE {
|
2012-11-19 16:26:40 +00:00
|
|
|
#if defined(SK_BUILD_FOR_WIN32)
|
|
|
|
// CPU timer doesn't work well on Windows
|
2012-11-27 16:04:42 +00:00
|
|
|
double time = fTimer.endWall();
|
2012-11-19 16:26:40 +00:00
|
|
|
#else
|
2012-11-27 16:04:42 +00:00
|
|
|
double time = fTimer.endCpu();
|
2012-11-19 16:26:40 +00:00
|
|
|
#endif
|
2012-11-27 16:04:42 +00:00
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
SkASSERT(opIndex == fCurCommand);
|
2012-11-27 16:04:42 +00:00
|
|
|
SkASSERT(fCurType <= LAST_DRAWTYPE_ENUM);
|
|
|
|
|
|
|
|
fTimes[fCurCommand] += time;
|
|
|
|
fTypeTimes[fCurType] += time;
|
|
|
|
fTot += time;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
2013-05-23 13:21:18 +00:00
|
|
|
#endif
|
2012-11-15 14:57:57 +00:00
|
|
|
|
|
|
|
private:
|
2013-10-01 15:30:46 +00:00
|
|
|
// SkPicturePlayback::parseStream is protected, so it can be
|
|
|
|
// called here, but not by our static factory function. This
|
|
|
|
// allows the factory function to call it.
|
|
|
|
bool parseStream(SkStream* stream, const SkPictInfo& info,
|
|
|
|
SkPicture::InstallPixelRefProc proc) {
|
|
|
|
return this->INHERITED::parseStream(stream, info, proc);
|
|
|
|
}
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
typedef SkPicturePlayback INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Wrap SkPicture to allow installation of an SkTimedPicturePlayback object
|
|
|
|
class SkTimedPicture : public SkPicture {
|
|
|
|
public:
|
2013-06-28 21:32:00 +00:00
|
|
|
static SkTimedPicture* CreateTimedPicture(SkStream* stream,
|
|
|
|
SkPicture::InstallPixelRefProc proc,
|
|
|
|
const SkTDArray<bool>& deletedCommands) {
|
2012-11-15 14:57:57 +00:00
|
|
|
SkPictInfo info;
|
2013-06-28 21:32:00 +00:00
|
|
|
if (!StreamIsSKP(stream, &info)) {
|
|
|
|
return NULL;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
SkTimedPicturePlayback* playback;
|
|
|
|
// Check to see if there is a playback to recreate.
|
2012-11-15 14:57:57 +00:00
|
|
|
if (stream->readBool()) {
|
2013-10-01 15:30:46 +00:00
|
|
|
playback = SkTimedPicturePlayback::CreateFromStream(stream, info, proc,
|
|
|
|
deletedCommands);
|
|
|
|
if (NULL == playback) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-06-28 21:32:00 +00:00
|
|
|
} else {
|
|
|
|
playback = NULL;
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
return SkNEW_ARGS(SkTimedPicture, (playback, info.fWidth, info.fHeight));
|
2012-11-15 14:57:57 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
void resetTimes() { ((SkTimedPicturePlayback*) fPlayback)->resetTimes(); }
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
int count() const { return ((SkTimedPicturePlayback*) fPlayback)->count(); }
|
|
|
|
|
|
|
|
// return the fraction of the total time this command consumed
|
|
|
|
double time(int index) const { return ((SkTimedPicturePlayback*) fPlayback)->time(index); }
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
const SkTDArray<double>* typeTimes() const { return ((SkTimedPicturePlayback*) fPlayback)->typeTimes(); }
|
|
|
|
|
|
|
|
double totTime() const { return ((SkTimedPicturePlayback*) fPlayback)->totTime(); }
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
private:
|
2012-11-19 20:44:29 +00:00
|
|
|
// disallow default ctor b.c. we don't have a good way to setup the fPlayback ptr
|
|
|
|
SkTimedPicture();
|
2013-06-28 21:32:00 +00:00
|
|
|
// Private ctor only used by CreateTimedPicture, which has created the playback.
|
|
|
|
SkTimedPicture(SkTimedPicturePlayback* playback, int width, int height)
|
|
|
|
: INHERITED(playback, width, height) {}
|
2012-11-19 20:44:29 +00:00
|
|
|
// disallow the copy ctor - enabling would require copying code from SkPicture
|
|
|
|
SkTimedPicture(const SkTimedPicture& src);
|
|
|
|
|
2012-11-15 14:57:57 +00:00
|
|
|
typedef SkPicture INHERITED;
|
|
|
|
};
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
// This is a simplification of PictureBenchmark's run with the addition of
|
|
|
|
// clearing of the times after the first pass (in resetTimes)
|
2012-11-20 02:01:23 +00:00
|
|
|
void SkDebuggerGUI::run(SkTimedPicture* pict,
|
|
|
|
sk_tools::PictureRenderer* renderer,
|
2012-11-19 20:44:29 +00:00
|
|
|
int repeats) {
|
|
|
|
SkASSERT(pict);
|
|
|
|
if (NULL == pict) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkASSERT(renderer != NULL);
|
|
|
|
if (NULL == renderer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer->init(pict);
|
|
|
|
|
|
|
|
renderer->setup();
|
|
|
|
renderer->render(NULL);
|
2013-01-28 21:09:05 +00:00
|
|
|
renderer->resetState(true);
|
2012-11-19 20:44:29 +00:00
|
|
|
|
|
|
|
// We throw this away the first batch of times to remove first time effects (such as paging in this program)
|
|
|
|
pict->resetTimes();
|
|
|
|
|
|
|
|
for (int i = 0; i < repeats; ++i) {
|
|
|
|
renderer->setup();
|
|
|
|
renderer->render(NULL);
|
2013-01-28 21:09:05 +00:00
|
|
|
renderer->resetState(true);
|
2012-11-19 20:44:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderer->end();
|
|
|
|
}
|
|
|
|
|
2012-11-12 20:42:12 +00:00
|
|
|
void SkDebuggerGUI::actionProfile() {
|
2012-11-15 14:57:57 +00:00
|
|
|
// In order to profile we pass the command offsets (that were read-in
|
|
|
|
// in loadPicture by the SkOffsetPicture) to an SkTimedPlaybackPicture.
|
2012-11-16 02:01:17 +00:00
|
|
|
// The SkTimedPlaybackPicture in turn passes the offsets to an
|
2012-11-15 14:57:57 +00:00
|
|
|
// SkTimedPicturePlayback object which uses them to track the performance
|
|
|
|
// of individual commands.
|
|
|
|
if (fFileName.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkFILEStream inputStream;
|
|
|
|
|
|
|
|
inputStream.setPath(fFileName.c_str());
|
|
|
|
if (!inputStream.isValid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
SkAutoTUnref<SkTimedPicture> picture(SkTimedPicture::CreateTimedPicture(&inputStream,
|
|
|
|
&SkImageDecoder::DecodeMemory, fSkipCommands));
|
|
|
|
if (NULL == picture.get()) {
|
2012-11-15 14:57:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
// For now this #if allows switching between tiled and simple rendering
|
|
|
|
// modes. Eventually this will be accomplished via the GUI
|
2012-11-27 16:04:42 +00:00
|
|
|
#if 0
|
|
|
|
// With the current batch of SysTimers, profiling in tiled mode
|
|
|
|
// gets swamped by the timing overhead:
|
|
|
|
//
|
|
|
|
// tile mode simple mode
|
|
|
|
// debugger 64.2ms 12.8ms
|
|
|
|
// bench_pictures 16.9ms 12.4ms
|
|
|
|
//
|
|
|
|
// This is b.c. in tiled mode each command is called many more times
|
|
|
|
// but typically does less work on each invocation (due to clipping)
|
2012-11-15 14:57:57 +00:00
|
|
|
sk_tools::TiledPictureRenderer* renderer = NULL;
|
|
|
|
|
|
|
|
renderer = SkNEW(sk_tools::TiledPictureRenderer);
|
|
|
|
renderer->setTileWidth(256);
|
|
|
|
renderer->setTileHeight(256);
|
2012-11-19 20:44:29 +00:00
|
|
|
#else
|
|
|
|
sk_tools::SimplePictureRenderer* renderer = NULL;
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
renderer = SkNEW(sk_tools::SimplePictureRenderer);
|
2013-01-30 21:09:09 +00:00
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
2013-08-02 13:59:50 +00:00
|
|
|
if (fSettingsWidget.isGLActive()) {
|
2013-01-30 21:09:09 +00:00
|
|
|
renderer->setDeviceType(sk_tools::PictureRenderer::kGPU_DeviceType);
|
2013-08-02 13:59:50 +00:00
|
|
|
renderer->setSampleCount(fSettingsWidget.getGLSampleCount());
|
2013-01-30 21:09:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
#endif
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-11-27 16:04:42 +00:00
|
|
|
static const int kNumRepeats = 10;
|
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
run(picture.get(), renderer, kNumRepeats);
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
SkASSERT(picture->count() == fListWidget.count());
|
2012-11-15 14:57:57 +00:00
|
|
|
|
|
|
|
// extract the individual command times from the SkTimedPlaybackPicture
|
2013-06-28 21:32:00 +00:00
|
|
|
for (int i = 0; i < picture->count(); ++i) {
|
|
|
|
double temp = picture->time(i);
|
2012-11-15 14:57:57 +00:00
|
|
|
|
|
|
|
QListWidgetItem* item = fListWidget.item(i);
|
|
|
|
|
|
|
|
item->setData(Qt::UserRole + 4, 100.0*temp);
|
|
|
|
}
|
2012-11-19 20:44:29 +00:00
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
setupOverviewText(picture->typeTimes(), picture->totTime(), kNumRepeats);
|
2012-11-12 20:42:12 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionCancel() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
fListWidget.item(row)->setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
void SkDebuggerGUI::actionClearBreakpoints() {
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
|
|
|
item->setData(Qt::DecorationRole,
|
2012-11-19 17:39:18 +00:00
|
|
|
QPixmap(":/blank.png"));
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionClearDeletes() {
|
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
2012-11-19 17:39:18 +00:00
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.setCommandVisible(row, true);
|
2012-12-07 20:48:56 +00:00
|
|
|
fSkipCommands[row] = false;
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
|
|
|
if (fPause) {
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-17 15:40:51 +00:00
|
|
|
} else {
|
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-17 15:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionCommandFilter() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.highlightCurrentCommand(
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.getVisibilityButton()->isChecked());
|
|
|
|
fCanvasWidget.drawTo(fListWidget.currentRow());
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionClose() {
|
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionDelete() {
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2013-01-22 19:38:46 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); ++row) {
|
|
|
|
QListWidgetItem* item = fListWidget.item(row);
|
|
|
|
|
|
|
|
if (!item->isSelected()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fDebugger.isCommandVisible(row)) {
|
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/delete.png"));
|
|
|
|
fDebugger.setCommandVisible(row, false);
|
|
|
|
fSkipCommands[row] = true;
|
|
|
|
} else {
|
|
|
|
item->setData(Qt::UserRole + 2, QPixmap(":/blank.png"));
|
|
|
|
fDebugger.setCommandVisible(row, true);
|
|
|
|
fSkipCommands[row] = false;
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-17 15:40:51 +00:00
|
|
|
|
2013-01-22 19:38:46 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
if (fPause) {
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-16 18:35:23 +00:00
|
|
|
} else {
|
|
|
|
fCanvasWidget.drawTo(currentRow);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-16 18:35:23 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 13:26:13 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2013-08-02 13:59:50 +00:00
|
|
|
void SkDebuggerGUI::actionGLWidget() {
|
|
|
|
bool isToggled = fSettingsWidget.isGLActive();
|
|
|
|
if (isToggled) {
|
|
|
|
fCanvasWidget.setGLSampleCount(fSettingsWidget.getGLSampleCount());
|
|
|
|
}
|
2012-07-26 19:38:22 +00:00
|
|
|
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kGPU_WidgetType, !isToggled);
|
|
|
|
}
|
2013-02-13 13:26:13 +00:00
|
|
|
#endif
|
2012-07-26 19:38:22 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionInspector() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fInspectorWidget.isHidden()) {
|
|
|
|
fInspectorWidget.setHidden(false);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setHidden(true);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionPlay() {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = fListWidget.currentRow() + 1; row < fListWidget.count();
|
2012-07-09 20:26:53 +00:00
|
|
|
row++) {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Checked) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(fListWidget.count() - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 19:38:22 +00:00
|
|
|
void SkDebuggerGUI::actionRasterWidget(bool isToggled) {
|
|
|
|
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType, !isToggled);
|
|
|
|
}
|
|
|
|
|
2013-02-06 20:13:54 +00:00
|
|
|
void SkDebuggerGUI::actionOverdrawVizWidget(bool isToggled) {
|
|
|
|
fDebugger.setOverdrawViz(isToggled);
|
|
|
|
fCanvasWidget.update();
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionRewind() {
|
2012-07-16 18:35:23 +00:00
|
|
|
fListWidget.setCurrentRow(0);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
void SkDebuggerGUI::actionSave() {
|
2013-01-28 19:25:43 +00:00
|
|
|
fFileName = fPath.toAscii().data();
|
2012-11-12 20:42:12 +00:00
|
|
|
fFileName.append("/");
|
2013-01-28 19:25:43 +00:00
|
|
|
fFileName.append(fDirectoryWidget.currentItem()->text().toAscii().data());
|
2012-11-12 20:42:12 +00:00
|
|
|
saveToFile(fFileName);
|
2012-07-28 20:16:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionSaveAs() {
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
|
|
|
|
"Skia Picture (*skp)");
|
2012-07-28 23:26:10 +00:00
|
|
|
if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
|
2012-07-28 20:16:11 +00:00
|
|
|
filename.append(".skp");
|
|
|
|
}
|
2012-11-13 18:35:10 +00:00
|
|
|
saveToFile(SkString(filename.toAscii().data()));
|
2012-07-28 20:16:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
void SkDebuggerGUI::actionScale(float scaleFactor) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setZoomText(scaleFactor);
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::actionSettings() {
|
2012-07-10 13:19:25 +00:00
|
|
|
if (fSettingsWidget.isHidden()) {
|
|
|
|
fSettingsWidget.setHidden(false);
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setHidden(true);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepBack() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (currentRow != 0) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setCurrentRow(currentRow - 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::actionStepForward() {
|
2012-07-10 13:19:25 +00:00
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-06-29 14:21:22 +00:00
|
|
|
QString curRow = QString::number(currentRow);
|
2012-07-10 13:19:25 +00:00
|
|
|
QString curCount = QString::number(fListWidget.count());
|
|
|
|
if (currentRow < fListWidget.count() - 1) {
|
|
|
|
fListWidget.setCurrentRow(currentRow + 1);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-03 17:32:05 +00:00
|
|
|
void SkDebuggerGUI::drawComplete() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fInspectorWidget.setMatrix(fDebugger.getCurrentMatrix());
|
|
|
|
fInspectorWidget.setClip(fDebugger.getCurrentClip());
|
2012-08-03 17:32:05 +00:00
|
|
|
}
|
|
|
|
|
2012-11-12 20:42:12 +00:00
|
|
|
void SkDebuggerGUI::saveToFile(const SkString& filename) {
|
|
|
|
SkFILEWStream file(filename.c_str());
|
2013-01-22 18:03:56 +00:00
|
|
|
SkAutoTUnref<SkPicture> copy(fDebugger.copyPicture());
|
|
|
|
|
|
|
|
copy->serialize(&file);
|
2012-07-28 20:16:11 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
|
|
|
|
if (fDirectoryWidgetActive) {
|
2013-01-28 19:25:43 +00:00
|
|
|
fFileName = fPath.toAscii().data();
|
2013-02-05 19:44:07 +00:00
|
|
|
// don't add a '/' to files in the local directory
|
|
|
|
if (fFileName.size() > 0) {
|
|
|
|
fFileName.append("/");
|
|
|
|
}
|
2013-01-28 19:25:43 +00:00
|
|
|
fFileName.append(item->text().toAscii().data());
|
2012-11-12 20:42:12 +00:00
|
|
|
loadPicture(fFileName);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::openFile() {
|
2012-11-12 20:42:12 +00:00
|
|
|
QString temp = QFileDialog::getOpenFileName(this, tr("Open File"), "",
|
2012-07-09 20:26:53 +00:00
|
|
|
tr("Files (*.*)"));
|
2013-01-28 17:43:26 +00:00
|
|
|
openFile(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::openFile(const QString &filename) {
|
2012-06-29 14:21:22 +00:00
|
|
|
fDirectoryWidgetActive = false;
|
2013-01-28 17:43:26 +00:00
|
|
|
if (!filename.isEmpty()) {
|
|
|
|
QFileInfo pathInfo(filename);
|
|
|
|
loadPicture(SkString(filename.toAscii().data()));
|
|
|
|
setupDirectoryWidget(pathInfo.path());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
}
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
void SkDebuggerGUI::pauseDrawing(bool isPaused) {
|
2012-08-07 16:12:23 +00:00
|
|
|
fPause = isPaused;
|
|
|
|
fPausedRow = fListWidget.currentRow();
|
|
|
|
fCanvasWidget.drawTo(fPausedRow);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-09 20:26:53 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
|
2012-07-19 13:41:27 +00:00
|
|
|
if(!fLoading) {
|
|
|
|
int currentRow = fListWidget.currentRow();
|
2012-07-26 19:38:22 +00:00
|
|
|
|
|
|
|
if (currentRow != -1) {
|
|
|
|
if (!fPause) {
|
|
|
|
fCanvasWidget.drawTo(currentRow);
|
2012-11-21 17:11:02 +00:00
|
|
|
fImageWidget.draw();
|
2012-07-26 19:38:22 +00:00
|
|
|
}
|
2012-08-07 20:41:37 +00:00
|
|
|
SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
|
2012-07-26 19:38:22 +00:00
|
|
|
currentRow);
|
|
|
|
|
|
|
|
/* TODO(chudy): Add command type before parameters. Rename v
|
|
|
|
* to something more informative. */
|
2012-08-07 20:41:37 +00:00
|
|
|
if (currInfo) {
|
2012-07-26 19:38:22 +00:00
|
|
|
QString info;
|
|
|
|
info.append("<b>Parameters: </b><br/>");
|
2012-08-07 20:41:37 +00:00
|
|
|
for (int i = 0; i < currInfo->count(); i++) {
|
|
|
|
|
|
|
|
info.append(QString((*currInfo)[i]->c_str()));
|
2012-07-26 19:38:22 +00:00
|
|
|
info.append("<br/>");
|
|
|
|
}
|
2012-08-14 19:34:13 +00:00
|
|
|
fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
|
2012-07-26 19:38:22 +00:00
|
|
|
fInspectorWidget.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
2012-07-26 19:38:22 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-12 21:58:14 +00:00
|
|
|
void SkDebuggerGUI::selectCommand(int command) {
|
|
|
|
if (fPause) {
|
|
|
|
fListWidget.setCurrentRow(command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
void SkDebuggerGUI::toggleBreakpoint() {
|
2012-07-10 13:19:25 +00:00
|
|
|
QListWidgetItem* item = fListWidget.currentItem();
|
2012-06-29 14:21:22 +00:00
|
|
|
if (item->checkState() == Qt::Unchecked) {
|
|
|
|
item->setCheckState(Qt::Checked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
2012-11-19 17:39:18 +00:00
|
|
|
QPixmap(":/breakpoint_16x16.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
} else {
|
|
|
|
item->setCheckState(Qt::Unchecked);
|
2012-07-12 14:15:54 +00:00
|
|
|
item->setData(Qt::DecorationRole,
|
2012-11-19 17:39:18 +00:00
|
|
|
QPixmap(":/blank.png"));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleDirectory() {
|
2012-08-07 16:12:23 +00:00
|
|
|
fDirectoryWidget.setHidden(!fDirectoryWidget.isHidden());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::toggleFilter(QString string) {
|
2012-07-10 13:19:25 +00:00
|
|
|
for (int row = 0; row < fListWidget.count(); row++) {
|
|
|
|
QListWidgetItem *item = fListWidget.item(row);
|
2012-08-07 16:12:23 +00:00
|
|
|
item->setHidden(item->text() != string);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
|
|
|
|
QIcon windowIcon;
|
2012-11-19 17:39:18 +00:00
|
|
|
windowIcon.addFile(QString::fromUtf8(":/skia.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-06-29 14:21:22 +00:00
|
|
|
SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
|
|
|
|
SkDebuggerGUI->resize(1200, 1000);
|
|
|
|
SkDebuggerGUI->setWindowIcon(windowIcon);
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setWindowTitle("Skia Debugger");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionOpen.setShortcuts(QKeySequence::Open);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionOpen.setText("Open");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon breakpoint;
|
2012-11-19 17:39:18 +00:00
|
|
|
breakpoint.addFile(QString::fromUtf8(":/breakpoint.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionBreakpoint.setShortcut(QKeySequence(tr("Ctrl+B")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionBreakpoint.setIcon(breakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionBreakpoint.setText("Breakpoints");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon cancel;
|
2012-11-19 17:39:18 +00:00
|
|
|
cancel.addFile(QString::fromUtf8(":/reload.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionCancel.setIcon(cancel);
|
|
|
|
fActionCancel.setText("Clear Filter");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionClearBreakpoints.setShortcut(QKeySequence(tr("Alt+B")));
|
|
|
|
fActionClearBreakpoints.setText("Clear Breakpoints");
|
|
|
|
|
|
|
|
fActionClearDeletes.setShortcut(QKeySequence(tr("Alt+X")));
|
|
|
|
fActionClearDeletes.setText("Clear Deletes");
|
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionClose.setShortcuts(QKeySequence::Quit);
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionClose.setText("Exit");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionCreateBreakpoint.setShortcut(QKeySequence(tr("B")));
|
|
|
|
fActionCreateBreakpoint.setText("Set Breakpoint");
|
|
|
|
|
|
|
|
fActionDelete.setShortcut(QKeySequence(tr("X")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionDelete.setText("Delete Command");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionDirectory.setShortcut(QKeySequence(tr("Ctrl+D")));
|
|
|
|
fActionDirectory.setText("Directory");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-11-12 20:42:12 +00:00
|
|
|
QIcon profile;
|
2012-11-19 18:25:09 +00:00
|
|
|
profile.addFile(QString::fromUtf8(":/profile.png"), QSize(),
|
2012-11-12 20:42:12 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
|
|
|
fActionProfile.setIcon(profile);
|
|
|
|
fActionProfile.setText("Profile");
|
2012-11-19 16:26:40 +00:00
|
|
|
fActionProfile.setDisabled(true);
|
2012-11-12 20:42:12 +00:00
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
QIcon inspector;
|
2012-11-19 18:25:09 +00:00
|
|
|
inspector.addFile(QString::fromUtf8(":/inspector.png"),
|
2012-07-09 20:26:53 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionInspector.setShortcut(QKeySequence(tr("Ctrl+I")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionInspector.setIcon(inspector);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionInspector.setText("Inspector");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2013-07-01 14:24:12 +00:00
|
|
|
QIcon settings;
|
|
|
|
settings.addFile(QString::fromUtf8(":/inspector.png"),
|
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
|
|
|
fActionSettings.setShortcut(QKeySequence(tr("Ctrl+G")));
|
|
|
|
fActionSettings.setIcon(settings);
|
|
|
|
fActionSettings.setText("Settings");
|
2013-07-02 07:00:59 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon play;
|
2012-11-19 18:25:09 +00:00
|
|
|
play.addFile(QString::fromUtf8(":/play.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionPlay.setShortcut(QKeySequence(tr("Ctrl+P")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionPlay.setIcon(play);
|
|
|
|
fActionPlay.setText("Play");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
QIcon pause;
|
2012-11-19 18:25:09 +00:00
|
|
|
pause.addFile(QString::fromUtf8(":/pause.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionPause.setShortcut(QKeySequence(tr("Space")));
|
|
|
|
fActionPause.setCheckable(true);
|
|
|
|
fActionPause.setIcon(pause);
|
|
|
|
fActionPause.setText("Pause");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon rewind;
|
2012-11-19 17:39:18 +00:00
|
|
|
rewind.addFile(QString::fromUtf8(":/rewind.png"), QSize(),
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionRewind.setShortcut(QKeySequence(tr("Ctrl+R")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionRewind.setIcon(rewind);
|
|
|
|
fActionRewind.setText("Rewind");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
fActionSave.setShortcut(QKeySequence::Save);
|
|
|
|
fActionSave.setText("Save");
|
|
|
|
fActionSave.setDisabled(true);
|
|
|
|
fActionSaveAs.setShortcut(QKeySequence::SaveAs);
|
|
|
|
fActionSaveAs.setText("Save As");
|
|
|
|
fActionSaveAs.setDisabled(true);
|
|
|
|
|
2012-07-17 15:40:51 +00:00
|
|
|
fActionShowDeletes.setShortcut(QKeySequence(tr("Ctrl+X")));
|
|
|
|
fActionShowDeletes.setText("Deleted Commands");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon stepBack;
|
2012-11-19 17:39:18 +00:00
|
|
|
stepBack.addFile(QString::fromUtf8(":/previous.png"), QSize(),
|
2012-07-09 20:26:53 +00:00
|
|
|
QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionStepBack.setShortcut(QKeySequence(tr("[")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionStepBack.setIcon(stepBack);
|
|
|
|
fActionStepBack.setText("Step Back");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
QIcon stepForward;
|
2012-11-19 17:39:18 +00:00
|
|
|
stepForward.addFile(QString::fromUtf8(":/next.png"),
|
2012-07-10 13:19:25 +00:00
|
|
|
QSize(), QIcon::Normal, QIcon::Off);
|
2012-07-16 18:35:23 +00:00
|
|
|
fActionStepForward.setShortcut(QKeySequence(tr("]")));
|
2012-07-10 13:19:25 +00:00
|
|
|
fActionStepForward.setIcon(stepForward);
|
|
|
|
fActionStepForward.setText("Step Forward");
|
|
|
|
|
2012-07-26 20:26:44 +00:00
|
|
|
fActionZoomIn.setShortcut(QKeySequence(tr("Ctrl+=")));
|
|
|
|
fActionZoomIn.setText("Zoom In");
|
|
|
|
fActionZoomOut.setShortcut(QKeySequence(tr("Ctrl+-")));
|
|
|
|
fActionZoomOut.setText("Zoom Out");
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.setItemDelegate(new SkListWidget(&fListWidget));
|
|
|
|
fListWidget.setObjectName(QString::fromUtf8("listWidget"));
|
|
|
|
fListWidget.setMaximumWidth(250);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.setMaximumWidth(250);
|
|
|
|
fDirectoryWidget.setStyleSheet("QListWidget::Item {padding: 5px;}");
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-11-22 02:02:41 +00:00
|
|
|
fImageWidget.setFixedSize(SkImageWidget::kImageWidgetWidth,
|
2012-11-21 17:11:02 +00:00
|
|
|
SkImageWidget::kImageWidgetHeight);
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
|
2012-07-09 20:26:53 +00:00
|
|
|
QSizePolicy::Expanding);
|
2012-07-10 13:19:25 +00:00
|
|
|
fInspectorWidget.setMaximumHeight(300);
|
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
fSettingsAndImageLayout.setSpacing(6);
|
|
|
|
fSettingsAndImageLayout.addWidget(&fSettingsWidget);
|
|
|
|
fSettingsAndImageLayout.addWidget(&fImageWidget);
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Expanding);
|
|
|
|
fSettingsWidget.setMaximumWidth(250);
|
|
|
|
|
|
|
|
fLeftColumnLayout.setSpacing(6);
|
|
|
|
fLeftColumnLayout.addWidget(&fListWidget);
|
|
|
|
fLeftColumnLayout.addWidget(&fDirectoryWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-11-21 17:11:02 +00:00
|
|
|
fCanvasSettingsAndImageLayout.setSpacing(6);
|
|
|
|
fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget);
|
|
|
|
fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout);
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMainAndRightColumnLayout.setSpacing(6);
|
2012-11-21 17:11:02 +00:00
|
|
|
fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout);
|
2012-07-10 13:19:25 +00:00
|
|
|
fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-31 12:49:52 +00:00
|
|
|
fCentralWidget.setLayout(&fContainerLayout);
|
2012-07-10 13:19:25 +00:00
|
|
|
fContainerLayout.setSpacing(6);
|
|
|
|
fContainerLayout.setContentsMargins(11, 11, 11, 11);
|
|
|
|
fContainerLayout.addLayout(&fLeftColumnLayout);
|
|
|
|
fContainerLayout.addLayout(&fMainAndRightColumnLayout);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setCentralWidget(&fCentralWidget);
|
|
|
|
SkDebuggerGUI->setStatusBar(&fStatusBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.setIconSize(QSize(32, 32));
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
|
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, &fToolBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-28 20:16:11 +00:00
|
|
|
fSpacer.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addAction(&fActionRewind);
|
|
|
|
fToolBar.addAction(&fActionStepBack);
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.addAction(&fActionPause);
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addAction(&fActionStepForward);
|
|
|
|
fToolBar.addAction(&fActionPlay);
|
|
|
|
fToolBar.addSeparator();
|
2012-07-16 18:35:23 +00:00
|
|
|
fToolBar.addAction(&fActionInspector);
|
2013-07-01 14:24:12 +00:00
|
|
|
fToolBar.addAction(&fActionSettings);
|
2012-11-12 20:42:12 +00:00
|
|
|
fToolBar.addSeparator();
|
|
|
|
fToolBar.addAction(&fActionProfile);
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addSeparator();
|
2012-07-28 20:16:11 +00:00
|
|
|
fToolBar.addWidget(&fSpacer);
|
2012-07-10 13:19:25 +00:00
|
|
|
fToolBar.addWidget(&fFilter);
|
|
|
|
fToolBar.addAction(&fActionCancel);
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// TODO(chudy): Remove static call.
|
|
|
|
fDirectoryWidgetActive = false;
|
2012-11-12 20:42:12 +00:00
|
|
|
fFileName = "";
|
2013-01-28 17:43:26 +00:00
|
|
|
setupDirectoryWidget("");
|
2012-06-29 14:21:22 +00:00
|
|
|
fDirectoryWidgetActive = true;
|
|
|
|
|
|
|
|
// Menu Bar
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuFile.setTitle("File");
|
|
|
|
fMenuFile.addAction(&fActionOpen);
|
2012-07-28 20:16:11 +00:00
|
|
|
fMenuFile.addAction(&fActionSave);
|
|
|
|
fMenuFile.addAction(&fActionSaveAs);
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuFile.addAction(&fActionClose);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
|
|
|
fMenuEdit.setTitle("Edit");
|
|
|
|
fMenuEdit.addAction(&fActionDelete);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuEdit.addAction(&fActionClearDeletes);
|
|
|
|
fMenuEdit.addSeparator();
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuEdit.addAction(&fActionCreateBreakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuEdit.addAction(&fActionClearBreakpoints);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuNavigate.setTitle("Navigate");
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuNavigate.addAction(&fActionRewind);
|
|
|
|
fMenuNavigate.addAction(&fActionStepBack);
|
|
|
|
fMenuNavigate.addAction(&fActionStepForward);
|
|
|
|
fMenuNavigate.addAction(&fActionPlay);
|
|
|
|
fMenuNavigate.addAction(&fActionPause);
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuNavigate.addAction(&fActionGoToLine);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuView.setTitle("View");
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuView.addAction(&fActionBreakpoint);
|
2012-07-17 15:40:51 +00:00
|
|
|
fMenuView.addAction(&fActionShowDeletes);
|
2012-07-26 20:26:44 +00:00
|
|
|
fMenuView.addAction(&fActionZoomIn);
|
|
|
|
fMenuView.addAction(&fActionZoomOut);
|
2012-07-16 18:35:23 +00:00
|
|
|
|
|
|
|
fMenuWindows.setTitle("Window");
|
|
|
|
fMenuWindows.addAction(&fActionInspector);
|
2013-07-01 14:24:12 +00:00
|
|
|
fMenuWindows.addAction(&fActionSettings);
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuWindows.addAction(&fActionDirectory);
|
2012-07-10 13:19:25 +00:00
|
|
|
|
|
|
|
fActionGoToLine.setText("Go to Line...");
|
|
|
|
fActionGoToLine.setDisabled(true);
|
|
|
|
fMenuBar.addAction(fMenuFile.menuAction());
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuBar.addAction(fMenuEdit.menuAction());
|
2012-07-10 13:19:25 +00:00
|
|
|
fMenuBar.addAction(fMenuView.menuAction());
|
|
|
|
fMenuBar.addAction(fMenuNavigate.menuAction());
|
2012-07-16 18:35:23 +00:00
|
|
|
fMenuBar.addAction(fMenuWindows.menuAction());
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
fPause = false;
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
SkDebuggerGUI->setMenuBar(&fMenuBar);
|
2012-06-29 14:21:22 +00:00
|
|
|
QMetaObject::connectSlotsByName(SkDebuggerGUI);
|
|
|
|
}
|
|
|
|
|
2013-01-28 17:43:26 +00:00
|
|
|
void SkDebuggerGUI::setupDirectoryWidget(const QString& path) {
|
|
|
|
fPath = path;
|
|
|
|
QDir dir(path);
|
2012-06-29 14:21:22 +00:00
|
|
|
QRegExp r(".skp");
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.clear();
|
|
|
|
const QStringList files = dir.entryList();
|
2012-06-29 14:21:22 +00:00
|
|
|
foreach (QString f, files) {
|
2012-07-09 20:26:53 +00:00
|
|
|
if (f.contains(r))
|
2012-07-10 13:19:25 +00:00
|
|
|
fDirectoryWidget.addItem(f);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-12 20:42:12 +00:00
|
|
|
void SkDebuggerGUI::loadPicture(const SkString& fileName) {
|
|
|
|
fFileName = fileName;
|
2012-07-19 13:41:27 +00:00
|
|
|
fLoading = true;
|
2012-11-12 20:42:12 +00:00
|
|
|
SkStream* stream = SkNEW_ARGS(SkFILEStream, (fileName.c_str()));
|
2013-02-07 20:39:40 +00:00
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
SkPicture* picture = SkPicture::CreateFromStream(stream);
|
2013-02-07 20:39:40 +00:00
|
|
|
|
2013-06-28 21:32:00 +00:00
|
|
|
if (NULL == picture) {
|
2013-02-07 20:39:40 +00:00
|
|
|
QMessageBox::critical(this, "Error loading file", "Couldn't read file, sorry.");
|
|
|
|
SkSafeUnref(stream);
|
|
|
|
return;
|
|
|
|
}
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-08-14 16:00:32 +00:00
|
|
|
fCanvasWidget.resetWidgetTransform();
|
2012-08-07 16:12:23 +00:00
|
|
|
fDebugger.loadPicture(picture);
|
2012-08-14 19:38:31 +00:00
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
fSkipCommands.setCount(fDebugger.getSize());
|
|
|
|
for (int i = 0; i < fSkipCommands.count(); ++i) {
|
2012-12-07 20:48:56 +00:00
|
|
|
fSkipCommands[i] = false;
|
|
|
|
}
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
SkSafeUnref(stream);
|
|
|
|
SkSafeUnref(picture);
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
// Will this automatically clear out due to nature of refcnt?
|
2012-11-19 20:44:29 +00:00
|
|
|
SkTArray<SkString>* commands = fDebugger.getDrawCommandsAsStrings();
|
2012-08-07 16:12:23 +00:00
|
|
|
|
2013-05-23 13:21:18 +00:00
|
|
|
fActionProfile.setDisabled(false);
|
2012-11-15 14:57:57 +00:00
|
|
|
|
2012-07-09 20:26:53 +00:00
|
|
|
/* fDebugCanvas is reinitialized every load picture. Need it to retain value
|
2012-08-07 16:12:23 +00:00
|
|
|
* of the visibility filter.
|
|
|
|
* TODO(chudy): This should be deprecated since fDebugger is not
|
|
|
|
* recreated.
|
|
|
|
* */
|
|
|
|
fDebugger.highlightCurrentCommand(fSettingsWidget.getVisibilityButton()->isChecked());
|
|
|
|
|
2012-08-07 20:41:37 +00:00
|
|
|
setupListWidget(commands);
|
|
|
|
setupComboBox(commands);
|
2013-03-12 15:33:40 +00:00
|
|
|
setupOverviewText(NULL, 0.0, 1);
|
2012-07-17 15:40:51 +00:00
|
|
|
fInspectorWidget.setDisabled(false);
|
2012-07-12 14:31:25 +00:00
|
|
|
fSettingsWidget.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
fMenuEdit.setDisabled(false);
|
|
|
|
fMenuNavigate.setDisabled(false);
|
|
|
|
fMenuView.setDisabled(false);
|
2012-07-28 20:16:11 +00:00
|
|
|
fActionSave.setDisabled(false);
|
|
|
|
fActionSaveAs.setDisabled(false);
|
2012-07-19 13:41:27 +00:00
|
|
|
fLoading = false;
|
|
|
|
actionPlay();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
void SkDebuggerGUI::setupListWidget(SkTArray<SkString>* command) {
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.clear();
|
2012-06-29 14:21:22 +00:00
|
|
|
int counter = 0;
|
2012-11-06 16:45:36 +00:00
|
|
|
int indent = 0;
|
2012-08-07 20:41:37 +00:00
|
|
|
for (int i = 0; i < command->count(); i++) {
|
2012-06-29 14:21:22 +00:00
|
|
|
QListWidgetItem *item = new QListWidgetItem();
|
2012-11-19 20:44:29 +00:00
|
|
|
item->setData(Qt::DisplayRole, (*command)[i].c_str());
|
2012-06-29 14:21:22 +00:00
|
|
|
item->setData(Qt::UserRole + 1, counter++);
|
2012-11-06 16:45:36 +00:00
|
|
|
|
2013-05-29 13:24:23 +00:00
|
|
|
if (0 == strcmp("Restore", (*command)[i].c_str()) ||
|
|
|
|
0 == strcmp("EndCommentGroup", (*command)[i].c_str())) {
|
2012-11-06 16:45:36 +00:00
|
|
|
indent -= 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->setData(Qt::UserRole + 3, indent);
|
|
|
|
|
2012-11-19 20:44:29 +00:00
|
|
|
if (0 == strcmp("Save", (*command)[i].c_str()) ||
|
2013-05-29 13:24:23 +00:00
|
|
|
0 == strcmp("Save Layer", (*command)[i].c_str()) ||
|
|
|
|
0 == strcmp("BeginCommentGroup", (*command)[i].c_str())) {
|
2012-11-06 16:45:36 +00:00
|
|
|
indent += 10;
|
|
|
|
}
|
|
|
|
|
2012-11-12 20:42:12 +00:00
|
|
|
item->setData(Qt::UserRole + 4, -1.0);
|
|
|
|
|
2012-07-10 13:19:25 +00:00
|
|
|
fListWidget.addItem(item);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-13 07:01:04 +00:00
|
|
|
void SkDebuggerGUI::setupOverviewText(const SkTDArray<double>* typeTimes,
|
2013-03-12 15:33:40 +00:00
|
|
|
double totTime,
|
|
|
|
int numRuns) {
|
2013-03-12 13:07:40 +00:00
|
|
|
SkString overview;
|
2013-03-12 15:33:40 +00:00
|
|
|
fDebugger.getOverviewText(typeTimes, totTime, &overview, numRuns);
|
2013-03-12 13:07:40 +00:00
|
|
|
fInspectorWidget.setText(overview.c_str(), SkInspectorWidget::kOverview_TabType);
|
2012-11-19 20:44:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkDebuggerGUI::setupComboBox(SkTArray<SkString>* command) {
|
|
|
|
fFilter.clear();
|
|
|
|
fFilter.addItem("--Filter By Available Commands--");
|
|
|
|
|
|
|
|
std::map<std::string, int> map;
|
|
|
|
for (int i = 0; i < command->count(); i++) {
|
|
|
|
map[(*command)[i].c_str()]++;
|
|
|
|
}
|
|
|
|
|
2012-11-20 02:01:23 +00:00
|
|
|
for (std::map<std::string, int>::iterator it = map.begin(); it != map.end();
|
2012-11-19 20:44:29 +00:00
|
|
|
++it) {
|
|
|
|
fFilter.addItem((it->first).c_str());
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
// NOTE(chudy): Makes first item unselectable.
|
2012-07-09 20:26:53 +00:00
|
|
|
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
|
2012-07-10 13:19:25 +00:00
|
|
|
fFilter.model());
|
|
|
|
QModelIndex firstIndex = model->index(0, fFilter.modelColumn(),
|
|
|
|
fFilter.rootModelIndex());
|
2012-06-29 14:21:22 +00:00
|
|
|
QStandardItem* firstItem = model->itemFromIndex(firstIndex);
|
|
|
|
firstItem->setSelectable(false);
|
|
|
|
}
|