mirror of
https://github.com/yawut/SDL.git
synced 2026-09-07 08:36:19 -05:00
Fixed bug 2816 - [patch] Android: Expose screen refresh rate
Jonas Kulla Display::getRefreshRate() is available on all API levels.
This commit is contained in:
@@ -143,9 +143,9 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
|
||||
/* Resize */
|
||||
JNIEXPORT void JNICALL Java_org_libsdl_app_SDLActivity_onNativeResize(
|
||||
JNIEnv* env, jclass jcls,
|
||||
jint width, jint height, jint format)
|
||||
jint width, jint height, jint format, jfloat rate)
|
||||
{
|
||||
Android_SetScreenResolution(width, height, format);
|
||||
Android_SetScreenResolution(width, height, format, rate);
|
||||
}
|
||||
|
||||
/* Paddown */
|
||||
|
||||
@@ -64,6 +64,8 @@ extern int Android_GLES_LoadLibrary(_THIS, const char *path);
|
||||
int Android_ScreenWidth = 0;
|
||||
int Android_ScreenHeight = 0;
|
||||
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
int Android_ScreenRate = 0;
|
||||
|
||||
SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
|
||||
|
||||
/* Currently only one window */
|
||||
@@ -166,7 +168,7 @@ Android_VideoInit(_THIS)
|
||||
mode.format = Android_ScreenFormat;
|
||||
mode.w = Android_ScreenWidth;
|
||||
mode.h = Android_ScreenHeight;
|
||||
mode.refresh_rate = 0;
|
||||
mode.refresh_rate = Android_ScreenRate;
|
||||
mode.driverdata = NULL;
|
||||
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
|
||||
return -1;
|
||||
@@ -189,11 +191,12 @@ Android_VideoQuit(_THIS)
|
||||
|
||||
/* This function gets called before VideoInit() */
|
||||
void
|
||||
Android_SetScreenResolution(int width, int height, Uint32 format)
|
||||
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
|
||||
{
|
||||
Android_ScreenWidth = width;
|
||||
Android_ScreenHeight = height;
|
||||
Android_ScreenFormat = format;
|
||||
Android_ScreenRate = rate;
|
||||
|
||||
if (Android_Window) {
|
||||
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* Called by the JNI layer when the screen changes size or format */
|
||||
extern void Android_SetScreenResolution(int width, int height, Uint32 format);
|
||||
extern void Android_SetScreenResolution(int width, int height, Uint32 format, float rate);
|
||||
|
||||
/* Private display data */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user