Moved the ownership of the current clip and current matrix into the debug canvas...
authorchudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 3 Aug 2012 17:32:05 +0000 (17:32 +0000)
committerchudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 3 Aug 2012 17:32:05 +0000 (17:32 +0000)
Review URL: https://codereview.appspot.com/6447077

git-svn-id: http://skia.googlecode.com/svn/trunk@4950 2bbb7eff-a529-9590-31e7-b0007b416f81

15 files changed:
debugger/QT/SkCanvasWidget.cpp
debugger/QT/SkCanvasWidget.h
debugger/QT/SkDebuggerGUI.cpp
debugger/QT/SkDebuggerGUI.h
debugger/QT/SkGLWidget.cpp
debugger/QT/SkGLWidget.h
debugger/QT/SkRasterWidget.cpp
debugger/QT/SkRasterWidget.h
debugger/QT/moc_SkDebuggerGUI.cpp
debugger/QT/moc_SkGLWidget.cpp [new file with mode: 0644]
debugger/QT/moc_SkRasterWidget.cpp [new file with mode: 0644]
debugger/SkDebugCanvas.cpp
debugger/SkDebugCanvas.h
debugger/moc.sh
gyp/debugger.gyp

index 2ff21b0..ee9e5da 100644 (file)
@@ -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 @@ SkCanvasWidget::SkCanvasWidget() : QWidget()
 
     setWidgetVisibility(kGPU_WidgetType, true);
     this->setDisabled(true);
+    connect(&fRasterWidget, SIGNAL(drawComplete()),
+            this->parentWidget(), SLOT(drawComplete()));
 }
 
 SkCanvasWidget::~SkCanvasWidget() {
index 2c34240..13e4b27 100644 (file)
@@ -20,7 +20,7 @@ class SkCanvasWidget : public QWidget {
     Q_OBJECT
 
 public:
-    SkCanvasWidget();
+    SkCanvasWidget(QWidget* parent);
 
     ~SkCanvasWidget();
 
@@ -78,11 +78,11 @@ public:
     }
 
     const SkMatrix& getCurrentMatrix() {
-        return fRasterWidget.getCurrentMatrix();
+        return fDebugCanvas->getCurrentMatrix();
     }
 
     const SkIRect& getCurrentClip() {
-        return fRasterWidget.getCurrentClip();
+        return fDebugCanvas->getCurrentClip();
     }
 
     void loadPicture(QString filename);
index 25f2ba9..24eeabd 100644 (file)
@@ -38,6 +38,7 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) :
     , fMapper(this)
     , fListWidget(&fCentralWidget)
     , fDirectoryWidget(&fCentralWidget)
+    , fCanvasWidget(this)
     , fMenuBar(this)
     , fMenuFile(this)
     , fMenuNavigate(this)
@@ -245,6 +246,11 @@ void SkDebuggerGUI::actionStepForward() {
     }
 }
 
+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 @@ void SkDebuggerGUI::registerListClick(QListWidgetItem *item) {
                 }
                 fInspectorWidget.setDetailText(info);
                 fInspectorWidget.setDisabled(false);
-                fInspectorWidget.setMatrix(fCanvasWidget.getCurrentMatrix());
-                fInspectorWidget.setClip(fCanvasWidget.getCurrentClip());
             }
         }
 
index d8b5c74..b1bbfa7 100644 (file)
@@ -147,6 +147,11 @@ private slots:
     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);
index ff903ad..d3d5389 100644 (file)
@@ -55,6 +55,7 @@ void SkGLWidget::paintGL() {
     fDebugCanvas->drawTo(fCanvas, fIndex);
     // TODO(chudy): Implement an optional flush button in Gui.
     fCanvas->flush();
+    emit drawComplete();
 }
 
 GrPlatformRenderTargetDesc SkGLWidget::getDesc(int w, int h) {
index 76257be..5eeb1cb 100644 (file)
@@ -21,6 +21,7 @@
 #include "GrRenderTarget.h"
 
 class SkGLWidget : public QGLWidget {
+Q_OBJECT
 
 public:
     SkGLWidget();
@@ -46,6 +47,9 @@ public:
         fScaleFactor = scale;
     }
 
+signals:
+    void drawComplete();
+
 protected:
     void initializeGL();
     void resizeGL(int w, int h);
index 33728d0..ecb949c 100644 (file)
@@ -40,10 +40,6 @@ void SkRasterWidget::resizeEvent(QResizeEvent* event) {
 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 @@ void SkRasterWidget::paintEvent(QPaintEvent* event) {
 
         painter.drawImage(origin, image);
         painter.end();
+        emit drawComplete();
     }
 }
index 3fca4f3..b0ded02 100644 (file)
@@ -18,6 +18,7 @@
 #include <QWidget>
 
 class  SkRasterWidget : public QWidget {
+    Q_OBJECT
 
 public:
     SkRasterWidget();
@@ -43,14 +44,6 @@ public:
         return fBitmap.width();
     }
 
-    const SkMatrix& getCurrentMatrix() {
-        return fMatrix;
-    }
-
-    const SkIRect& getCurrentClip() {
-        return fClip;
-    }
-
     void setTranslate(SkIPoint transform) {
         fTransform = transform;
     }
@@ -59,6 +52,9 @@ public:
         fScaleFactor = scale;
     }
 
+signals:
+    void drawComplete();
+
 protected:
     void paintEvent(QPaintEvent* event);
 
@@ -70,9 +66,6 @@ private:
     SkCanvas* fCanvas;
     SkDevice* fDevice;
 
-    SkMatrix fMatrix;
-    SkIRect fClip;
-
     int fIndex;
     SkIPoint fTransform;
     float fScaleFactor;
index 0d207aa..b78b39a 100644 (file)
@@ -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 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
        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 @@ static const uint qt_meta_data_SkDebuggerGUI[] = {
      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 @@ static const char qt_meta_stringdata_SkDebuggerGUI[] = {
     "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 @@ int SkDebuggerGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
         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 (file)
index 0000000..9d09c26
--- /dev/null
@@ -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 (file)
index 0000000..82a803a
--- /dev/null
@@ -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
index 6070867..47734b1 100644 (file)
@@ -109,7 +109,8 @@ void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) {
             commandVector[i]->execute(canvas);
         }
     }
-
+    fMatrix = canvas->getTotalMatrix();
+    fClip = canvas->getTotalClip().getBounds();
     fIndex = index;
 }
 
index c51e40f..e02c34c 100644 (file)
@@ -45,6 +45,20 @@ public:
     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 @@ private:
     int fIndex;
     SkIPoint fUserOffset;
     float fUserScale;
+    SkMatrix fMatrix;
+    SkIRect fClip;
 
     /**
         Adds the command to the classes vector of commands.
index 86cb5e7..f271b21 100755 (executable)
@@ -10,3 +10,5 @@ $MOC $SRC_DIR/SkCanvasWidget.h -o $SRC_DIR/moc_SkCanvasWidget.cpp
 $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
index f2c3fe9..be3c793 100644 (file)
@@ -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',