mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-08-30 02:21:39 +00:00
Displays are now referenced by instance ID instead of index
This commit is contained in:
@@ -72,7 +72,7 @@ static void android_egl_context_restore(SDL_Window *window)
|
||||
{
|
||||
if (window) {
|
||||
SDL_Event event;
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) {
|
||||
/* The context is no longer valid, create a new one */
|
||||
data->egl_context = (EGLContext)SDL_GL_CreateContext(window);
|
||||
@@ -89,7 +89,7 @@ static void android_egl_context_backup(SDL_Window *window)
|
||||
{
|
||||
if (window) {
|
||||
/* Keep a copy of the EGL Context so we can try to restore it when we resume */
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
data->egl_context = SDL_GL_GetCurrentContext();
|
||||
/* We need to do this so the EGLSurface can be freed */
|
||||
SDL_GL_MakeCurrent(window, NULL);
|
||||
@@ -107,7 +107,7 @@ static void android_egl_context_backup(SDL_Window *window)
|
||||
|
||||
void Android_PumpEvents_Blocking(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
|
||||
if (videodata->isPaused) {
|
||||
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
|
||||
@@ -182,7 +182,7 @@ void Android_PumpEvents_Blocking(_THIS)
|
||||
|
||||
void Android_PumpEvents_NonBlocking(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
static int backup_context = 0;
|
||||
|
||||
if (videodata->isPaused) {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
int Android_GLES_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context)
|
||||
{
|
||||
if (window && context) {
|
||||
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *)window->driverdata)->egl_surface, context);
|
||||
return SDL_EGL_MakeCurrent(_this, window->driverdata->egl_surface, context);
|
||||
} else {
|
||||
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ Android_GLES_CreateContext(_THIS, SDL_Window *window)
|
||||
|
||||
Android_ActivityMutex_Lock_Running();
|
||||
|
||||
ret = SDL_EGL_CreateContext(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
|
||||
ret = SDL_EGL_CreateContext(_this, window->driverdata->egl_surface);
|
||||
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
|
||||
@@ -71,7 +71,7 @@ int Android_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
||||
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
_this->egl_data->eglWaitGL();*/
|
||||
retval = SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *)window->driverdata)->egl_surface);
|
||||
retval = SDL_EGL_SwapBuffers(_this, window->driverdata->egl_surface);
|
||||
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
|
||||
|
||||
void Android_StartTextInput(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
Android_JNI_ShowTextInput(&videodata->textRect);
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ void Android_StopTextInput(_THIS)
|
||||
|
||||
void Android_SetTextInputRect(_THIS, const SDL_Rect *rect)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
|
||||
if (rect == NULL) {
|
||||
SDL_InvalidParamError("rect");
|
||||
|
||||
@@ -169,8 +169,8 @@ VideoBootStrap Android_bootstrap = {
|
||||
|
||||
int Android_VideoInit(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
int display_index;
|
||||
SDL_VideoData *videodata = _this->driverdata;
|
||||
SDL_DisplayID displayID;
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
@@ -186,11 +186,11 @@ int Android_VideoInit(_THIS)
|
||||
mode.refresh_rate = Android_ScreenRate;
|
||||
mode.driverdata = NULL;
|
||||
|
||||
display_index = SDL_AddBasicVideoDisplay(&mode);
|
||||
if (display_index < 0) {
|
||||
displayID = SDL_AddBasicVideoDisplay(&mode);
|
||||
if (displayID == 0) {
|
||||
return -1;
|
||||
}
|
||||
display = SDL_GetDisplay(display_index);
|
||||
display = SDL_GetVideoDisplay(displayID);
|
||||
display->orientation = Android_JNI_GetDisplayOrientation();
|
||||
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
@@ -291,7 +291,7 @@ void Android_SendResize(SDL_Window *window)
|
||||
/* Force the current mode to match the resize otherwise the SDL_EVENT_WINDOW_RESTORED event
|
||||
* will fall back to the old mode */
|
||||
int w, h;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window);
|
||||
SDL_DisplayMode current_mode;
|
||||
|
||||
current_mode.format = Android_ScreenFormat;
|
||||
|
||||
@@ -32,13 +32,13 @@ extern void Android_SendResize(SDL_Window *window);
|
||||
|
||||
/* Private display data */
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
struct SDL_VideoData
|
||||
{
|
||||
SDL_Rect textRect;
|
||||
int isPaused;
|
||||
int isPausing;
|
||||
int pauseAudio;
|
||||
} SDL_VideoData;
|
||||
};
|
||||
|
||||
extern int Android_SurfaceWidth;
|
||||
extern int Android_SurfaceHeight;
|
||||
|
||||
@@ -130,7 +130,7 @@ SDL_bool Android_Vulkan_CreateSurface(_THIS,
|
||||
VkInstance instance,
|
||||
VkSurfaceKHR *surface)
|
||||
{
|
||||
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *windowData = window->driverdata;
|
||||
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
|
||||
(PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr;
|
||||
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR =
|
||||
|
||||
@@ -128,7 +128,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di
|
||||
goto endfunction;
|
||||
}
|
||||
|
||||
data = (SDL_WindowData *)window->driverdata;
|
||||
data = window->driverdata;
|
||||
if (data == NULL || !data->native_window) {
|
||||
if (data && !data->native_window) {
|
||||
SDL_SetError("Missing native window");
|
||||
@@ -175,7 +175,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
|
||||
Android_Window = NULL;
|
||||
|
||||
if (window->driverdata) {
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (data->egl_surface != EGL_NO_SURFACE) {
|
||||
@@ -196,7 +196,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
|
||||
|
||||
int Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
|
||||
info->subsystem = SDL_SYSWM_ANDROID;
|
||||
info->info.android.window = data->native_window;
|
||||
|
||||
@@ -36,7 +36,7 @@ extern void Android_DestroyWindow(_THIS, SDL_Window *window);
|
||||
extern int Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
|
||||
extern SDL_Window *Android_Window;
|
||||
|
||||
typedef struct
|
||||
struct SDL_WindowData
|
||||
{
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
@@ -45,6 +45,6 @@ typedef struct
|
||||
SDL_bool backup_done;
|
||||
ANativeWindow *native_window;
|
||||
|
||||
} SDL_WindowData;
|
||||
};
|
||||
|
||||
#endif /* SDL_androidwindow_h_ */
|
||||
|
||||
Reference in New Issue
Block a user