Add cmake option to enable microprofile (#179)

Backported from dd9c743041.

Co-authored-by: PabloMK7 <hackyglitch2@gmail.com>

Co-authored-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/179
Co-authored-by: Gamer64 <gamer64@eden-emu.dev>
Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
This commit is contained in:
Gamer64 2025-08-02 17:22:38 +02:00 committed by crueter
parent b32a667d6f
commit 1f34d836b4
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
17 changed files with 64 additions and 11 deletions

View file

@ -1,6 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2015 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#if MICROPROFILE_ENABLED
#include <QAction>
#include <QLayout>
#include <QMouseEvent>
@ -14,7 +19,7 @@
// Include the implementation of the UI in this file. This isn't in microprofile.cpp because the
// non-Qt frontends don't need it (and don't implement the UI drawing hooks either).
#if MICROPROFILE_ENABLED
#define MICROPROFILEUI_IMPL 1
#include "common/microprofileui.h"
@ -43,8 +48,6 @@ private:
qreal x_scale = 1.0, y_scale = 1.0;
};
#endif
MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Dialog) {
setObjectName(QStringLiteral("MicroProfile"));
setWindowTitle(tr("&MicroProfile"));
@ -52,8 +55,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di
// Enable the maximize button
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
#if MICROPROFILE_ENABLED
MicroProfileWidget* widget = new MicroProfileWidget(this);
QLayout* layout = new QVBoxLayout(this);
@ -66,7 +67,6 @@ MicroProfileDialog::MicroProfileDialog(QWidget* parent) : QWidget(parent, Qt::Di
setFocusProxy(widget);
widget->setFocusPolicy(Qt::StrongFocus);
widget->setFocus();
#endif
}
QAction* MicroProfileDialog::toggleViewAction() {
@ -94,8 +94,6 @@ void MicroProfileDialog::hideEvent(QHideEvent* ev) {
QWidget::hideEvent(ev);
}
#if MICROPROFILE_ENABLED
/// There's no way to pass a user pointer to MicroProfile, so this variable is used to make the
/// QPainter available inside the drawing callbacks.
static QPainter* mp_painter = nullptr;

View file

@ -1,8 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2015 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#if MICROPROFILE_ENABLED
#include <QWidget>
class QAction;
@ -25,3 +30,4 @@ protected:
private:
QAction* toggle_view_action = nullptr;
};
#endif

View file

@ -1348,6 +1348,11 @@ void GMainWindow::InitializeDebugWidgets() {
microProfileDialog = new MicroProfileDialog(this);
microProfileDialog->hide();
debug_menu->addAction(microProfileDialog->toggleViewAction());
#else
auto micro_profile_stub = new QAction(tr("MicroProfile (unavailable)"), this);
micro_profile_stub->setEnabled(false);
micro_profile_stub->setChecked(false);
debug_menu->addAction(micro_profile_stub);
#endif
waitTreeWidget = new WaitTreeWidget(*system, this);
@ -5630,10 +5635,13 @@ int main(int argc, char* argv[]) {
#endif
Common::DetachedTasks detached_tasks;
#if MICROPROFILE_ENABLED
MicroProfileOnThreadCreate("Frontend");
SCOPE_EXIT {
MicroProfileShutdown();
};
#endif
Common::ConfigureNvidiaEnvironmentFlags();

View file

@ -43,7 +43,9 @@ class GameList;
class GImageInfo;
class GRenderWindow;
class LoadingScreen;
#if MICROPROFILE_ENABLED
class MicroProfileDialog;
#endif
class OverlayDialog;
class ProfilerWidget;
class ControllerDialog;
@ -565,7 +567,9 @@ private:
// Debugger panes
ProfilerWidget* profilerWidget;
#if MICROPROFILE_ENABLED
MicroProfileDialog* microProfileDialog;
#endif
WaitTreeWidget* waitTreeWidget;
ControllerDialog* controller_dialog;