Android: try to fix resize with software rendering (bug 4669)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 088a0a5..fd98b4c 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -82,6 +82,11 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
static int
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
{
+#if defined(ANDROID)
+ extern void Android_GetScreenResolution(int *w, int *h);
+ Android_GetScreenResolution(w, h);
+ return 0;
+#else
SDL_Surface *surface = SW_ActivateRenderer(renderer);
if (surface) {
@@ -96,6 +101,7 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
SDL_SetError("Software renderer doesn't have an output surface");
return -1;
}
+#endif
}
static int
diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c
index 91e6e99..2a9e304 100644
--- a/src/video/android/SDL_androidvideo.c
+++ b/src/video/android/SDL_androidvideo.c
@@ -237,6 +237,18 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth
Android_ScreenRate = (int)rate;
}
+void
+Android_GetScreenResolution(int *w, int *h)
+{
+ if (w) {
+ *w = Android_SurfaceWidth;
+ }
+
+ if (h) {
+ *h = Android_SurfaceHeight;
+ }
+}
+
void Android_SendResize(SDL_Window *window)
{
/*
diff --git a/src/video/android/SDL_androidvideo.h b/src/video/android/SDL_androidvideo.h
index ef90996..f54396e 100644
--- a/src/video/android/SDL_androidvideo.h
+++ b/src/video/android/SDL_androidvideo.h
@@ -30,6 +30,7 @@
/* Called by the JNI layer when the screen changes size or format */
extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate);
extern void Android_SendResize(SDL_Window *window);
+extern void Android_GetScreenResolution(int *w, int *h);
/* Private display data */