Remove the AndroidGraphicsContext middle-level class

This commit is contained in:
Henrik Rydgård committed 2026-07-26 10:21:59 +02:00
1 parent a7ee0a7280
commit c2c0fa3634
8 files changed
+17 -52

No files matched your search

-25
View File
@@ -1,25 +0,0 @@
#pragma once
#include <android/native_window_jni.h>
#include "Common/GPU/thin3d.h"
#include "Common/GraphicsContext.h"
enum {
ANDROID_VERSION_GINGERBREAD = 9,
ANDROID_VERSION_ICS = 14,
ANDROID_VERSION_JELLYBEAN = 16,
ANDROID_VERSION_KITKAT = 19,
ANDROID_VERSION_LOLLIPOP = 21,
ANDROID_VERSION_MARSHMALLOW = 23,
ANDROID_VERSION_NOUGAT = 24,
ANDROID_VERSION_NOUGAT_1 = 25,
};
class AndroidGraphicsContext : public GraphicsContext {
public:
// This is different than the base class function since on
// Android (EGL, Vulkan) we do have all this info on the render thread.
virtual bool Init(ANativeWindow *wnd) { return true; }
virtual void BeginAndroidShutdown() {}
};
+3 -3
View File
@@ -1,10 +1,10 @@
#pragma once
#include "AndroidGraphicsContext.h"
#include "Common/GraphicsContext.h"
#include "Common/GPU/OpenGL/GLRenderManager.h"
#include "Common/GPU/thin3d_create.h"
class AndroidJavaEGLGraphicsContext : public AndroidGraphicsContext {
class AndroidJavaEGLGraphicsContext : public GraphicsContext {
public:
AndroidJavaEGLGraphicsContext();
~AndroidJavaEGLGraphicsContext() override { delete draw_; }
@@ -30,7 +30,7 @@ public:
return renderManager_->ThreadFrame(waitIfEmpty);
}
void BeginAndroidShutdown() override {
void BeginShutdown() override {
renderManager_->SetSkipGLCalls();
}
+6 -3
View File
@@ -1,17 +1,20 @@
#pragma once
#include "AndroidGraphicsContext.h"
#include "Common/GraphicsContext.h"
#include "Common/GPU/thin3d.h"
#include <android/native_window_jni.h>
class VulkanContext;
class AndroidVulkanContext : public AndroidGraphicsContext {
class AndroidVulkanContext : public GraphicsContext {
public:
AndroidVulkanContext();
~AndroidVulkanContext();
bool InitAPI();
bool Init(ANativeWindow *wnd) override;
bool Init(ANativeWindow *wnd);
void ShutdownFromRenderThread() override; // Inverses InitFromRenderThread.
void Shutdown() override;
+7 -9
View File
@@ -91,7 +91,6 @@ struct JNIEnv {};
#include "Common/StringUtils.h"
#include "Common/TimeUtil.h"
#include "AndroidGraphicsContext.h"
#include "AndroidVulkanContext.h"
#include "AndroidJavaGLContext.h"
@@ -190,7 +189,7 @@ static std::string g_installerName;
static std::map<SystemPermission, PermissionStatus> permissions;
static AndroidGraphicsContext *graphicsContext;
static GraphicsContext *graphicsContext;
#define MessageBox(a, b, c, d) __android_log_print(ANDROID_LOG_INFO, APP_NAME, "%s %s", (b), (c));
@@ -963,8 +962,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) {
// Now we know that more frames won't be coming in.
INFO_LOG(Log::System, "BeginAndroidShutdown");
graphicsContext->BeginAndroidShutdown(); // Makes sure we don't actually perform draws.
INFO_LOG(Log::System, "BeginShutdown");
graphicsContext->BeginShutdown(); // Makes sure we don't actually perform draws.
// Now, it could be that we had some frames queued up. Get through them.
// We're on the render thread, so this is synchronous.
@@ -1039,7 +1038,7 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
INFO_LOG(Log::G3D, "NativeApp.displayInit() restoring");
EmuThreadStop("displayInit");
graphicsContext->BeginAndroidShutdown();
graphicsContext->BeginShutdown();
INFO_LOG(Log::G3D, "BeginAndroidShutdown. Looping until emu thread done...");
// Skipping GL calls here because the old context is lost.
graphicsContext->ThreadFrameUntilCondition([]() -> bool {
@@ -1053,7 +1052,6 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
INFO_LOG(Log::G3D, "Shut down both threads. Now let's bring it up again!");
std::string errorMessage;
if (!graphicsContext->InitFromRenderThread(&errorMessage)) {
System_Toast(("Graphics initialization failed: Quitting: " + errorMessage).c_str());
return false;
@@ -1699,7 +1697,7 @@ static void ProcessFrameCommands() {
std::thread g_renderLoopThread;
static void VulkanEmuThread(ANativeWindow *wnd);
static void VulkanEmuThread(ANativeWindow *wnd, AndroidVulkanContext *graphicsContext);
// This runs in Vulkan mode only.
// This handles the entire lifecycle of the Vulkan context, init and exit.
@@ -1727,7 +1725,7 @@ extern "C" jboolean JNICALL Java_org_ppsspp_ppsspp_PpssppActivity_runVulkanRende
return false;
}
g_renderLoopThread = std::thread(VulkanEmuThread, wnd);
g_renderLoopThread = std::thread(VulkanEmuThread, wnd, (AndroidVulkanContext *)graphicsContext);
return true;
}
@@ -1744,7 +1742,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_PpssppActivity_requestExitVulkanR
// TODO: Merge with the Win32 EmuThread and so on, and the Java EmuThread?
// This function must release the window reference.
static void VulkanEmuThread(ANativeWindow *wnd) {
static void VulkanEmuThread(ANativeWindow *wnd, AndroidVulkanContext *graphicsContext) {
SetCurrentThreadName("EmuThread");
AndroidJNIThreadContext ctx;