diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/citra_qt/debugger/graphics_cmdlists.cpp | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/citra_qt/debugger/graphics_cmdlists.cpp')
| -rw-r--r-- | src/citra_qt/debugger/graphics_cmdlists.cpp | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp index 3e0a0a145..8a784d108 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics_cmdlists.cpp | |||
| @@ -13,16 +13,13 @@ | |||
| 13 | #include <QSpinBox> | 13 | #include <QSpinBox> |
| 14 | #include <QTreeView> | 14 | #include <QTreeView> |
| 15 | #include <QVBoxLayout> | 15 | #include <QVBoxLayout> |
| 16 | |||
| 17 | #include "citra_qt/debugger/graphics_cmdlists.h" | 16 | #include "citra_qt/debugger/graphics_cmdlists.h" |
| 18 | #include "citra_qt/util/spinbox.h" | 17 | #include "citra_qt/util/spinbox.h" |
| 19 | #include "citra_qt/util/util.h" | 18 | #include "citra_qt/util/util.h" |
| 20 | |||
| 21 | #include "common/vector_math.h" | 19 | #include "common/vector_math.h" |
| 22 | 20 | #include "video_core/debug_utils/debug_utils.h" | |
| 23 | #include "video_core/pica.h" | 21 | #include "video_core/pica.h" |
| 24 | #include "video_core/pica_state.h" | 22 | #include "video_core/pica_state.h" |
| 25 | #include "video_core/debug_utils/debug_utils.h" | ||
| 26 | 23 | ||
| 27 | QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { | 24 | QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { |
| 28 | QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); | 25 | QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); |
| @@ -38,7 +35,8 @@ QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { | |||
| 38 | 35 | ||
| 39 | class TextureInfoWidget : public QWidget { | 36 | class TextureInfoWidget : public QWidget { |
| 40 | public: | 37 | public: |
| 41 | TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) : QWidget(parent) { | 38 | TextureInfoWidget(u8* src, const Pica::DebugUtils::TextureInfo& info, QWidget* parent = nullptr) |
| 39 | : QWidget(parent) { | ||
| 42 | QLabel* image_widget = new QLabel; | 40 | QLabel* image_widget = new QLabel; |
| 43 | QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info)); | 41 | QPixmap image_pixmap = QPixmap::fromImage(LoadTexture(src, info)); |
| 44 | image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); | 42 | image_pixmap = image_pixmap.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation); |
| @@ -50,9 +48,7 @@ public: | |||
| 50 | } | 48 | } |
| 51 | }; | 49 | }; |
| 52 | 50 | ||
| 53 | GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) { | 51 | GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractListModel(parent) {} |
| 54 | |||
| 55 | } | ||
| 56 | 52 | ||
| 57 | int GPUCommandListModel::rowCount(const QModelIndex& parent) const { | 53 | int GPUCommandListModel::rowCount(const QModelIndex& parent) const { |
| 58 | return static_cast<int>(pica_trace.writes.size()); | 54 | return static_cast<int>(pica_trace.writes.size()); |
| @@ -70,7 +66,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const { | |||
| 70 | 66 | ||
| 71 | if (role == Qt::DisplayRole) { | 67 | if (role == Qt::DisplayRole) { |
| 72 | QString content; | 68 | QString content; |
| 73 | switch ( index.column() ) { | 69 | switch (index.column()) { |
| 74 | case 0: | 70 | case 0: |
| 75 | return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str()); | 71 | return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str()); |
| 76 | case 1: | 72 | case 1: |
| @@ -88,9 +84,8 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const { | |||
| 88 | } | 84 | } |
| 89 | 85 | ||
| 90 | QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const { | 86 | QVariant GPUCommandListModel::headerData(int section, Qt::Orientation orientation, int role) const { |
| 91 | switch(role) { | 87 | switch (role) { |
| 92 | case Qt::DisplayRole: | 88 | case Qt::DisplayRole: { |
| 93 | { | ||
| 94 | switch (section) { | 89 | switch (section) { |
| 95 | case 0: | 90 | case 0: |
| 96 | return tr("Command Name"); | 91 | return tr("Command Name"); |
| @@ -117,14 +112,14 @@ void GPUCommandListModel::OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace& | |||
| 117 | endResetModel(); | 112 | endResetModel(); |
| 118 | } | 113 | } |
| 119 | 114 | ||
| 120 | #define COMMAND_IN_RANGE(cmd_id, reg_name) \ | 115 | #define COMMAND_IN_RANGE(cmd_id, reg_name) \ |
| 121 | (cmd_id >= PICA_REG_INDEX(reg_name) && \ | 116 | (cmd_id >= PICA_REG_INDEX(reg_name) && \ |
| 122 | cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4) | 117 | cmd_id < PICA_REG_INDEX(reg_name) + sizeof(decltype(Pica::g_state.regs.reg_name)) / 4) |
| 123 | 118 | ||
| 124 | void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) { | 119 | void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) { |
| 125 | const unsigned int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); | 120 | const unsigned int command_id = |
| 126 | if (COMMAND_IN_RANGE(command_id, texture0) || | 121 | list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); |
| 127 | COMMAND_IN_RANGE(command_id, texture1) || | 122 | if (COMMAND_IN_RANGE(command_id, texture0) || COMMAND_IN_RANGE(command_id, texture1) || |
| 128 | COMMAND_IN_RANGE(command_id, texture2)) { | 123 | COMMAND_IN_RANGE(command_id, texture2)) { |
| 129 | 124 | ||
| 130 | unsigned index; | 125 | unsigned index; |
| @@ -148,9 +143,9 @@ void GPUCommandListWidget::OnCommandDoubleClicked(const QModelIndex& index) { | |||
| 148 | void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { | 143 | void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { |
| 149 | QWidget* new_info_widget = nullptr; | 144 | QWidget* new_info_widget = nullptr; |
| 150 | 145 | ||
| 151 | const unsigned int command_id = list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); | 146 | const unsigned int command_id = |
| 152 | if (COMMAND_IN_RANGE(command_id, texture0) || | 147 | list_widget->model()->data(index, GPUCommandListModel::CommandIdRole).toUInt(); |
| 153 | COMMAND_IN_RANGE(command_id, texture1) || | 148 | if (COMMAND_IN_RANGE(command_id, texture0) || COMMAND_IN_RANGE(command_id, texture1) || |
| 154 | COMMAND_IN_RANGE(command_id, texture2)) { | 149 | COMMAND_IN_RANGE(command_id, texture2)) { |
| 155 | 150 | ||
| 156 | unsigned index; | 151 | unsigned index; |
| @@ -179,7 +174,8 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) { | |||
| 179 | } | 174 | } |
| 180 | #undef COMMAND_IN_RANGE | 175 | #undef COMMAND_IN_RANGE |
| 181 | 176 | ||
| 182 | GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent) { | 177 | GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) |
| 178 | : QDockWidget(tr("Pica Command List"), parent) { | ||
| 183 | setObjectName("Pica Command List"); | 179 | setObjectName("Pica Command List"); |
| 184 | GPUCommandListModel* model = new GPUCommandListModel(this); | 180 | GPUCommandListModel* model = new GPUCommandListModel(this); |
| 185 | 181 | ||
| @@ -191,23 +187,24 @@ GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pi | |||
| 191 | list_widget->setRootIsDecorated(false); | 187 | list_widget->setRootIsDecorated(false); |
| 192 | list_widget->setUniformRowHeights(true); | 188 | list_widget->setUniformRowHeights(true); |
| 193 | 189 | ||
| 194 | #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) | 190 | #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) |
| 195 | list_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); | 191 | list_widget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); |
| 196 | #else | 192 | #else |
| 197 | list_widget->header()->setResizeMode(QHeaderView::ResizeToContents); | 193 | list_widget->header()->setResizeMode(QHeaderView::ResizeToContents); |
| 198 | #endif | 194 | #endif |
| 199 | 195 | ||
| 200 | connect(list_widget->selectionModel(), SIGNAL(currentChanged(const QModelIndex&,const QModelIndex&)), | 196 | connect(list_widget->selectionModel(), |
| 201 | this, SLOT(SetCommandInfo(const QModelIndex&))); | 197 | SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, |
| 202 | connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)), | 198 | SLOT(SetCommandInfo(const QModelIndex&))); |
| 203 | this, SLOT(OnCommandDoubleClicked(const QModelIndex&))); | 199 | connect(list_widget, SIGNAL(doubleClicked(const QModelIndex&)), this, |
| 200 | SLOT(OnCommandDoubleClicked(const QModelIndex&))); | ||
| 204 | 201 | ||
| 205 | toggle_tracing = new QPushButton(tr("Start Tracing")); | 202 | toggle_tracing = new QPushButton(tr("Start Tracing")); |
| 206 | QPushButton* copy_all = new QPushButton(tr("Copy All")); | 203 | QPushButton* copy_all = new QPushButton(tr("Copy All")); |
| 207 | 204 | ||
| 208 | connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); | 205 | connect(toggle_tracing, SIGNAL(clicked()), this, SLOT(OnToggleTracing())); |
| 209 | connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), | 206 | connect(this, SIGNAL(TracingFinished(const Pica::DebugUtils::PicaTrace&)), model, |
| 210 | model, SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); | 207 | SLOT(OnPicaTraceFinished(const Pica::DebugUtils::PicaTrace&))); |
| 211 | 208 | ||
| 212 | connect(copy_all, SIGNAL(clicked()), this, SLOT(CopyAllToClipboard())); | 209 | connect(copy_all, SIGNAL(clicked()), this, SLOT(CopyAllToClipboard())); |
| 213 | 210 | ||