citra-emu
/
citra
Archived
1
0
Fork 0

android: minor refactor disk shadercache

This commit is contained in:
SachinVin 2023-05-01 10:03:58 +05:30
parent 238a574645
commit ccb2a7cbea
3 changed files with 24 additions and 32 deletions

View File

@ -2,7 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
package org.citra.citra_emu.disk_shader_cache;
package org.citra.citra_emu.utils;
import android.app.Activity;
import android.app.Dialog;

View File

@ -21,8 +21,6 @@ static JavaVM* s_java_vm;
static jclass s_core_error_class;
static jclass s_savestate_info_class;
static jclass s_disk_cache_progress_class;
static jclass s_load_callback_stage_class;
static jclass s_native_library_class;
static jmethodID s_on_core_error;
@ -34,7 +32,6 @@ static jmethodID s_landscape_screen_layout;
static jmethodID s_exit_emulation_activity;
static jmethodID s_request_camera_permission;
static jmethodID s_request_mic_permission;
static jmethodID s_disk_cache_load_progress;
static jclass s_cheat_class;
static jfieldID s_cheat_pointer;
@ -44,6 +41,8 @@ static jfieldID s_cheat_engine_pointer;
static jfieldID s_game_info_pointer;
static jclass s_disk_cache_progress_class;
static jmethodID s_disk_cache_load_progress;
static std::unordered_map<VideoCore::LoadCallbackStage, jobject> s_java_load_callback_stages;
namespace IDCache {
@ -75,14 +74,6 @@ jclass GetSavestateInfoClass() {
return s_savestate_info_class;
}
jclass GetDiskCacheProgressClass() {
return s_disk_cache_progress_class;
}
jclass GetDiskCacheLoadCallbackStageClass() {
return s_load_callback_stage_class;
}
jclass GetNativeLibraryClass() {
return s_native_library_class;
}
@ -123,10 +114,6 @@ jmethodID GetRequestMicPermission() {
return s_request_mic_permission;
}
jmethodID GetDiskCacheLoadProgress() {
return s_disk_cache_load_progress;
}
jclass GetCheatClass() {
return s_cheat_class;
}
@ -147,6 +134,14 @@ jfieldID GetGameInfoPointer() {
return s_game_info_pointer;
}
jclass GetDiskCacheProgressClass() {
return s_disk_cache_progress_class;
}
jmethodID GetDiskCacheLoadProgress() {
return s_disk_cache_load_progress;
}
jobject GetJavaLoadCallbackStage(VideoCore::LoadCallbackStage stage) {
const auto it = s_java_load_callback_stages.find(stage);
ASSERT_MSG(it != s_java_load_callback_stages.end(), "Invalid LoadCallbackStage: {}", stage);
@ -178,10 +173,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
env->NewGlobalRef(env->FindClass("org/citra/citra_emu/NativeLibrary$SavestateInfo")));
s_core_error_class = reinterpret_cast<jclass>(
env->NewGlobalRef(env->FindClass("org/citra/citra_emu/NativeLibrary$CoreError")));
s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
env->FindClass("org/citra/citra_emu/disk_shader_cache/DiskShaderCacheProgress")));
s_load_callback_stage_class = reinterpret_cast<jclass>(env->NewGlobalRef(env->FindClass(
"org/citra/citra_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage")));
// Initialize NativeLibrary
const jclass native_library_class = env->FindClass("org/citra/citra_emu/NativeLibrary");
@ -205,9 +196,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
env->GetStaticMethodID(s_native_library_class, "RequestCameraPermission", "()Z");
s_request_mic_permission =
env->GetStaticMethodID(s_native_library_class, "RequestMicPermission", "()Z");
s_disk_cache_load_progress = env->GetStaticMethodID(
s_disk_cache_progress_class, "loadProgress",
"(Lorg/citra/citra_emu/disk_shader_cache/DiskShaderCacheProgress$LoadCallbackStage;II)V");
env->DeleteLocalRef(native_library_class);
// Initialize Cheat
@ -228,16 +216,22 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
s_game_info_pointer = env->GetFieldID(game_info_class, "mPointer", "J");
env->DeleteLocalRef(game_info_class);
// Initialize Disk Shader Cache Progress Dialog
s_disk_cache_progress_class = reinterpret_cast<jclass>(env->NewGlobalRef(
env->FindClass("org/citra/citra_emu/utils/DiskShaderCacheProgress")));
jclass load_callback_stage_class = env->FindClass(
"org/citra/citra_emu/utils/DiskShaderCacheProgress$LoadCallbackStage");
s_disk_cache_load_progress = env->GetStaticMethodID(
s_disk_cache_progress_class, "loadProgress",
"(Lorg/citra/citra_emu/utils/DiskShaderCacheProgress$LoadCallbackStage;II)V");
// Initialize LoadCallbackStage map
const auto to_java_load_callback_stage = [env](const std::string& stage) {
jclass load_callback_stage_class = IDCache::GetDiskCacheLoadCallbackStageClass();
const auto to_java_load_callback_stage = [env, load_callback_stage_class](const std::string& stage) {
return env->NewGlobalRef(env->GetStaticObjectField(
load_callback_stage_class,
env->GetStaticFieldID(load_callback_stage_class, stage.c_str(),
"Lorg/citra/citra_emu/disk_shader_cache/"
"Lorg/citra/citra_emu/utils/"
"DiskShaderCacheProgress$LoadCallbackStage;")));
};
s_java_load_callback_stages.emplace(VideoCore::LoadCallbackStage::Prepare,
to_java_load_callback_stage("Prepare"));
s_java_load_callback_stages.emplace(VideoCore::LoadCallbackStage::Decompile,
@ -246,7 +240,7 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
to_java_load_callback_stage("Build"));
s_java_load_callback_stages.emplace(VideoCore::LoadCallbackStage::Complete,
to_java_load_callback_stage("Complete"));
env->DeleteLocalRef(load_callback_stage_class);
MiiSelector::InitJNI(env);
SoftwareKeyboard::InitJNI(env);
Camera::StillImage::InitJNI(env);
@ -264,7 +258,6 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) {
env->DeleteGlobalRef(s_savestate_info_class);
env->DeleteGlobalRef(s_core_error_class);
env->DeleteGlobalRef(s_disk_cache_progress_class);
env->DeleteGlobalRef(s_load_callback_stage_class);
env->DeleteGlobalRef(s_native_library_class);
env->DeleteGlobalRef(s_cheat_class);

View File

@ -15,8 +15,6 @@ JNIEnv* GetEnvForThread();
jclass GetCoreErrorClass();
jclass GetSavestateInfoClass();
jclass GetDiskCacheProgressClass();
jclass GetDiskCacheLoadCallbackStageClass();
jclass GetNativeLibraryClass();
jmethodID GetOnCoreError();
@ -28,7 +26,6 @@ jmethodID GetLandscapeScreenLayout();
jmethodID GetExitEmulationActivity();
jmethodID GetRequestCameraPermission();
jmethodID GetRequestMicPermission();
jmethodID GetDiskCacheLoadProgress();
jclass GetCheatClass();
jfieldID GetCheatPointer();
@ -38,6 +35,8 @@ jfieldID GetCheatEnginePointer();
jfieldID GetGameInfoPointer();
jclass GetDiskCacheProgressClass();
jmethodID GetDiskCacheLoadProgress();
jobject GetJavaLoadCallbackStage(VideoCore::LoadCallbackStage stage);
} // namespace IDCache