Fixed bug 2816 - [patch] Android: Expose screen refresh rate
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Fri, 23 Jan 2015 20:29:08 +0100
changeset 93148d826bc39a45
parent 9313 6f04557c6e1f
child 9315 541f12d1edcd
child 9535 a66a7f7e8cd8
Fixed bug 2816 - [patch] Android: Expose screen refresh rate

Jonas Kulla

Display::getRefreshRate() is available on all API levels.
android-project/src/org/libsdl/app/SDLActivity.java
src/core/android/SDL_android.c
src/video/android/SDL_androidvideo.c
src/video/android/SDL_androidvideo.h
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sun Jan 18 02:50:14 2015 -0500
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Fri Jan 23 20:29:08 2015 +0100
     1.3 @@ -392,7 +392,7 @@
     1.4      public static native void nativeQuit();
     1.5      public static native void nativePause();
     1.6      public static native void nativeResume();
     1.7 -    public static native void onNativeResize(int x, int y, int format);
     1.8 +    public static native void onNativeResize(int x, int y, int format, float rate);
     1.9      public static native int onNativePadDown(int device_id, int keycode);
    1.10      public static native int onNativePadUp(int device_id, int keycode);
    1.11      public static native void onNativeJoy(int device_id, int axis,
    1.12 @@ -1041,7 +1041,7 @@
    1.13  
    1.14          mWidth = width;
    1.15          mHeight = height;
    1.16 -        SDLActivity.onNativeResize(width, height, sdlFormat);
    1.17 +        SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate());
    1.18          Log.v("SDL", "Window size:" + width + "x"+height);
    1.19  
    1.20          // Set mIsSurfaceReady to 'true' *before* making a call to handleResume
     2.1 --- a/src/core/android/SDL_android.c	Sun Jan 18 02:50:14 2015 -0500
     2.2 +++ b/src/core/android/SDL_android.c	Fri Jan 23 20:29:08 2015 +0100
     2.3 @@ -143,9 +143,9 @@
     2.4  /* Resize */
     2.5  JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeResize(
     2.6                                      JNIEnv* env, jclass jcls,
     2.7 -                                    jint width, jint height, jint format)
     2.8 +                                    jint width, jint height, jint format, jfloat rate)
     2.9  {
    2.10 -    Android_SetScreenResolution(width, height, format);
    2.11 +    Android_SetScreenResolution(width, height, format, rate);
    2.12  }
    2.13  
    2.14  /* Paddown */
     3.1 --- a/src/video/android/SDL_androidvideo.c	Sun Jan 18 02:50:14 2015 -0500
     3.2 +++ b/src/video/android/SDL_androidvideo.c	Fri Jan 23 20:29:08 2015 +0100
     3.3 @@ -64,6 +64,8 @@
     3.4  int Android_ScreenWidth = 0;
     3.5  int Android_ScreenHeight = 0;
     3.6  Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
     3.7 +int Android_ScreenRate = 0;
     3.8 +
     3.9  SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
    3.10  
    3.11  /* Currently only one window */
    3.12 @@ -166,7 +168,7 @@
    3.13      mode.format = Android_ScreenFormat;
    3.14      mode.w = Android_ScreenWidth;
    3.15      mode.h = Android_ScreenHeight;
    3.16 -    mode.refresh_rate = 0;
    3.17 +    mode.refresh_rate = Android_ScreenRate;
    3.18      mode.driverdata = NULL;
    3.19      if (SDL_AddBasicVideoDisplay(&mode) < 0) {
    3.20          return -1;
    3.21 @@ -189,11 +191,12 @@
    3.22  
    3.23  /* This function gets called before VideoInit() */
    3.24  void
    3.25 -Android_SetScreenResolution(int width, int height, Uint32 format)
    3.26 +Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
    3.27  {
    3.28      Android_ScreenWidth = width;
    3.29      Android_ScreenHeight = height;
    3.30      Android_ScreenFormat = format;
    3.31 +    Android_ScreenRate = rate;
    3.32  
    3.33      if (Android_Window) {
    3.34          SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
     4.1 --- a/src/video/android/SDL_androidvideo.h	Sun Jan 18 02:50:14 2015 -0500
     4.2 +++ b/src/video/android/SDL_androidvideo.h	Fri Jan 23 20:29:08 2015 +0100
     4.3 @@ -28,7 +28,7 @@
     4.4  #include "../SDL_sysvideo.h"
     4.5  
     4.6  /* Called by the JNI layer when the screen changes size or format */
     4.7 -extern void Android_SetScreenResolution(int width, int height, Uint32 format);
     4.8 +extern void Android_SetScreenResolution(int width, int height, Uint32 format, float rate);
     4.9  
    4.10  /* Private display data */
    4.11