diff options
author | 2012-07-12 14:31:25 +0000 | |
---|---|---|
committer | 2012-07-12 14:31:25 +0000 | |
commit | e606d6e210b17dd9dd582d4d3ec70acb4f3213d5 (patch) | |
tree | 0435ebc517896f6958ef4e1ab99372197c1d2d6e /debugger/QT | |
parent | e565de4fad5598890124daadf385930043269415 (diff) |
SkHitBox added.
SkHitBox is a class that determines which draw command is associated with the pixel located at x,y. By calculating a single point instead of the entire bitmap at once there is no visible performance slowdown.
Review URL: https://codereview.appspot.com/6350098
git-svn-id: http://skia.googlecode.com/svn/trunk@4565 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger/QT')
-rw-r--r-- | debugger/QT/SkCanvasWidget.cpp | 10 | ||||
-rw-r--r-- | debugger/QT/SkCanvasWidget.h | 1 | ||||
-rw-r--r-- | debugger/QT/SkDebuggerGUI.cpp | 5 | ||||
-rw-r--r-- | debugger/QT/SkSettingsWidget.cpp | 21 | ||||
-rw-r--r-- | debugger/QT/SkSettingsWidget.h | 7 | ||||
-rw-r--r-- | debugger/QT/moc_SkCanvasWidget.cpp | 19 | ||||
-rw-r--r-- | debugger/QT/moc_SkSettingsWidget.cpp | 10 |
7 files changed, 58 insertions, 15 deletions
diff --git a/debugger/QT/SkCanvasWidget.cpp b/debugger/QT/SkCanvasWidget.cpp index 39fb1f5aad..8c660a4a23 100644 --- a/debugger/QT/SkCanvasWidget.cpp +++ b/debugger/QT/SkCanvasWidget.cpp @@ -11,7 +11,6 @@ #include "SkStream.h" #include "SkCanvasWidget.h" #include "SkColor.h" -#include <iostream> SkCanvasWidget::SkCanvasWidget(QWidget *parent) : QWidget(parent) { @@ -56,7 +55,7 @@ void SkCanvasWidget::resizeEvent(QResizeEvent* event) { fDevice = new SkDevice(fBitmap); fCanvas = new SkCanvas(fDevice); fDebugCanvas->setBounds(event->size().width(), event->size().height()); - fDebugCanvas->drawTo(fCanvas, fIndex); + fDebugCanvas->drawTo(fCanvas, fIndex+1, &fBitmap); this->update(); } @@ -72,7 +71,7 @@ void SkCanvasWidget::drawTo(int fIndex) { } emit commandChanged(fIndex); - fDebugCanvas->drawTo(fCanvas, fIndex+1); + fDebugCanvas->drawTo(fCanvas, fIndex+1, &fBitmap); this->update(); this->fIndex = fIndex; } @@ -128,6 +127,11 @@ void SkCanvasWidget::mouseMoveEvent(QMouseEvent* event) { void SkCanvasWidget::mousePressEvent(QMouseEvent* event) { fPreviousPoint.set(event->globalX(), event->globalY()); + fDebugCanvas->getBoxClass()->setHitPoint(event->x(), event->y()); + fDebugCanvas->isCalculatingHits(true); + drawTo(fIndex); + emit hitChanged(fDebugCanvas->getHitBoxPoint()); + fDebugCanvas->isCalculatingHits(false); } void SkCanvasWidget::mouseDoubleClickEvent(QMouseEvent* event) { diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h index 3f18749786..65fa2baf09 100644 --- a/debugger/QT/SkCanvasWidget.h +++ b/debugger/QT/SkCanvasWidget.h @@ -132,6 +132,7 @@ public: signals: void scaleFactorChanged(float newScaleFactor); void commandChanged(int newCommand); + void hitChanged(int hit); protected: /** diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp index 96e155167e..12c3bdc9c3 100644 --- a/debugger/QT/SkDebuggerGUI.cpp +++ b/debugger/QT/SkDebuggerGUI.cpp @@ -71,10 +71,12 @@ SkDebuggerGUI::SkDebuggerGUI(QWidget *parent) : SLOT(actionCommandFilter())); connect(&fCanvasWidget, SIGNAL(scaleFactorChanged(float)), this, SLOT(actionScale(float))); - connect(fSettingsWidget.getCommandCheckBox(), SIGNAL(stateChanged(int)), + connect(fSettingsWidget.getCommandCheckBox(), SIGNAL(toggled(bool)), this, SLOT(pauseDrawing(bool))); connect(&fCanvasWidget, SIGNAL(commandChanged(int)), &fSettingsWidget, SLOT(updateCommand(int))); + connect(&fCanvasWidget, SIGNAL(hitChanged(int)), &fSettingsWidget, + SLOT(updateHit(int))); } SkDebuggerGUI::~SkDebuggerGUI() { @@ -478,6 +480,7 @@ void SkDebuggerGUI::loadPicture(QString fileName) { fSettingsWidget.getVisibilityButton()->isChecked()); setupListWidget(cv); setupComboBox(cv); + fSettingsWidget.setDisabled(false); } void SkDebuggerGUI::setupListWidget(std::vector<std::string>* cv) { diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp index 117e7bf71e..5b5236a322 100644 --- a/debugger/QT/SkSettingsWidget.cpp +++ b/debugger/QT/SkSettingsWidget.cpp @@ -19,6 +19,7 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent) , fVisibleOff(&fVisibleFrame) , fCommandLayout(&fCommandFrame) , fCurrentCommandBox(&fCommandFrame) + , fCommandHitBox(&fCommandFrame) , fCommandCheckBox(&fCommandFrame) , fZoomBox(&fZoomFrame) , fZoomLayout(&fZoomFrame) @@ -65,10 +66,24 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent) fCurrentCommandLayout.addWidget(&fCurrentCommandLabel); fCurrentCommandLayout.addWidget(&fCurrentCommandBox); + fCommandHitLabel.setText("Command HitBox: "); + fCommandHitLabel.setMinimumWidth(178); + fCommandHitLabel.setMaximumWidth(178); + fCommandHitBox.setText("0"); + fCommandHitBox.setMinimumSize(QSize(50,25)); + fCommandHitBox.setMaximumSize(QSize(50,25)); + fCommandHitBox.setAlignment(Qt::AlignRight); + fCommandHitLayout.setSpacing(0); + fCommandHitLayout.setContentsMargins(0,0,0,0); + fCommandHitLayout.setAlignment(Qt::AlignLeft); + fCommandHitLayout.addWidget(&fCommandHitLabel); + fCommandHitLayout.addWidget(&fCommandHitBox); + fCommandCheckBox.setText("Pause"); fCommandLayout.setSpacing(6); fCommandLayout.setContentsMargins(11,11,11,11); fCommandLayout.addLayout(&fCurrentCommandLayout); + fCommandLayout.addLayout(&fCommandHitLayout); fCommandLayout.addWidget(&fCommandCheckBox); // Zoom Info @@ -93,7 +108,7 @@ SkSettingsWidget::SkSettingsWidget(QWidget *parent) : QWidget(parent) fVerticalLayout.addWidget(&fCommandFrame); fVerticalLayout.addWidget(&fZoomFrame); - //this->setDisabled(true); + this->setDisabled(true); } SkSettingsWidget::~SkSettingsWidget() {} @@ -103,6 +118,10 @@ void SkSettingsWidget::updateCommand(int newCommand) { fCurrentCommandBox.setText(QString::number(newCommand)); } +void SkSettingsWidget::updateHit(int newHit) { + fCommandHitBox.setText(QString::number(newHit)); +} + QCheckBox* SkSettingsWidget::getCommandCheckBox() { return &fCommandCheckBox; } diff --git a/debugger/QT/SkSettingsWidget.h b/debugger/QT/SkSettingsWidget.h index da7326b68e..839a331ae3 100644 --- a/debugger/QT/SkSettingsWidget.h +++ b/debugger/QT/SkSettingsWidget.h @@ -43,6 +43,7 @@ public: private slots: void updateCommand(int newCommand); + void updateHit(int newHit); signals: void scrollingPreferences(bool isStickyActivate); @@ -64,10 +65,14 @@ private: QFrame fCommandFrame; QVBoxLayout fCommandLayout; - QLineEdit fCurrentCommandBox; QLabel fCurrentCommandLabel; + QLineEdit fCurrentCommandBox; QHBoxLayout fCurrentCommandLayout; + QLabel fCommandHitLabel; + QLineEdit fCommandHitBox; + QHBoxLayout fCommandHitLayout; + QCheckBox fCommandCheckBox; QLabel fZoomSetting; diff --git a/debugger/QT/moc_SkCanvasWidget.cpp b/debugger/QT/moc_SkCanvasWidget.cpp index 0187620abb..098b3bb745 100644 --- a/debugger/QT/moc_SkCanvasWidget.cpp +++ b/debugger/QT/moc_SkCanvasWidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'SkCanvasWidget.h' ** -** Created: Mon Jul 9 13:45:07 2012 +** Created: Wed Jul 11 15:15:07 2012 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.2) ** ** WARNING! All changes made in this file will be lost! @@ -23,16 +23,17 @@ static const uint qt_meta_data_SkCanvasWidget[] = { 4, // revision 0, // classname 0, 0, // classinfo - 2, 14, // methods + 3, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags - 2, // signalCount + 3, // signalCount // signals: signature, parameters, type, tag, flags 31, 16, 15, 15, 0x05, 68, 57, 15, 15, 0x05, + 92, 88, 15, 15, 0x05, 0 // eod }; @@ -40,7 +41,7 @@ static const uint qt_meta_data_SkCanvasWidget[] = { static const char qt_meta_stringdata_SkCanvasWidget[] = { "SkCanvasWidget\0\0newScaleFactor\0" "scaleFactorChanged(float)\0newCommand\0" - "commandChanged(int)\0" + "commandChanged(int)\0hit\0hitChanged(int)\0" }; const QMetaObject SkCanvasWidget::staticMetaObject = { @@ -74,9 +75,10 @@ int SkCanvasWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) switch (_id) { case 0: scaleFactorChanged((*reinterpret_cast< float(*)>(_a[1]))); break; case 1: commandChanged((*reinterpret_cast< int(*)>(_a[1]))); break; + case 2: hitChanged((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } - _id -= 2; + _id -= 3; } return _id; } @@ -94,4 +96,11 @@ void SkCanvasWidget::commandChanged(int _t1) void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; QMetaObject::activate(this, &staticMetaObject, 1, _a); } + +// SIGNAL 2 +void SkCanvasWidget::hitChanged(int _t1) +{ + void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) }; + QMetaObject::activate(this, &staticMetaObject, 2, _a); +} QT_END_MOC_NAMESPACE diff --git a/debugger/QT/moc_SkSettingsWidget.cpp b/debugger/QT/moc_SkSettingsWidget.cpp index 336b1ef2f9..d2822ce334 100644 --- a/debugger/QT/moc_SkSettingsWidget.cpp +++ b/debugger/QT/moc_SkSettingsWidget.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'SkSettingsWidget.h' ** -** Created: Mon Jul 9 13:45:07 2012 +** Created: Wed Jul 11 15:20:23 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_SkSettingsWidget[] = { 4, // revision 0, // classname 0, 0, // classinfo - 4, 14, // methods + 5, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -37,6 +37,7 @@ static const uint qt_meta_data_SkSettingsWidget[] = { // slots: signature, parameters, type, tag, flags 138, 127, 17, 17, 0x08, + 164, 157, 17, 17, 0x08, 0 // eod }; @@ -46,7 +47,7 @@ static const char qt_meta_stringdata_SkSettingsWidget[] = { "scrollingPreferences(bool)\0isSingleCommand\0" "showStyle(bool)\0isEnabled\0" "visibilityFilter(bool)\0newCommand\0" - "updateCommand(int)\0" + "updateCommand(int)\0newHit\0updateHit(int)\0" }; const QMetaObject SkSettingsWidget::staticMetaObject = { @@ -82,9 +83,10 @@ int SkSettingsWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) case 1: showStyle((*reinterpret_cast< bool(*)>(_a[1]))); break; case 2: visibilityFilter((*reinterpret_cast< bool(*)>(_a[1]))); break; case 3: updateCommand((*reinterpret_cast< int(*)>(_a[1]))); break; + case 4: updateHit((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } - _id -= 4; + _id -= 5; } return _id; } |