diff options
| author | 2018-01-11 19:21:20 -0700 | |
|---|---|---|
| committer | 2018-01-12 19:11:03 -0700 | |
| commit | ebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch) | |
| tree | d585685a1c0a34b903af1d086d62560bf56bb29f /src/citra_qt/debugger/graphics/graphics_breakpoints.cpp | |
| parent | config: Default CPU core to Unicorn. (diff) | |
| download | yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip | |
Massive removal of unused modules
Diffstat (limited to 'src/citra_qt/debugger/graphics/graphics_breakpoints.cpp')
| -rw-r--r-- | src/citra_qt/debugger/graphics/graphics_breakpoints.cpp | 213 |
1 files changed, 0 insertions, 213 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp deleted file mode 100644 index 030828ba8..000000000 --- a/src/citra_qt/debugger/graphics/graphics_breakpoints.cpp +++ /dev/null | |||
| @@ -1,213 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <QLabel> | ||
| 6 | #include <QMetaType> | ||
| 7 | #include <QPushButton> | ||
| 8 | #include <QTreeView> | ||
| 9 | #include <QVBoxLayout> | ||
| 10 | #include "citra_qt/debugger/graphics/graphics_breakpoints.h" | ||
| 11 | #include "citra_qt/debugger/graphics/graphics_breakpoints_p.h" | ||
| 12 | #include "common/assert.h" | ||
| 13 | |||
| 14 | BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) | ||
| 15 | : QAbstractListModel(parent), context_weak(debug_context), | ||
| 16 | at_breakpoint(debug_context->at_breakpoint), | ||
| 17 | active_breakpoint(debug_context->active_breakpoint) {} | ||
| 18 | |||
| 19 | int BreakPointModel::columnCount(const QModelIndex& parent) const { | ||
| 20 | return 1; | ||
| 21 | } | ||
| 22 | |||
| 23 | int BreakPointModel::rowCount(const QModelIndex& parent) const { | ||
| 24 | return static_cast<int>(Pica::DebugContext::Event::NumEvents); | ||
| 25 | } | ||
| 26 | |||
| 27 | QVariant BreakPointModel::data(const QModelIndex& index, int role) const { | ||
| 28 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | ||
| 29 | |||
| 30 | switch (role) { | ||
| 31 | case Qt::DisplayRole: { | ||
| 32 | if (index.column() == 0) { | ||
| 33 | static const std::map<Pica::DebugContext::Event, QString> map = { | ||
| 34 | {Pica::DebugContext::Event::PicaCommandLoaded, tr("Pica command loaded")}, | ||
| 35 | {Pica::DebugContext::Event::PicaCommandProcessed, tr("Pica command processed")}, | ||
| 36 | {Pica::DebugContext::Event::IncomingPrimitiveBatch, tr("Incoming primitive batch")}, | ||
| 37 | {Pica::DebugContext::Event::FinishedPrimitiveBatch, tr("Finished primitive batch")}, | ||
| 38 | {Pica::DebugContext::Event::VertexShaderInvocation, tr("Vertex shader invocation")}, | ||
| 39 | {Pica::DebugContext::Event::IncomingDisplayTransfer, | ||
| 40 | tr("Incoming display transfer")}, | ||
| 41 | {Pica::DebugContext::Event::GSPCommandProcessed, tr("GSP command processed")}, | ||
| 42 | {Pica::DebugContext::Event::BufferSwapped, tr("Buffers swapped")}, | ||
| 43 | }; | ||
| 44 | |||
| 45 | DEBUG_ASSERT(map.size() == static_cast<size_t>(Pica::DebugContext::Event::NumEvents)); | ||
| 46 | return (map.find(event) != map.end()) ? map.at(event) : QString(); | ||
| 47 | } | ||
| 48 | |||
| 49 | break; | ||
| 50 | } | ||
| 51 | |||
| 52 | case Qt::CheckStateRole: { | ||
| 53 | if (index.column() == 0) | ||
| 54 | return data(index, Role_IsEnabled).toBool() ? Qt::Checked : Qt::Unchecked; | ||
| 55 | break; | ||
| 56 | } | ||
| 57 | |||
| 58 | case Qt::BackgroundRole: { | ||
| 59 | if (at_breakpoint && index.row() == static_cast<int>(active_breakpoint)) { | ||
| 60 | return QBrush(QColor(0xE0, 0xE0, 0x10)); | ||
| 61 | } | ||
| 62 | break; | ||
| 63 | } | ||
| 64 | |||
| 65 | case Role_IsEnabled: { | ||
| 66 | auto context = context_weak.lock(); | ||
| 67 | return context && context->breakpoints[(int)event].enabled; | ||
| 68 | } | ||
| 69 | |||
| 70 | default: | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | return QVariant(); | ||
| 74 | } | ||
| 75 | |||
| 76 | Qt::ItemFlags BreakPointModel::flags(const QModelIndex& index) const { | ||
| 77 | if (!index.isValid()) | ||
| 78 | return 0; | ||
| 79 | |||
| 80 | Qt::ItemFlags flags = Qt::ItemIsEnabled; | ||
| 81 | if (index.column() == 0) | ||
| 82 | flags |= Qt::ItemIsUserCheckable; | ||
| 83 | return flags; | ||
| 84 | } | ||
| 85 | |||
| 86 | bool BreakPointModel::setData(const QModelIndex& index, const QVariant& value, int role) { | ||
| 87 | const auto event = static_cast<Pica::DebugContext::Event>(index.row()); | ||
| 88 | |||
| 89 | switch (role) { | ||
| 90 | case Qt::CheckStateRole: { | ||
| 91 | if (index.column() != 0) | ||
| 92 | return false; | ||
| 93 | |||
| 94 | auto context = context_weak.lock(); | ||
| 95 | if (!context) | ||
| 96 | return false; | ||
| 97 | |||
| 98 | context->breakpoints[(int)event].enabled = value == Qt::Checked; | ||
| 99 | QModelIndex changed_index = createIndex(index.row(), 0); | ||
| 100 | emit dataChanged(changed_index, changed_index); | ||
| 101 | return true; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | return false; | ||
| 106 | } | ||
| 107 | |||
| 108 | void BreakPointModel::OnBreakPointHit(Pica::DebugContext::Event event) { | ||
| 109 | auto context = context_weak.lock(); | ||
| 110 | if (!context) | ||
| 111 | return; | ||
| 112 | |||
| 113 | active_breakpoint = context->active_breakpoint; | ||
| 114 | at_breakpoint = context->at_breakpoint; | ||
| 115 | emit dataChanged(createIndex(static_cast<int>(event), 0), | ||
| 116 | createIndex(static_cast<int>(event), 0)); | ||
| 117 | } | ||
| 118 | |||
| 119 | void BreakPointModel::OnResumed() { | ||
| 120 | auto context = context_weak.lock(); | ||
| 121 | if (!context) | ||
| 122 | return; | ||
| 123 | |||
| 124 | at_breakpoint = context->at_breakpoint; | ||
| 125 | emit dataChanged(createIndex(static_cast<int>(active_breakpoint), 0), | ||
| 126 | createIndex(static_cast<int>(active_breakpoint), 0)); | ||
| 127 | active_breakpoint = context->active_breakpoint; | ||
| 128 | } | ||
| 129 | |||
| 130 | GraphicsBreakPointsWidget::GraphicsBreakPointsWidget( | ||
| 131 | std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) | ||
| 132 | : QDockWidget(tr("Pica Breakpoints"), parent), | ||
| 133 | Pica::DebugContext::BreakPointObserver(debug_context) { | ||
| 134 | setObjectName("PicaBreakPointsWidget"); | ||
| 135 | |||
| 136 | status_text = new QLabel(tr("Emulation running")); | ||
| 137 | resume_button = new QPushButton(tr("Resume")); | ||
| 138 | resume_button->setEnabled(false); | ||
| 139 | |||
| 140 | breakpoint_model = new BreakPointModel(debug_context, this); | ||
| 141 | breakpoint_list = new QTreeView; | ||
| 142 | breakpoint_list->setRootIsDecorated(false); | ||
| 143 | breakpoint_list->setHeaderHidden(true); | ||
| 144 | breakpoint_list->setModel(breakpoint_model); | ||
| 145 | |||
| 146 | qRegisterMetaType<Pica::DebugContext::Event>("Pica::DebugContext::Event"); | ||
| 147 | |||
| 148 | connect(breakpoint_list, SIGNAL(doubleClicked(const QModelIndex&)), this, | ||
| 149 | SLOT(OnItemDoubleClicked(const QModelIndex&))); | ||
| 150 | |||
| 151 | connect(resume_button, SIGNAL(clicked()), this, SLOT(OnResumeRequested())); | ||
| 152 | |||
| 153 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), this, | ||
| 154 | SLOT(OnBreakPointHit(Pica::DebugContext::Event, void*)), Qt::BlockingQueuedConnection); | ||
| 155 | connect(this, SIGNAL(Resumed()), this, SLOT(OnResumed())); | ||
| 156 | |||
| 157 | connect(this, SIGNAL(BreakPointHit(Pica::DebugContext::Event, void*)), breakpoint_model, | ||
| 158 | SLOT(OnBreakPointHit(Pica::DebugContext::Event)), Qt::BlockingQueuedConnection); | ||
| 159 | connect(this, SIGNAL(Resumed()), breakpoint_model, SLOT(OnResumed())); | ||
| 160 | |||
| 161 | connect(this, SIGNAL(BreakPointsChanged(const QModelIndex&, const QModelIndex&)), | ||
| 162 | breakpoint_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&))); | ||
| 163 | |||
| 164 | QWidget* main_widget = new QWidget; | ||
| 165 | auto main_layout = new QVBoxLayout; | ||
| 166 | { | ||
| 167 | auto sub_layout = new QHBoxLayout; | ||
| 168 | sub_layout->addWidget(status_text); | ||
| 169 | sub_layout->addWidget(resume_button); | ||
| 170 | main_layout->addLayout(sub_layout); | ||
| 171 | } | ||
| 172 | main_layout->addWidget(breakpoint_list); | ||
| 173 | main_widget->setLayout(main_layout); | ||
| 174 | |||
| 175 | setWidget(main_widget); | ||
| 176 | } | ||
| 177 | |||
| 178 | void GraphicsBreakPointsWidget::OnPicaBreakPointHit(Event event, void* data) { | ||
| 179 | // Process in GUI thread | ||
| 180 | emit BreakPointHit(event, data); | ||
| 181 | } | ||
| 182 | |||
| 183 | void GraphicsBreakPointsWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) { | ||
| 184 | status_text->setText(tr("Emulation halted at breakpoint")); | ||
| 185 | resume_button->setEnabled(true); | ||
| 186 | } | ||
| 187 | |||
| 188 | void GraphicsBreakPointsWidget::OnPicaResume() { | ||
| 189 | // Process in GUI thread | ||
| 190 | emit Resumed(); | ||
| 191 | } | ||
| 192 | |||
| 193 | void GraphicsBreakPointsWidget::OnResumed() { | ||
| 194 | status_text->setText(tr("Emulation running")); | ||
| 195 | resume_button->setEnabled(false); | ||
| 196 | } | ||
| 197 | |||
| 198 | void GraphicsBreakPointsWidget::OnResumeRequested() { | ||
| 199 | if (auto context = context_weak.lock()) | ||
| 200 | context->Resume(); | ||
| 201 | } | ||
| 202 | |||
| 203 | void GraphicsBreakPointsWidget::OnItemDoubleClicked(const QModelIndex& index) { | ||
| 204 | if (!index.isValid()) | ||
| 205 | return; | ||
| 206 | |||
| 207 | QModelIndex check_index = breakpoint_list->model()->index(index.row(), 0); | ||
| 208 | QVariant enabled = breakpoint_list->model()->data(check_index, Qt::CheckStateRole); | ||
| 209 | QVariant new_state = Qt::Unchecked; | ||
| 210 | if (enabled == Qt::Unchecked) | ||
| 211 | new_state = Qt::Checked; | ||
| 212 | breakpoint_list->model()->setData(check_index, new_state, Qt::CheckStateRole); | ||
| 213 | } | ||