diff options
| author | 2016-09-18 09:38:01 +0900 | |
|---|---|---|
| committer | 2016-09-18 09:38:01 +0900 | |
| commit | dc8479928c5aee4c6ad6fe4f59006fb604cee701 (patch) | |
| tree | 569a7f13128450bbab973236615587ff00bced5f /src/citra_qt/debugger/graphics_breakpoints.cpp | |
| parent | Travis: Import Dolphin’s clang-format hook. (diff) | |
| download | yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.gz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.tar.xz yuzu-dc8479928c5aee4c6ad6fe4f59006fb604cee701.zip | |
Sources: Run clang-format on everything.
Diffstat (limited to '')
| -rw-r--r-- | src/citra_qt/debugger/graphics_breakpoints.cpp | 104 |
1 files changed, 39 insertions, 65 deletions
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp index fe66918a8..953840e7f 100644 --- a/src/citra_qt/debugger/graphics_breakpoints.cpp +++ b/src/citra_qt/debugger/graphics_breakpoints.cpp | |||
| @@ -16,39 +16,33 @@ | |||
| 16 | BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) | 16 | BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) |
| 17 | : QAbstractListModel(parent), context_weak(debug_context), | 17 | : QAbstractListModel(parent), context_weak(debug_context), |
| 18 | at_breakpoint(debug_context->at_breakpoint), | 18 | at_breakpoint(debug_context->at_breakpoint), |
| 19 | active_breakpoint(debug_context->active_breakpoint) | 19 | active_breakpoint(debug_context->active_breakpoint) { |
| 20 | { | ||
| 21 | |||
| 22 | } | 20 | } |
| 23 | 21 | ||
| 24 | int BreakPointModel::columnCount(const QModelIndex& parent) const | 22 | int BreakPointModel::columnCount(const QModelIndex& parent) const { |
| 25 | { | ||
| 26 | return 1; | 23 | return 1; |
| 27 | } | 24 | } |
| 28 | 25 | ||
| 29 | int BreakPointModel::rowCount(const QModelIndex& parent) const | 26 | int BreakPointModel::rowCount(const QModelIndex& parent) const { |
| 30 | { | ||
| 31 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); | 27 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); |
| 32 | } | 28 | } |
| 33 | 29 | ||
| 34 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const | 30 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const { |
| 35 | { | ||
| 36 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | 31 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); |
| 37 | 32 | ||
| 38 | switch (role) { | 33 | switch (role) { |
| 39 | case Qt::DisplayRole: | 34 | case Qt::DisplayRole: { |
| 40 | { | ||
| 41 | if (index.column() == 0) { | 35 | if (index.column() == 0) { |
| 42 | static const std::map<Pica::DebugContext::Event, QString> map = { | 36 | static const std::map<Pica::DebugContext::Event, QString> map = { |
| 43 | { Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded") }, | 37 | {Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded")}, |
| 44 | { Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed") }, | 38 | {Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed")}, |
| 45 | { Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch") }, | 39 | {Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")}, |
| 46 | { Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch") }, | 40 | {Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")}, |
| 47 | { Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation") }, | 41 | {Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation")}, |
| 48 | { Pica::DebugContext::Event::IncomingDisplayTransfer, tr("Incoming display transfer") }, | 42 | {Pica::DebugContext::Event::IncomingDisplayTransfer, |
| 49 | { Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed") }, | 43 | tr("Incoming display transfer")}, |
| 50 | { Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped") } | 44 | {Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed")}, |
| 51 | }; | 45 | {Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped")}}; |
| 52 | 46 | ||
| 53 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); | 47 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); |
| 54 | return (map.find(event) != map.end()) ? map.at(event) : QString(); | 48 | return (map.find(event) != map.end()) ? map.at(event) : QString(); |
| @@ -57,23 +51,20 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const | |||
| 57 | break; | 51 | break; |
| 58 | } | 52 | } |
| 59 | 53 | ||
| 60 | case Qt::CheckStateRole: | 54 | case Qt::CheckStateRole: { |
| 61 | { | ||
| 62 | if (index.column() == 0) | 55 | if (index.column() == 0) |
| 63 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; | 56 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; |
| 64 | break; | 57 | break; |
| 65 | } | 58 | } |
| 66 | 59 | ||
| 67 | case Qt::BackgroundRole: | 60 | case Qt::BackgroundRole: { |
| 68 | { | ||
| 69 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { | 61 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { |
| 70 | return QBrush(QColor(0xE0, 0xE0, 0x10)); | 62 | return QBrush(QColor(0xE0, 0xE0, 0x10)); |
| 71 | } | 63 | } |
| 72 | break; | 64 | break; |
| 73 | } | 65 | } |
| 74 | 66 | ||
| 75 | case Role_IsEnabled: | 67 | case Role_IsEnabled: { |
| 76 | { | ||
| 77 | auto context = context_weak.lock(); | 68 | auto context = context_weak.lock(); |
| 78 | return context && context->breakpoints[(int)event].enabled; | 69 | return context && context->breakpoints[(int)event].enabled; |
| 79 | } | 70 | } |
| @@ -84,8 +75,7 @@ QVariant BreakPointModel::data(const QModelIndex& index, int role) const | |||
| 84 | return QVariant(); | 75 | return QVariant(); |
| 85 | } | 76 | } |
| 86 | 77 | ||
| 87 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const | 78 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex& index) const { |
| 88 | { | ||
| 89 | if (!index.isValid()) | 79 | if (!index.isValid()) |
| 90 | return 0; | 80 | return 0; |
| 91 | 81 | ||
| @@ -95,14 +85,11 @@ Qt::ItemFlags BreakPointModel::flags(const QModelIndex &index) const | |||
| 95 | return flags; | 85 | return flags; |
| 96 | } | 86 | } |
| 97 | 87 | ||
| 98 | 88 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) { | |
| 99 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) | ||
| 100 | { | ||
| 101 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | 89 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); |
| 102 | 90 | ||
| 103 | switch (role) { | 91 | switch (role) { |
| 104 | case Qt::CheckStateRole: | 92 | case Qt::CheckStateRole: { |
| 105 | { | ||
| 106 | if (index.column() != 0) | 93 | if (index.column() != 0) |
| 107 | return false; | 94 | return false; |
| 108 | 95 | ||
| @@ -120,9 +107,7 @@ bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, i | |||
| 120 | return false; | 107 | return false; |
| 121 | } | 108 | } |
| 122 | 109 | ||
| 123 | 110 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) { | |
| 124 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) | ||
| 125 | { | ||
| 126 | auto context = context_weak.lock(); | 111 | auto context = context_weak.lock(); |
| 127 | if (!context) | 112 | if (!context) |
| 128 | return; | 113 | return; |
| @@ -133,8 +118,7 @@ void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) | |||
| 133 | createIndex(static_cast<int>(event), 0)); | 118 | createIndex(static_cast<int>(event), 0)); |
| 134 | } | 119 | } |
| 135 | 120 | ||
| 136 | void BreakPointModel::OnResumed() | 121 | void BreakPointModel::OnResumed() { |
| 137 | { | ||
| 138 | auto context = context_weak.lock(); | 122 | auto context = context_weak.lock(); |
| 139 | if (!context) | 123 | if (!context) |
| 140 | return; | 124 | return; |
| @@ -145,12 +129,10 @@ void BreakPointModel::OnResumed() | |||
| 145 | active_breakpoint = context->active_breakpoint; | 129 | active_breakpoint = context->active_breakpoint; |
| 146 | } | 130 | } |
| 147 | 131 | ||
| 148 | 132 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget( | |
| 149 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::DebugContext> debug_context, | 133 | std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) |
| 150 | QWidget* parent) | ||
| 151 | : QDockWidget(tr("Pica Breakpoints"), parent), | 134 | : QDockWidget(tr("Pica Breakpoints"), parent), |
| 152 | Pica::DebugContext::BreakPointObserver(debug_context) | 135 | Pica::DebugContext::BreakPointObserver(debug_context) { |
| 153 | { | ||
| 154 | setObjectName("PicaBreakPointsWidget"); | 136 | setObjectName("PicaBreakPointsWidget"); |
| 155 | 137 | ||
| 156 | status_text = new QLabel(tr("Emulation running")); | 138 | status_text = new QLabel(tr("Emulation running")); |
| @@ -165,23 +147,21 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug | |||
| 165 | 147 | ||
| 166 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); | 148 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); |
| 167 | 149 | ||
| 168 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), | 150 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), this, |
| 169 | this, SLOT(OnItemDoubleClicked(const QModelIndex&))); | 151 | SLOT(OnItemDoubleClicked(const QModelIndex&))); |
| 170 | 152 | ||
| 171 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); | 153 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); |
| 172 | 154 | ||
| 173 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), | 155 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), this, |
| 174 | this, SLOT(OnBreakPointHit(Pica::DebugContext::Event,void*)), | 156 | SLOT(OnBreakPointHit(Pica::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); |
| 175 | Qt::BlockingQueuedConnection); | ||
| 176 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); | 157 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); |
| 177 | 158 | ||
| 178 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event,void*)), | 159 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), breakpoint_model, |
| 179 | breakpoint_model, SLOT(OnBreakPointHit(Pica::DebugContext::Event)), | 160 | SLOT(OnBreakPointHit(Pica::DebugContext::Event)), Qt::BlockingQueuedConnection); |
| 180 | Qt::BlockingQueuedConnection); | ||
| 181 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); | 161 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); |
| 182 | 162 | ||
| 183 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&,const QModelIndex&)), | 163 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&, const QModelIndex&)), |
| 184 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&))); | 164 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); |
| 185 | 165 | ||
| 186 | QWidget* main_widget = new QWidget; | 166 | QWidget* main_widget = new QWidget; |
| 187 | auto main_layout = new QVBoxLayout; | 167 | auto main_layout = new QVBoxLayout; |
| @@ -197,38 +177,32 @@ GraphicsBreakPointsWidget::GraphicsBreakPointsWidget(std::shared_ptr<Pica::Debug | |||
| 197 | setWidget(main_widget); | 177 | setWidget(main_widget); |
| 198 | } | 178 | } |
| 199 | 179 | ||
| 200 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) | 180 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) { |
| 201 | { | ||
| 202 | // Process in GUI thread | 181 | // Process in GUI thread |
| 203 | emit BreakPointHit(event, data); | 182 | emit BreakPointHit(event, data); |
| 204 | } | 183 | } |
| 205 | 184 | ||
| 206 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) | 185 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { |
| 207 | { | ||
| 208 | status_text->setText(tr("Emulation halted at breakpoint")); | 186 | status_text->setText(tr("Emulation halted at breakpoint")); |
| 209 | resume_button->setEnabled(true); | 187 | resume_button->setEnabled(true); |
| 210 | } | 188 | } |
| 211 | 189 | ||
| 212 | void GraphicsBreakPointsWidget::OnPicaResume() | 190 | void GraphicsBreakPointsWidget::OnPicaResume() { |
| 213 | { | ||
| 214 | // Process in GUI thread | 191 | // Process in GUI thread |
| 215 | emit Resumed(); | 192 | emit Resumed(); |
| 216 | } | 193 | } |
| 217 | 194 | ||
| 218 | void GraphicsBreakPointsWidget::OnResumed() | 195 | void GraphicsBreakPointsWidget::OnResumed() { |
| 219 | { | ||
| 220 | status_text->setText(tr("Emulation running")); | 196 | status_text->setText(tr("Emulation running")); |
| 221 | resume_button->setEnabled(false); | 197 | resume_button->setEnabled(false); |
| 222 | } | 198 | } |
| 223 | 199 | ||
| 224 | void GraphicsBreakPointsWidget::OnResumeRequested() | 200 | void GraphicsBreakPointsWidget::OnResumeRequested() { |
| 225 | { | ||
| 226 | if (auto context = context_weak.lock()) | 201 | if (auto context = context_weak.lock()) |
| 227 | context->Resume(); | 202 | context->Resume(); |
| 228 | } | 203 | } |
| 229 | 204 | ||
| 230 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) | 205 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) { |
| 231 | { | ||
| 232 | if (!index.isValid()) | 206 | if (!index.isValid()) |
| 233 | return; | 207 | return; |
| 234 | 208 | ||