Moved the ownership of the current clip and current matrix into the debug canvas as part of the upcoming general refactor to everything living in debug canvas.
Review URL: https://codereview.appspot.com/6447077
git-svn-id: http://skia.googlecode.com/svn/trunk@4950 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp
index 2ff21b0..ee9e5da 100644
--- a/debugger/QT/SkCanvasWidget.cpp
+++ b/debugger/QT/SkCanvasWidget.cpp
@@ -9,7 +9,7 @@
#include "SkCanvasWidget.h"
-SkCanvasWidget::SkCanvasWidget() : QWidget()
+SkCanvasWidget::SkCanvasWidget(QWidget* parent) : QWidget(parent)
, fHorizontalLayout(this)
{
fHorizontalLayout.setSpacing(6);
@@ -30,6 +30,8 @@
setWidgetVisibility(kGPU_WidgetType, true);
this->setDisabled(true);
+ connect(&fRasterWidget, SIGNAL(drawComplete()),
+ this->parentWidget(), SLOT(drawComplete()));
}
SkCanvasWidget::~SkCanvasWidget() {
diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h
index 2c34240..13e4b27 100644
--- a/debugger/QT/SkCanvasWidget.h
+++ b/debugger/QT/SkCanvasWidget.h
@@ -20,7 +20,7 @@
Q_OBJECT
public:
- SkCanvasWidget();
+ SkCanvasWidget(QWidget* parent);
~SkCanvasWidget();
@@ -78,11 +78,11 @@
}
const SkMatrix& getCurrentMatrix() {
- return fRasterWidget.getCurrentMatrix();
+ return fDebugCanvas->getCurrentMatrix();
}
const SkIRect& getCurrentClip() {
- return fRasterWidget.getCurrentClip();
+ return fDebugCanvas->getCurrentClip();
}
void loadPicture(QString filename);
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 25f2ba9..24eeabd 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -38,6 +38,7 @@
, fMapper(this)
, fListWidget(&fCentralWidget)
, fDirectoryWidget(&fCentralWidget)
+ , fCanvasWidget(this)
, fMenuBar(this)
, fMenuFile(this)
, fMenuNavigate(this)
@@ -245,6 +246,11 @@
}
}
+void SkDebuggerGUI::drawComplete() {
+ fInspectorWidget.setMatrix(fCanvasWidget.getCurrentMatrix());
+ fInspectorWidget.setClip(fCanvasWidget.getCurrentClip());
+}
+
void SkDebuggerGUI::saveToFile(QString filename) {
SkFILEWStream file(filename.toAscii());
SkPicture picture;
@@ -312,8 +318,6 @@
}
fInspectorWidget.setDetailText(info);
fInspectorWidget.setDisabled(false);
- fInspectorWidget.setMatrix(fCanvasWidget.getCurrentMatrix());
- fInspectorWidget.setClip(fCanvasWidget.getCurrentClip());
}
}
diff --git a/debugger/QT/SkDebuggerGUI.h b/debugger/QT/SkDebuggerGUI.h
index d8b5c74..b1bbfa7 100644
--- a/debugger/QT/SkDebuggerGUI.h
+++ b/debugger/QT/SkDebuggerGUI.h
@@ -147,6 +147,11 @@
void actionStepForward();
/**
+ Called when the canvas is done being drawn to by SkCanvasWidget.
+ */
+ void drawComplete();
+
+ /**
Loads an skpicture selected from the directory.
*/
void loadFile(QListWidgetItem *item);
diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp
index ff903ad..d3d5389 100644
--- a/debugger/QT/SkGLWidget.cpp
+++ b/debugger/QT/SkGLWidget.cpp
@@ -55,6 +55,7 @@
fDebugCanvas->drawTo(fCanvas, fIndex);
// TODO(chudy): Implement an optional flush button in Gui.
fCanvas->flush();
+ emit drawComplete();
}
GrPlatformRenderTargetDesc SkGLWidget::getDesc(int w, int h) {
diff --git a/debugger/QT/SkGLWidget.h b/debugger/QT/SkGLWidget.h
index 76257be..5eeb1cb 100644
--- a/debugger/QT/SkGLWidget.h
+++ b/debugger/QT/SkGLWidget.h
@@ -21,6 +21,7 @@
#include "GrRenderTarget.h"
class SkGLWidget : public QGLWidget {
+Q_OBJECT
public:
SkGLWidget();
@@ -46,6 +47,9 @@
fScaleFactor = scale;
}
+signals:
+ void drawComplete();
+
protected:
void initializeGL();
void resizeGL(int w, int h);
diff --git a/debugger/QT/SkRasterWidget.cpp b/debugger/QT/SkRasterWidget.cpp
index 33728d0..ecb949c 100644
--- a/debugger/QT/SkRasterWidget.cpp
+++ b/debugger/QT/SkRasterWidget.cpp
@@ -40,10 +40,6 @@
void SkRasterWidget::paintEvent(QPaintEvent* event) {
if (fDebugCanvas) {
fDebugCanvas->drawTo(fCanvas, fIndex);
- // TODO(chudy): Refactor into SkDebugCanvas.
- fMatrix = fCanvas->getTotalMatrix();
- fClip = fCanvas->getTotalClip().getBounds();
-
QPainter painter(this);
QStyleOption opt;
opt.init(this);
@@ -56,5 +52,6 @@
painter.drawImage(origin, image);
painter.end();
+ emit drawComplete();
}
}
diff --git a/debugger/QT/SkRasterWidget.h b/debugger/QT/SkRasterWidget.h
index 3fca4f3..b0ded02 100644
--- a/debugger/QT/SkRasterWidget.h
+++ b/debugger/QT/SkRasterWidget.h
@@ -18,6 +18,7 @@
#include <QWidget>
class SkRasterWidget : public QWidget {
+ Q_OBJECT
public:
SkRasterWidget();
@@ -43,14 +44,6 @@
return fBitmap.width();
}
- const SkMatrix& getCurrentMatrix() {
- return fMatrix;
- }
-
- const SkIRect& getCurrentClip() {
- return fClip;
- }
-
void setTranslate(SkIPoint transform) {
fTransform = transform;
}
@@ -59,6 +52,9 @@
fScaleFactor = scale;
}
+signals:
+ void drawComplete();
+
protected:
void paintEvent(QPaintEvent* event);
@@ -70,9 +66,6 @@
SkCanvas* fCanvas;
SkDevice* fDevice;
- SkMatrix fMatrix;
- SkIRect fClip;
-
int fIndex;
SkIPoint fTransform;
float fScaleFactor;
diff --git a/debugger/QT/moc_SkDebuggerGUI.cpp b/debugger/QT/moc_SkDebuggerGUI.cpp
index 0d207aa..b78b39a 100644
--- a/debugger/QT/moc_SkDebuggerGUI.cpp
+++ b/debugger/QT/moc_SkDebuggerGUI.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'SkDebuggerGUI.h'
**
-** Created: Thu Jul 26 16:33:10 2012
+** Created: Wed Aug 1 14:54:26 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
**
** WARNING! All changes made in this file will be lost!
@@ -23,7 +23,7 @@
4, // revision
0, // classname
0, 0, // classinfo
- 29, 14, // methods
+ 30, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@@ -52,16 +52,17 @@
336, 14, 14, 14, 0x08,
353, 14, 14, 14, 0x08,
370, 14, 14, 14, 0x08,
- 395, 390, 14, 14, 0x08,
- 422, 14, 14, 14, 0x08,
- 442, 433, 14, 14, 0x08,
- 461, 14, 14, 14, 0x28,
- 476, 390, 14, 14, 0x08,
- 512, 15, 14, 14, 0x08,
- 531, 14, 14, 14, 0x08,
- 545, 14, 14, 14, 0x08,
- 564, 14, 14, 14, 0x08,
- 589, 582, 14, 14, 0x08,
+ 390, 14, 14, 14, 0x08,
+ 410, 405, 14, 14, 0x08,
+ 437, 14, 14, 14, 0x08,
+ 457, 448, 14, 14, 0x08,
+ 476, 14, 14, 14, 0x28,
+ 491, 405, 14, 14, 0x08,
+ 527, 15, 14, 14, 0x08,
+ 546, 14, 14, 14, 0x08,
+ 560, 14, 14, 14, 0x08,
+ 579, 14, 14, 14, 0x08,
+ 604, 597, 14, 14, 0x08,
0 // eod
};
@@ -77,7 +78,7 @@
"actionSave()\0actionSaveAs()\0scaleFactor\0"
"actionScale(float)\0actionSettings()\0"
"actionStepBack()\0actionStepForward()\0"
- "item\0loadFile(QListWidgetItem*)\0"
+ "drawComplete()\0item\0loadFile(QListWidgetItem*)\0"
"openFile()\0isPaused\0pauseDrawing(bool)\0"
"pauseDrawing()\0registerListClick(QListWidgetItem*)\0"
"selectCommand(int)\0showDeletes()\0"
@@ -133,19 +134,20 @@
case 16: actionSettings(); break;
case 17: actionStepBack(); break;
case 18: actionStepForward(); break;
- case 19: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 20: openFile(); break;
- case 21: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
- case 22: pauseDrawing(); break;
- case 23: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
- case 24: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
- case 25: showDeletes(); break;
- case 26: toggleBreakpoint(); break;
- case 27: toggleDirectory(); break;
- case 28: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
+ case 19: drawComplete(); break;
+ case 20: loadFile((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 21: openFile(); break;
+ case 22: pauseDrawing((*reinterpret_cast< bool(*)>(_a[1]))); break;
+ case 23: pauseDrawing(); break;
+ case 24: registerListClick((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break;
+ case 25: selectCommand((*reinterpret_cast< int(*)>(_a[1]))); break;
+ case 26: showDeletes(); break;
+ case 27: toggleBreakpoint(); break;
+ case 28: toggleDirectory(); break;
+ case 29: toggleFilter((*reinterpret_cast< QString(*)>(_a[1]))); break;
default: ;
}
- _id -= 29;
+ _id -= 30;
}
return _id;
}
diff --git a/debugger/QT/moc_SkGLWidget.cpp b/debugger/QT/moc_SkGLWidget.cpp
new file mode 100644
index 0000000..9d09c26
--- /dev/null
+++ b/debugger/QT/moc_SkGLWidget.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'SkGLWidget.h'
+**
+** Created: Wed Aug 1 14:54:26 2012
+** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "SkGLWidget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'SkGLWidget.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_SkGLWidget[] = {
+
+ // content:
+ 4, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 1, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 1, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 12, 11, 11, 11, 0x05,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_SkGLWidget[] = {
+ "SkGLWidget\0\0drawComplete()\0"
+};
+
+const QMetaObject SkGLWidget::staticMetaObject = {
+ { &QGLWidget::staticMetaObject, qt_meta_stringdata_SkGLWidget,
+ qt_meta_data_SkGLWidget, 0 }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &SkGLWidget::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *SkGLWidget::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *SkGLWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_SkGLWidget))
+ return static_cast<void*>(const_cast< SkGLWidget*>(this));
+ return QGLWidget::qt_metacast(_clname);
+}
+
+int SkGLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QGLWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: drawComplete(); break;
+ default: ;
+ }
+ _id -= 1;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void SkGLWidget::drawComplete()
+{
+ QMetaObject::activate(this, &staticMetaObject, 0, 0);
+}
+QT_END_MOC_NAMESPACE
diff --git a/debugger/QT/moc_SkRasterWidget.cpp b/debugger/QT/moc_SkRasterWidget.cpp
new file mode 100644
index 0000000..82a803a
--- /dev/null
+++ b/debugger/QT/moc_SkRasterWidget.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+** Meta object code from reading C++ file 'SkRasterWidget.h'
+**
+** Created: Wed Aug 1 14:54:26 2012
+** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2)
+**
+** WARNING! All changes made in this file will be lost!
+*****************************************************************************/
+
+#include "SkRasterWidget.h"
+#if !defined(Q_MOC_OUTPUT_REVISION)
+#error "The header file 'SkRasterWidget.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_SkRasterWidget[] = {
+
+ // content:
+ 4, // revision
+ 0, // classname
+ 0, 0, // classinfo
+ 1, 14, // methods
+ 0, 0, // properties
+ 0, 0, // enums/sets
+ 0, 0, // constructors
+ 0, // flags
+ 1, // signalCount
+
+ // signals: signature, parameters, type, tag, flags
+ 16, 15, 15, 15, 0x05,
+
+ 0 // eod
+};
+
+static const char qt_meta_stringdata_SkRasterWidget[] = {
+ "SkRasterWidget\0\0drawComplete()\0"
+};
+
+const QMetaObject SkRasterWidget::staticMetaObject = {
+ { &QWidget::staticMetaObject, qt_meta_stringdata_SkRasterWidget,
+ qt_meta_data_SkRasterWidget, 0 }
+};
+
+#ifdef Q_NO_DATA_RELOCATION
+const QMetaObject &SkRasterWidget::getStaticMetaObject() { return staticMetaObject; }
+#endif //Q_NO_DATA_RELOCATION
+
+const QMetaObject *SkRasterWidget::metaObject() const
+{
+ return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
+}
+
+void *SkRasterWidget::qt_metacast(const char *_clname)
+{
+ if (!_clname) return 0;
+ if (!strcmp(_clname, qt_meta_stringdata_SkRasterWidget))
+ return static_cast<void*>(const_cast< SkRasterWidget*>(this));
+ return QWidget::qt_metacast(_clname);
+}
+
+int SkRasterWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
+{
+ _id = QWidget::qt_metacall(_c, _id, _a);
+ if (_id < 0)
+ return _id;
+ if (_c == QMetaObject::InvokeMetaMethod) {
+ switch (_id) {
+ case 0: drawComplete(); break;
+ default: ;
+ }
+ _id -= 1;
+ }
+ return _id;
+}
+
+// SIGNAL 0
+void SkRasterWidget::drawComplete()
+{
+ QMetaObject::activate(this, &staticMetaObject, 0, 0);
+}
+QT_END_MOC_NAMESPACE
diff --git a/debugger/SkDebugCanvas.cpp b/debugger/SkDebugCanvas.cpp
index 6070867..47734b1 100644
--- a/debugger/SkDebugCanvas.cpp
+++ b/debugger/SkDebugCanvas.cpp
@@ -109,7 +109,8 @@
commandVector[i]->execute(canvas);
}
}
-
+ fMatrix = canvas->getTotalMatrix();
+ fClip = canvas->getTotalClip().getBounds();
fIndex = index;
}
diff --git a/debugger/SkDebugCanvas.h b/debugger/SkDebugCanvas.h
index c51e40f..e02c34c 100644
--- a/debugger/SkDebugCanvas.h
+++ b/debugger/SkDebugCanvas.h
@@ -45,6 +45,20 @@
void drawTo(SkCanvas* canvas, int index);
/**
+ Returns the most recently calculated transformation matrix
+ */
+ const SkMatrix& getCurrentMatrix() {
+ return fMatrix;
+ }
+
+ /**
+ Returns the most recently calculated clip
+ */
+ const SkIRect& getCurrentClip() {
+ return fClip;
+ }
+
+ /**
Returns the index of the last draw command to write to the pixel at (x,y)
*/
int getCommandAtPoint(int x, int y, int index);
@@ -191,6 +205,8 @@
int fIndex;
SkIPoint fUserOffset;
float fUserScale;
+ SkMatrix fMatrix;
+ SkIRect fClip;
/**
Adds the command to the classes vector of commands.
diff --git a/debugger/moc.sh b/debugger/moc.sh
index 86cb5e7..f271b21 100755
--- a/debugger/moc.sh
+++ b/debugger/moc.sh
@@ -10,3 +10,5 @@
$MOC $SRC_DIR/SkDebuggerGUI.h -o $SRC_DIR/moc_SkDebuggerGUI.cpp
$MOC $SRC_DIR/SkInspectorWidget.h -o $SRC_DIR/moc_SkInspectorWidget.cpp
$MOC $SRC_DIR/SkSettingsWidget.h -o $SRC_DIR/moc_SkSettingsWidget.cpp
+$MOC $SRC_DIR/SkRasterWidget.h -o $SRC_DIR/moc_SkRasterWidget.cpp
+$MOC $SRC_DIR/SkGLWidget.h -o $SRC_DIR/moc_SkGLWidget.cpp
diff --git a/gyp/debugger.gyp b/gyp/debugger.gyp
index f2c3fe9..be3c793 100644
--- a/gyp/debugger.gyp
+++ b/gyp/debugger.gyp
@@ -19,6 +19,8 @@
'../debugger/QT/moc_SkDebuggerGUI.cpp',
'../debugger/QT/moc_SkInspectorWidget.cpp',
'../debugger/QT/moc_SkSettingsWidget.cpp',
+ '../debugger/QT/moc_SkRasterWidget.cpp',
+ '../debugger/QT/moc_SkGLWidget.cpp',
'../debugger/QT/SkDebuggerGUI.cpp',
'../debugger/QT/SkDebuggerGUI.h',
'../debugger/QT/SkCanvasWidget.cpp',