mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-11-17 15:51:25 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user