src/video/android/SDL_androidvideo.c
changeset 12556 9b2e48b381db
parent 12552 6bc8c73ab0fe
child 12625 e58468e48179
     1.1 --- a/src/video/android/SDL_androidvideo.c	Thu Jan 17 09:28:30 2019 +0100
     1.2 +++ b/src/video/android/SDL_androidvideo.c	Thu Jan 17 11:05:05 2019 +0100
     1.3 @@ -59,15 +59,15 @@
     1.4  
     1.5  
     1.6  /* These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) */
     1.7 -int Android_SurfaceWidth = 0;
     1.8 -int Android_SurfaceHeight = 0;
     1.9 -int Android_DeviceWidth = 0;
    1.10 -int Android_DeviceHeight = 0;
    1.11 +int Android_SurfaceWidth           = 0;
    1.12 +int Android_SurfaceHeight          = 0;
    1.13 +static int Android_DeviceWidth     = 0;
    1.14 +static int Android_DeviceHeight    = 0;
    1.15  static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
    1.16 -static int Android_ScreenRate = 0;
    1.17 -
    1.18 -SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
    1.19 -SDL_mutex *Android_ActivityMutex = NULL;
    1.20 +static int Android_ScreenRate      = 0;
    1.21 +SDL_sem *Android_PauseSem          = NULL;
    1.22 +SDL_sem *Android_ResumeSem         = NULL;
    1.23 +SDL_mutex *Android_ActivityMutex   = NULL;
    1.24  
    1.25  static int
    1.26  Android_Available(void)
    1.27 @@ -178,11 +178,12 @@
    1.28      videodata->isPaused  = SDL_FALSE;
    1.29      videodata->isPausing = SDL_FALSE;
    1.30  
    1.31 -    mode.format = Android_ScreenFormat;
    1.32 -    mode.w = Android_DeviceWidth;
    1.33 -    mode.h = Android_DeviceHeight;
    1.34 -    mode.refresh_rate = Android_ScreenRate;
    1.35 -    mode.driverdata = NULL;
    1.36 +    mode.format          = Android_ScreenFormat;
    1.37 +    mode.w               = Android_DeviceWidth;
    1.38 +    mode.h               = Android_DeviceHeight;
    1.39 +    mode.refresh_rate    = Android_ScreenRate;
    1.40 +    mode.driverdata      = NULL;
    1.41 +
    1.42      if (SDL_AddBasicVideoDisplay(&mode) < 0) {
    1.43          return -1;
    1.44      }
    1.45 @@ -213,45 +214,45 @@
    1.46  }
    1.47  
    1.48  void
    1.49 -Android_SetScreenResolution(SDL_Window *window, int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate)
    1.50 +Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate)
    1.51  {
    1.52 -    SDL_VideoDevice *device;
    1.53 -    SDL_VideoDisplay *display;
    1.54 -    Android_SurfaceWidth = surfaceWidth;
    1.55 +    Android_SurfaceWidth  = surfaceWidth;
    1.56      Android_SurfaceHeight = surfaceHeight;
    1.57 -    Android_DeviceWidth = deviceWidth;
    1.58 -    Android_DeviceHeight = deviceHeight;
    1.59 -    Android_ScreenFormat = format;
    1.60 -    Android_ScreenRate = (int)rate;
    1.61 +    Android_DeviceWidth   = deviceWidth;
    1.62 +    Android_DeviceHeight  = deviceHeight;
    1.63 +    Android_ScreenFormat  = format;
    1.64 +    Android_ScreenRate    = (int)rate;
    1.65 +}
    1.66  
    1.67 +void Android_SendResize(SDL_Window *window)
    1.68 +{
    1.69      /*
    1.70        Update the resolution of the desktop mode, so that the window
    1.71        can be properly resized. The screen resolution change can for
    1.72        example happen when the Activity enters or exits immersive mode,
    1.73        which can happen after VideoInit().
    1.74      */
    1.75 -    device = SDL_GetVideoDevice();
    1.76 +    SDL_VideoDevice *device = SDL_GetVideoDevice();
    1.77      if (device && device->num_displays > 0)
    1.78      {
    1.79 -        display = &device->displays[0];
    1.80 -        display->desktop_mode.format = Android_ScreenFormat;
    1.81 -        display->desktop_mode.w = Android_DeviceWidth;
    1.82 -        display->desktop_mode.h = Android_DeviceHeight;
    1.83 -        display->desktop_mode.refresh_rate  = Android_ScreenRate;
    1.84 +        SDL_VideoDisplay *display          = &device->displays[0];
    1.85 +        display->desktop_mode.format       = Android_ScreenFormat;
    1.86 +        display->desktop_mode.w            = Android_DeviceWidth;
    1.87 +        display->desktop_mode.h            = Android_DeviceHeight;
    1.88 +        display->desktop_mode.refresh_rate = Android_ScreenRate;
    1.89      }
    1.90  
    1.91      if (window) {
    1.92          /* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
    1.93           * will fall back to the old mode */
    1.94 -        display = SDL_GetDisplayForWindow(window);
    1.95 +        SDL_VideoDisplay *display              = SDL_GetDisplayForWindow(window);
    1.96 +        display->display_modes[0].format       = Android_ScreenFormat;
    1.97 +        display->display_modes[0].w            = Android_DeviceWidth;
    1.98 +        display->display_modes[0].h            = Android_DeviceHeight;
    1.99 +        display->display_modes[0].refresh_rate = Android_ScreenRate;
   1.100 +        display->current_mode                  = display->display_modes[0];
   1.101  
   1.102 -        display->display_modes[0].format = format;
   1.103 -        display->display_modes[0].w = Android_DeviceWidth;
   1.104 -        display->display_modes[0].h = Android_DeviceHeight;
   1.105 -        display->display_modes[0].refresh_rate = (int)rate;
   1.106 -        display->current_mode = display->display_modes[0];
   1.107 -
   1.108 -        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight);
   1.109 +        SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, Android_SurfaceWidth, Android_SurfaceHeight);
   1.110      }
   1.111  }
   1.112