clt debugger
Review URL: https://codereview.appspot.com/6267043 git-svn-id: http://skia.googlecode.com/svn/trunk@4404 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
05a718c9d2
commit
902ebe5eb4
73
debugger/QT/SkCanvasWidget.cpp
Normal file
73
debugger/QT/SkCanvasWidget.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
/*
|
||||
* 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 "SkPicture.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkCanvasWidget.h"
|
||||
#include <iostream>
|
||||
|
||||
SkCanvasWidget::SkCanvasWidget(QWidget *parent) :
|
||||
QWidget(parent) {
|
||||
|
||||
fBitmap = new SkBitmap();
|
||||
fBitmap->setConfig(SkBitmap::kARGB_8888_Config, 800, 800);
|
||||
fBitmap->allocPixels();
|
||||
fBitmap->eraseColor(0);
|
||||
fDevice = new SkDevice(*fBitmap);
|
||||
fCanvas = new SkCanvas(fDevice);
|
||||
fDebugCanvas = new SkDebugCanvas();
|
||||
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
|
||||
}
|
||||
|
||||
SkCanvasWidget::~SkCanvasWidget() {}
|
||||
|
||||
void SkCanvasWidget::drawTo(int index) {
|
||||
delete fCanvas;
|
||||
fCanvas = new SkCanvas(fDevice);
|
||||
fDebugCanvas->drawTo(fCanvas, index+1);
|
||||
this->update();
|
||||
}
|
||||
|
||||
void SkCanvasWidget::loadPicture(QString filename) {
|
||||
SkStream *stream = new SkFILEStream(filename.toAscii());
|
||||
SkPicture *picture = new SkPicture(stream);
|
||||
|
||||
delete fDebugCanvas;
|
||||
fDebugCanvas = new SkDebugCanvas();
|
||||
|
||||
picture->draw(fDebugCanvas);
|
||||
fDebugCanvas->draw(fCanvas);
|
||||
|
||||
/* NOTE(chudy): This was a test to determine if the canvas size is accurately
|
||||
* saved in the bounds of the recorded picture. It is not. Everyone of the
|
||||
* sample GM images is 1000x1000. Even the one that claims it is
|
||||
* 2048x2048.
|
||||
std::cout << "Width: " << picture->width();
|
||||
std::cout << " Height: " << picture->height() << std::endl; */
|
||||
|
||||
/* NOTE(chudy): Updated style sheet without a background specified to
|
||||
* draw over our SkCanvas. */
|
||||
this->setStyleSheet("QWidget {border: 1px solid #cccccc;}");
|
||||
this->update();
|
||||
}
|
||||
|
||||
void SkCanvasWidget::paintEvent(QPaintEvent *event) {
|
||||
QPainter painter(this);
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
|
||||
if (fBitmap) {
|
||||
const QPoint origin(0,0);
|
||||
QImage image((uchar *)fBitmap->getPixels(), fBitmap->width(), fBitmap->height(), QImage::Format_ARGB32_Premultiplied);
|
||||
painter.drawImage(origin,image);
|
||||
}
|
||||
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
|
||||
painter.end();
|
||||
}
|
118
debugger/QT/SkCanvasWidget.h
Normal file
118
debugger/QT/SkCanvasWidget.h
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKCANVASWIDGET_H
|
||||
#define SKCANVASWIDGET_H
|
||||
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDebugCanvas.h"
|
||||
#include "SkDevice.h"
|
||||
#include "SkPicture.h"
|
||||
#include <QApplication>
|
||||
#include <QtGui>
|
||||
#include <QWidget>
|
||||
|
||||
/** \class SkCanvasWidget
|
||||
|
||||
The QtWidget encompasses all skia screen drawing elements. It initializes
|
||||
an SkBitmap in memory that our SkCanvas draws to directly in memory.
|
||||
Then using QImage and QPainter we draw those pixels on the screen in
|
||||
this widget.
|
||||
*/
|
||||
class SkCanvasWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs a widget with the specified parent for layout purposes.
|
||||
@param parent The parent container of this widget
|
||||
*/
|
||||
SkCanvasWidget(QWidget *parent);
|
||||
|
||||
~SkCanvasWidget();
|
||||
|
||||
/**
|
||||
Executes all saved draw commands up to the specified index.
|
||||
@param index The position of the command we draw up to.
|
||||
*/
|
||||
void drawTo(int index);
|
||||
|
||||
/**
|
||||
Returns the height of the bitmap.
|
||||
*/
|
||||
int getBitmapHeight() { return fBitmap->height(); }
|
||||
|
||||
|
||||
/*
|
||||
Returns the width of the bitmap.
|
||||
*/
|
||||
int getBitmapWidth() { return fBitmap->width(); }
|
||||
|
||||
/**
|
||||
TODO(chudy): Refactor into a struct of char**
|
||||
Returns parameter information about the ith draw command.
|
||||
@param: i The index of the draw command we are accessing
|
||||
*/
|
||||
std::vector<std::string>* getCurrentCommandInfo(int i) {
|
||||
return fDebugCanvas->getCommandInfoAt(i);
|
||||
}
|
||||
|
||||
/**
|
||||
Returns a vector of strings with all the current canvas draw
|
||||
commands.
|
||||
*/
|
||||
std::vector<std::string>* getDrawCommands() {
|
||||
return fDebugCanvas->getDrawCommandsAsStrings();
|
||||
}
|
||||
|
||||
/**
|
||||
Loads a skia picture located at filename.
|
||||
@param filename The name of the file we are loading.
|
||||
*/
|
||||
void loadPicture(QString filename);
|
||||
|
||||
/**
|
||||
Toggles the visibility / execution of the draw command at index i.
|
||||
*/
|
||||
void toggleCommand(int index) {
|
||||
fDebugCanvas->toggleCommand(index);
|
||||
}
|
||||
|
||||
/**
|
||||
Toggles the visibility / execution of the draw command at index i with
|
||||
the value of toggle.
|
||||
*/
|
||||
void toggleCommand(int index, bool toggle) {
|
||||
fDebugCanvas->toggleCommand(index, toggle);
|
||||
}
|
||||
|
||||
/**
|
||||
Toggles drawing filter on all drawing commands previous to current.
|
||||
*/
|
||||
void toggleCurrentCommandFilter(bool toggle) {
|
||||
fDebugCanvas->toggleFilter(toggle);
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
Draws the current state of the widget.
|
||||
@param event The event intercepted by Qt
|
||||
*/
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
private:
|
||||
SkBitmap* fBitmap;
|
||||
SkCanvas* fCanvas;
|
||||
SkDebugCanvas* fDebugCanvas;
|
||||
SkDevice* fDevice;
|
||||
};
|
||||
|
||||
#endif
|
593
debugger/QT/SkDebuggerGUI.cpp
Normal file
593
debugger/QT/SkDebuggerGUI.cpp
Normal file
@ -0,0 +1,593 @@
|
||||
|
||||
/*
|
||||
* 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 <iostream>
|
||||
#include "SkDebuggerGUI.h"
|
||||
#include <QListWidgetItem>
|
||||
|
||||
SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
|
||||
QMainWindow(parent) {
|
||||
|
||||
setupUi(this);
|
||||
connect(fListWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
|
||||
QListWidgetItem*)), this, SLOT(registerListClick(QListWidgetItem *)));
|
||||
connect(fActionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||
connect(fActionDirectory, SIGNAL(triggered()), this, SLOT(toggleDirectory()));
|
||||
connect(fDirectoryWidget, SIGNAL(currentItemChanged(QListWidgetItem*,
|
||||
QListWidgetItem*)), this, SLOT(loadFile(QListWidgetItem *)));
|
||||
connect(fActionDelete, SIGNAL(triggered()), this, SLOT(actionDelete()));
|
||||
connect(fActionReload, SIGNAL(triggered()), this, SLOT(actionReload()));
|
||||
connect(fListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(toggleBreakpoint()));
|
||||
connect(fActionRewind, SIGNAL(triggered()), this, SLOT(actionRewind()));
|
||||
connect(fActionPlay, SIGNAL(triggered()), this, SLOT(actionPlay()));
|
||||
connect(fActionStepBack, SIGNAL(triggered()), this, SLOT(actionStepBack()));
|
||||
connect(fActionStepForward, SIGNAL(triggered()), this, SLOT(actionStepForward()));
|
||||
connect(fActionBreakpoint, SIGNAL(triggered()), this, SLOT(actionBreakpoints()));
|
||||
connect(fActionInspector, SIGNAL(triggered()), this, SLOT(actionInspector()));
|
||||
connect(fFilter, SIGNAL(activated(QString)), this, SLOT(toggleFilter(QString)));
|
||||
connect(fActionCancel, SIGNAL(triggered()), this, SLOT(actionCancel()));
|
||||
connect(fActionClose, SIGNAL(triggered()), this, SLOT(actionClose()));
|
||||
connect(fActionSettings, SIGNAL(triggered()), this, SLOT(actionSettings()));
|
||||
connect(fActionToggleCurrentCommand, SIGNAL(triggered()), this, SLOT(actionCommandFilter()));
|
||||
}
|
||||
|
||||
SkDebuggerGUI::~SkDebuggerGUI() {
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionBreakpoints() {
|
||||
if(!fBreakpointsActivated) {
|
||||
fBreakpointsActivated = true;
|
||||
} else {
|
||||
fBreakpointsActivated = false;
|
||||
}
|
||||
|
||||
for(int row=0; row<fListWidget->count(); row++) {
|
||||
QListWidgetItem *item = fListWidget->item(row);
|
||||
|
||||
if (item->checkState() == Qt::Unchecked && fBreakpointsActivated) {
|
||||
item->setHidden(true);
|
||||
} else {
|
||||
item->setHidden(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionCancel() {
|
||||
for(int row=0; row<fListWidget->count(); row++) {
|
||||
fListWidget->item(row)->setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionCommandFilter() {
|
||||
if (fActionToggleCurrentCommand->text() == "Show Filter") {
|
||||
fCanvasWidget->toggleCurrentCommandFilter(true);
|
||||
fActionToggleCurrentCommand->setText("Hide Filter");
|
||||
} else {
|
||||
fActionToggleCurrentCommand->setText("Show Filter");
|
||||
fCanvasWidget->toggleCurrentCommandFilter(false);
|
||||
}
|
||||
|
||||
fCanvasWidget->drawTo(fListWidget->currentRow());
|
||||
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionClose() {
|
||||
this->close();
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionDelete() {
|
||||
QListWidgetItem* item = fListWidget->currentItem();
|
||||
|
||||
if(item->data(Qt::UserRole + 2) == true) {
|
||||
item->setData(Qt::UserRole + 2, false);
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/delete.png"));
|
||||
|
||||
} else {
|
||||
item->setData(Qt::UserRole + 2, true);
|
||||
if(item->checkState() == Qt::Unchecked) {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/blank.png"));
|
||||
} else {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/breakpoint_16x16.png"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int currentRow = fListWidget->currentRow();
|
||||
|
||||
// NOTE(chudy): Forces a redraw up to current selected command.
|
||||
if (fCanvasWidget) {
|
||||
fCanvasWidget->toggleCommand(currentRow);
|
||||
fCanvasWidget->drawTo(currentRow);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionInspector() {
|
||||
if (fInspectorWidget->isHidden()) {
|
||||
fInspectorWidget->setHidden(false);
|
||||
} else {
|
||||
fInspectorWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionPlay() {
|
||||
for(int row=fListWidget->currentRow()+1; row<fListWidget->count(); row++) {
|
||||
QListWidgetItem *item = fListWidget->item(row);
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
fListWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fListWidget->setCurrentRow(fListWidget->count() - 1);
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionReload() {
|
||||
for(int row=0; row<fListWidget->count(); row++) {
|
||||
QListWidgetItem* item = fListWidget->item(row);
|
||||
item->setData(Qt::UserRole + 2, true);
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/blank.png"));
|
||||
fCanvasWidget->toggleCommand(row, true);
|
||||
}
|
||||
|
||||
fCanvasWidget->drawTo(fListWidget->currentRow());
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionRewind() {
|
||||
/* NOTE(chudy): Hack. All skps opened so far start with save and concat
|
||||
* commands that don't clear or reset the canvas. */
|
||||
fListWidget->setCurrentRow(2);
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionSettings() {
|
||||
if (fSettingsWidget->isHidden()) {
|
||||
fSettingsWidget->setHidden(false);
|
||||
} else {
|
||||
fSettingsWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionStepBack() {
|
||||
int currentRow = fListWidget->currentRow();
|
||||
if (currentRow != 0) {
|
||||
fListWidget->setCurrentRow(currentRow - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::actionStepForward() {
|
||||
int currentRow = fListWidget->currentRow();
|
||||
|
||||
QString curRow = QString::number(currentRow);
|
||||
QString curCount = QString::number(fListWidget->count());
|
||||
|
||||
|
||||
if (currentRow < fListWidget->count() - 1) {
|
||||
fListWidget->setCurrentRow(currentRow + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::loadFile(QListWidgetItem *item) {
|
||||
if (fDirectoryWidgetActive) {
|
||||
QString fileName;
|
||||
fileName.append(fPath);
|
||||
fileName.append("/");
|
||||
fileName.append(item->text());
|
||||
loadPicture(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::openFile() {
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
|
||||
"",
|
||||
tr("Files (*.*)"));
|
||||
fDirectoryWidgetActive = false;
|
||||
if (!fileName.isNull()) {
|
||||
|
||||
QFileInfo pathInfo(fileName);
|
||||
fPath = pathInfo.path();
|
||||
loadPicture(fileName);
|
||||
setupDirectoryWidget();
|
||||
}
|
||||
/* TODO(chudy): Need something here that sets the active directory
|
||||
* widget selection to what was opened. OR we can just add a new function
|
||||
* to change the directory (would be much easier).
|
||||
*/
|
||||
fDirectoryWidgetActive = true;
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
|
||||
int currentRow = fListWidget->currentRow();
|
||||
|
||||
// NOTE(chudy): Prevents initialization errors.
|
||||
if (fCanvasWidget) {
|
||||
fCanvasWidget->drawTo(currentRow);
|
||||
std::vector<std::string> *v =
|
||||
fCanvasWidget->getCurrentCommandInfo(currentRow);
|
||||
|
||||
|
||||
/* TODO(chudy): Add command type before parameters. Rename v
|
||||
* to something more informative. */
|
||||
if (v) {
|
||||
std::vector<std::string>::iterator it;
|
||||
|
||||
QString info;
|
||||
info.append("<b>Parameters: </b><br/>");
|
||||
for (it = v->begin(); it != v->end(); ++it) {
|
||||
info.append(QString((*it).c_str()));
|
||||
info.append("<br/>");
|
||||
}
|
||||
fInspectorWidget->setDetailText(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::toggleBreakpoint() {
|
||||
QListWidgetItem* item = fListWidget->currentItem();
|
||||
if (item->checkState() == Qt::Unchecked) {
|
||||
item->setCheckState(Qt::Checked);
|
||||
|
||||
|
||||
/* NOTE(chudy): If the command is toggled as hidden that takes
|
||||
* precendence over the breakpoint icon.
|
||||
*/
|
||||
if(item->data(Qt::UserRole + 2) == false) {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/delete.png"));
|
||||
} else {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/breakpoint_16x16.png"));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* NOTE(chudy): When untoggling as a breakpoint if the command
|
||||
* is hidden then the portraying icon should remain the delete icon.
|
||||
*/
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
|
||||
if(item->data(Qt::UserRole + 2) == false) {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/delete.png"));
|
||||
} else {
|
||||
item->setData(Qt::DecorationRole,
|
||||
QPixmap(":/images/Icons/blank.png"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::toggleDirectory() {
|
||||
if (fDirectoryWidget->isHidden()) {
|
||||
fDirectoryWidget->setHidden(false);
|
||||
} else {
|
||||
fDirectoryWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::toggleFilter(QString string) {
|
||||
for(int row=0; row<fListWidget->count(); row++) {
|
||||
QListWidgetItem *item = fListWidget->item(row);
|
||||
if (item->text() == string) {
|
||||
item->setHidden(false);
|
||||
} else {
|
||||
item->setHidden(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::setupUi(QMainWindow *SkDebuggerGUI) {
|
||||
QIcon windowIcon;
|
||||
windowIcon.addFile(QString::fromUtf8(":/images/Icons/skia.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
SkDebuggerGUI->setObjectName(QString::fromUtf8("SkDebuggerGUI"));
|
||||
SkDebuggerGUI->resize(1200, 1000);
|
||||
SkDebuggerGUI->setWindowIcon(windowIcon);
|
||||
|
||||
QIcon open;
|
||||
open.addFile(QString::fromUtf8(":/images/Icons/package-br32.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionOpen = new QAction(SkDebuggerGUI);
|
||||
fActionOpen->setObjectName(QString::fromUtf8("actionOpen"));
|
||||
fActionOpen->setIcon(open);
|
||||
|
||||
QIcon directory;
|
||||
directory.addFile(QString::fromUtf8(":/images/Icons/drawer-open-icon.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionDirectory = new QAction(SkDebuggerGUI);
|
||||
fActionDirectory->setObjectName(QString::fromUtf8("actionDirectory"));
|
||||
fActionDirectory->setIcon(directory);
|
||||
fActionDirectory->setText("Toggle Directory");
|
||||
|
||||
QIcon rewind;
|
||||
rewind.addFile(QString::fromUtf8(":/images/Icons/rewind.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionRewind = new QAction(SkDebuggerGUI);
|
||||
fActionRewind->setObjectName(QString::fromUtf8("actionRewind"));
|
||||
fActionRewind->setIcon(rewind);
|
||||
fActionRewind->setText("Rewind");
|
||||
|
||||
QIcon stepBack;
|
||||
stepBack.addFile(QString::fromUtf8(":/images/Icons/back.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionStepBack = new QAction(SkDebuggerGUI);
|
||||
fActionStepBack->setObjectName(QString::fromUtf8("actionStepBack"));
|
||||
fActionStepBack->setIcon(stepBack);
|
||||
fActionStepBack->setText("Step Back");
|
||||
|
||||
QIcon stepForward;
|
||||
stepForward.addFile(QString::fromUtf8(":/images/Icons/go-next.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionStepForward = new QAction(SkDebuggerGUI);
|
||||
fActionStepForward->setObjectName(QString::fromUtf8("actionStepBack"));
|
||||
fActionStepForward->setIcon(stepForward);
|
||||
fActionStepForward->setText("Step Forward");
|
||||
|
||||
QIcon play;
|
||||
play.addFile(QString::fromUtf8(":/images/Icons/play.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionPlay = new QAction(SkDebuggerGUI);
|
||||
fActionPlay->setObjectName(QString::fromUtf8("actionPlay"));
|
||||
fActionPlay->setIcon(play);
|
||||
fActionPlay->setText("Play");
|
||||
|
||||
QIcon breakpoint;
|
||||
breakpoint.addFile(QString::fromUtf8(":/images/Icons/breakpoint.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionBreakpoint = new QAction(SkDebuggerGUI);
|
||||
fActionBreakpoint->setObjectName(QString::fromUtf8("actionBreakpoint"));
|
||||
fActionBreakpoint->setIcon(breakpoint);
|
||||
fActionBreakpoint->setText("Show Breakpoints");
|
||||
|
||||
QIcon inspector;
|
||||
inspector.addFile(QString::fromUtf8(":/images/Icons/inspector.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionInspector = new QAction(SkDebuggerGUI);
|
||||
fActionInspector->setObjectName(QString::fromUtf8("actionInspector"));
|
||||
fActionInspector->setIcon(inspector);
|
||||
fActionInspector->setText("Inspector");
|
||||
|
||||
QIcon deleteIcon;
|
||||
deleteIcon.addFile(QString::fromUtf8(":/images/Icons/delete.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionDelete = new QAction(SkDebuggerGUI);
|
||||
fActionDelete->setObjectName(QString::fromUtf8("actionDelete"));
|
||||
fActionDelete->setIcon(deleteIcon);
|
||||
fActionDelete->setText("Delete Command");
|
||||
|
||||
QIcon reload;
|
||||
reload.addFile(QString::fromUtf8(":/images/Icons/reload.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionReload = new QAction(SkDebuggerGUI);
|
||||
fActionReload->setObjectName(QString::fromUtf8("actionReload"));
|
||||
fActionReload->setIcon(reload);
|
||||
fActionReload->setText("Reset Picture");
|
||||
|
||||
QIcon settings;
|
||||
settings.addFile(QString::fromUtf8(":/images/Icons/settings.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionSettings = new QAction(SkDebuggerGUI);
|
||||
fActionSettings->setObjectName(QString::fromUtf8("actionSettings"));
|
||||
fActionSettings->setIcon(settings);
|
||||
fActionSettings->setText("Settings");
|
||||
|
||||
QIcon cancel;
|
||||
cancel.addFile(QString::fromUtf8(":/images/Icons/reset.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
fActionCancel = new QAction(SkDebuggerGUI);
|
||||
fActionCancel->setObjectName(QString::fromUtf8("actionCancel"));
|
||||
fActionCancel->setIcon(cancel);
|
||||
fActionCancel->setText("Clear Filter");
|
||||
|
||||
fCentralWidget = new QWidget(SkDebuggerGUI);
|
||||
fCentralWidget->setObjectName(QString::fromUtf8("centralWidget"));
|
||||
|
||||
fHorizontalLayout = new QHBoxLayout(fCentralWidget);
|
||||
fHorizontalLayout->setSpacing(6);
|
||||
fHorizontalLayout->setContentsMargins(11, 11, 11, 11);
|
||||
fHorizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
|
||||
|
||||
fVerticalLayout = new QVBoxLayout();
|
||||
fVerticalLayout->setSpacing(6);
|
||||
fVerticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
|
||||
|
||||
fVerticalLayout_2 = new QVBoxLayout();
|
||||
fVerticalLayout_2->setSpacing(6);
|
||||
fVerticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
|
||||
|
||||
fListWidget = new QListWidget(fCentralWidget);
|
||||
fListWidget->setItemDelegate(new SkListWidget(fListWidget));
|
||||
fListWidget->setObjectName(QString::fromUtf8("listWidget"));
|
||||
fListWidget->setMaximumWidth(250);
|
||||
|
||||
fInspectorWidget = new SkInspectorWidget();
|
||||
fInspectorWidget->setObjectName(QString::fromUtf8("inspectorWidget"));
|
||||
fInspectorWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
fInspectorWidget->setMaximumHeight(300);
|
||||
|
||||
fFilter = new QComboBox(fCentralWidget);
|
||||
fFilter->setObjectName(QString::fromUtf8("comboBox"));
|
||||
fFilter->addItem("--Filter By Available Commands--");
|
||||
|
||||
fDirectoryWidget = new QListWidget(fCentralWidget);
|
||||
fDirectoryWidget->setObjectName(QString::fromUtf8("listWidget_2"));
|
||||
fDirectoryWidget->setMaximumWidth(250);
|
||||
fDirectoryWidget->setStyleSheet("QListWidget::Item {padding: 5px;}");
|
||||
|
||||
fVerticalLayout_2->addWidget(fListWidget);
|
||||
fVerticalLayout_2->addWidget(fDirectoryWidget);
|
||||
|
||||
fCanvasWidget = new SkCanvasWidget(fCentralWidget);
|
||||
fCanvasWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
fSettingsWidget = new SkSettingsWidget(fCentralWidget);
|
||||
fSettingsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
fSettingsWidget->setMaximumWidth(250);
|
||||
fSettingsWidget->setHidden(true);
|
||||
|
||||
fHorizontalLayout_2 = new QHBoxLayout();
|
||||
fHorizontalLayout_2->setSpacing(6);
|
||||
|
||||
fHorizontalLayout_2->addWidget(fCanvasWidget);
|
||||
fHorizontalLayout_2->addWidget(fSettingsWidget);
|
||||
|
||||
fVerticalLayout->addLayout(fHorizontalLayout_2);
|
||||
fVerticalLayout->addWidget(fInspectorWidget);
|
||||
|
||||
fHorizontalLayout->addLayout(fVerticalLayout_2);
|
||||
fHorizontalLayout->addLayout(fVerticalLayout);
|
||||
|
||||
SkDebuggerGUI->setCentralWidget(fCentralWidget);
|
||||
fStatusBar = new QStatusBar(SkDebuggerGUI);
|
||||
fStatusBar->setObjectName(QString::fromUtf8("statusBar"));
|
||||
SkDebuggerGUI->setStatusBar(fStatusBar);
|
||||
fToolBar = new QToolBar(SkDebuggerGUI);
|
||||
fToolBar->setObjectName(QString::fromUtf8("toolBar"));
|
||||
fToolBar->setIconSize(QSize(24, 24));
|
||||
//fToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
SkDebuggerGUI->addToolBar(Qt::TopToolBarArea, fToolBar);
|
||||
|
||||
QWidget *spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
fToolBar->addAction(fActionOpen);
|
||||
fToolBar->addSeparator();
|
||||
fToolBar->addAction(fActionDirectory);
|
||||
fToolBar->addSeparator();
|
||||
fToolBar->addAction(fActionRewind);
|
||||
fToolBar->addAction(fActionStepBack);
|
||||
fToolBar->addAction(fActionStepForward);
|
||||
fToolBar->addAction(fActionPlay);
|
||||
fToolBar->addSeparator();
|
||||
fToolBar->addAction(fActionBreakpoint);
|
||||
fToolBar->addAction(fActionInspector);
|
||||
fToolBar->addSeparator();
|
||||
fToolBar->addAction(fActionDelete);
|
||||
fToolBar->addAction(fActionReload);
|
||||
fToolBar->addSeparator();
|
||||
fToolBar->addAction(fActionSettings);
|
||||
fToolBar->addWidget(spacer);
|
||||
fToolBar->addWidget(fFilter);
|
||||
fToolBar->addAction(fActionCancel);
|
||||
|
||||
// TODO(chudy): Remove static call.
|
||||
fDirectoryWidgetActive = false;
|
||||
fPath= "/usr/local/google/home/chudy/trunk-linux/debugger/skp";
|
||||
setupDirectoryWidget();
|
||||
fDirectoryWidgetActive = true;
|
||||
|
||||
fMenuBar = new QMenuBar(SkDebuggerGUI);
|
||||
|
||||
// File
|
||||
fMenuFile = new QMenu(SkDebuggerGUI);
|
||||
fMenuFile->setTitle("File");
|
||||
|
||||
fActionClose = new QAction(SkDebuggerGUI);
|
||||
fActionClose->setText("Close");
|
||||
|
||||
fMenuFile->addAction(fActionOpen);
|
||||
fMenuFile->addAction(fActionClose);
|
||||
|
||||
// View
|
||||
fMenuView = new QMenu(SkDebuggerGUI);
|
||||
fMenuView->setTitle("View");
|
||||
|
||||
fActionToggleCurrentCommand = new QAction(SkDebuggerGUI);
|
||||
fActionToggleCurrentCommand->setText("Show Filter");
|
||||
|
||||
fMenuView->addAction(fActionToggleCurrentCommand);
|
||||
|
||||
// Navigate
|
||||
fMenuNavigate = new QMenu(SkDebuggerGUI);
|
||||
fMenuNavigate->setTitle("Navigate");
|
||||
|
||||
fActionGoToLine = new QAction(SkDebuggerGUI);
|
||||
fActionGoToLine->setText("Go to Line...");
|
||||
fActionGoToLine->setDisabled(true);
|
||||
|
||||
fMenuNavigate->addAction(fActionGoToLine);
|
||||
|
||||
// Menu Bar
|
||||
fMenuBar->addAction(fMenuFile->menuAction());
|
||||
fMenuBar->addAction(fMenuView->menuAction());
|
||||
fMenuBar->addAction(fMenuNavigate->menuAction());
|
||||
|
||||
SkDebuggerGUI->setMenuBar(fMenuBar);
|
||||
|
||||
retranslateUi(SkDebuggerGUI);
|
||||
QMetaObject::connectSlotsByName(SkDebuggerGUI);
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::setupDirectoryWidget() {
|
||||
fDir = new QDir(fPath);
|
||||
QRegExp r(".skp");
|
||||
fDirectoryWidget->clear();
|
||||
const QStringList files = fDir->entryList();
|
||||
foreach (QString f, files) {
|
||||
if (f.contains(r)) fDirectoryWidget->addItem(f);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(chudy): Is this necessary?
|
||||
void SkDebuggerGUI::retranslateUi(QMainWindow *SkDebuggerGUI) {
|
||||
SkDebuggerGUI->setWindowTitle(QApplication::translate("SkDebuggerGUI", "SkDebuggerGUI", 0, QApplication::UnicodeUTF8));
|
||||
fActionOpen->setText(QApplication::translate("SkDebuggerGUI", "Open", 0, QApplication::UnicodeUTF8));
|
||||
fToolBar->setWindowTitle(QApplication::translate("SkDebuggerGUI", "toolBar", 0, QApplication::UnicodeUTF8));
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::loadPicture(QString fileName) {
|
||||
fCanvasWidget->loadPicture(fileName);
|
||||
std::vector<std::string> *cv = fCanvasWidget->getDrawCommands();
|
||||
setupListWidget(cv);
|
||||
setupComboBox(cv);
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) {
|
||||
fListWidget->clear();
|
||||
int counter = 0;
|
||||
for (unsigned int i = 0; i < cv->size(); i++) {
|
||||
QListWidgetItem *item = new QListWidgetItem();
|
||||
item->setData(Qt::DisplayRole, (*cv)[i].c_str());
|
||||
item->setData(Qt::UserRole + 1, counter++);
|
||||
item->setData(Qt::UserRole + 2, true);
|
||||
fListWidget->addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebuggerGUI::setupComboBox(std::vector<std::string>* cv) {
|
||||
fFilter->clear();
|
||||
fFilter->addItem("--Filter By Available Commands--");
|
||||
|
||||
std::map<std::string, int> map;
|
||||
for (unsigned int i = 0; i < cv->size(); i++) {
|
||||
map[(*cv)[i]]++;
|
||||
}
|
||||
|
||||
QString overview;
|
||||
int counter;
|
||||
for(std::map<std::string, int>::iterator it = map.begin(); it != map.end(); ++it) {
|
||||
overview.append((it->first).c_str());
|
||||
overview.append(": ");
|
||||
overview.append(QString::number(it->second));
|
||||
overview.append("<br/>");
|
||||
counter+=it->second;
|
||||
fFilter->addItem((it->first).c_str());
|
||||
}
|
||||
QString total;
|
||||
total.append("Total Draw Commands: ");
|
||||
total.append(QString::number(counter));
|
||||
total.append("<br/>");
|
||||
overview.insert(0, total);
|
||||
|
||||
overview.append("<br/>");
|
||||
overview.append("SkBitmap Width: ");
|
||||
// NOTE(chudy): This is where we can pull out the SkPictures width.
|
||||
overview.append(QString::number(fCanvasWidget->getBitmapWidth()));
|
||||
overview.append("px<br/>");
|
||||
overview.append("SkBitmap Height: ");
|
||||
overview.append(QString::number(fCanvasWidget->getBitmapHeight()));
|
||||
overview.append("px");
|
||||
fInspectorWidget->setOverviewText(overview);
|
||||
|
||||
// NOTE(chudy): Makes first item unselectable.
|
||||
QStandardItemModel* model =
|
||||
qobject_cast<QStandardItemModel*>(fFilter->model());
|
||||
QModelIndex firstIndex = model->index(0, fFilter->modelColumn(),
|
||||
fFilter->rootModelIndex());
|
||||
QStandardItem* firstItem = model->itemFromIndex(firstIndex);
|
||||
firstItem->setSelectable(false);
|
||||
}
|
229
debugger/QT/SkDebuggerGUI.h
Normal file
229
debugger/QT/SkDebuggerGUI.h
Normal file
@ -0,0 +1,229 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKDEBUGGERUI_H
|
||||
#define SKDEBUGGERUI_H
|
||||
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDebugCanvas.h"
|
||||
#include "SkListWidget.h"
|
||||
#include "SkInspectorWidget.h"
|
||||
#include "SkCanvasWidget.h"
|
||||
#include "SkSettingsWidget.h"
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QListView>
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <vector>
|
||||
|
||||
/** \class SkDebuggerGUI
|
||||
|
||||
Container for the UI and it's functions.
|
||||
*/
|
||||
class SkDebuggerGUI : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs the view of the application.
|
||||
@param parent The parent container of this widget.
|
||||
*/
|
||||
SkDebuggerGUI(QWidget *parent = 0);
|
||||
|
||||
~SkDebuggerGUI();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
Toggles breakpoint view in the list widget.
|
||||
*/
|
||||
void actionBreakpoints();
|
||||
|
||||
/**
|
||||
Cancels the command filter in the list widget.
|
||||
*/
|
||||
void actionCancel();
|
||||
|
||||
/**
|
||||
Applies a visible filter to all drawing commands other than the previous.
|
||||
*/
|
||||
void actionCommandFilter();
|
||||
|
||||
/**
|
||||
Closes the application.
|
||||
*/
|
||||
void actionClose();
|
||||
|
||||
/**
|
||||
Deletes the command in question.
|
||||
*/
|
||||
void actionDelete();
|
||||
|
||||
/**
|
||||
Toggles the visibility of the inspector widget.
|
||||
*/
|
||||
void actionInspector();
|
||||
|
||||
/**
|
||||
Plays from the current step to the next breakpoint if it exists, otherwise
|
||||
executes all remaining draw commands.
|
||||
*/
|
||||
void actionPlay();
|
||||
|
||||
/**
|
||||
Resets all deleted commands.
|
||||
*/
|
||||
void actionReload();
|
||||
|
||||
/**
|
||||
Rewinds from the current step back to the start of the commands.
|
||||
*/
|
||||
void actionRewind();
|
||||
|
||||
/**
|
||||
Toggles the settings widget visibility.
|
||||
*/
|
||||
void actionSettings();
|
||||
|
||||
/**
|
||||
Steps forward to the next draw command.
|
||||
*/
|
||||
void actionStepBack();
|
||||
|
||||
/**
|
||||
Steps backwards to the next draw command.
|
||||
*/
|
||||
void actionStepForward();
|
||||
|
||||
/**
|
||||
Loads an skpicture selected from the directory.
|
||||
*/
|
||||
void loadFile(QListWidgetItem *item);
|
||||
|
||||
/**
|
||||
Toggles a dialog with a file browser for navigating to a skpicture. Loads
|
||||
the seleced file.
|
||||
*/
|
||||
void openFile();
|
||||
|
||||
/**
|
||||
Executes draw commands up to the selected command
|
||||
*/
|
||||
void registerListClick(QListWidgetItem *item);
|
||||
|
||||
/**
|
||||
Toggles a breakpoint on the current step in the list widget.
|
||||
*/
|
||||
void toggleBreakpoint();
|
||||
|
||||
/**
|
||||
Toggles the visibility of the directory widget.
|
||||
*/
|
||||
void toggleDirectory();
|
||||
|
||||
/**
|
||||
Filters the list widgets command visibility based on the currently
|
||||
active selection.
|
||||
*/
|
||||
void toggleFilter(QString string);
|
||||
|
||||
private:
|
||||
QAction* fActionOpen;
|
||||
QAction* fActionDirectory;
|
||||
QAction* fActionRewind;
|
||||
QAction* fActionStepBack;
|
||||
QAction* fActionStepForward;
|
||||
QAction* fActionPlay;
|
||||
QAction* fActionBreakpoint;
|
||||
QAction* fActionInspector;
|
||||
QAction* fActionDelete;
|
||||
QAction* fActionReload;
|
||||
QAction* fActionClose;
|
||||
QAction* fActionSettings;
|
||||
|
||||
QComboBox* fFilter;
|
||||
QAction* fActionCancel;
|
||||
|
||||
QWidget* fCentralWidget;
|
||||
QHBoxLayout* fHorizontalLayout;
|
||||
QHBoxLayout* fHorizontalLayout_2;
|
||||
QVBoxLayout* fVerticalLayout;
|
||||
QVBoxLayout* fVerticalLayout_2;
|
||||
QListWidget* fListWidget;
|
||||
QListWidget* fDirectoryWidget;
|
||||
QListView* fListView;
|
||||
QStatusBar* fStatusBar;
|
||||
QToolBar* fToolBar;
|
||||
|
||||
SkCanvasWidget* fCanvasWidget;
|
||||
SkInspectorWidget* fInspectorWidget;
|
||||
SkSettingsWidget* fSettingsWidget;
|
||||
|
||||
QDir* fDir;
|
||||
QString fPath;
|
||||
bool fDirectoryWidgetActive;
|
||||
QMenuBar* fMenuBar;
|
||||
|
||||
QMenu* fMenuFile;
|
||||
QAction* fActionQuit;
|
||||
QAction* fActionTemp;
|
||||
|
||||
QMenu* fMenuView;
|
||||
QAction* fActionToggleCurrentCommand;
|
||||
|
||||
QMenu* fMenuNavigate;
|
||||
QAction *fActionGoToLine;
|
||||
|
||||
bool fBreakpointsActivated;
|
||||
|
||||
/**
|
||||
Creates the entire UI.
|
||||
*/
|
||||
void setupUi(QMainWindow *SkDebuggerGUI);
|
||||
|
||||
/**
|
||||
Placeholder function for executing new commands on window translate
|
||||
and resize.
|
||||
*/
|
||||
void retranslateUi(QMainWindow *SkDebuggerGUI);
|
||||
|
||||
/**
|
||||
Pipes a QString in with the location of the filename, proceeds to updating
|
||||
the listwidget, combowidget and inspectorwidget.
|
||||
*/
|
||||
void loadPicture(QString fileName);
|
||||
|
||||
/**
|
||||
Populates the list widget with the vector of strings passed in.
|
||||
*/
|
||||
void setupListWidget(std::vector<std::string>* cv);
|
||||
|
||||
/**
|
||||
Populates the combo box widget with the vector of strings passed in.
|
||||
*/
|
||||
void setupComboBox(std::vector<std::string>* cv);
|
||||
|
||||
/**
|
||||
Updates the directory widget with the latest directory path stored in
|
||||
the global class variable fPath.
|
||||
*/
|
||||
void setupDirectoryWidget();
|
||||
};
|
||||
|
||||
#endif // SKDEBUGGERUI_H
|
18
debugger/QT/SkIcons.qrc
Normal file
18
debugger/QT/SkIcons.qrc
Normal file
@ -0,0 +1,18 @@
|
||||
<RCC>
|
||||
<qresource prefix="/images">
|
||||
<file>Icons/package-br32.png</file>
|
||||
<file>Icons/drawer-open-icon.png</file>
|
||||
<file>Icons/rewind.png</file>
|
||||
<file>Icons/back.png</file>
|
||||
<file>Icons/go-next.png</file>
|
||||
<file>Icons/play.png</file>
|
||||
<file>Icons/breakpoint.png</file>
|
||||
<file>Icons/breakpoint_16x16.png</file>
|
||||
<file>Icons/inspector.png</file>
|
||||
<file>Icons/reset.png</file>
|
||||
<file>Icons/skia.png</file>
|
||||
<file>Icons/delete.png</file>
|
||||
<file>Icons/reload.png</file>
|
||||
<file>Icons/settings.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
127
debugger/QT/SkInspectorWidget.cpp
Normal file
127
debugger/QT/SkInspectorWidget.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
/*
|
||||
* 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 "SkInspectorWidget.h"
|
||||
#include <iostream>
|
||||
|
||||
SkInspectorWidget::SkInspectorWidget(QWidget *parent) : QWidget(parent) {
|
||||
// NOTE(chudy): Keeps the inspector widget fully expanded.
|
||||
fHorizontalLayout = new QHBoxLayout(this);
|
||||
fHorizontalLayout->setSpacing(6);
|
||||
fHorizontalLayout->setContentsMargins(11, 11, 11, 11);
|
||||
|
||||
fTabWidget = new QTabWidget();
|
||||
|
||||
fOverviewTab = new QWidget();
|
||||
fOverviewLayout = new QHBoxLayout(fOverviewTab);
|
||||
fOverviewLayout->setSpacing(6);
|
||||
fOverviewLayout->setContentsMargins(11, 11, 11, 11);
|
||||
fOverviewText = new QTextEdit();
|
||||
fOverviewText->setReadOnly(true);
|
||||
fOverviewLayout->addWidget(fOverviewText);
|
||||
|
||||
fDetailTab = new QWidget();
|
||||
fDetailLayout = new QHBoxLayout(fDetailTab);
|
||||
fDetailLayout->setSpacing(6);
|
||||
fDetailLayout->setContentsMargins(11,11,11,11);
|
||||
fDetailText = new QTextEdit();
|
||||
fDetailText->setReadOnly(true);
|
||||
fDetailLayout->addWidget(fDetailText);
|
||||
|
||||
fTabWidget->addTab(fOverviewTab, QString("Overview"));
|
||||
fTabWidget->addTab(fDetailTab, QString("Details"));
|
||||
|
||||
fHorizontalLayout->setAlignment(Qt::AlignTop);
|
||||
fHorizontalLayout->addWidget(fTabWidget);
|
||||
|
||||
/* NOTE(chudy): We add all the line edits to (this). Then we lay them out
|
||||
* by adding them to horizontal layouts.
|
||||
*
|
||||
* We will have 1 big vertical layout, 3 horizontal layouts and then 3
|
||||
* line edits in each horizontal layout.
|
||||
*/
|
||||
|
||||
fMatrixAndClipWidget = new QWidget(this);
|
||||
fMatrixAndClipWidget->setFixedSize(200,300);
|
||||
fMatrixAndClipWidget->setDisabled(true);
|
||||
|
||||
fVerticalLayout = new QVBoxLayout(fMatrixAndClipWidget);
|
||||
fVerticalLayout->setAlignment(Qt::AlignVCenter);
|
||||
fVerticalLayout->addLayout(currentMatrix());
|
||||
fVerticalLayout->addLayout(currentClip());
|
||||
fHorizontalLayout->addWidget(fMatrixAndClipWidget);
|
||||
|
||||
|
||||
}
|
||||
|
||||
SkInspectorWidget::~SkInspectorWidget() {}
|
||||
|
||||
QString SkInspectorWidget::getDetailText() {
|
||||
return fDetailText->toHtml();
|
||||
}
|
||||
|
||||
QString SkInspectorWidget::getOverviewText() {
|
||||
return fOverviewText->toHtml();
|
||||
}
|
||||
|
||||
void SkInspectorWidget::setDetailText(QString text) {
|
||||
fDetailText->setHtml(text);
|
||||
}
|
||||
|
||||
void SkInspectorWidget::setOverviewText(QString text) {
|
||||
fOverviewText->setHtml(text);
|
||||
}
|
||||
|
||||
QVBoxLayout* SkInspectorWidget::currentMatrix() {
|
||||
fMatrixLabel = new QLabel(this);
|
||||
fMatrixLabel->setText("Current Matrix");
|
||||
fMatrixLabel->setAlignment(Qt::AlignHCenter);
|
||||
fMatrixLayout = new QVBoxLayout();
|
||||
fMatrixLayout->setSpacing(6);
|
||||
fMatrixLayout->setContentsMargins(11,11,11,0);
|
||||
fMatrixLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
|
||||
fMatrixLayout->addWidget(fMatrixLabel);
|
||||
|
||||
for(int i =0; i<9; i++) {
|
||||
fMatrixEntry[i] = new QLineEdit();
|
||||
fMatrixEntry[i]->setMinimumSize(QSize(50,25));
|
||||
fMatrixEntry[i]->setMaximumSize(QSize(50,16777215));
|
||||
fMatrixEntry[i]->setReadOnly(true);
|
||||
|
||||
if(!(i%3)) fMatrixRow[i/3] = new QHBoxLayout();
|
||||
fMatrixRow[i/3]->addWidget(fMatrixEntry[i]);
|
||||
if(i%3 == 2) fMatrixLayout->addLayout(fMatrixRow[i/3]);
|
||||
}
|
||||
|
||||
return fMatrixLayout;
|
||||
}
|
||||
|
||||
QVBoxLayout* SkInspectorWidget::currentClip() {
|
||||
fClipLabel = new QLabel(this);
|
||||
fClipLabel->setText("Current Clip");
|
||||
fClipLabel->setAlignment(Qt::AlignHCenter);
|
||||
fClipLayout = new QVBoxLayout();
|
||||
fClipLayout->setSpacing(6);
|
||||
fClipLayout->setContentsMargins(11,11,11,0);
|
||||
fClipLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
|
||||
fClipLayout->addWidget(fClipLabel);
|
||||
|
||||
for(int i =0; i<4; i++) {
|
||||
fClipEntry[i] = new QLineEdit();
|
||||
fClipEntry[i]->setMinimumSize(QSize(50,25));
|
||||
fClipEntry[i]->setMaximumSize(QSize(50,16777215));
|
||||
fClipEntry[i]->setReadOnly(true);
|
||||
|
||||
if(!(i%2)) fClipRow[i/2] = new QHBoxLayout();
|
||||
fClipRow[i/2]->addWidget(fClipEntry[i]);
|
||||
if(i%2 == 1) fClipLayout->addLayout(fClipRow[i/2]);
|
||||
}
|
||||
|
||||
return fClipLayout;
|
||||
}
|
86
debugger/QT/SkInspectorWidget.h
Normal file
86
debugger/QT/SkInspectorWidget.h
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKINSPECTORWIDGET_H_
|
||||
#define SKINSPECTORWIDGET_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
/** \class SkInspectorWidget
|
||||
|
||||
The InspectorWidget contains the overview and details tab. These contain
|
||||
information about the whole picture and details about each draw command.
|
||||
*/
|
||||
class SkInspectorWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs a widget with the specified parent for layout purposes.
|
||||
@param parent The parent container of this widget
|
||||
*/
|
||||
SkInspectorWidget(QWidget *parent = NULL);
|
||||
|
||||
~SkInspectorWidget();
|
||||
|
||||
/**
|
||||
Returns a QString representation of the text currently in the detail tab.
|
||||
*/
|
||||
QString getDetailText();
|
||||
|
||||
/**
|
||||
Returns a QString representation of the text currently in the overview tab.
|
||||
*/
|
||||
QString getOverviewText();
|
||||
|
||||
/**
|
||||
Sets the text in the detail tab.
|
||||
@param text
|
||||
*/
|
||||
void setDetailText(QString text);
|
||||
|
||||
/**
|
||||
Sets the text in the overview tab.
|
||||
@param text
|
||||
*/
|
||||
void setOverviewText(QString text);
|
||||
|
||||
private:
|
||||
QWidget* fDetailTab;
|
||||
QTextEdit* fDetailText;
|
||||
QHBoxLayout* fDetailLayout;
|
||||
QHBoxLayout* fHorizontalLayout;
|
||||
QWidget* fOverviewTab;
|
||||
QTextEdit* fOverviewText;
|
||||
QHBoxLayout* fOverviewLayout;
|
||||
QTabWidget* fTabWidget;
|
||||
|
||||
QWidget* fMatrixAndClipWidget;
|
||||
QVBoxLayout* fVerticalLayout;
|
||||
|
||||
QVBoxLayout* fMatrixLayout;
|
||||
QLabel* fMatrixLabel;
|
||||
QHBoxLayout* fMatrixRow[3];
|
||||
QLineEdit* fMatrixEntry[9];
|
||||
|
||||
QVBoxLayout* fClipLayout;
|
||||
QLabel* fClipLabel;
|
||||
QHBoxLayout* fClipRow[2];
|
||||
QLineEdit* fClipEntry[4];
|
||||
|
||||
QVBoxLayout* currentMatrix();
|
||||
QVBoxLayout* currentClip();
|
||||
};
|
||||
|
||||
#endif
|
80
debugger/QT/SkListWidget.cpp
Normal file
80
debugger/QT/SkListWidget.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
/*
|
||||
* 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 "SkListWidget.h"
|
||||
|
||||
SkListWidget::SkListWidget(QObject *parent) {}
|
||||
|
||||
SkListWidget::~SkListWidget() {}
|
||||
|
||||
void SkListWidget::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
/*
|
||||
* NOTE(chudy): We adjust the initial position of the list item so that
|
||||
* we don't have overlapping top and bottom borders of concurrent
|
||||
* widget items.
|
||||
*/
|
||||
QRect r = option.rect;
|
||||
r.adjust(-1,-1,1,0);
|
||||
|
||||
QPen linePen(QColor::fromRgb(211,211,211), 1, Qt::SolidLine);
|
||||
QPen fontPen(QColor::fromRgb(51,51,51), 1, Qt::SolidLine);
|
||||
QPen fontMarkedPen(Qt::white, 1, Qt::SolidLine);
|
||||
|
||||
// NOTE(chudy): If selected.
|
||||
if(option.state & QStyle::State_Selected){
|
||||
QLinearGradient gradientSelected(r.left(),r.top(),r.left(),r.height()+r.top());
|
||||
gradientSelected.setColorAt(0.0, QColor::fromRgb(119,213,247));
|
||||
gradientSelected.setColorAt(0.9, QColor::fromRgb(27,134,183));
|
||||
gradientSelected.setColorAt(1.0, QColor::fromRgb(0,120,174));
|
||||
painter->setBrush(gradientSelected);
|
||||
painter->drawRect(r);
|
||||
|
||||
painter->setPen(linePen);
|
||||
painter->drawLine(r.topLeft(),r.topRight());
|
||||
painter->drawLine(r.topRight(),r.bottomRight());
|
||||
painter->drawLine(r.bottomLeft(),r.bottomRight());
|
||||
painter->drawLine(r.topLeft(),r.bottomLeft());
|
||||
|
||||
painter->setPen(fontMarkedPen);
|
||||
|
||||
} else {
|
||||
// NOTE(chudy): Alternating background.
|
||||
painter->setBrush( (index.row() % 2) ? Qt::white : QColor(252,252,252) );
|
||||
painter->drawRect(r);
|
||||
|
||||
painter->setPen(linePen);
|
||||
painter->drawLine(r.topLeft(),r.topRight());
|
||||
painter->drawLine(r.topRight(),r.bottomRight());
|
||||
painter->drawLine(r.bottomLeft(),r.bottomRight());
|
||||
painter->drawLine(r.topLeft(),r.bottomLeft());
|
||||
|
||||
painter->setPen(fontPen);
|
||||
}
|
||||
|
||||
QIcon ic = QIcon(qvariant_cast<QPixmap>(index.data(Qt::DecorationRole)));
|
||||
QString title = index.data(Qt::DisplayRole).toString();
|
||||
QString description = index.data(Qt::UserRole + 1).toString();
|
||||
QString hidden = index.data(Qt::UserRole + 2).toString();
|
||||
|
||||
int imageSpace = 35;
|
||||
r = option.rect.adjusted(5, 10, -10, -10);
|
||||
ic.paint(painter, r, Qt::AlignVCenter|Qt::AlignLeft);
|
||||
|
||||
// NOTE(chudy): Draw command.
|
||||
r = option.rect.adjusted(imageSpace, 0, -10, -7);
|
||||
painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignRight, title, &r);
|
||||
|
||||
// NOTE(chudy): Number of draw command.
|
||||
r = option.rect.adjusted(imageSpace, 0, -10, -7);
|
||||
painter->drawText(r.left(), r.top(), r.width(), r.height(), Qt::AlignBottom|Qt::AlignLeft, description, &r);
|
||||
}
|
||||
|
||||
QSize SkListWidget::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const{
|
||||
return QSize(200, 30);
|
||||
}
|
43
debugger/QT/SkListWidget.h
Normal file
43
debugger/QT/SkListWidget.h
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKLISTWIDGET_H_
|
||||
#define SKLISTWIDGET_H_
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPainter>
|
||||
|
||||
/** \class SkListWidget
|
||||
|
||||
This widget contains the draw commands.
|
||||
*/
|
||||
class SkListWidget : public QAbstractItemDelegate {
|
||||
public:
|
||||
/**
|
||||
Constructs the list widget with the specified parent for layout purposes.
|
||||
@param parent The parent container of this widget
|
||||
*/
|
||||
SkListWidget(QObject* parent = NULL);
|
||||
|
||||
~SkListWidget();
|
||||
|
||||
/**
|
||||
Draws the current state of the widget. Overriden from QWidget.
|
||||
*/
|
||||
void paint (QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index ) const;
|
||||
|
||||
/**
|
||||
Returns the default size of the widget. Overriden from QWidget.
|
||||
*/
|
||||
QSize sizeHint (const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const;
|
||||
};
|
||||
|
||||
#endif
|
77
debugger/QT/SkSettingsWidget.cpp
Normal file
77
debugger/QT/SkSettingsWidget.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
/*
|
||||
* 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 "SkSettingsWidget.h"
|
||||
|
||||
SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent) {
|
||||
mainFrameLayout = new QVBoxLayout(this);
|
||||
mainFrameLayout->setSpacing(6);
|
||||
mainFrameLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
|
||||
mainFrame = new QFrame();
|
||||
mainFrame->setFrameShape(QFrame::StyledPanel);
|
||||
mainFrame->setFrameShadow(QFrame::Raised);
|
||||
|
||||
mainFrameLayout->addWidget(mainFrame);
|
||||
|
||||
fVerticalLayout = new QVBoxLayout(mainFrame);
|
||||
fVerticalLayout->setContentsMargins(11,11,11,11);
|
||||
fVerticalLayout->setAlignment(Qt::AlignTop);
|
||||
|
||||
fVisibility = new QLabel();
|
||||
fVisibility->setText("Visibility Filter");
|
||||
|
||||
fFrame = new QFrame();
|
||||
fFrame->setFrameShape(QFrame::StyledPanel);
|
||||
fFrame->setFrameShadow(QFrame::Raised);
|
||||
|
||||
fVerticalLayout_2 = new QVBoxLayout(fFrame);
|
||||
fVerticalLayout_2->setSpacing(6);
|
||||
fVerticalLayout_2->setContentsMargins(11,11,11,11);
|
||||
|
||||
fVerticalLayout->addWidget(fVisibility);
|
||||
fVerticalLayout->addWidget(fFrame);
|
||||
|
||||
fVisibleOn = new QRadioButton(fFrame);
|
||||
fVisibleOn->setText("On");
|
||||
fVisibleOff = new QRadioButton(fFrame);
|
||||
fVisibleOff->setText("Off");
|
||||
|
||||
fVisibleOff->setChecked(true);
|
||||
|
||||
fVerticalLayout_2->addWidget(fVisibleOn);
|
||||
fVerticalLayout_2->addWidget(fVisibleOff);
|
||||
|
||||
fCommandToggle = new QLabel();
|
||||
fCommandToggle->setText("Command Scrolling Preferences");
|
||||
|
||||
fCommandFrame = new QFrame();
|
||||
fCommandFrame->setFrameShape(QFrame::StyledPanel);
|
||||
fCommandFrame->setFrameShadow(QFrame::Raised);
|
||||
|
||||
fCommandLayout = new QVBoxLayout(fCommandFrame);
|
||||
fCommandLayout->setSpacing(6);
|
||||
fCommandLayout->setContentsMargins(11,11,11,11);
|
||||
|
||||
fVerticalLayout->addWidget(fCommandToggle);
|
||||
fVerticalLayout->addWidget(fCommandFrame);
|
||||
|
||||
fCommandCheckBox = new QCheckBox(fCommandFrame);
|
||||
fCommandCheckBox->setText("Toggle Sticky Activate");
|
||||
fCommandSingleDraw = new QCheckBox(fCommandFrame);
|
||||
fCommandSingleDraw->setText("Display Single Command");
|
||||
|
||||
fCommandLayout->addWidget(fCommandCheckBox);
|
||||
fCommandLayout->addWidget(fCommandSingleDraw);
|
||||
|
||||
this->setDisabled(true);
|
||||
}
|
||||
|
||||
SkSettingsWidget::~SkSettingsWidget() {}
|
60
debugger/QT/SkSettingsWidget.h
Normal file
60
debugger/QT/SkSettingsWidget.h
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKSETTINGSWIDGET_H_
|
||||
#define SKSETTINGSWIDGET_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTextEdit>
|
||||
#include <QFrame>
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QCheckBox>
|
||||
|
||||
/** \class SkSettingsWidget
|
||||
|
||||
The SettingsWidget contains multiple checkboxes and toggles for altering
|
||||
the visibility.
|
||||
*/
|
||||
class SkSettingsWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
Constructs a widget with the specified parent for layout purposes.
|
||||
@param parent The parent container of this widget
|
||||
*/
|
||||
SkSettingsWidget(QWidget *parent = NULL);
|
||||
~SkSettingsWidget();
|
||||
|
||||
private:
|
||||
QHBoxLayout* fHorizontalLayout;
|
||||
|
||||
QVBoxLayout* mainFrameLayout;
|
||||
|
||||
QVBoxLayout* fVerticalLayout;
|
||||
QVBoxLayout* fVerticalLayout_2;
|
||||
QTextEdit* fText;
|
||||
QFrame* fFrame;
|
||||
QFrame* mainFrame;
|
||||
|
||||
QLabel* fVisibility;
|
||||
QRadioButton* fVisibleOn;
|
||||
QRadioButton* fVisibleOff;
|
||||
|
||||
QLabel* fCommandToggle;
|
||||
QFrame* fCommandFrame;
|
||||
QVBoxLayout* fCommandLayout;
|
||||
|
||||
QCheckBox* fCommandCheckBox;
|
||||
QCheckBox* fCommandSingleDraw;
|
||||
};
|
||||
|
||||
#endif /* SKSETTINGSWIDGET_H_ */
|
69
debugger/QT/moc_SkCanvasWidget.cpp
Normal file
69
debugger/QT/moc_SkCanvasWidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'SkCanvasWidget.h'
|
||||
**
|
||||
** Created: Thu Jun 28 17:18:47 2012
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkCanvasWidget.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'SkCanvasWidget.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_SkCanvasWidget[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_SkCanvasWidget[] = {
|
||||
"SkCanvasWidget\0"
|
||||
};
|
||||
|
||||
const QMetaObject SkCanvasWidget::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_SkCanvasWidget,
|
||||
qt_meta_data_SkCanvasWidget, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &SkCanvasWidget::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *SkCanvasWidget::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *SkCanvasWidget::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_SkCanvasWidget))
|
||||
return static_cast<void*>(const_cast< SkCanvasWidget*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int SkCanvasWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
123
debugger/QT/moc_SkDebuggerGUI.cpp
Normal file
123
debugger/QT/moc_SkDebuggerGUI.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'SkDebuggerGUI.h'
|
||||
**
|
||||
** Created: Thu Jun 28 17:18:47 2012
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkDebuggerGUI.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'SkDebuggerGUI.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_SkDebuggerGUI[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
18, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
// slots: signature, parameters, type, tag, flags
|
||||
15, 14, 14, 14, 0x08,
|
||||
35, 14, 14, 14, 0x08,
|
||||
50, 14, 14, 14, 0x08,
|
||||
72, 14, 14, 14, 0x08,
|
||||
86, 14, 14, 14, 0x08,
|
||||
101, 14, 14, 14, 0x08,
|
||||
119, 14, 14, 14, 0x08,
|
||||
132, 14, 14, 14, 0x08,
|
||||
147, 14, 14, 14, 0x08,
|
||||
162, 14, 14, 14, 0x08,
|
||||
179, 14, 14, 14, 0x08,
|
||||
196, 14, 14, 14, 0x08,
|
||||
221, 216, 14, 14, 0x08,
|
||||
248, 14, 14, 14, 0x08,
|
||||
259, 216, 14, 14, 0x08,
|
||||
295, 14, 14, 14, 0x08,
|
||||
314, 14, 14, 14, 0x08,
|
||||
339, 332, 14, 14, 0x08,
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_SkDebuggerGUI[] = {
|
||||
"SkDebuggerGUI\0\0actionBreakpoints()\0"
|
||||
"actionCancel()\0actionCommandFilter()\0"
|
||||
"actionClose()\0actionDelete()\0"
|
||||
"actionInspector()\0actionPlay()\0"
|
||||
"actionReload()\0actionRewind()\0"
|
||||
"actionSettings()\0actionStepBack()\0"
|
||||
"actionStepForward()\0item\0"
|
||||
"loadFile(QListWidgetItem*)\0openFile()\0"
|
||||
"registerListClick(QListWidgetItem*)\0"
|
||||
"toggleBreakpoint()\0toggleDirectory()\0"
|
||||
"string\0toggleFilter(QString)\0"
|
||||
};
|
||||
|
||||
const QMetaObject SkDebuggerGUI::staticMetaObject = {
|
||||
{ &QMainWindow::staticMetaObject, qt_meta_stringdata_SkDebuggerGUI,
|
||||
qt_meta_data_SkDebuggerGUI, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &SkDebuggerGUI::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *SkDebuggerGUI::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *SkDebuggerGUI::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_SkDebuggerGUI))
|
||||
return static_cast<void*>(const_cast< SkDebuggerGUI*>(this));
|
||||
return QMainWindow::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int SkDebuggerGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QMainWindow::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
switch (_id) {
|
||||
case 0: actionBreakpoints(); break;
|
||||
case 1: actionCancel(); break;
|
||||
case 2: actionCommandFilter(); break;
|
||||
case 3: actionClose(); break;
|
||||
case 4: actionDelete(); break;
|
||||
case 5: actionInspector(); break;
|
||||
case 6: actionPlay(); break;
|
||||
case 7: actionReload(); break;
|
||||
case 8: actionRewind(); break;
|
||||
case 9: actionSettings(); break;
|
||||
case 10: actionStepBack(); break;
|
||||
case 11: actionStepForward(); break;
|
||||
case 12: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
|
||||
case 13: openFile(); break;
|
||||
case 14: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
|
||||
case 15: toggleBreakpoint(); break;
|
||||
case 16: toggleDirectory(); break;
|
||||
case 17: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
|
||||
default: ;
|
||||
}
|
||||
_id -= 18;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
69
debugger/QT/moc_SkInspectorWidget.cpp
Normal file
69
debugger/QT/moc_SkInspectorWidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'SkInspectorWidget.h'
|
||||
**
|
||||
** Created: Thu Jun 28 17:18:47 2012
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkInspectorWidget.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'SkInspectorWidget.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_SkInspectorWidget[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_SkInspectorWidget[] = {
|
||||
"SkInspectorWidget\0"
|
||||
};
|
||||
|
||||
const QMetaObject SkInspectorWidget::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_SkInspectorWidget,
|
||||
qt_meta_data_SkInspectorWidget, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &SkInspectorWidget::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *SkInspectorWidget::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *SkInspectorWidget::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_SkInspectorWidget))
|
||||
return static_cast<void*>(const_cast< SkInspectorWidget*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int SkInspectorWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
69
debugger/QT/moc_SkQtWidget.cpp
Normal file
69
debugger/QT/moc_SkQtWidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'SkQtWidget.h'
|
||||
**
|
||||
** Created: Tue Jun 26 16:43:31 2012
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkQtWidget.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'SkQtWidget.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_SkQtWidget[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_SkQtWidget[] = {
|
||||
"SkQtWidget\0"
|
||||
};
|
||||
|
||||
const QMetaObject SkQtWidget::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_SkQtWidget,
|
||||
qt_meta_data_SkQtWidget, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &SkQtWidget::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *SkQtWidget::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *SkQtWidget::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_SkQtWidget))
|
||||
return static_cast<void*>(const_cast< SkQtWidget*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int SkQtWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
69
debugger/QT/moc_SkSettingsWidget.cpp
Normal file
69
debugger/QT/moc_SkSettingsWidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'SkSettingsWidget.h'
|
||||
**
|
||||
** Created: Thu Jun 28 17:18:47 2012
|
||||
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "SkSettingsWidget.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'SkSettingsWidget.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 62
|
||||
#error "This file was generated using the moc from 4.6.2. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_SkSettingsWidget[] = {
|
||||
|
||||
// content:
|
||||
4, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
0, 0, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
0, // signalCount
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_SkSettingsWidget[] = {
|
||||
"SkSettingsWidget\0"
|
||||
};
|
||||
|
||||
const QMetaObject SkSettingsWidget::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_SkSettingsWidget,
|
||||
qt_meta_data_SkSettingsWidget, 0 }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &SkSettingsWidget::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *SkSettingsWidget::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *SkSettingsWidget::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_SkSettingsWidget))
|
||||
return static_cast<void*>(const_cast< SkSettingsWidget*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int SkSettingsWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
return _id;
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
1725
debugger/QT/qrc_SkIcons.cpp
Normal file
1725
debugger/QT/qrc_SkIcons.cpp
Normal file
File diff suppressed because it is too large
Load Diff
289
debugger/SkDebugCanvas.cpp
Normal file
289
debugger/SkDebugCanvas.cpp
Normal file
@ -0,0 +1,289 @@
|
||||
|
||||
/*
|
||||
* 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 <iostream>
|
||||
#include "SkDebugCanvas.h"
|
||||
#include "SkDrawCommand.h"
|
||||
|
||||
SkDebugCanvas::SkDebugCanvas() {
|
||||
// TODO(chudy): Free up memory from all draw commands in destructor.
|
||||
int width = 100;
|
||||
int height = 100;
|
||||
fBm.setConfig(SkBitmap::kNo_Config, width, height);
|
||||
this->setBitmapDevice(fBm);
|
||||
fFilter = false;
|
||||
}
|
||||
|
||||
SkDebugCanvas::~SkDebugCanvas() {}
|
||||
|
||||
void SkDebugCanvas::addDrawCommand(SkDrawCommand* command) {
|
||||
commandVector.push_back(command);
|
||||
}
|
||||
|
||||
void SkDebugCanvas::draw(SkCanvas* canvas) {
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
(*it)->execute(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
|
||||
int counter = 0;
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
if (counter != (index-1)) {
|
||||
if ((*it)->getVisibility()) {
|
||||
(*it)->execute(canvas);
|
||||
}
|
||||
} else {
|
||||
if (fFilter) {
|
||||
SkPaint* p = new SkPaint();
|
||||
p->setColor(0xAAFFFFFF);
|
||||
canvas->save();
|
||||
canvas->resetMatrix();
|
||||
SkRect dump;
|
||||
// TODO(chudy): Replace with a call to QtWidget to get dimensions.
|
||||
dump.set(SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(800), SkIntToScalar(800));
|
||||
canvas->clipRect(dump, SkRegion::kReplace_Op, false );
|
||||
canvas->drawRectCoords(SkIntToScalar(0),SkIntToScalar(0),SkIntToScalar(800),SkIntToScalar(800), *p);
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
if ((*it)->getVisibility()) {
|
||||
(*it)->execute(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO(chudy): Implement a bitmap wide function that will take
|
||||
* ~50 out of each R,G,B. This will make everything but the last
|
||||
* command brighter.
|
||||
*/
|
||||
if (++counter == index) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SkDrawCommand* SkDebugCanvas::getDrawCommandAt(int index) {
|
||||
int counter = 0;
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
if (counter==index) {
|
||||
return (*it);
|
||||
}
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<std::string>* SkDebugCanvas::getCommandInfoAt(int index) {
|
||||
std::string info;
|
||||
|
||||
int counter = 0;
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
if (counter==index) {
|
||||
return (*it)->Info();
|
||||
}
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::vector<SkDrawCommand*> SkDebugCanvas::getDrawCommands() {
|
||||
return commandVector;
|
||||
}
|
||||
|
||||
// TODO(chudy): Free command string memory.
|
||||
std::vector<std::string>* SkDebugCanvas::getDrawCommandsAsStrings() {
|
||||
std::vector<std::string>* commandString = new std::vector<std::string>();
|
||||
if (!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
commandString->push_back((*it)->toString());
|
||||
}
|
||||
}
|
||||
return commandString;
|
||||
}
|
||||
|
||||
void SkDebugCanvas::toggleFilter(bool toggle) {
|
||||
fFilter = toggle;
|
||||
}
|
||||
|
||||
void SkDebugCanvas::clear(SkColor color) {
|
||||
addDrawCommand(new Clear(color));
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
|
||||
addDrawCommand(new ClipPath(path, op, doAA));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
||||
addDrawCommand(new ClipRect(rect, op, doAA));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::clipRegion(const SkRegion& region, SkRegion::Op op) {
|
||||
addDrawCommand(new ClipRegion(region, op));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::concat(const SkMatrix& matrix) {
|
||||
addDrawCommand(new Concat(matrix));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar left,
|
||||
SkScalar top, const SkPaint* paint = NULL) {
|
||||
addDrawCommand(new DrawBitmap(bitmap, left, top, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawBitmapRect(const SkBitmap& bitmap,
|
||||
const SkIRect* src, const SkRect& dst, const SkPaint* paint) {
|
||||
addDrawCommand(new DrawBitmapRect(bitmap, src, dst, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawBitmapMatrix(const SkBitmap& bitmap,
|
||||
const SkMatrix& matrix, const SkPaint* paint) {
|
||||
addDrawCommand(new DrawBitmapMatrix(bitmap, matrix, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawBitmapNine(const SkBitmap& bitmap,
|
||||
const SkIRect& center, const SkRect& dst, const SkPaint* paint) {
|
||||
addDrawCommand(new DrawBitmapNine(bitmap, center, dst, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawData(const void* data, size_t length) {
|
||||
addDrawCommand(new DrawData(data, length));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPaint(const SkPaint& paint) {
|
||||
addDrawCommand(new DrawPaint(paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
|
||||
addDrawCommand(new DrawPath(path, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPicture(SkPicture& picture) {
|
||||
addDrawCommand(new DrawPicture(picture));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPoints(PointMode mode, size_t count,
|
||||
const SkPoint pts[], const SkPaint& paint) {
|
||||
addDrawCommand(new DrawPoints(mode, count, pts, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPosText(const void* text, size_t byteLength,
|
||||
const SkPoint pos[], const SkPaint& paint) {
|
||||
addDrawCommand(new DrawPosText(text, byteLength, pos, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
|
||||
addDrawCommand(new DrawPosTextH(text, byteLength, xpos, constY, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
|
||||
// NOTE(chudy): Messing up when renamed to DrawRect... Why?
|
||||
addDrawCommand(new DrawRectC(rect, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawSprite(const SkBitmap& bitmap, int left, int top,
|
||||
const SkPaint* paint = NULL) {
|
||||
addDrawCommand(new DrawSprite(bitmap, left, top, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawText(const void* text, size_t byteLength, SkScalar x,
|
||||
SkScalar y, const SkPaint& paint) {
|
||||
addDrawCommand(new DrawTextC(text, byteLength, x, y, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) {
|
||||
addDrawCommand(new DrawTextOnPath(text, byteLength, path, matrix, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::drawVertices(VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
|
||||
SkXfermode*, const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint) {
|
||||
addDrawCommand(new DrawVertices(vmode, vertexCount, vertices, texs, colors,
|
||||
NULL, indices, indexCount, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::restore() {
|
||||
addDrawCommand(new Restore());
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::rotate(SkScalar degrees) {
|
||||
addDrawCommand(new Rotate(degrees));
|
||||
return true;
|
||||
}
|
||||
|
||||
int SkDebugCanvas::save(SaveFlags flags) {
|
||||
addDrawCommand(new Save(flags));
|
||||
return true;
|
||||
}
|
||||
|
||||
int SkDebugCanvas::saveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||
SaveFlags flags) {
|
||||
addDrawCommand(new SaveLayer(bounds, paint, flags));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::scale(SkScalar sx, SkScalar sy) {
|
||||
addDrawCommand(new Scale(sx, sy));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkDebugCanvas::setMatrix(const SkMatrix& matrix) {
|
||||
addDrawCommand(new SetMatrix(matrix));
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::skew(SkScalar sx, SkScalar sy) {
|
||||
addDrawCommand(new Skew(sx, sy));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) {
|
||||
addDrawCommand(new Translate(dx, dy));
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkDebugCanvas::toggleCommand(int index) {
|
||||
int counter = 0;
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
if (counter == index) {
|
||||
if ((*it)->getVisibility()) {
|
||||
(*it)->setVisibility(false);
|
||||
} else {
|
||||
(*it)->setVisibility(true);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkDebugCanvas::toggleCommand(int index, bool toggle) {
|
||||
int counter = 0;
|
||||
if(!commandVector.empty()) {
|
||||
for(it = commandVector.begin(); it != commandVector.end(); ++it) {
|
||||
if (counter == index) {
|
||||
(*it)->setVisibility(toggle);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
174
debugger/SkDebugCanvas.h
Normal file
174
debugger/SkDebugCanvas.h
Normal file
@ -0,0 +1,174 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKDEBUGCANVAS_H_
|
||||
#define SKDEBUGCANVAS_H_
|
||||
|
||||
#include <iostream>
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDrawCommand.h"
|
||||
#include "SkPicture.h"
|
||||
#include <vector>
|
||||
|
||||
class SkDebugCanvas : public SkCanvas {
|
||||
public:
|
||||
bool fFilter;
|
||||
|
||||
SkDebugCanvas();
|
||||
~SkDebugCanvas();
|
||||
|
||||
void toggleFilter(bool toggle);
|
||||
|
||||
/**
|
||||
Executes all draw calls to the canvas.
|
||||
@param canvas The canvas being drawn to
|
||||
*/
|
||||
void draw(SkCanvas* canvas);
|
||||
|
||||
/**
|
||||
Executes the draw calls in the specified range.
|
||||
@param canvas The canvas being drawn to
|
||||
@param i The beginning of the range
|
||||
@param j The end of the range
|
||||
TODO(chudy): Implement
|
||||
*/
|
||||
void drawRange(SkCanvas* canvas, int i, int j);
|
||||
|
||||
/**
|
||||
Executes the draw calls up to the specified index.
|
||||
@param canvas The canvas being drawn to
|
||||
@param index The index of the final command being executed
|
||||
*/
|
||||
void drawTo(SkCanvas* canvas, int index);
|
||||
|
||||
/**
|
||||
Returns the draw command at the given index.
|
||||
@param index The index of the command
|
||||
*/
|
||||
SkDrawCommand* getDrawCommandAt(int index);
|
||||
|
||||
/**
|
||||
Returns information about the command at the given index.
|
||||
@param index The index of the command
|
||||
*/
|
||||
std::vector<std::string>* getCommandInfoAt(int index);
|
||||
|
||||
/**
|
||||
Returns the vector of draw commands
|
||||
*/
|
||||
std::vector<SkDrawCommand*> getDrawCommands();
|
||||
|
||||
/**
|
||||
* Returns the string vector of draw commands
|
||||
*/
|
||||
std::vector<std::string>* getDrawCommandsAsStrings();
|
||||
|
||||
/**
|
||||
Toggles the execution of the draw command at index i.
|
||||
*/
|
||||
void toggleCommand(int index);
|
||||
|
||||
/**
|
||||
Toggles the visibility / execution of the draw command at index i with
|
||||
the value of toggle.
|
||||
*/
|
||||
void toggleCommand(int index, bool toggle);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Inherited from SkCanvas
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void clear(SkColor) SK_OVERRIDE;
|
||||
|
||||
virtual bool clipPath(const SkPath&, SkRegion::Op, bool) SK_OVERRIDE;
|
||||
|
||||
virtual bool clipRect(const SkRect&, SkRegion::Op, bool) SK_OVERRIDE;
|
||||
|
||||
virtual bool clipRegion(const SkRegion& region, SkRegion::Op op) SK_OVERRIDE;
|
||||
|
||||
virtual bool concat(const SkMatrix& matrix) SK_OVERRIDE;
|
||||
|
||||
virtual void drawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
||||
virtual void drawBitmapRect(const SkBitmap&, const SkIRect* src,
|
||||
const SkRect& dst, const SkPaint*) SK_OVERRIDE;
|
||||
|
||||
virtual void drawBitmapMatrix(const SkBitmap&, const SkMatrix&,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
||||
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint*) SK_OVERRIDE;
|
||||
|
||||
virtual void drawData(const void*, size_t) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPaint(const SkPaint& paint) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPath(const SkPath& path, const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPicture(SkPicture& picture) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPoints(PointMode, size_t count, const SkPoint pts[],
|
||||
const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPosText(const void* text, size_t byteLength,
|
||||
const SkPoint pos[], const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY, const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawSprite(const SkBitmap&, int left, int top,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
||||
virtual void drawText(const void* text, size_t byteLength, SkScalar x,
|
||||
SkScalar y, const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void drawVertices(VertexMode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[],
|
||||
const SkColor colors[], SkXfermode*,
|
||||
const uint16_t indices[], int indexCount,
|
||||
const SkPaint&) SK_OVERRIDE;
|
||||
|
||||
virtual void restore() SK_OVERRIDE;
|
||||
|
||||
virtual bool rotate(SkScalar degrees) SK_OVERRIDE;
|
||||
|
||||
virtual int save(SaveFlags) SK_OVERRIDE;
|
||||
|
||||
virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE;
|
||||
|
||||
virtual bool scale(SkScalar sx, SkScalar sy) SK_OVERRIDE;
|
||||
|
||||
virtual void setMatrix(const SkMatrix& matrix) SK_OVERRIDE;
|
||||
|
||||
virtual bool skew(SkScalar sx, SkScalar sy) SK_OVERRIDE;
|
||||
|
||||
virtual bool translate(SkScalar dx, SkScalar dy) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef SkCanvas INHERITED;
|
||||
std::vector<SkDrawCommand*> commandVector;
|
||||
std::vector<SkDrawCommand*>::const_iterator it;
|
||||
|
||||
SkBitmap fBm;
|
||||
|
||||
/**
|
||||
Adds the command to the classes vector of commands.
|
||||
@param command The draw command for execution
|
||||
*/
|
||||
void addDrawCommand(SkDrawCommand* command);
|
||||
};
|
||||
|
||||
#endif
|
17
debugger/SkDebugger.cpp
Normal file
17
debugger/SkDebugger.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
/*
|
||||
* 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"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
SkDebuggerGUI w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
491
debugger/SkDrawCommand.cpp
Normal file
491
debugger/SkDrawCommand.cpp
Normal file
@ -0,0 +1,491 @@
|
||||
|
||||
/*
|
||||
* 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 <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "SkDrawCommand.h"
|
||||
#include "SkObjectParser.h"
|
||||
|
||||
// TODO(chudy): Refactor into non subclass model.
|
||||
|
||||
SkDrawCommand::SkDrawCommand() {
|
||||
fVisible = true;
|
||||
}
|
||||
|
||||
SkDrawCommand::~SkDrawCommand() {
|
||||
}
|
||||
|
||||
const char* SkDrawCommand::GetCommandString(DrawType type) {
|
||||
switch (type) {
|
||||
case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break;
|
||||
case DRAW_CLEAR: return "Clear";
|
||||
case CLIP_PATH: return "Clip Path";
|
||||
case CLIP_REGION: return "Clip Region";
|
||||
case CLIP_RECT: return "Clip Rect";
|
||||
case CONCAT: return "Concat";
|
||||
case DRAW_BITMAP: return "Draw Bitmap";
|
||||
case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix";
|
||||
case DRAW_BITMAP_NINE: return "Draw Bitmap Nine";
|
||||
case DRAW_BITMAP_RECT: return "Draw Bitmap Rect";
|
||||
case DRAW_DATA: return "Draw Data";
|
||||
case DRAW_PAINT: return "Draw Paint";
|
||||
case DRAW_PATH: return "Draw Path";
|
||||
case DRAW_PICTURE: return "Draw Picture";
|
||||
case DRAW_POINTS: return "Draw Points";
|
||||
case DRAW_POS_TEXT: return "Draw Pos Text";
|
||||
case DRAW_POS_TEXT_H: return "Draw Pos Text H";
|
||||
case DRAW_RECT: return "Draw Rect";
|
||||
case DRAW_SPRITE: return "Draw Sprite";
|
||||
case DRAW_TEXT: return "Draw Text";
|
||||
case DRAW_TEXT_ON_PATH: return "Draw Text On Path";
|
||||
case DRAW_VERTICES: return "Draw Vertices";
|
||||
case RESTORE: return "Restore";
|
||||
case ROTATE: return "Rotate";
|
||||
case SAVE: return "Save";
|
||||
case SAVE_LAYER: return "Save Layer";
|
||||
case SCALE: return "Scale";
|
||||
case SET_MATRIX: return "Set Matrix";
|
||||
case SKEW: return "Skew";
|
||||
case TRANSLATE: return "Translate";
|
||||
default:
|
||||
SkDebugf("DrawType error 0x%08x\n", type);
|
||||
SkASSERT(0);
|
||||
break;
|
||||
}
|
||||
SkDEBUGFAIL("DrawType UNUSED\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string SkDrawCommand::toString() {
|
||||
std::stringstream ss;
|
||||
ss << GetCommandString(fDrawType);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
Clear::Clear(SkColor color) {
|
||||
this->fColor = color;
|
||||
this->fDrawType = DRAW_CLEAR;
|
||||
this->fInfo.push_back(std::string("No Parameters"));
|
||||
}
|
||||
|
||||
void Clear::execute(SkCanvas* canvas) {
|
||||
canvas->clear(this->fColor);
|
||||
}
|
||||
|
||||
ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
|
||||
this->fPath = &path;
|
||||
this->fOp = op;
|
||||
this->fDoAA = doAA;
|
||||
this->fDrawType = CLIP_PATH;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::PathToString(path));
|
||||
this->fInfo.push_back(SkObjectParser::RegionOpToString(op));
|
||||
this->fInfo.push_back(SkObjectParser::BoolToString(doAA));
|
||||
}
|
||||
|
||||
void ClipPath::execute(SkCanvas* canvas) {
|
||||
canvas->clipPath(*this->fPath, this->fOp, this->fDoAA);
|
||||
}
|
||||
|
||||
ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
|
||||
this->fRegion = ®ion;
|
||||
this->fOp = op;
|
||||
this->fDrawType = CLIP_REGION;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::RegionToString(region));
|
||||
this->fInfo.push_back(SkObjectParser::RegionOpToString(op));
|
||||
}
|
||||
|
||||
void ClipRegion::execute(SkCanvas* canvas) {
|
||||
canvas->clipRegion(*this->fRegion, this->fOp);
|
||||
}
|
||||
|
||||
ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
|
||||
this->fRect = ▭
|
||||
this->fOp = op;
|
||||
this->fDoAA = doAA;
|
||||
this->fDrawType = CLIP_RECT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::RectToString(rect));
|
||||
this->fInfo.push_back(SkObjectParser::RegionOpToString(op));
|
||||
this->fInfo.push_back(SkObjectParser::BoolToString(doAA));
|
||||
}
|
||||
|
||||
void ClipRect::execute(SkCanvas* canvas) {
|
||||
canvas->clipRect(*this->fRect, this->fOp, this->fDoAA);
|
||||
}
|
||||
|
||||
Concat::Concat(const SkMatrix& matrix) {
|
||||
this->fMatrix = &matrix;
|
||||
this->fDrawType = CONCAT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::MatrixToString(matrix));
|
||||
}
|
||||
|
||||
void Concat::execute(SkCanvas* canvas) {
|
||||
canvas->concat(*this->fMatrix);
|
||||
}
|
||||
|
||||
DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint) {
|
||||
this->fBitmap = &bitmap;
|
||||
this->fLeft = left;
|
||||
this->fTop = top;
|
||||
this->fPaint = paint;
|
||||
this->fDrawType = DRAW_BITMAP;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::BitmapToString(bitmap));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(left, "SkScalar left: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(top, "SkScalar top: "));
|
||||
}
|
||||
|
||||
void DrawBitmap::execute(SkCanvas* canvas) {
|
||||
canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
|
||||
}
|
||||
|
||||
DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
|
||||
const SkMatrix& matrix, const SkPaint* paint) {
|
||||
this->fBitmap = &bitmap;
|
||||
this->fMatrix = &matrix;
|
||||
this->fPaint = paint;
|
||||
this->fDrawType = DRAW_BITMAP_MATRIX;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::BitmapToString(bitmap));
|
||||
this->fInfo.push_back(SkObjectParser::MatrixToString(matrix));
|
||||
if (paint) this->fInfo.push_back(SkObjectParser::PaintToString(*paint));
|
||||
}
|
||||
|
||||
void DrawBitmapMatrix::execute(SkCanvas* canvas) {
|
||||
canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint);
|
||||
}
|
||||
|
||||
DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
this->fBitmap = &bitmap;
|
||||
this->fCenter = ¢er;
|
||||
this->fDst = &dst;
|
||||
this->fPaint = paint;
|
||||
this->fDrawType = DRAW_BITMAP_NINE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::BitmapToString(bitmap));
|
||||
this->fInfo.push_back(SkObjectParser::IRectToString(center));
|
||||
this->fInfo.push_back(SkObjectParser::RectToString(dst));
|
||||
if (paint) this->fInfo.push_back(SkObjectParser::PaintToString(*paint));
|
||||
}
|
||||
|
||||
void DrawBitmapNine::execute(SkCanvas* canvas) {
|
||||
canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint);
|
||||
}
|
||||
|
||||
DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
|
||||
const SkRect& dst, const SkPaint* paint) {
|
||||
this->fBitmap = &bitmap;
|
||||
this->fSrc = src;
|
||||
this->fDst = &dst;
|
||||
this->fPaint = paint;
|
||||
this->fDrawType = DRAW_BITMAP_RECT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::BitmapToString(bitmap));
|
||||
if (src) this->fInfo.push_back(SkObjectParser::IRectToString(*src));
|
||||
this->fInfo.push_back(SkObjectParser::RectToString(dst));
|
||||
if (paint) this->fInfo.push_back(SkObjectParser::PaintToString(*paint));
|
||||
}
|
||||
|
||||
void DrawBitmapRect::execute(SkCanvas* canvas) {
|
||||
canvas->drawBitmapRect(*this->fBitmap, this->fSrc, *this->fDst, this->fPaint);
|
||||
}
|
||||
|
||||
DrawData::DrawData(const void* data, size_t length) {
|
||||
this->fData = data;
|
||||
this->fLength = length;
|
||||
this->fDrawType = DRAW_DATA;
|
||||
// TODO(chudy): See if we can't display data and length.
|
||||
}
|
||||
|
||||
void DrawData::execute(SkCanvas* canvas) {
|
||||
canvas->drawData(this->fData, this->fLength);
|
||||
}
|
||||
|
||||
DrawPaint::DrawPaint(const SkPaint& paint) {
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_PAINT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawPaint::execute(SkCanvas* canvas) {
|
||||
canvas->drawPaint(*this->fPaint);
|
||||
}
|
||||
|
||||
DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) {
|
||||
this->fPath = &path;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_PATH;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::PathToString(path));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawPath::execute(SkCanvas* canvas) {
|
||||
canvas->drawPath(*this->fPath, *this->fPaint);
|
||||
}
|
||||
|
||||
DrawPicture::DrawPicture(SkPicture& picture) {
|
||||
this->fPicture = &picture;
|
||||
this->fDrawType = DRAW_PICTURE;
|
||||
this->fInfo.push_back(std::string("Data unavailable. To be implemented"));
|
||||
}
|
||||
|
||||
void DrawPicture::execute(SkCanvas* canvas) {
|
||||
canvas->drawPicture(*this->fPicture);
|
||||
}
|
||||
|
||||
DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
|
||||
const SkPoint pts[], const SkPaint& paint) {
|
||||
this->fMode = mode;
|
||||
this->fCount = count;
|
||||
this->fPts = pts;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_POINTS;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::PointsToString(pts, count));
|
||||
}
|
||||
|
||||
void DrawPoints::execute(SkCanvas* canvas) {
|
||||
canvas->drawPoints(this->fMode, this->fCount, this->fPts, *this->fPaint);
|
||||
}
|
||||
|
||||
DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
||||
const SkPaint& paint) {
|
||||
this->fText = text;
|
||||
this->fByteLength = byteLength;
|
||||
this->fPos = pos;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_POS_TEXT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::TextToString(text, byteLength));
|
||||
// TODO(chudy): Test that this works.
|
||||
this->fInfo.push_back(SkObjectParser::PointsToString(pos, 1));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawPosText::execute(SkCanvas* canvas) {
|
||||
canvas->drawPosText(this->fText, this->fByteLength, this->fPos, *this->fPaint);
|
||||
}
|
||||
|
||||
|
||||
DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
|
||||
this->fText = text;
|
||||
this->fByteLength = byteLength;
|
||||
this->fXpos = xpos;
|
||||
this->fConstY = constY;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_POS_TEXT_H;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::TextToString(text, byteLength));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawPosTextH::execute(SkCanvas* canvas) {
|
||||
canvas->drawPosTextH(this->fText, this->fByteLength, this->fXpos, this->fConstY,
|
||||
*this->fPaint);
|
||||
}
|
||||
|
||||
DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
|
||||
this->fRect = ▭
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_RECT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::RectToString(rect));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawRectC::execute(SkCanvas* canvas) {
|
||||
canvas->drawRect(*this->fRect, *this->fPaint);
|
||||
}
|
||||
|
||||
DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
|
||||
const SkPaint* paint) {
|
||||
this->fBitmap = &bitmap;
|
||||
this->fLeft = left;
|
||||
this->fTop = top;
|
||||
this->fPaint = paint;
|
||||
this->fDrawType = DRAW_SPRITE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::BitmapToString(bitmap));
|
||||
this->fInfo.push_back(SkObjectParser::IntToString(left, "Left: "));
|
||||
this->fInfo.push_back(SkObjectParser::IntToString(top, "Top: "));
|
||||
}
|
||||
|
||||
void DrawSprite::execute(SkCanvas* canvas) {
|
||||
canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
|
||||
}
|
||||
|
||||
DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) {
|
||||
this->fText = text;
|
||||
this->fByteLength = byteLength;
|
||||
this->fX = x;
|
||||
this->fY = y;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_TEXT;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::TextToString(text, byteLength));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(x, "SkScalar x: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(y, "SkScalar y: "));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawTextC::execute(SkCanvas* canvas) {
|
||||
canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint);
|
||||
}
|
||||
|
||||
DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) {
|
||||
this->fText = text;
|
||||
this->fByteLength = byteLength;
|
||||
this->fPath = &path;
|
||||
this->fMatrix = matrix;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_TEXT_ON_PATH;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::TextToString(text, byteLength));
|
||||
this->fInfo.push_back(SkObjectParser::PathToString(path));
|
||||
if (matrix) this->fInfo.push_back(SkObjectParser::MatrixToString(*matrix));
|
||||
this->fInfo.push_back(SkObjectParser::PaintToString(paint));
|
||||
}
|
||||
|
||||
void DrawTextOnPath::execute(SkCanvas* canvas) {
|
||||
canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath,
|
||||
this->fMatrix, *this->fPaint);
|
||||
}
|
||||
|
||||
DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
|
||||
SkXfermode* xfermode, const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint) {
|
||||
this->fVmode = vmode;
|
||||
this->fVertexCount = vertexCount;
|
||||
this->fTexs = texs;
|
||||
this->fColors = colors;
|
||||
this->fXfermode = xfermode;
|
||||
this->fIndices = indices;
|
||||
this->fIndexCount = indexCount;
|
||||
this->fPaint = &paint;
|
||||
this->fDrawType = DRAW_VERTICES;
|
||||
// TODO(chudy)
|
||||
this->fInfo.push_back(std::string("To be implemented"));
|
||||
}
|
||||
|
||||
void DrawVertices::execute(SkCanvas* canvas) {
|
||||
canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices,
|
||||
this->fTexs, this->fColors, this->fXfermode, this->fIndices,
|
||||
this->fIndexCount, *this->fPaint);
|
||||
}
|
||||
|
||||
Restore::Restore() {
|
||||
this->fDrawType = RESTORE;
|
||||
this->fInfo.push_back(std::string("No Parameters"));
|
||||
}
|
||||
|
||||
void Restore::execute(SkCanvas* canvas) {
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
Rotate::Rotate(SkScalar degrees) {
|
||||
this->fDegrees = degrees;
|
||||
this->fDrawType = ROTATE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
|
||||
}
|
||||
|
||||
void Rotate::execute(SkCanvas* canvas) {
|
||||
canvas->rotate(this->fDegrees);
|
||||
}
|
||||
|
||||
Save::Save(SkCanvas::SaveFlags flags) {
|
||||
this->fFlags = flags;
|
||||
this->fDrawType = SAVE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::SaveFlagsToString(flags));
|
||||
}
|
||||
|
||||
void Save::execute(SkCanvas* canvas) {
|
||||
canvas->save(this->fFlags);
|
||||
}
|
||||
|
||||
SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||
SkCanvas::SaveFlags flags) {
|
||||
this->fBounds = bounds;
|
||||
this->fPaint = paint;
|
||||
this->fFlags = flags;
|
||||
this->fDrawType = SAVE_LAYER;
|
||||
|
||||
if (bounds) this->fInfo.push_back(SkObjectParser::RectToString(*bounds));
|
||||
if (paint) this->fInfo.push_back(SkObjectParser::PaintToString(*paint));
|
||||
this->fInfo.push_back(SkObjectParser::SaveFlagsToString(flags));
|
||||
}
|
||||
|
||||
void SaveLayer::execute(SkCanvas* canvas) {
|
||||
canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags);
|
||||
}
|
||||
|
||||
Scale::Scale(SkScalar sx, SkScalar sy) {
|
||||
this->fSx = sx;
|
||||
this->fSy = sy;
|
||||
this->fDrawType = SCALE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
||||
}
|
||||
|
||||
void Scale::execute(SkCanvas* canvas) {
|
||||
canvas->scale(this->fSx, this->fSy);
|
||||
}
|
||||
|
||||
SetMatrix::SetMatrix(const SkMatrix& matrix) {
|
||||
this->fMatrix = &matrix;
|
||||
this->fDrawType = SET_MATRIX;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::MatrixToString(matrix));
|
||||
}
|
||||
|
||||
void SetMatrix::execute(SkCanvas* canvas) {
|
||||
canvas->setMatrix(*this->fMatrix);
|
||||
}
|
||||
|
||||
Skew::Skew(SkScalar sx, SkScalar sy) {
|
||||
this->fSx = sx;
|
||||
this->fSy = sy;
|
||||
this->fDrawType = SKEW;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
|
||||
}
|
||||
|
||||
void Skew::execute(SkCanvas* canvas) {
|
||||
canvas->skew(this->fSx, this->fSy);
|
||||
}
|
||||
|
||||
Translate::Translate(SkScalar dx, SkScalar dy) {
|
||||
this->fDx = dx;
|
||||
this->fDy = dy;
|
||||
this->fDrawType = TRANSLATE;
|
||||
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
|
||||
this->fInfo.push_back(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
|
||||
}
|
||||
|
||||
void Translate::execute(SkCanvas* canvas) {
|
||||
canvas->translate(this->fDx, this->fDy);
|
||||
}
|
346
debugger/SkDrawCommand.h
Normal file
346
debugger/SkDrawCommand.h
Normal file
@ -0,0 +1,346 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKDRAWCOMMAND_H_
|
||||
#define SKDRAWCOMMAND_H_
|
||||
|
||||
#include <iostream>
|
||||
#include "SkPictureFlat.h"
|
||||
#include "SkCanvas.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
class SkDrawCommand {
|
||||
public:
|
||||
/* TODO(chudy): Remove subclasses. */
|
||||
SkDrawCommand();
|
||||
|
||||
virtual ~SkDrawCommand();
|
||||
|
||||
virtual std::string toString();
|
||||
|
||||
virtual const char* toCString() {
|
||||
return GetCommandString(fDrawType);
|
||||
}
|
||||
|
||||
bool getVisibility() const { return fVisible; }
|
||||
void setVisibility(bool toggle) {fVisible = toggle; }
|
||||
|
||||
std::vector<std::string>* Info() {return &fInfo; };
|
||||
virtual void execute(SkCanvas* canvas)=0;
|
||||
DrawType getType() { return fDrawType; };
|
||||
|
||||
protected:
|
||||
DrawType fDrawType;
|
||||
std::vector<std::string> fInfo;
|
||||
|
||||
private:
|
||||
bool fVisible;
|
||||
static const char* GetCommandString(DrawType type);
|
||||
};
|
||||
|
||||
class Restore : public SkDrawCommand {
|
||||
public:
|
||||
Restore();
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
};
|
||||
|
||||
class Clear : public SkDrawCommand {
|
||||
public:
|
||||
Clear(SkColor color);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkColor fColor;
|
||||
};
|
||||
|
||||
class ClipPath : public SkDrawCommand {
|
||||
public:
|
||||
ClipPath(const SkPath& path, SkRegion::Op op, bool doAA);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPath* fPath;
|
||||
SkRegion::Op fOp;
|
||||
bool fDoAA;
|
||||
};
|
||||
|
||||
class ClipRegion : public SkDrawCommand {
|
||||
public:
|
||||
ClipRegion(const SkRegion& region, SkRegion::Op op);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkRegion* fRegion;
|
||||
SkRegion::Op fOp;
|
||||
};
|
||||
|
||||
class ClipRect : public SkDrawCommand {
|
||||
public:
|
||||
ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkRect* fRect;
|
||||
SkRegion::Op fOp;
|
||||
bool fDoAA;
|
||||
};
|
||||
|
||||
class Concat : public SkDrawCommand {
|
||||
public:
|
||||
Concat(const SkMatrix& matrix);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkMatrix* fMatrix;
|
||||
};
|
||||
|
||||
class DrawBitmap : public SkDrawCommand {
|
||||
public:
|
||||
DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
||||
const SkPaint* paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPaint* fPaint;
|
||||
const SkBitmap* fBitmap;
|
||||
SkScalar fLeft;
|
||||
SkScalar fTop;
|
||||
};
|
||||
|
||||
class DrawBitmapMatrix : public SkDrawCommand {
|
||||
public:
|
||||
DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
|
||||
const SkPaint* paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPaint* fPaint;
|
||||
const SkBitmap* fBitmap;
|
||||
const SkMatrix* fMatrix;
|
||||
};
|
||||
|
||||
class DrawBitmapNine : public SkDrawCommand {
|
||||
public:
|
||||
DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
|
||||
const SkRect& dst, const SkPaint* paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkBitmap* fBitmap;
|
||||
const SkIRect* fCenter;
|
||||
const SkRect* fDst;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawBitmapRect : public SkDrawCommand {
|
||||
public:
|
||||
DrawBitmapRect(const SkBitmap& bitmap, const SkIRect* src,
|
||||
const SkRect& dst, const SkPaint* paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkIRect* fSrc;
|
||||
const SkPaint* fPaint;
|
||||
const SkBitmap* fBitmap;
|
||||
const SkRect* fDst;
|
||||
};
|
||||
|
||||
class DrawData : public SkDrawCommand {
|
||||
public:
|
||||
DrawData(const void* data, size_t length);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const void* fData;
|
||||
size_t fLength;
|
||||
};
|
||||
|
||||
class DrawPaint : public SkDrawCommand {
|
||||
public:
|
||||
DrawPaint(const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawPath : public SkDrawCommand {
|
||||
public:
|
||||
DrawPath(const SkPath& path, const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPath* fPath;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawPicture : public SkDrawCommand {
|
||||
public:
|
||||
DrawPicture(SkPicture& picture);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkPicture* fPicture;
|
||||
};
|
||||
|
||||
class DrawPoints : public SkDrawCommand {
|
||||
public:
|
||||
DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
|
||||
const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPoint* fPts;
|
||||
SkCanvas::PointMode fMode;
|
||||
size_t fCount;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
/* TODO(chudy): DrawText is a predefined macro and was breaking something
|
||||
* in the windows build of the debugger.
|
||||
*/
|
||||
class DrawTextC : public SkDrawCommand {
|
||||
public:
|
||||
DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const void* fText;
|
||||
size_t fByteLength;
|
||||
SkScalar fX;
|
||||
SkScalar fY;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawPosText : public SkDrawCommand {
|
||||
public:
|
||||
DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
|
||||
const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPoint* fPos;
|
||||
const void* fText;
|
||||
size_t fByteLength;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawTextOnPath : public SkDrawCommand {
|
||||
public:
|
||||
DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkMatrix* fMatrix;
|
||||
const void* fText;
|
||||
size_t fByteLength;
|
||||
const SkPath* fPath;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawPosTextH : public SkDrawCommand {
|
||||
public:
|
||||
DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkScalar* fXpos;
|
||||
const void* fText;
|
||||
size_t fByteLength;
|
||||
SkScalar fConstY;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawRectC : public SkDrawCommand {
|
||||
public:
|
||||
DrawRectC(const SkRect& rect, const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkRect* fRect;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class DrawSprite : public SkDrawCommand {
|
||||
public:
|
||||
DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkPaint* fPaint;
|
||||
int fLeft;
|
||||
int fTop;
|
||||
const SkBitmap* fBitmap;
|
||||
};
|
||||
|
||||
class DrawVertices : public SkDrawCommand {
|
||||
public:
|
||||
DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
|
||||
const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
|
||||
SkXfermode* xfermode, const uint16_t indices[], int indexCount,
|
||||
const SkPaint& paint);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkCanvas::VertexMode fVmode;
|
||||
int fVertexCount;
|
||||
int fIndexCount;
|
||||
const SkPoint* fVertices;
|
||||
const SkPoint* fTexs;
|
||||
const SkColor* fColors;
|
||||
const uint16_t* fIndices;
|
||||
SkXfermode* fXfermode;
|
||||
const SkPaint* fPaint;
|
||||
};
|
||||
|
||||
class Rotate : public SkDrawCommand {
|
||||
public:
|
||||
Rotate(SkScalar degrees);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkScalar fDegrees;
|
||||
};
|
||||
|
||||
class Save : public SkDrawCommand {
|
||||
public:
|
||||
Save(SkCanvas::SaveFlags flags);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkCanvas::SaveFlags fFlags;
|
||||
};
|
||||
|
||||
class SaveLayer : public SkDrawCommand {
|
||||
public:
|
||||
SaveLayer(const SkRect* bounds, const SkPaint* paint,
|
||||
SkCanvas::SaveFlags flags);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkRect* fBounds;
|
||||
const SkPaint* fPaint;
|
||||
SkCanvas::SaveFlags fFlags;
|
||||
};
|
||||
|
||||
class Scale : public SkDrawCommand {
|
||||
public:
|
||||
Scale(SkScalar sx, SkScalar sy);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkScalar fSx;
|
||||
SkScalar fSy;
|
||||
};
|
||||
|
||||
class SetMatrix : public SkDrawCommand {
|
||||
public:
|
||||
SetMatrix(const SkMatrix& matrix);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
const SkMatrix* fMatrix;
|
||||
};
|
||||
|
||||
class Skew : public SkDrawCommand {
|
||||
public:
|
||||
Skew(SkScalar sx, SkScalar sy);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkScalar fSx;
|
||||
SkScalar fSy;
|
||||
};
|
||||
|
||||
class Translate : public SkDrawCommand {
|
||||
public:
|
||||
Translate(SkScalar dx, SkScalar dy);
|
||||
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
|
||||
private:
|
||||
SkScalar fDx;
|
||||
SkScalar fDy;
|
||||
};
|
||||
|
||||
#endif
|
185
debugger/SkObjectParser.cpp
Normal file
185
debugger/SkObjectParser.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
|
||||
/*
|
||||
* 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 "SkObjectParser.h"
|
||||
|
||||
/* TODO(chudy): Replace all std::strings with char */
|
||||
|
||||
std::string SkObjectParser::BitmapToString(const SkBitmap& bitmap) {
|
||||
const char* mBitmap("SkBitmap: Data unavailable");
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::BoolToString(bool doAA) {
|
||||
if (doAA) {
|
||||
return "bool doAA: True";
|
||||
} else {
|
||||
return "bool doAA: False";
|
||||
}
|
||||
}
|
||||
|
||||
std::string SkObjectParser::IntToString(int x, const char* text) {
|
||||
std::stringstream ss;
|
||||
ss << text << x;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string SkObjectParser::IRectToString(const SkIRect& rect) {
|
||||
std::stringstream ss;
|
||||
ss << "SkIRect: ";
|
||||
ss << "L: " << rect.left() << ",";
|
||||
ss << "T: " << rect.top() << ",";
|
||||
ss << "R: " << rect.right() << ",";
|
||||
ss << "B: " << rect.bottom();
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string SkObjectParser::MatrixToString(const SkMatrix& matrix) {
|
||||
std::stringstream ss;
|
||||
/* NOTE(chudy): Cleaner looking than loops. */
|
||||
/* TODO(chudy): Decide whether to remove html part in order to really
|
||||
* seperate view / model. */
|
||||
ss << "SkMatrix:<br/>(";
|
||||
ss << matrix.get(0) << "), (";
|
||||
ss << matrix.get(1) << "), (";
|
||||
ss << matrix.get(2) << "), <br/>(";
|
||||
ss << matrix.get(3) << "), (";
|
||||
ss << matrix.get(4) << "), (";
|
||||
ss << matrix.get(5) << "), <br/>(";
|
||||
ss << matrix.get(6) << "), (";
|
||||
ss << matrix.get(7) << "), (";
|
||||
ss << matrix.get(8) << ")";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string SkObjectParser::PaintToString(const SkPaint& paint) {
|
||||
std::stringstream ss;
|
||||
SkColor color = paint.getColor();
|
||||
ss << "SkPaint: 0x" << std::hex << std::uppercase << color;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string SkObjectParser::PathToString(const SkPath& path) {
|
||||
std::string mPath;
|
||||
std::stringstream ss;
|
||||
mPath.append("SkPath: ");
|
||||
|
||||
for (int i=0; i<path.countPoints(); i++) {
|
||||
ss << "(" << path.getPoint(i).fX << ", " << path.getPoint(i).fY << ") ";
|
||||
mPath.append(ss.str());
|
||||
ss.str("");
|
||||
}
|
||||
|
||||
return mPath;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::PointsToString(const SkPoint pts[], size_t count) {
|
||||
std::stringstream ss;
|
||||
ss << "SkPoint pts[]: ";
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
ss << "(" << pts[i].fX << "," << pts[i].fY << ") ";
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string SkObjectParser::RectToString(const SkRect& rect) {
|
||||
std::string mRect("SkRect: ");
|
||||
std::stringstream ss;
|
||||
|
||||
mRect.append("(");
|
||||
ss << rect.left();
|
||||
mRect.append(ss.str());
|
||||
|
||||
ss.str("");
|
||||
mRect.append(", ");
|
||||
ss << rect.top();
|
||||
mRect.append(ss.str());
|
||||
|
||||
ss.str("");
|
||||
mRect.append(", ");
|
||||
ss << rect.right();
|
||||
mRect.append(ss.str());
|
||||
|
||||
ss.str("");
|
||||
mRect.append(", ");
|
||||
ss << rect.bottom();
|
||||
mRect.append(ss.str());
|
||||
mRect.append(")");
|
||||
|
||||
return mRect;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::RegionOpToString(SkRegion::Op op) {
|
||||
std::string mOp("SkRegion::Op: ");
|
||||
|
||||
if (op == SkRegion::kDifference_Op) {
|
||||
mOp.append("kDifference_Op");
|
||||
} else if (op == SkRegion::kIntersect_Op) {
|
||||
mOp.append("kIntersect_Op");
|
||||
} else if (op == SkRegion::kUnion_Op) {
|
||||
mOp.append("kUnion_Op");
|
||||
} else if (op == SkRegion::kXOR_Op) {
|
||||
mOp.append("kXOR_Op");
|
||||
} else if (op == SkRegion::kReverseDifference_Op) {
|
||||
mOp.append("kReverseDifference_Op");
|
||||
} else if (op == SkRegion::kReplace_Op) {
|
||||
mOp.append("kReplace_Op");
|
||||
} else {
|
||||
mOp.append("Unknown Type");
|
||||
}
|
||||
|
||||
return mOp;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::RegionToString(const SkRegion& region) {
|
||||
return "SkRegion: Data unavailable.";
|
||||
}
|
||||
|
||||
std::string SkObjectParser::SaveFlagsToString(SkCanvas::SaveFlags flags) {
|
||||
std::string mFlags;
|
||||
mFlags.append("SkCanvas::SaveFlags: ");
|
||||
|
||||
if(flags == SkCanvas::kMatrixClip_SaveFlag) {
|
||||
mFlags.append("kMatrixClip_SaveFlag");
|
||||
} else if (flags == SkCanvas::kClip_SaveFlag) {
|
||||
mFlags.append("kClip_SaveFlag");
|
||||
} else if (flags == SkCanvas::kHasAlphaLayer_SaveFlag) {
|
||||
mFlags.append("kHasAlphaLayer_SaveFlag");
|
||||
} else if (flags == SkCanvas::kFullColorLayer_SaveFlag) {
|
||||
mFlags.append("kFullColorLayer_SaveFlag");
|
||||
} else if (flags == SkCanvas::kClipToLayer_SaveFlag) {
|
||||
mFlags.append("kClipToLayer_SaveFlag");
|
||||
} else if (flags == SkCanvas::kMatrixClip_SaveFlag) {
|
||||
mFlags.append("kMatrixClip_SaveFlag");
|
||||
} else if (flags == SkCanvas::kARGB_NoClipLayer_SaveFlag) {
|
||||
mFlags.append("kARGB_NoClipLayer_SaveFlag");
|
||||
} else if (flags == SkCanvas::kARGB_ClipLayer_SaveFlag) {
|
||||
mFlags.append("kARGB_ClipLayer_SaveFlag");
|
||||
} else {
|
||||
mFlags.append("Data Unavailable");
|
||||
}
|
||||
|
||||
return mFlags;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::ScalarToString(SkScalar x, const char* text) {
|
||||
std::string mScalar;
|
||||
mScalar.append(text);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << x;
|
||||
mScalar.append(ss.str());
|
||||
return mScalar;
|
||||
}
|
||||
|
||||
std::string SkObjectParser::TextToString(const void* text, size_t byteLength) {
|
||||
char result[6+byteLength];
|
||||
strcpy(result,"Text: ");
|
||||
strcat(result, (char*)text);
|
||||
return result;
|
||||
}
|
114
debugger/SkObjectParser.h
Normal file
114
debugger/SkObjectParser.h
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SKOBJECTPARSER_H_
|
||||
#define SKOBJECTPARSER_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "SkCanvas.h"
|
||||
/** \class SkObjectParser
|
||||
|
||||
The ObjectParser is used to return string information about parameters
|
||||
in each draw command.
|
||||
TODO(chudy): Change std::string to SkString
|
||||
*/
|
||||
class SkObjectParser {
|
||||
public:
|
||||
|
||||
/**
|
||||
Returns a string about a bitmaps bounds and config.
|
||||
@param bitmap SkBitmap
|
||||
*/
|
||||
static std::string BitmapToString(const SkBitmap& bitmap);
|
||||
|
||||
/**
|
||||
Returns a string representation of a boolean.
|
||||
@param doAA boolean
|
||||
*/
|
||||
static std::string BoolToString(bool doAA);
|
||||
|
||||
/**
|
||||
Returns a string representation of an integer with the text parameter
|
||||
at the front of the string.
|
||||
@param x integer
|
||||
@param text
|
||||
*/
|
||||
static std::string IntToString(int x, const char* text);
|
||||
/**
|
||||
Returns a string representation of the SkIRects coordinates.
|
||||
@param rect SkIRect
|
||||
*/
|
||||
static std::string IRectToString(const SkIRect& rect);
|
||||
|
||||
/**
|
||||
Returns a string representation of an SkMatrix's contents
|
||||
@param matrix SkMatrix
|
||||
*/
|
||||
static std::string MatrixToString(const SkMatrix& matrix);
|
||||
|
||||
/**
|
||||
Returns a string representation of an SkPaint's color
|
||||
@param paint SkPaint
|
||||
*/
|
||||
static std::string PaintToString(const SkPaint& paint);
|
||||
|
||||
/**
|
||||
Returns a string representation of a SkPath's points.
|
||||
@param path SkPath
|
||||
*/
|
||||
static std::string PathToString(const SkPath& path);
|
||||
|
||||
/**
|
||||
Returns a string representation of the points in the point array.
|
||||
@param pts[] Array of SkPoints
|
||||
@param count
|
||||
*/
|
||||
static std::string PointsToString(const SkPoint pts[], size_t count);
|
||||
|
||||
/**
|
||||
Returns a string representation of the SkRects coordinates.
|
||||
@param rect SkRect
|
||||
*/
|
||||
static std::string RectToString(const SkRect& rect);
|
||||
|
||||
/**
|
||||
Returns a string representation of the SkRegion enum.
|
||||
@param op SkRegion::op enum
|
||||
*/
|
||||
static std::string RegionOpToString(SkRegion::Op op);
|
||||
|
||||
/**
|
||||
Returns a string representation of the SkRegion.
|
||||
@param region SkRegion
|
||||
*/
|
||||
static std::string RegionToString(const SkRegion& region);
|
||||
|
||||
/**
|
||||
Returns a string representation of the SkCanvas::SaveFlags enum.
|
||||
@param flags SkCanvas::SaveFlags enum
|
||||
*/
|
||||
static std::string SaveFlagsToString(SkCanvas::SaveFlags flags);
|
||||
|
||||
/**
|
||||
Returns a string representation of an SkScalar with the text parameter
|
||||
at the front of the string.
|
||||
@param x SkScalar
|
||||
@param text
|
||||
*/
|
||||
static std::string ScalarToString(SkScalar x, const char* text);
|
||||
|
||||
/**
|
||||
Returns a string representation of the char pointer passed in.
|
||||
@param text const void* that will be cast to a char*
|
||||
*/
|
||||
static std::string TextToString(const void* text, size_t byteLength);
|
||||
};
|
||||
|
||||
#endif
|
12
debugger/moc.sh
Executable file
12
debugger/moc.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
# NOTE(chudy): May have to update location of moc binary depending on system.
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
MOC="/usr/bin/moc"
|
||||
#MOC="/usr/local/google/home/chudy/tools/Qt/Desktop/Qt/4.8.1/gcc/bin/moc"
|
||||
SRC_DIR=$SCRIPT_DIR/QT
|
||||
|
||||
$MOC $SRC_DIR/SkDebuggerGUI.h -o $SRC_DIR/moc_SkDebuggerGUI.cpp
|
||||
$MOC $SRC_DIR/SkCanvasWidget.h -o $SRC_DIR/moc_SkCanvasWidget.cpp
|
||||
$MOC $SRC_DIR/SkInspectorWidget.h -o $SRC_DIR/moc_SkInspectorWidget.cpp
|
||||
$MOC $SRC_DIR/SkSettingsWidget.h -o $SRC_DIR/moc_SkSettingsWidget.cpp
|
93
gyp/debugger.gyp
Normal file
93
gyp/debugger.gyp
Normal file
@ -0,0 +1,93 @@
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'debugger',
|
||||
'type': 'executable',
|
||||
'include_dirs' : [
|
||||
'../src/core',
|
||||
'../debugger', # To pull SkDebugger.h
|
||||
'../debugger/QT', # For all the QT UI Goodies
|
||||
],
|
||||
'sources': [
|
||||
'../debugger/SkDebugCanvas.h',
|
||||
'../debugger/SkDebugCanvas.cpp',
|
||||
'../debugger/SkDebugger.cpp',
|
||||
'../debugger/SkDrawCommand.h',
|
||||
'../debugger/SkDrawCommand.cpp',
|
||||
'../debugger/QT/moc_SkDebuggerGUI.cpp',
|
||||
'../debugger/QT/moc_SkCanvasWidget.cpp',
|
||||
'../debugger/QT/moc_SkInspectorWidget.cpp',
|
||||
'../debugger/QT/moc_SkSettingsWidget.cpp',
|
||||
'../debugger/QT/SkDebuggerGUI.cpp',
|
||||
'../debugger/QT/SkDebuggerGUI.h',
|
||||
'../debugger/QT/SkCanvasWidget.cpp',
|
||||
'../debugger/QT/SkCanvasWidget.h',
|
||||
'../debugger/QT/SkInspectorWidget.h',
|
||||
'../debugger/QT/SkInspectorWidget.cpp',
|
||||
'../debugger/QT/SkListWidget.h',
|
||||
'../debugger/QT/SkListWidget.cpp',
|
||||
'../debugger/SkObjectParser.h',
|
||||
'../debugger/SkObjectParser.cpp',
|
||||
'../debugger/QT/SkSettingsWidget.h',
|
||||
'../debugger/QT/SkSettingsWidget.cpp',
|
||||
|
||||
# To update this file edit SkIcons.qrc and rerun rcc to generate cpp
|
||||
'../debugger/QT/qrc_SkIcons.cpp',
|
||||
],
|
||||
'dependencies': [
|
||||
'core.gyp:core',
|
||||
'images.gyp:images',
|
||||
'ports.gyp:ports',
|
||||
'effects.gyp:effects',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
|
||||
'include_dirs': [
|
||||
'/usr/include/qt4',
|
||||
'/usr/include/qt4/QtCore',
|
||||
'/usr/include/qt4/QtGui',
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries' : [
|
||||
'/usr/lib/libQtCore.so',
|
||||
'/usr/lib/libQtGui.so',
|
||||
],
|
||||
},
|
||||
}],
|
||||
[ 'skia_os == "mac"', {
|
||||
'mac_bundle' : 1,
|
||||
'include_dirs': [
|
||||
'/Library/Frameworks/QtCore.framework/Headers/',
|
||||
'/Library/Frameworks/QtGui.framework/Headers/',
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'/Library/Frameworks/QtCore.framework',
|
||||
'/Library/Frameworks/QtGui.framework',
|
||||
],
|
||||
},
|
||||
}],
|
||||
[ 'skia_os == "win"', {
|
||||
'include_dirs': [
|
||||
# TODO(chudy): Dynamically generate these paths?
|
||||
'C:/Qt/4.6.4/include',
|
||||
'C:/Qt/4.6.4/include/QtCore',
|
||||
'C:/Qt/4.6.4/include/QtGui',
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'C:/Qt/4.6.4/lib/QtCore4.lib',
|
||||
'C:/Qt/4.6.4/lib/QtGui4.lib',
|
||||
],
|
||||
},
|
||||
}],
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# tab-width:2
|
||||
# indent-tabs-mode:nil
|
||||
# End:
|
||||
# vim: set expandtab tabstop=2 shiftwidth=2:
|
Loading…
Reference in New Issue
Block a user