summaryrefslogtreecommitdiff
path: root/android-project/app
diff options
context:
space:
mode:
authorSylvain Becker <sylvain.becker@gmail.com>2019-01-02 18:06:33 +0100
committerSylvain Becker <sylvain.becker@gmail.com>2019-01-02 18:06:33 +0100
commitd81254cc3f0f62cd1f247f86a3d3082a4999fc18 (patch)
treeea214013a6976e3f3ded691e0a70354e9465cc11 /android-project/app
parent976804d92e01ca67dd55e707164d9294e3afb30c (diff)
Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565
Use the egl format to reconfigure java SurfaceView holder format. If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
Diffstat (limited to 'android-project/app')
-rw-r--r--android-project/app/src/main/java/org/libsdl/app/SDLActivity.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index a58ce34475..b4d5c461da 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -530,6 +530,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
static final int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_CHANGE_WINDOW_STYLE = 2;
static final int COMMAND_TEXTEDIT_HIDE = 3;
+ static final int COMMAND_CHANGE_SURFACEVIEW_FORMAT = 4;
static final int COMMAND_SET_KEEP_SCREEN_ON = 5;
protected static final int COMMAND_USER = 0x8000;
@@ -627,6 +628,32 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
break;
}
+ case COMMAND_CHANGE_SURFACEVIEW_FORMAT:
+ {
+ int format = ((int)msg.obj);
+ int pf;
+
+ if (SDLActivity.mSurface == null) {
+ return;
+ }
+
+ SurfaceHolder holder = SDLActivity.mSurface.getHolder();
+ if (holder == null) {
+ return;
+ }
+
+ if (format == 1) {
+ pf = PixelFormat.RGBA_8888;
+ } else if (format == 2) {
+ pf = PixelFormat.RGBX_8888;
+ } else {
+ pf = PixelFormat.RGB_565;
+ }
+
+ holder.setFormat(pf);
+
+ break;
+ }
default:
if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) {
Log.e(TAG, "error handling message, command is " + msg.arg1);
@@ -1032,6 +1059,14 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return SDLActivity.mSurface.getNativeSurface();
}
+ /**
+ * This method is called by SDL using JNI.
+ */
+ public static void setSurfaceViewFormat(int format) {
+ mSingleton.sendCommand(COMMAND_CHANGE_SURFACEVIEW_FORMAT, format);
+ return;
+ }
+
// Input
/**