summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2021-05-20 16:34:30 +0200
committerJosJuice <josjuice@gmail.com>2021-05-20 16:43:03 +0200
commitb7ba126db0d796348ba884333b341e50252433ad (patch)
treedec3ad31f3a48b269232ff98f3b1a5521fddc3c7 /Source/Android/app/src/main/java
parentece32247159c1a78d44a36779d121a8580d06289 (diff)
Android: Use JNI for getting post-processsing shaders
The Java implementation of getting the list of post-processing shaders only looked in the Sys folder and not the User folder. This could be fixed in the Java implementation, but it's simpler to just call the C++ implementation instead.
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.java15
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java55
2 files changed, 26 insertions, 44 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.java
new file mode 100644
index 0000000000..4d7ccd5032
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/PostProcessing.java
@@ -0,0 +1,15 @@
+package org.dolphinemu.dolphinemu.features.settings.model;
+
+import androidx.annotation.NonNull;
+
+public class PostProcessing
+{
+ @NonNull
+ public static native String[] getShaderList();
+
+ @NonNull
+ public static native String[] getAnaglyphShaderList();
+
+ @NonNull
+ public static native String[] getPassiveShaderList();
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
index f23e0cf374..75c0faaa09 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
@@ -17,6 +17,7 @@ import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.LegacyBooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.LegacyIntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.LegacyStringSetting;
+import org.dolphinemu.dolphinemu.features.settings.model.PostProcessing;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
import org.dolphinemu.dolphinemu.features.settings.model.WiimoteProfileStringSetting;
@@ -622,11 +623,17 @@ public final class SettingsFragmentPresenter
int stereoModeValue = IntSetting.GFX_STEREO_MODE.getInt(mSettings);
final int anaglyphMode = 3;
- String subDir = stereoModeValue == anaglyphMode ? "Anaglyph" : null;
- String[] shaderListEntries = getShaderList(subDir);
- String[] shaderListValues = new String[shaderListEntries.length];
- System.arraycopy(shaderListEntries, 0, shaderListValues, 0, shaderListEntries.length);
+ String[] shaderList = stereoModeValue == anaglyphMode ?
+ PostProcessing.getAnaglyphShaderList() : PostProcessing.getShaderList();
+
+ String[] shaderListEntries = new String[shaderList.length + 1];
+ shaderListEntries[0] = mContext.getString(R.string.off);
+ System.arraycopy(shaderList, 0, shaderListEntries, 1, shaderList.length);
+
+ String[] shaderListValues = new String[shaderList.length + 1];
shaderListValues[0] = "";
+ System.arraycopy(shaderList, 0, shaderListValues, 1, shaderList.length);
+
sl.add(new StringSingleChoiceSetting(mContext, StringSetting.GFX_ENHANCE_POST_SHADER,
R.string.post_processing_shader, 0, shaderListEntries, shaderListValues));
@@ -664,46 +671,6 @@ public final class SettingsFragmentPresenter
}
}
- private String[] getShaderList(String subDir)
- {
- try
- {
- String shadersPath =
- DirectoryInitialization.getDolphinInternalDirectory() + "/Shaders";
- if (!TextUtils.isEmpty(subDir))
- {
- shadersPath += "/" + subDir;
- }
-
- File file = new File(shadersPath);
- File[] shaderFiles = file.listFiles();
- if (shaderFiles != null)
- {
- String[] result = new String[shaderFiles.length + 1];
- result[0] = mView.getActivity().getString(R.string.off);
- for (int i = 0; i < shaderFiles.length; i++)
- {
- String name = shaderFiles[i].getName();
- int extensionIndex = name.indexOf(".glsl");
- if (extensionIndex > 0)
- {
- name = name.substring(0, extensionIndex);
- }
- result[i + 1] = name;
- }
-
- return result;
- }
- }
- catch (Exception ex)
- {
- Log.debug("[Settings] Unable to find shader files");
- // return empty list
- }
-
- return new String[]{};
- }
-
private void addHackSettings(ArrayList<SettingsItem> sl)
{
sl.add(new HeaderSetting(mContext, R.string.embedded_frame_buffer, 0));