aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/mdbviz
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-09-05 15:10:12 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-06 01:02:22 +0000
commit5fccf9d8017ab8c288548ab566cf78e698ac721f (patch)
tree2f62cf3b43c11664317215f14ca3918027730a22 /tools/mdbviz
parentbc534f6888b17958e80c848d88fa4fe7a3d3ea04 (diff)
[MDBViz] Add tear off windows for the op list & main canvas window
Change-Id: I4086a17eafecccaf0bac34c850c249a5e4efc719 Reviewed-on: https://skia-review.googlesource.com/42524 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tools/mdbviz')
-rw-r--r--tools/mdbviz/mainwindow.cpp87
-rw-r--r--tools/mdbviz/mainwindow.h16
2 files changed, 95 insertions, 8 deletions
diff --git a/tools/mdbviz/mainwindow.cpp b/tools/mdbviz/mainwindow.cpp
index c77bfd613b..5fb1e7e344 100644
--- a/tools/mdbviz/mainwindow.cpp
+++ b/tools/mdbviz/mainwindow.cpp
@@ -14,12 +14,13 @@
#include "SkPicture.h"
#include "SkStream.h"
-MainWindow::MainWindow()
- : fImageLabel(new QLabel) {
- this->setCentralWidget(fImageLabel);
-
+MainWindow::MainWindow() {
this->createActions();
this->createStatusBar();
+ this->createDockWindows();
+
+ this->setWindowTitle("MDB Viz");
+
this->readSettings();
this->setUnifiedTitleAndToolBarOnMac(true);
}
@@ -31,6 +32,21 @@ void MainWindow::openFile() {
}
}
+void MainWindow::setupOpListWidget() {
+ fOpListWidget->clear();
+
+ for (int i = 0; i < fDebugCanvas->getSize(); i++) {
+ QListWidgetItem *item = new QListWidgetItem();
+
+ const SkDrawCommand* command = fDebugCanvas->getDrawCommandAt(i);
+
+ SkString commandString = command->toString();
+ item->setData(Qt::DisplayRole, commandString.c_str());
+
+ fOpListWidget->addItem(item);
+ }
+}
+
void MainWindow::loadFile(const QString &fileName) {
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
@@ -58,6 +74,15 @@ void MainWindow::loadFile(const QString &fileName) {
return;
}
+ fDebugCanvas.reset(new SkDebugCanvas(SkScalarCeilToInt(pic->cullRect().width()),
+ SkScalarCeilToInt(pic->cullRect().height())));
+
+ fDebugCanvas->setPicture(pic.get());
+ pic->playback(fDebugCanvas.get());
+ fDebugCanvas->setPicture(nullptr);
+
+ this->setupOpListWidget();
+
SkBitmap bm;
SkImageInfo ii = SkImageInfo::MakeN32Premul(1024, 1024);
@@ -65,7 +90,7 @@ void MainWindow::loadFile(const QString &fileName) {
SkCanvas canvas(bm);
- canvas.drawPicture(pic);
+ fDebugCanvas->draw(&canvas);
fImage = QImage((uchar*)bm.getPixels(), bm.width(), bm.height(), QImage::Format_RGBA8888);
fImageLabel->setPixmap(QPixmap::fromImage(fImage));
@@ -75,13 +100,19 @@ void MainWindow::loadFile(const QString &fileName) {
#endif
}
+
+void MainWindow::about() {
+ QMessageBox::about(this, "About MDB Viz", "Visualize MDB");
+}
+
void MainWindow::createActions() {
- QMenu *fileMenu = this->menuBar()->addMenu(tr("&File"));
- QToolBar *fileToolBar = this->addToolBar(tr("File"));
+ // File menu
+ QMenu* fileMenu = this->menuBar()->addMenu(tr("&File"));
+ QToolBar* fileToolBar = this->addToolBar(tr("File"));
const QIcon openIcon = QIcon::fromTheme("document-open", QIcon(":/images/open.png"));
- QAction *openAct = new QAction(openIcon, tr("&Open..."), this);
+ QAction* openAct = new QAction(openIcon, tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, &QAction::triggered, this, &MainWindow::openFile);
@@ -94,12 +125,52 @@ void MainWindow::createActions() {
QAction *exitAct = fileMenu->addAction(exitIcon, tr("E&xit"), this, &QWidget::close);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
+
+ // View menu
+ fViewMenu = this->menuBar()->addMenu(tr("&View"));
+
+ // Help menu
+ this->menuBar()->addSeparator();
+
+ QMenu* helpMenu = this->menuBar()->addMenu(tr("&Help"));
+
+ QAction *aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::about);
+ aboutAct->setStatusTip(tr("Show the application's About box"));
}
void MainWindow::createStatusBar() {
this->statusBar()->showMessage(tr("Ready"));
}
+void MainWindow::createDockWindows() {
+
+ // Op List Window
+ {
+ QDockWidget* opListDock = new QDockWidget("Ops", this);
+ opListDock->setAllowedAreas(Qt::LeftDockWidgetArea);
+
+ fOpListWidget = new QListWidget(opListDock);
+
+ opListDock->setWidget(fOpListWidget);
+ this->addDockWidget(Qt::LeftDockWidgetArea, opListDock);
+
+ fViewMenu->addAction(opListDock->toggleViewAction());
+ }
+
+ // Main canvas Window
+ {
+ QDockWidget* mainCanvasDock = new QDockWidget("Main Canvas", this);
+ mainCanvasDock->setAllowedAreas(Qt::RightDockWidgetArea);
+
+ fImageLabel = new QLabel(mainCanvasDock);
+
+ mainCanvasDock->setWidget(fImageLabel);
+ this->addDockWidget(Qt::RightDockWidgetArea, mainCanvasDock);
+
+ fViewMenu->addAction(mainCanvasDock->toggleViewAction());
+ }
+}
+
void MainWindow::readSettings() {
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
diff --git a/tools/mdbviz/mainwindow.h b/tools/mdbviz/mainwindow.h
index 9aa9fcfda1..80c86b0471 100644
--- a/tools/mdbviz/mainwindow.h
+++ b/tools/mdbviz/mainwindow.h
@@ -8,9 +8,15 @@
#ifndef MainWindow_DEFINED
#define MainWindow_DEFINED
+#include <memory>
#include <QMainWindow>
+#include "SkDebugCanvas.h"
+
class QLabel;
+class QListWidget;
+class QMenu;
+
class MainWindow : public QMainWindow {
Q_OBJECT
@@ -20,17 +26,27 @@ public:
private slots:
void openFile();
+ void about();
private:
void loadFile(const QString &fileName);
+ void setupOpListWidget();
void createActions();
void createStatusBar();
+ void createDockWindows();
+
void readSettings();
void writeSettings();
QImage fImage;
QLabel* fImageLabel;
+
+ QListWidget* fOpListWidget;
+
+ QMenu* fViewMenu;
+
+ std::unique_ptr<SkDebugCanvas> fDebugCanvas;
};
#endif