mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-03 10:27:40 +00:00
Android: don't need to set the SurfaceHolder format from java code
It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface. - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken: calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen. - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
This commit is contained in:
parent
8e3ec34d34
commit
98a966d1c2
6 changed files with 70 additions and 108 deletions
|
@ -79,7 +79,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
|
|||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint surfaceWidth, jint surfaceHeight,
|
||||
jint deviceWidth, jint deviceHeight, jint format, jfloat rate);
|
||||
jint deviceWidth, jint deviceHeight, jfloat rate);
|
||||
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)(
|
||||
JNIEnv *env, jclass cls);
|
||||
|
@ -168,7 +168,7 @@ static JNINativeMethod SDLActivity_tab[] = {
|
|||
{ "nativeSetupJNI", "()I", SDL_JAVA_INTERFACE(nativeSetupJNI) },
|
||||
{ "nativeRunMain", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I", SDL_JAVA_INTERFACE(nativeRunMain) },
|
||||
{ "onNativeDropFile", "(Ljava/lang/String;)V", SDL_JAVA_INTERFACE(onNativeDropFile) },
|
||||
{ "nativeSetScreenResolution", "(IIIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) },
|
||||
{ "nativeSetScreenResolution", "(IIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) },
|
||||
{ "onNativeResize", "()V", SDL_JAVA_INTERFACE(onNativeResize) },
|
||||
{ "onNativeSurfaceCreated", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceCreated) },
|
||||
{ "onNativeSurfaceChanged", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceChanged) },
|
||||
|
@ -318,7 +318,6 @@ static jmethodID midSetActivityTitle;
|
|||
static jmethodID midSetCustomCursor;
|
||||
static jmethodID midSetOrientation;
|
||||
static jmethodID midSetRelativeMouseEnabled;
|
||||
static jmethodID midSetSurfaceViewFormat;
|
||||
static jmethodID midSetSystemCursor;
|
||||
static jmethodID midSetWindowStyle;
|
||||
static jmethodID midShouldMinimizeOnFocusLoss;
|
||||
|
@ -598,7 +597,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
|||
midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z");
|
||||
midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass, "setOrientation","(IIZLjava/lang/String;)V");
|
||||
midSetRelativeMouseEnabled = (*env)->GetStaticMethodID(env, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
|
||||
midSetSurfaceViewFormat = (*env)->GetStaticMethodID(env, mActivityClass, "setSurfaceViewFormat","(I)V");
|
||||
midSetSystemCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setSystemCursor", "(I)Z");
|
||||
midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass, "setWindowStyle","(Z)V");
|
||||
midShouldMinimizeOnFocusLoss = (*env)->GetStaticMethodID(env, mActivityClass, "shouldMinimizeOnFocusLoss","()Z");
|
||||
|
@ -629,7 +627,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
|
|||
!midSetCustomCursor ||
|
||||
!midSetOrientation ||
|
||||
!midSetRelativeMouseEnabled ||
|
||||
!midSetSurfaceViewFormat ||
|
||||
!midSetSystemCursor ||
|
||||
!midSetWindowStyle ||
|
||||
!midShouldMinimizeOnFocusLoss ||
|
||||
|
@ -845,11 +842,11 @@ retry:
|
|||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)(
|
||||
JNIEnv *env, jclass jcls,
|
||||
jint surfaceWidth, jint surfaceHeight,
|
||||
jint deviceWidth, jint deviceHeight, jint format, jfloat rate)
|
||||
jint deviceWidth, jint deviceHeight, jfloat rate)
|
||||
{
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
|
||||
Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate);
|
||||
Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, rate);
|
||||
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
|
@ -1384,26 +1381,6 @@ ANativeWindow* Android_JNI_GetNativeWindow(void)
|
|||
return anw;
|
||||
}
|
||||
|
||||
void Android_JNI_SetSurfaceViewFormat(int format)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
int new_format = 0;
|
||||
|
||||
/* Format from android/native_window.h,
|
||||
* convert to temporary arbitrary values,
|
||||
* then to java PixelFormat */
|
||||
if (format == WINDOW_FORMAT_RGBA_8888) {
|
||||
new_format = 1;
|
||||
} else if (format == WINDOW_FORMAT_RGBX_8888) {
|
||||
new_format = 2;
|
||||
} else if (format == WINDOW_FORMAT_RGB_565) {
|
||||
/* Default */
|
||||
new_format = 0;
|
||||
}
|
||||
|
||||
(*env)->CallStaticVoidMethod(env, mActivityClass, midSetSurfaceViewFormat, new_format);
|
||||
}
|
||||
|
||||
void Android_JNI_SetActivityTitle(const char *title)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue