mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-29 15:56:37 +02:00
Remove the AndroidGraphicsContext middle-level class
This commit is contained in:
@@ -913,7 +913,6 @@ if(ANDROID)
|
||||
android/jni/AndroidJavaGLContext.h
|
||||
android/jni/AndroidVulkanContext.cpp
|
||||
android/jni/AndroidVulkanContext.h
|
||||
android/jni/AndroidGraphicsContext.h
|
||||
android/jni/AndroidAudio.cpp
|
||||
android/jni/AndroidAudio.h
|
||||
android/jni/OpenSLContext.cpp
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
virtual bool InitFromRenderThread(std::string *errorMessage) { return true; }
|
||||
virtual void ShutdownFromRenderThread() {}
|
||||
|
||||
virtual void BeginShutdown() {} // This is currently only used on Android.
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
// Used during window resize. Must be called from the window thread,
|
||||
|
||||
@@ -728,14 +728,6 @@
|
||||
<ClCompile Include="XinputDevice.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\android\jni\AndroidGraphicsContext.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\AndroidJavaGLContext.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
|
||||
@@ -412,9 +412,6 @@
|
||||
<ClInclude Include="GPU\WindowsVulkanContext.h">
|
||||
<Filter>Windows\System</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\AndroidGraphicsContext.h">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\android\jni\AndroidJavaGLContext.h">
|
||||
<Filter>Other Platforms\Android</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -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() {}
|
||||
};
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user