early-access version 1617

This commit is contained in:
pineappleEA
2021-04-20 21:40:33 +02:00
parent 242b6f6b49
commit f46563104f
510 changed files with 141726 additions and 62846 deletions

View File

@@ -96,6 +96,7 @@ static VideoBootStrap *bootstrap[] = {
#endif
#if SDL_VIDEO_DRIVER_KMSDRM
&KMSDRM_bootstrap,
&KMSDRM_LEGACY_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_RPI
&RPI_bootstrap,
@@ -112,6 +113,10 @@ static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_OFFSCREEN
&OFFSCREEN_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_OS2
&OS2DIVE_bootstrap,
&OS2VMAN_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
#endif
@@ -493,19 +498,15 @@ SDL_VideoInit(const char *driver_name)
if (driver_name != NULL) {
for (i = 0; bootstrap[i]; ++i) {
if (SDL_strncasecmp(bootstrap[i]->name, driver_name, SDL_strlen(driver_name)) == 0) {
if (bootstrap[i]->available()) {
video = bootstrap[i]->create(index);
break;
}
video = bootstrap[i]->create(index);
break;
}
}
} else {
for (i = 0; bootstrap[i]; ++i) {
if (bootstrap[i]->available()) {
video = bootstrap[i]->create(index);
if (video != NULL) {
break;
}
video = bootstrap[i]->create(index);
if (video != NULL) {
break;
}
}
}
@@ -599,11 +600,11 @@ SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
}
display.current_mode = display.desktop_mode;
return SDL_AddVideoDisplay(&display);
return SDL_AddVideoDisplay(&display, SDL_FALSE);
}
int
SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event)
{
SDL_VideoDisplay *displays;
int index = -1;
@@ -625,12 +626,31 @@ SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
SDL_itoa(index, name, 10);
displays[index].name = SDL_strdup(name);
}
if (send_event) {
SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_CONNECTED, 0);
}
} else {
SDL_OutOfMemory();
}
return index;
}
void
SDL_DelVideoDisplay(int index)
{
if (index < 0 || index >= _this->num_displays) {
return;
}
SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0);
if (index < (_this->num_displays - 1)) {
SDL_memmove(&_this->displays[index], &_this->displays[index+1], (_this->num_displays - index - 1)*sizeof(_this->displays[index]));
}
--_this->num_displays;
}
int
SDL_GetNumVideoDisplays(void)
{
@@ -1366,7 +1386,7 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
}
#define CREATE_FLAGS \
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED)
(SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED | SDL_WINDOW_METAL)
static SDL_INLINE SDL_bool
IsAcceptingDragAndDrop(void)
@@ -1429,7 +1449,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
if (!_this) {
/* Initialize the video system if needed */
if (SDL_VideoInit(NULL) < 0) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
return NULL;
}
}
@@ -1455,7 +1475,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
/* Some platforms have OpenGL enabled by default */
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !SDL_IsVideoContextExternal()) {
if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !(flags & SDL_WINDOW_METAL) && !SDL_IsVideoContextExternal()) {
flags |= SDL_WINDOW_OPENGL;
}
#endif
@@ -1487,6 +1507,24 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
}
}
if (flags & SDL_WINDOW_METAL) {
if (!_this->Metal_CreateView) {
SDL_SetError("Metal support is either not configured in SDL "
"or not available in current SDL video driver "
"(%s) or platform", _this->name);
return NULL;
}
if (flags & SDL_WINDOW_OPENGL) {
SDL_SetError("Metal and OpenGL not supported on same window");
return NULL;
}
if (flags & SDL_WINDOW_VULKAN) {
SDL_SetError("Metal and Vulkan not supported on same window. "
"To use MoltenVK, set SDL_WINDOW_VULKAN only.");
return NULL;
}
}
/* Unless the user has specified the high-DPI disabling hint, respect the
* SDL_WINDOW_ALLOW_HIGHDPI flag.
*/
@@ -1635,6 +1673,11 @@ int
SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
{
SDL_bool loaded_opengl = SDL_FALSE;
SDL_bool need_gl_unload = SDL_FALSE;
SDL_bool need_gl_load = SDL_FALSE;
SDL_bool loaded_vulkan = SDL_FALSE;
SDL_bool need_vulkan_unload = SDL_FALSE;
SDL_bool need_vulkan_load = SDL_FALSE;
if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
return SDL_SetError("OpenGL support is either not configured in SDL "
@@ -1668,29 +1711,72 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) {
if (flags & SDL_WINDOW_OPENGL) {
if (SDL_GL_LoadLibrary(NULL) < 0) {
return -1;
}
loaded_opengl = SDL_TRUE;
need_gl_load = SDL_TRUE;
} else {
SDL_GL_UnloadLibrary();
need_gl_unload = SDL_TRUE;
}
} else if (window->flags & SDL_WINDOW_OPENGL) {
need_gl_unload = SDL_TRUE;
need_gl_load = SDL_TRUE;
}
if ((window->flags & SDL_WINDOW_METAL) != (flags & SDL_WINDOW_METAL)) {
if (flags & SDL_WINDOW_METAL) {
need_gl_load = SDL_TRUE;
} else {
need_gl_unload = SDL_TRUE;
}
} else if (window->flags & SDL_WINDOW_METAL) {
need_gl_unload = SDL_TRUE;
need_gl_load = SDL_TRUE;
}
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
if (flags & SDL_WINDOW_VULKAN) {
need_vulkan_load = SDL_TRUE;
} else {
need_vulkan_unload = SDL_TRUE;
}
} else if (window->flags & SDL_WINDOW_VULKAN) {
need_vulkan_unload = SDL_TRUE;
need_vulkan_load = SDL_TRUE;
}
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
}
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Metal and OpenGL not supported on same window");
return -1;
}
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Metal and Vulkan not supported on same window");
return -1;
}
if (need_gl_unload) {
SDL_GL_UnloadLibrary();
}
if (need_vulkan_unload) {
SDL_Vulkan_UnloadLibrary();
}
if (need_gl_load) {
if (SDL_GL_LoadLibrary(NULL) < 0) {
return -1;
}
loaded_opengl = SDL_TRUE;
}
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Can't change SDL_WINDOW_VULKAN window flag");
return -1;
}
if ((window->flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
if (need_vulkan_load) {
if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
return -1;
}
loaded_vulkan = SDL_TRUE;
}
window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN);
@@ -1703,6 +1789,10 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
SDL_GL_UnloadLibrary();
window->flags &= ~SDL_WINDOW_OPENGL;
}
if (loaded_vulkan) {
SDL_Vulkan_UnloadLibrary();
window->flags &= ~SDL_WINDOW_VULKAN;
}
return -1;
}
}
@@ -2098,8 +2188,8 @@ SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h)
return;
}
if ((window->max_w && min_w >= window->max_w) ||
(window->max_h && min_h >= window->max_h)) {
if ((window->max_w && min_w > window->max_w) ||
(window->max_h && min_h > window->max_h)) {
SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size");
return;
}
@@ -2141,7 +2231,7 @@ SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h)
return;
}
if (max_w <= window->min_w || max_h <= window->min_h) {
if (max_w < window->min_w || max_h < window->min_h) {
SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
return;
}
@@ -2319,6 +2409,10 @@ SDL_CreateWindowFramebuffer(SDL_Window * window)
return NULL;
}
if (window->surface) {
return window->surface;
}
if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
return NULL;
}
@@ -2335,6 +2429,7 @@ SDL_GetWindowSurface(SDL_Window * window)
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
SDL_FreeSurface(window->surface);
window->surface = NULL;
}
window->surface = SDL_CreateWindowFramebuffer(window);
if (window->surface) {
@@ -2694,7 +2789,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
}
#endif
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_TRUE);
return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, SDL_FALSE);
}
void
@@ -2759,6 +2854,8 @@ SDL_DestroyWindow(SDL_Window * window)
if (window->surface) {
window->surface->flags &= ~SDL_DONTFREE;
SDL_FreeSurface(window->surface);
window->surface = NULL;
window->surface_valid = SDL_FALSE;
}
if (_this->DestroyWindowFramebuffer) {
_this->DestroyWindowFramebuffer(_this, window);
@@ -3111,24 +3208,24 @@ SDL_GL_ResetAttributes()
_this->gl_config.retained_backing = 1;
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
#if SDL_VIDEO_OPENGL
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = 0;
#elif SDL_VIDEO_OPENGL_ES2
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 0;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#elif SDL_VIDEO_OPENGL_ES
_this->gl_config.major_version = 1;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#endif
if (_this->GL_DefaultProfileConfig) {
_this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask,
&_this->gl_config.major_version,
&_this->gl_config.minor_version);
} else {
#if SDL_VIDEO_OPENGL
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = 0;
#elif SDL_VIDEO_OPENGL_ES2
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 0;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#elif SDL_VIDEO_OPENGL_ES
_this->gl_config.major_version = 1;
_this->gl_config.minor_version = 1;
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#endif
}
_this->gl_config.flags = 0;
@@ -3546,12 +3643,14 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
if (!ctx) {
window = NULL;
} else {
} else if (window) {
CHECK_WINDOW_MAGIC(window, -1);
if (!(window->flags & SDL_WINDOW_OPENGL)) {
return SDL_SetError("The specified window isn't an OpenGL window");
}
} else if (!_this->gl_allow_no_surface) {
return SDL_SetError("Use of OpenGL without a window is not supported on this platform");
}
retval = _this->GL_MakeCurrent(_this, window, ctx);
@@ -3867,9 +3966,11 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
#if SDL_VIDEO_DRIVER_HAIKU
#include "haiku/SDL_bmessagebox.h"
#endif
#if SDL_VIDEO_DRIVER_OS2
#include "os2/SDL_os2messagebox.h"
#endif
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
{
SDL_SysWMinfo info;
@@ -3897,6 +3998,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
int show_cursor_prev;
SDL_bool mouse_captured;
SDL_Window *current_window;
SDL_MessageBoxData mbdata;
if (!messageboxdata) {
return SDL_InvalidParamError("messageboxdata");
@@ -3916,6 +4018,11 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
buttonid = &dummybutton;
}
SDL_memcpy(&mbdata, messageboxdata, sizeof(*messageboxdata));
if (!mbdata.title) mbdata.title = "";
if (!mbdata.message) mbdata.message = "";
messageboxdata = &mbdata;
if (_this && _this->ShowMessageBox) {
retval = _this->ShowMessageBox(_this, messageboxdata, buttonid);
}
@@ -3968,6 +4075,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
#if SDL_VIDEO_DRIVER_OS2
if (retval == -1 &&
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_OS2) &&
OS2_ShowMessageBox(messageboxdata, buttonid) == 0) {
retval = 0;
}
#endif
if (retval == -1) {
SDL_SetError("No message system available");
@@ -3994,6 +4108,8 @@ SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, S
/* Web browsers don't (currently) have an API for a custom message box
that can block, but for the most common case (SDL_ShowSimpleMessageBox),
we can use the standard Javascript alert() function. */
if (!title) title = "";
if (!message) message = "";
EM_ASM_({
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
}, title, message);
@@ -4219,6 +4335,11 @@ SDL_Metal_CreateView(SDL_Window * window)
{
CHECK_WINDOW_MAGIC(window, NULL);
if (!(window->flags & SDL_WINDOW_METAL)) {
SDL_SetError("The specified window isn't a Metal window");
return NULL;
}
if (_this->Metal_CreateView) {
return _this->Metal_CreateView(_this, window);
} else {
@@ -4235,4 +4356,31 @@ SDL_Metal_DestroyView(SDL_MetalView view)
}
}
void *
SDL_Metal_GetLayer(SDL_MetalView view)
{
if (_this && _this->Metal_GetLayer) {
if (view) {
return _this->Metal_GetLayer(_this, view);
} else {
SDL_InvalidParamError("view");
return NULL;
}
} else {
SDL_SetError("Metal is not supported.");
return NULL;
}
}
void SDL_Metal_GetDrawableSize(SDL_Window * window, int *w, int *h)
{
CHECK_WINDOW_MAGIC(window,);
if (_this->Metal_GetDrawableSize) {
_this->Metal_GetDrawableSize(_this, window, w, h);
} else {
SDL_GetWindowSize(window, w, h);
}
}
/* vi: set ts=4 sw=4 expandtab: */