, fListWidget(&fCentralWidget)
, fDirectoryWidget(&fCentralWidget)
, fCanvasWidget(this, &fDebugger)
+ , fImageWidget(&fDebugger)
, fMenuBar(this)
, fMenuFile(this)
, fMenuNavigate(this)
}
if (fPause) {
fCanvasWidget.drawTo(fPausedRow);
+ fImageWidget.draw();
} else {
fCanvasWidget.drawTo(fListWidget.currentRow());
+ fImageWidget.draw();
}
}
fDebugger.highlightCurrentCommand(
fSettingsWidget.getVisibilityButton()->isChecked());
fCanvasWidget.drawTo(fListWidget.currentRow());
+ fImageWidget.draw();
}
void SkDebuggerGUI::actionClose() {
if (fPause) {
fCanvasWidget.drawTo(fPausedRow);
+ fImageWidget.draw();
} else {
fCanvasWidget.drawTo(currentRow);
+ fImageWidget.draw();
}
}
void SkDebuggerGUI::actionInspector() {
if (fInspectorWidget.isHidden()) {
fInspectorWidget.setHidden(false);
+ fImageWidget.setHidden(false);
} else {
fInspectorWidget.setHidden(true);
+ fImageWidget.setHidden(true);
}
}
fPause = isPaused;
fPausedRow = fListWidget.currentRow();
fCanvasWidget.drawTo(fPausedRow);
+ fImageWidget.draw();
}
void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
if (currentRow != -1) {
if (!fPause) {
fCanvasWidget.drawTo(currentRow);
+ fImageWidget.draw();
}
SkTDArray<SkString*> *currInfo = fDebugger.getCommandInfo(
currentRow);
fCanvasWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
+ fImageWidget.setFixedSize(SkImageWidget::kImageWidgetWidth,
+ SkImageWidget::kImageWidgetHeight);
+
fInspectorWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fInspectorWidget.setMaximumHeight(300);
+ fSettingsAndImageLayout.setSpacing(6);
+ fSettingsAndImageLayout.addWidget(&fSettingsWidget);
+ fSettingsAndImageLayout.addWidget(&fImageWidget);
+
fSettingsWidget.setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
fSettingsWidget.setMaximumWidth(250);
fLeftColumnLayout.addWidget(&fListWidget);
fLeftColumnLayout.addWidget(&fDirectoryWidget);
- fCanvasAndSettingsLayout.setSpacing(6);
- fCanvasAndSettingsLayout.addWidget(&fCanvasWidget);
- fCanvasAndSettingsLayout.addWidget(&fSettingsWidget);
+ fCanvasSettingsAndImageLayout.setSpacing(6);
+ fCanvasSettingsAndImageLayout.addWidget(&fCanvasWidget);
+ fCanvasSettingsAndImageLayout.addLayout(&fSettingsAndImageLayout);
+
fMainAndRightColumnLayout.setSpacing(6);
- fMainAndRightColumnLayout.addLayout(&fCanvasAndSettingsLayout);
+ fMainAndRightColumnLayout.addLayout(&fCanvasSettingsAndImageLayout);
fMainAndRightColumnLayout.addWidget(&fInspectorWidget);
fCentralWidget.setLayout(&fContainerLayout);
#include "SkListWidget.h"
#include "SkInspectorWidget.h"
#include "SkRasterWidget.h"
+#include "SkImageWidget.h"
#include "SkSettingsWidget.h"
#include <QtCore/QVariant>
#include <QtGui/QAction>
QHBoxLayout fContainerLayout;
QVBoxLayout fLeftColumnLayout;
QVBoxLayout fMainAndRightColumnLayout;
- QHBoxLayout fCanvasAndSettingsLayout;
+ QHBoxLayout fCanvasSettingsAndImageLayout;
+ QVBoxLayout fSettingsAndImageLayout;
QListWidget fListWidget;
QListWidget fDirectoryWidget;
SkDebugger fDebugger;
SkCanvasWidget fCanvasWidget;
+ SkImageWidget fImageWidget;
SkInspectorWidget fInspectorWidget;
SkSettingsWidget fSettingsWidget;
--- /dev/null
+
+/*
+ * 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 <QtGui>
+
+#include "SkDebugger.h"
+#include "SkImageWidget.h"
+
+SkImageWidget::SkImageWidget(SkDebugger *debugger)
+ : QWidget()
+ , fDebugger(debugger) {
+ this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
+}
+
+void SkImageWidget::paintEvent(QPaintEvent* event) {
+ if (this->isHidden()) {
+ return;
+ }
+
+ QPainter painter(this);
+ QStyleOption opt;
+ opt.init(this);
+
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+ const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
+ if (0 != commands.count()) {
+ SkDrawCommand* command = commands[fDebugger->index()];
+
+ const SkBitmap* bitmap = command->getBitmap();
+
+ if (NULL != bitmap) {
+ bitmap->lockPixels();
+
+ QPoint origin(0,0);
+ QImage image((uchar *)bitmap->getPixels(), bitmap->width(),
+ bitmap->height(), QImage::Format_ARGB32_Premultiplied);
+
+ painter.drawImage(origin, image);
+
+ bitmap->unlockPixels();
+ } else {
+ painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
+ }
+ }
+
+ painter.end();
+ emit drawComplete();
+}
--- /dev/null
+/*
+ * 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 SKIMAGEWIDGET_H_
+#define SKIMAGEWIDGET_H_
+
+#include <QWidget>
+
+class SkDebugger;
+
+class SkImageWidget : public QWidget {
+ Q_OBJECT
+
+public:
+ SkImageWidget(SkDebugger* debugger);
+
+ void draw() {
+ this->update();
+ }
+
+ static const int kImageWidgetWidth = 256;
+ static const int kImageWidgetHeight = 256;
+
+signals:
+ void drawComplete();
+
+protected:
+ void paintEvent(QPaintEvent* event);
+
+private:
+ SkDebugger *fDebugger;
+};
+
+#endif /* SKIMAGEWIDGET_H_ */
#include <iostream>
#include "SkDebugCanvas.h"
#include "SkDrawCommand.h"
+#include "SkDevice.h"
+#include "SkImageWidget.h"
static SkBitmap make_noconfig_bm(int width, int height) {
SkBitmap bm;
addDrawCommand(new Clear(color));
}
+static SkBitmap createBitmap(const SkPath& path) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ SkImageWidget::kImageWidgetWidth,
+ SkImageWidget::kImageWidgetHeight);
+ bitmap.allocPixels();
+ bitmap.eraseColor(SK_ColorWHITE);
+ SkDevice* device = new SkDevice(bitmap);
+
+ SkCanvas canvas(device);
+ device->unref();
+
+ const SkRect& bounds = path.getBounds();
+
+ if (bounds.width() > bounds.height()) {
+ canvas.scale(SkDoubleToScalar((0.9*SkImageWidget::kImageWidgetWidth)/bounds.width()),
+ SkDoubleToScalar((0.9*SkImageWidget::kImageWidgetHeight)/bounds.width()));
+ } else {
+ canvas.scale(SkDoubleToScalar((0.9*SkImageWidget::kImageWidgetWidth)/bounds.height()),
+ SkDoubleToScalar((0.9*SkImageWidget::kImageWidgetHeight)/bounds.height()));
+ }
+ canvas.translate(-bounds.fLeft+2, -bounds.fTop+2);
+
+ SkPaint p;
+ p.setColor(SK_ColorBLACK);
+ p.setStyle(SkPaint::kStroke_Style);
+
+ canvas.drawPath(path, p);
+
+ return bitmap;
+}
+
bool SkDebugCanvas::clipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
- addDrawCommand(new ClipPath(path, op, doAA));
+ addDrawCommand(new ClipPath(path, op, doAA, createBitmap(path)));
return true;
}
}
void SkDebugCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
- addDrawCommand(new DrawPath(path, paint));
+ addDrawCommand(new DrawPath(path, paint, createBitmap(path)));
}
void SkDebugCanvas::drawPicture(SkPicture& picture) {
canvas->clear(this->fColor);
}
-ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
+ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) {
this->fPath = &path;
this->fOp = op;
this->fDoAA = doAA;
this->fDrawType = CLIP_PATH;
+ this->fBitmap = bitmap;
this->fInfo.push(SkObjectParser::PathToString(path));
this->fInfo.push(SkObjectParser::RegionOpToString(op));
canvas->clipPath(*this->fPath, this->fOp, this->fDoAA);
}
+const SkBitmap* ClipPath::getBitmap() const {
+ return &fBitmap;
+}
+
ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
this->fRegion = ®ion;
this->fOp = op;
canvas->drawPaint(*this->fPaint);
}
-DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) {
+DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
this->fPath = &path;
this->fPaint = &paint;
+ this->fBitmap = bitmap;
this->fDrawType = DRAW_PATH;
this->fInfo.push(SkObjectParser::PathToString(path));
canvas->drawPath(*this->fPath, *this->fPaint);
}
+const SkBitmap* DrawPath::getBitmap() const {
+ return &fBitmap;
+}
+
DrawPicture::DrawPicture(SkPicture& picture) {
this->fPicture = &picture;
this->fDrawType = DRAW_PICTURE;
virtual void execute(SkCanvas* canvas)=0;
DrawType getType() { return fDrawType; };
+ virtual const SkBitmap* getBitmap() const { return NULL; }
+
static const char* GetCommandString(DrawType type);
protected:
class ClipPath : public SkDrawCommand {
public:
- ClipPath(const SkPath& path, SkRegion::Op op, bool doAA);
+ ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
+ virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
private:
const SkPath* fPath;
SkRegion::Op fOp;
bool fDoAA;
+ SkBitmap fBitmap;
};
class ClipRegion : public SkDrawCommand {
class DrawPath : public SkDrawCommand {
public:
- DrawPath(const SkPath& path, const SkPaint& paint);
+ DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap);
virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
+ virtual const SkBitmap* DrawPath::getBitmap() const SK_OVERRIDE;
+
private:
const SkPath* fPath;
const SkPaint* fPaint;
+ SkBitmap fBitmap;
};
class DrawPicture : public SkDrawCommand {
'../debugger/QT/SkGLWidget.cpp',
'../debugger/QT/SkRasterWidget.h',
'../debugger/QT/SkRasterWidget.cpp',
+ '../debugger/QT/SkImageWidget.h',
+ '../debugger/QT/SkImageWidget.cpp',
# To update this file edit SkIcons.qrc and rerun rcc to generate cpp
'../debugger/QT/qrc_SkIcons.cpp',
'<(moc_gen_dir)/moc_SkInspectorWidget.cpp',
'<(moc_gen_dir)/moc_SkSettingsWidget.cpp',
'<(moc_gen_dir)/moc_SkRasterWidget.cpp',
+ '<(moc_gen_dir)/moc_SkImageWidget.cpp',
'<(moc_gen_dir)/moc_SkGLWidget.cpp',
],
'dependencies': [
'<(moc_src_dir)/SkInspectorWidget.h',
'<(moc_src_dir)/SkSettingsWidget.h',
'<(moc_src_dir)/SkRasterWidget.h',
+ '<(moc_src_dir)/SkImageWidget.h',
'<(moc_src_dir)/SkGLWidget.h',
],
'rules': [