Mac and Linux SDL2 binary snapshots
Edward Rudd
2018-08-19 561f0d614098a95527367cc3f911e476f35643d6
source/src/video/android/SDL_androidvideo.c
@@ -1,6 +1,6 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
@@ -33,25 +33,23 @@
#include "../../events/SDL_windowevents_c.h"
#include "SDL_androidvideo.h"
#include "SDL_androidgl.h"
#include "SDL_androidclipboard.h"
#include "SDL_androidevents.h"
#include "SDL_androidkeyboard.h"
#include "SDL_androidmouse.h"
#include "SDL_androidtouch.h"
#include "SDL_androidwindow.h"
#include "SDL_androidvulkan.h"
#define ANDROID_VID_DRIVER_NAME "Android"
/* Initialization/Query functions */
static int Android_VideoInit(_THIS);
static void Android_VideoQuit(_THIS);
int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
#include "../SDL_egl_c.h"
/* GL functions (SDL_androidgl.c) */
extern SDL_GLContext Android_GLES_CreateContext(_THIS, SDL_Window * window);
extern int Android_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
extern void Android_GLES_SwapWindow(_THIS, SDL_Window * window);
extern int Android_GLES_LoadLibrary(_THIS, const char *path);
#define Android_GLES_GetProcAddress SDL_EGL_GetProcAddress
#define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
#define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
@@ -65,7 +63,7 @@
int Android_ScreenWidth = 0;
int Android_ScreenHeight = 0;
Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
int Android_ScreenRate = 0;
static int Android_ScreenRate = 0;
SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
@@ -118,8 +116,11 @@
    device->VideoQuit = Android_VideoQuit;
    device->PumpEvents = Android_PumpEvents;
    device->CreateWindow = Android_CreateWindow;
    device->GetDisplayDPI = Android_GetDisplayDPI;
    device->CreateSDLWindow = Android_CreateWindow;
    device->SetWindowTitle = Android_SetWindowTitle;
    device->SetWindowFullscreen = Android_SetWindowFullscreen;
    device->DestroyWindow = Android_DestroyWindow;
    device->GetWindowWMInfo = Android_GetWindowWMInfo;
@@ -135,6 +136,13 @@
    device->GL_GetSwapInterval = Android_GLES_GetSwapInterval;
    device->GL_SwapWindow = Android_GLES_SwapWindow;
    device->GL_DeleteContext = Android_GLES_DeleteContext;
#if SDL_VIDEO_VULKAN
    device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary;
    device->Vulkan_UnloadLibrary = Android_Vulkan_UnloadLibrary;
    device->Vulkan_GetInstanceExtensions = Android_Vulkan_GetInstanceExtensions;
    device->Vulkan_CreateSurface = Android_Vulkan_CreateSurface;
#endif
    /* Screensaver */
    device->SuspendScreenSaver = Android_SuspendScreenSaver;
@@ -194,9 +202,17 @@
    Android_QuitTouch();
}
int
Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi)
{
    return Android_JNI_GetDisplayDPI(ddpi, hdpi, vdpi);
}
void
Android_SetScreenResolution(int width, int height, Uint32 format, float rate)
{
   SDL_VideoDevice* device;
   SDL_VideoDisplay *display;
    Android_ScreenWidth = width;
    Android_ScreenHeight = height;
    Android_ScreenFormat = format;
@@ -205,13 +221,13 @@
    /*
      Update the resolution of the desktop mode, so that the window
      can be properly resized. The screen resolution change can for
      example happen when the Activity enters or exists immersive mode,
      example happen when the Activity enters or exits immersive mode,
      which can happen after VideoInit().
    */
    SDL_VideoDevice* device = SDL_GetVideoDevice();
    device = SDL_GetVideoDevice();
    if (device && device->num_displays > 0)
    {
        SDL_VideoDisplay* display = &device->displays[0];
        display = &device->displays[0];
        display->desktop_mode.format = Android_ScreenFormat;
        display->desktop_mode.w = Android_ScreenWidth;
        display->desktop_mode.h = Android_ScreenHeight;
@@ -219,16 +235,17 @@
    }
    if (Android_Window) {
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
        /* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
         * will fall back to the old mode */
        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(Android_Window);
        display = SDL_GetDisplayForWindow(Android_Window);
        display->current_mode.format = format;
        display->current_mode.w = width;
        display->current_mode.h = height;
        display->current_mode.refresh_rate = rate;
        display->display_modes[0].format = format;
        display->display_modes[0].w = width;
        display->display_modes[0].h = height;
        display->display_modes[0].refresh_rate = rate;
        display->current_mode = display->display_modes[0];
        SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, width, height);
    }
}