early-access version 1667
This commit is contained in:
10
externals/SDL/src/video/SDL_RLEaccel.c
vendored
10
externals/SDL/src/video/SDL_RLEaccel.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -1423,9 +1423,13 @@ SDL_RLESurface(SDL_Surface * surface)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we don't have colorkey or blending, nothing to do... */
|
||||
flags = surface->map->info.flags;
|
||||
if (!(flags & (SDL_COPY_COLORKEY | SDL_COPY_BLEND))) {
|
||||
if (flags & SDL_COPY_COLORKEY) {
|
||||
/* ok */
|
||||
} else if ((flags & SDL_COPY_BLEND) && surface->format->Amask) {
|
||||
/* ok */
|
||||
} else {
|
||||
/* If we don't have colorkey or blending, nothing to do... */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
2
externals/SDL/src/video/SDL_RLEaccel_c.h
vendored
2
externals/SDL/src/video/SDL_RLEaccel_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_blit.c
vendored
2
externals/SDL/src/video/SDL_blit.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
8
externals/SDL/src/video/SDL_blit.h
vendored
8
externals/SDL/src/video/SDL_blit.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -27,6 +27,12 @@
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_surface.h"
|
||||
|
||||
/* pixman ARM blitters are 32 bit only : */
|
||||
#if defined(__aarch64__)||defined(_M_ARM64)
|
||||
#undef SDL_ARM_SIMD_BLITTERS
|
||||
#undef SDL_ARM_NEON_BLITTERS
|
||||
#endif
|
||||
|
||||
/* Table to do pixel byte expansion */
|
||||
extern Uint8* SDL_expand_byte[9];
|
||||
|
||||
|
2
externals/SDL/src/video/SDL_blit_0.c
vendored
2
externals/SDL/src/video/SDL_blit_0.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_blit_1.c
vendored
2
externals/SDL/src/video/SDL_blit_1.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_blit_A.c
vendored
2
externals/SDL/src/video/SDL_blit_A.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
35
externals/SDL/src/video/SDL_blit_N.c
vendored
35
externals/SDL/src/video/SDL_blit_N.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -2073,6 +2073,35 @@ Blit_RGB565_BGRA8888(SDL_BlitInfo * info)
|
||||
|
||||
#endif /* SDL_HAVE_BLIT_N_RGB565 */
|
||||
|
||||
/* RGB555->ARGB1555, and BGR555->ABGR1555, SET_ALPHA */
|
||||
static void
|
||||
Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint16 *src = (Uint16 *) info->src;
|
||||
int srcskip = info->src_skip;
|
||||
Uint16 *dst = (Uint16 *) info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
|
||||
Uint16 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src | mask;
|
||||
++dst;
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint16 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint16 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BlitNto1(SDL_BlitInfo * info)
|
||||
{
|
||||
@@ -3259,6 +3288,10 @@ static const struct blit_table normal_blit_2[] = {
|
||||
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000,
|
||||
0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
|
||||
#endif
|
||||
{0x00007C00, 0x000003E0, 0x0000001F, 2, 0x00007C00, 0x000003E0, 0x0000001F,
|
||||
0, Blit_RGB555_ARGB1555, SET_ALPHA},
|
||||
{0x0000001F, 0x000003E0, 0x00007C00, 2, 0x0000001F, 0x000003E0, 0x00007C00,
|
||||
0, Blit_RGB555_ARGB1555, SET_ALPHA},
|
||||
|
||||
/* Default for 16-bit RGB source, used if no other blitter matches */
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
|
||||
|
1658
externals/SDL/src/video/SDL_blit_auto.c
vendored
1658
externals/SDL/src/video/SDL_blit_auto.c
vendored
File diff suppressed because it is too large
Load Diff
2
externals/SDL/src/video/SDL_blit_auto.h
vendored
2
externals/SDL/src/video/SDL_blit_auto.h
vendored
@@ -1,7 +1,7 @@
|
||||
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_blit_copy.c
vendored
2
externals/SDL/src/video/SDL_blit_copy.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_blit_copy.h
vendored
2
externals/SDL/src/video/SDL_blit_copy.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
25
externals/SDL/src/video/SDL_blit_slow.c
vendored
25
externals/SDL/src/video/SDL_blit_slow.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -40,7 +40,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
Uint32 dstpixel;
|
||||
Uint32 dstR, dstG, dstB, dstA;
|
||||
int srcy, srcx;
|
||||
int posy, posx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
SDL_PixelFormat *src_fmt = info->src_fmt;
|
||||
SDL_PixelFormat *dst_fmt = info->dst_fmt;
|
||||
@@ -49,30 +49,19 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
Uint32 rgbmask = ~src_fmt->Amask;
|
||||
Uint32 ckey = info->colorkey & rgbmask;
|
||||
|
||||
srcy = 0;
|
||||
posy = 0;
|
||||
incy = (info->src_h << 16) / info->dst_h;
|
||||
incx = (info->src_w << 16) / info->dst_w;
|
||||
posy = incy / 2; /* start at the middle of pixel */
|
||||
|
||||
while (info->dst_h--) {
|
||||
Uint8 *src = 0;
|
||||
Uint8 *dst = info->dst;
|
||||
int n = info->dst_w;
|
||||
srcx = -1;
|
||||
posx = 0x10000L;
|
||||
while (posy >= 0x10000L) {
|
||||
++srcy;
|
||||
posy -= 0x10000L;
|
||||
}
|
||||
posx = incx / 2; /* start at the middle of pixel */
|
||||
srcy = posy >> 16;
|
||||
while (n--) {
|
||||
if (posx >= 0x10000L) {
|
||||
while (posx >= 0x10000L) {
|
||||
++srcx;
|
||||
posx -= 0x10000L;
|
||||
}
|
||||
src =
|
||||
(info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
|
||||
}
|
||||
srcx = posx >> 16;
|
||||
src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
|
||||
if (src_fmt->Amask) {
|
||||
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
|
||||
srcB, srcA);
|
||||
|
2
externals/SDL/src/video/SDL_blit_slow.h
vendored
2
externals/SDL/src/video/SDL_blit_slow.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
4
externals/SDL/src/video/SDL_bmp.c
vendored
4
externals/SDL/src/video/SDL_bmp.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -306,7 +306,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||
}
|
||||
}
|
||||
if (biWidth <= 0 || biHeight == 0) {
|
||||
SDL_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight);
|
||||
SDL_SetError("BMP file with bad dimensions (%" SDL_PRIs32 "x%" SDL_PRIs32 ")", biWidth, biHeight);
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
2
externals/SDL/src/video/SDL_clipboard.c
vendored
2
externals/SDL/src/video/SDL_clipboard.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
226
externals/SDL/src/video/SDL_egl.c
vendored
226
externals/SDL/src/video/SDL_egl.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Simple DirectMedia Layer
|
||||
* Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
* Copyright (C) 1997-2021 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
|
||||
@@ -28,6 +28,7 @@
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
#include <android/native_window.h>
|
||||
#include "../core/android/SDL_android.h"
|
||||
#include "../video/android/SDL_androidvideo.h"
|
||||
#endif
|
||||
|
||||
#include "SDL_sysvideo.h"
|
||||
@@ -73,6 +74,7 @@
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //???
|
||||
|
||||
#elif defined(__OpenBSD__)
|
||||
/* OpenBSD */
|
||||
#define DEFAULT_OGL "libGL.so"
|
||||
#define DEFAULT_EGL "libEGL.so"
|
||||
#define DEFAULT_OGL_ES2 "libGLESv2.so"
|
||||
@@ -80,9 +82,10 @@
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
|
||||
|
||||
#else
|
||||
/* Desktop Linux */
|
||||
/* Desktop Linux/Unix-like */
|
||||
#define DEFAULT_OGL "libGL.so.1"
|
||||
#define DEFAULT_EGL "libEGL.so.1"
|
||||
#define ALT_OGL "libOpenGL.so.0"
|
||||
#define DEFAULT_OGL_ES2 "libGLESv2.so.2"
|
||||
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1"
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
|
||||
@@ -374,6 +377,12 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
else {
|
||||
path = DEFAULT_OGL;
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
#ifdef ALT_OGL
|
||||
if (egl_dll_handle == NULL) {
|
||||
path = ALT_OGL;
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -476,26 +485,28 @@ SDL_EGL_GetVersion(_THIS) {
|
||||
int
|
||||
SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform)
|
||||
{
|
||||
int egl_version_major, egl_version_minor;
|
||||
int library_load_retcode = SDL_EGL_LoadLibraryOnly(_this, egl_path);
|
||||
if (library_load_retcode != 0) {
|
||||
return library_load_retcode;
|
||||
}
|
||||
|
||||
/* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY */
|
||||
SDL_EGL_GetVersion(_this);
|
||||
|
||||
egl_version_major = _this->egl_data->egl_version_major;
|
||||
egl_version_minor = _this->egl_data->egl_version_minor;
|
||||
|
||||
if (egl_version_major == 1 && egl_version_minor == 5) {
|
||||
LOAD_FUNC(eglGetPlatformDisplay);
|
||||
}
|
||||
|
||||
_this->egl_data->egl_display = EGL_NO_DISPLAY;
|
||||
|
||||
#if !defined(__WINRT__)
|
||||
if (platform) {
|
||||
if (egl_version_major == 1 && egl_version_minor == 5) {
|
||||
/* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY
|
||||
* --
|
||||
* Khronos doc: "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS."
|
||||
* Therefore SDL_EGL_GetVersion() shouldn't work with uninitialized display.
|
||||
* - it actually doesn't work on Android that has 1.5 egl client
|
||||
* - it works on desktop X11 (using SDL_VIDEO_X11_FORCE_EGL=1) */
|
||||
SDL_EGL_GetVersion(_this);
|
||||
|
||||
if (_this->egl_data->egl_version_major == 1 && _this->egl_data->egl_version_minor == 5) {
|
||||
LOAD_FUNC(eglGetPlatformDisplay);
|
||||
}
|
||||
|
||||
if (_this->egl_data->eglGetPlatformDisplay) {
|
||||
_this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplay(platform, (void *)(size_t)native_display, NULL);
|
||||
} else {
|
||||
if (SDL_EGL_HasExtension(_this, SDL_EGL_CLIENT_EXTENSION, "EGL_EXT_platform_base")) {
|
||||
@@ -515,7 +526,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
||||
*_this->gl_config.driver_path = '\0';
|
||||
return SDL_SetError("Could not get EGL display");
|
||||
}
|
||||
|
||||
|
||||
if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) {
|
||||
_this->gl_config.driver_loaded = 0;
|
||||
*_this->gl_config.driver_path = '\0';
|
||||
@@ -634,7 +645,8 @@ typedef struct {
|
||||
char const* name;
|
||||
} Attribute;
|
||||
|
||||
Attribute attributes[] = {
|
||||
static
|
||||
Attribute all_attributes[] = {
|
||||
ATTRIBUTE( EGL_BUFFER_SIZE ),
|
||||
ATTRIBUTE( EGL_ALPHA_SIZE ),
|
||||
ATTRIBUTE( EGL_BLUE_SIZE ),
|
||||
@@ -674,31 +686,27 @@ Attribute attributes[] = {
|
||||
static void dumpconfig(_THIS, EGLConfig config)
|
||||
{
|
||||
int attr;
|
||||
for (attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
|
||||
for (attr = 0 ; attr<sizeof(all_attributes)/sizeof(Attribute) ; attr++) {
|
||||
EGLint value;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value);
|
||||
SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value);
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, all_attributes[attr].attribute, &value);
|
||||
SDL_Log("\t%-32s: %10d (0x%08x)\n", all_attributes[attr].name, value, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DUMP_EGL_CONFIG */
|
||||
|
||||
int
|
||||
SDL_EGL_ChooseConfig(_THIS)
|
||||
static int
|
||||
SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none)
|
||||
{
|
||||
/* 64 seems nice. */
|
||||
/* 64 seems nice. */
|
||||
EGLint attribs[64];
|
||||
EGLint found_configs = 0, value;
|
||||
/* 128 seems even nicer here */
|
||||
EGLConfig configs[128];
|
||||
SDL_bool has_matching_format = SDL_FALSE;
|
||||
int i, j, best_bitdiff = -1, bitdiff;
|
||||
|
||||
if (!_this->egl_data) {
|
||||
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
||||
return -1;
|
||||
}
|
||||
|
||||
int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1;
|
||||
int truecolor_config_idx = -1;
|
||||
|
||||
/* Get a valid EGL configuration */
|
||||
i = 0;
|
||||
attribs[i++] = EGL_RED_SIZE;
|
||||
@@ -707,30 +715,37 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
attribs[i++] = _this->gl_config.green_size;
|
||||
attribs[i++] = EGL_BLUE_SIZE;
|
||||
attribs[i++] = _this->gl_config.blue_size;
|
||||
|
||||
|
||||
if (set_config_caveat_none) {
|
||||
attribs[i++] = EGL_CONFIG_CAVEAT;
|
||||
attribs[i++] = EGL_NONE;
|
||||
}
|
||||
|
||||
if (_this->gl_config.alpha_size) {
|
||||
attribs[i++] = EGL_ALPHA_SIZE;
|
||||
attribs[i++] = _this->gl_config.alpha_size;
|
||||
}
|
||||
|
||||
|
||||
if (_this->gl_config.buffer_size) {
|
||||
attribs[i++] = EGL_BUFFER_SIZE;
|
||||
attribs[i++] = _this->gl_config.buffer_size;
|
||||
}
|
||||
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = _this->gl_config.depth_size;
|
||||
|
||||
|
||||
if (_this->gl_config.depth_size) {
|
||||
attribs[i++] = EGL_DEPTH_SIZE;
|
||||
attribs[i++] = _this->gl_config.depth_size;
|
||||
}
|
||||
|
||||
if (_this->gl_config.stencil_size) {
|
||||
attribs[i++] = EGL_STENCIL_SIZE;
|
||||
attribs[i++] = _this->gl_config.stencil_size;
|
||||
}
|
||||
|
||||
|
||||
if (_this->gl_config.multisamplebuffers) {
|
||||
attribs[i++] = EGL_SAMPLE_BUFFERS;
|
||||
attribs[i++] = _this->gl_config.multisamplebuffers;
|
||||
}
|
||||
|
||||
|
||||
if (_this->gl_config.multisamplesamples) {
|
||||
attribs[i++] = EGL_SAMPLES;
|
||||
attribs[i++] = _this->gl_config.multisamplesamples;
|
||||
@@ -767,24 +782,28 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
|
||||
attribs[i++] = EGL_NONE;
|
||||
|
||||
SDL_assert(i < SDL_arraysize(attribs));
|
||||
|
||||
if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display,
|
||||
attribs,
|
||||
configs, SDL_arraysize(configs),
|
||||
&found_configs) == EGL_FALSE ||
|
||||
found_configs == 0) {
|
||||
return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* first ensure that a found config has a matching format, or the function will fall through. */
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
if (_this->egl_data->egl_required_visual_id)
|
||||
{
|
||||
if (_this->egl_data->egl_required_visual_id)
|
||||
{
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
configs[i],
|
||||
EGL_NATIVE_VISUAL_ID, &format);
|
||||
if (_this->egl_data->egl_required_visual_id == format)
|
||||
if (_this->egl_data->egl_required_visual_id == format) {
|
||||
has_matching_format = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -792,22 +811,35 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
/* From those, we select the one that matches our requirements more closely via a makeshift algorithm */
|
||||
|
||||
for (i = 0; i < found_configs; i++ ) {
|
||||
if (has_matching_format && _this->egl_data->egl_required_visual_id)
|
||||
{
|
||||
SDL_bool is_truecolor = SDL_FALSE;
|
||||
int bitdiff = 0;
|
||||
|
||||
if (has_matching_format && _this->egl_data->egl_required_visual_id) {
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
configs[i],
|
||||
configs[i],
|
||||
EGL_NATIVE_VISUAL_ID, &format);
|
||||
if (_this->egl_data->egl_required_visual_id != format)
|
||||
if (_this->egl_data->egl_required_visual_id != format) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_RED_SIZE, &value);
|
||||
if (value == 8) {
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_GREEN_SIZE, &value);
|
||||
if (value == 8) {
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_BLUE_SIZE, &value);
|
||||
if (value == 8) {
|
||||
is_truecolor = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitdiff = 0;
|
||||
for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) {
|
||||
if (attribs[j] == EGL_NONE) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( attribs[j+1] != EGL_DONT_CARE && (
|
||||
attribs[j] == EGL_RED_SIZE ||
|
||||
attribs[j] == EGL_GREEN_SIZE ||
|
||||
@@ -820,24 +852,71 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
}
|
||||
}
|
||||
|
||||
if (bitdiff < best_bitdiff || best_bitdiff == -1) {
|
||||
if ((bitdiff < best_bitdiff) || (best_bitdiff == -1)) {
|
||||
_this->egl_data->egl_config = configs[i];
|
||||
|
||||
best_bitdiff = bitdiff;
|
||||
}
|
||||
|
||||
if (bitdiff == 0) {
|
||||
break; /* we found an exact match! */
|
||||
if (is_truecolor && ((bitdiff < best_truecolor_bitdiff) || (best_truecolor_bitdiff == -1))) {
|
||||
truecolor_config_idx = i;
|
||||
best_truecolor_bitdiff = bitdiff;
|
||||
}
|
||||
}
|
||||
|
||||
#define FAVOR_TRUECOLOR 1
|
||||
#if FAVOR_TRUECOLOR
|
||||
/* Some apps request a low color depth, either because they _assume_
|
||||
they'll get a larger one but don't want to fail if only smaller ones
|
||||
are available, or they just never called SDL_GL_SetAttribute at all and
|
||||
got a tiny default. For these cases, a game that would otherwise run
|
||||
at 24-bit color might get dithered down to something smaller, which is
|
||||
worth avoiding. If the app requested <= 16 bit color and an exact 24-bit
|
||||
match is available, favor that. Otherwise, we look for the closest
|
||||
match. Note that while the API promises what you request _or better_,
|
||||
it's feasible this can be disastrous for performance for custom software
|
||||
on small hardware that all expected to actually get 16-bit color. In this
|
||||
case, turn off FAVOR_TRUECOLOR (and maybe send a patch to make this more
|
||||
flexible). */
|
||||
if ( ((_this->gl_config.red_size + _this->gl_config.blue_size + _this->gl_config.green_size) <= 16) ) {
|
||||
if (truecolor_config_idx != -1) {
|
||||
_this->egl_data->egl_config = configs[truecolor_config_idx];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DUMP_EGL_CONFIG
|
||||
dumpconfig(_this, _this->egl_data->egl_config);
|
||||
#endif
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_EGL_ChooseConfig(_THIS)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!_this->egl_data) {
|
||||
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG */
|
||||
ret = SDL_EGL_PrivateChooseConfig(_this, SDL_TRUE);
|
||||
if (ret == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fallback with all configs */
|
||||
ret = SDL_EGL_PrivateChooseConfig(_this, SDL_FALSE);
|
||||
if (ret == 0) {
|
||||
SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig");
|
||||
}
|
||||
|
||||
SDL_GLContext
|
||||
SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
{
|
||||
@@ -1034,6 +1113,13 @@ SDL_EGL_SetSwapInterval(_THIS, int interval)
|
||||
if (!_this->egl_data) {
|
||||
return SDL_SetError("EGL not initialized");
|
||||
}
|
||||
|
||||
/* FIXME: Revisit this check when EGL_EXT_swap_control_tear is published:
|
||||
* https://github.com/KhronosGroup/EGL-Registry/pull/113
|
||||
*/
|
||||
if (interval < 0) {
|
||||
return SDL_SetError("Late swap tearing currently unsupported");
|
||||
}
|
||||
|
||||
status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval);
|
||||
if (status == EGL_TRUE) {
|
||||
@@ -1083,6 +1169,10 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
EGLSurface *
|
||||
SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
{
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
EGLint format_wanted;
|
||||
EGLint format_got;
|
||||
#endif
|
||||
/* max 2 values plus terminator. */
|
||||
EGLint attribs[3];
|
||||
int attr = 0;
|
||||
@@ -1092,24 +1182,18 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
if (SDL_EGL_ChooseConfig(_this) != 0) {
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
{
|
||||
/* Android docs recommend doing this!
|
||||
* Ref: http://developer.android.com/reference/android/app/NativeActivity.html
|
||||
*/
|
||||
EGLint format;
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
EGL_NATIVE_VISUAL_ID, &format);
|
||||
/* On Android, EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
|
||||
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). */
|
||||
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
EGL_NATIVE_VISUAL_ID, &format_wanted);
|
||||
|
||||
ANativeWindow_setBuffersGeometry(nw, 0, 0, format);
|
||||
/* Format based on selected egl config. */
|
||||
ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted);
|
||||
#endif
|
||||
|
||||
/* Update SurfaceView holder format.
|
||||
* May triggers a sequence surfaceDestroyed(), surfaceCreated(), surfaceChanged(). */
|
||||
Android_JNI_SetSurfaceViewFormat(format);
|
||||
}
|
||||
#endif
|
||||
if (_this->gl_config.framebuffer_srgb_capable) {
|
||||
#ifdef EGL_KHR_gl_colorspace
|
||||
if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) {
|
||||
@@ -1132,6 +1216,12 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
format_got = ANativeWindow_getFormat(nw);
|
||||
Android_SetFormat(format_wanted, format_got);
|
||||
#endif
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
2
externals/SDL/src/video/SDL_egl_c.h
vendored
2
externals/SDL/src/video/SDL_egl_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
4
externals/SDL/src/video/SDL_fillrect.c
vendored
4
externals/SDL/src/video/SDL_fillrect.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -28,7 +28,7 @@
|
||||
#ifdef __SSE__
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SSE_BEGIN \
|
||||
__m128 c128; \
|
||||
c128.m128_u32[0] = color; \
|
||||
|
2
externals/SDL/src/video/SDL_pixels.c
vendored
2
externals/SDL/src/video/SDL_pixels.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_pixels_c.h
vendored
2
externals/SDL/src/video/SDL_pixels_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_rect.c
vendored
2
externals/SDL/src/video/SDL_rect.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_rect_c.h
vendored
2
externals/SDL/src/video/SDL_rect_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_shape.c
vendored
2
externals/SDL/src/video/SDL_shape.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
1140
externals/SDL/src/video/SDL_stretch.c
vendored
1140
externals/SDL/src/video/SDL_stretch.c
vendored
File diff suppressed because it is too large
Load Diff
308
externals/SDL/src/video/SDL_surface.c
vendored
308
externals/SDL/src/video/SDL_surface.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_yuv_c.h"
|
||||
#include "../render/SDL_sysrender.h"
|
||||
|
||||
|
||||
/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */
|
||||
@@ -325,11 +326,12 @@ SDL_GetColorKey(SDL_Surface * surface, Uint32 * key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is a fairly slow function to switch from colorkey to alpha */
|
||||
/* This is a fairly slow function to switch from colorkey to alpha
|
||||
NB: it doesn't handle bpp 1 or 3, because they have no alpha channel */
|
||||
static void
|
||||
SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha)
|
||||
{
|
||||
int x, y;
|
||||
int x, y, bpp;
|
||||
|
||||
if (!surface) {
|
||||
return;
|
||||
@@ -340,82 +342,74 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha)
|
||||
return;
|
||||
}
|
||||
|
||||
bpp = surface->format->BytesPerPixel;
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
switch (surface->format->BytesPerPixel) {
|
||||
case 2:
|
||||
{
|
||||
Uint16 *row, *spot;
|
||||
Uint16 ckey = (Uint16) surface->map->info.colorkey;
|
||||
Uint16 mask = (Uint16) (~surface->format->Amask);
|
||||
if (bpp == 2) {
|
||||
Uint16 *row, *spot;
|
||||
Uint16 ckey = (Uint16) surface->map->info.colorkey;
|
||||
Uint16 mask = (Uint16) (~surface->format->Amask);
|
||||
|
||||
/* Ignore, or not, alpha in colorkey comparison */
|
||||
if (ignore_alpha) {
|
||||
ckey &= mask;
|
||||
row = (Uint16 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if ((*spot & mask) == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
++spot;
|
||||
/* Ignore, or not, alpha in colorkey comparison */
|
||||
if (ignore_alpha) {
|
||||
ckey &= mask;
|
||||
row = (Uint16 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if ((*spot & mask) == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
row += surface->pitch / 2;
|
||||
++spot;
|
||||
}
|
||||
} else {
|
||||
row = (Uint16 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if (*spot == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
++spot;
|
||||
row += surface->pitch / 2;
|
||||
}
|
||||
} else {
|
||||
row = (Uint16 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if (*spot == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
row += surface->pitch / 2;
|
||||
++spot;
|
||||
}
|
||||
row += surface->pitch / 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* FIXME */
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
Uint32 *row, *spot;
|
||||
Uint32 ckey = surface->map->info.colorkey;
|
||||
Uint32 mask = ~surface->format->Amask;
|
||||
} else if (bpp == 4) {
|
||||
Uint32 *row, *spot;
|
||||
Uint32 ckey = surface->map->info.colorkey;
|
||||
Uint32 mask = ~surface->format->Amask;
|
||||
|
||||
/* Ignore, or not, alpha in colorkey comparison */
|
||||
if (ignore_alpha) {
|
||||
ckey &= mask;
|
||||
row = (Uint32 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if ((*spot & mask) == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
++spot;
|
||||
/* Ignore, or not, alpha in colorkey comparison */
|
||||
if (ignore_alpha) {
|
||||
ckey &= mask;
|
||||
row = (Uint32 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if ((*spot & mask) == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
row += surface->pitch / 4;
|
||||
++spot;
|
||||
}
|
||||
} else {
|
||||
row = (Uint32 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if (*spot == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
++spot;
|
||||
row += surface->pitch / 4;
|
||||
}
|
||||
} else {
|
||||
row = (Uint32 *) surface->pixels;
|
||||
for (y = surface->h; y--;) {
|
||||
spot = row;
|
||||
for (x = surface->w; x--;) {
|
||||
if (*spot == ckey) {
|
||||
*spot &= mask;
|
||||
}
|
||||
row += surface->pitch / 4;
|
||||
++spot;
|
||||
}
|
||||
row += surface->pitch / 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
@@ -745,6 +739,14 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
int
|
||||
SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
return SDL_PrivateUpperBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
double src_x0, src_y0, src_x1, src_y1;
|
||||
double dst_x0, dst_y0, dst_x1, dst_y1;
|
||||
@@ -788,25 +790,25 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
if (NULL == dstrect) {
|
||||
dst_x0 = 0;
|
||||
dst_y0 = 0;
|
||||
dst_x1 = dst_w - 1;
|
||||
dst_y1 = dst_h - 1;
|
||||
dst_x1 = dst_w;
|
||||
dst_y1 = dst_h;
|
||||
} else {
|
||||
dst_x0 = dstrect->x;
|
||||
dst_y0 = dstrect->y;
|
||||
dst_x1 = dst_x0 + dst_w - 1;
|
||||
dst_y1 = dst_y0 + dst_h - 1;
|
||||
dst_x1 = dst_x0 + dst_w;
|
||||
dst_y1 = dst_y0 + dst_h;
|
||||
}
|
||||
|
||||
if (NULL == srcrect) {
|
||||
src_x0 = 0;
|
||||
src_y0 = 0;
|
||||
src_x1 = src_w - 1;
|
||||
src_y1 = src_h - 1;
|
||||
src_x1 = src_w;
|
||||
src_y1 = src_h;
|
||||
} else {
|
||||
src_x0 = srcrect->x;
|
||||
src_y0 = srcrect->y;
|
||||
src_x1 = src_x0 + src_w - 1;
|
||||
src_y1 = src_y0 + src_h - 1;
|
||||
src_x1 = src_x0 + src_w;
|
||||
src_y1 = src_y0 + src_h;
|
||||
|
||||
/* Clip source rectangle to the source surface */
|
||||
|
||||
@@ -815,9 +817,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
src_x0 = 0;
|
||||
}
|
||||
|
||||
if (src_x1 >= src->w) {
|
||||
dst_x1 -= (src_x1 - src->w + 1) * scaling_w;
|
||||
src_x1 = src->w - 1;
|
||||
if (src_x1 > src->w) {
|
||||
dst_x1 -= (src_x1 - src->w) * scaling_w;
|
||||
src_x1 = src->w;
|
||||
}
|
||||
|
||||
if (src_y0 < 0) {
|
||||
@@ -825,9 +827,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
src_y0 = 0;
|
||||
}
|
||||
|
||||
if (src_y1 >= src->h) {
|
||||
dst_y1 -= (src_y1 - src->h + 1) * scaling_h;
|
||||
src_y1 = src->h - 1;
|
||||
if (src_y1 > src->h) {
|
||||
dst_y1 -= (src_y1 - src->h) * scaling_h;
|
||||
src_y1 = src->h;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,9 +846,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
dst_x0 = 0;
|
||||
}
|
||||
|
||||
if (dst_x1 >= dst->clip_rect.w) {
|
||||
src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w;
|
||||
dst_x1 = dst->clip_rect.w - 1;
|
||||
if (dst_x1 > dst->clip_rect.w) {
|
||||
src_x1 -= (dst_x1 - dst->clip_rect.w) / scaling_w;
|
||||
dst_x1 = dst->clip_rect.w;
|
||||
}
|
||||
|
||||
if (dst_y0 < 0) {
|
||||
@@ -854,9 +856,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
dst_y0 = 0;
|
||||
}
|
||||
|
||||
if (dst_y1 >= dst->clip_rect.h) {
|
||||
src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h;
|
||||
dst_y1 = dst->clip_rect.h - 1;
|
||||
if (dst_y1 > dst->clip_rect.h) {
|
||||
src_y1 -= (dst_y1 - dst->clip_rect.h) / scaling_h;
|
||||
dst_y1 = dst->clip_rect.h;
|
||||
}
|
||||
|
||||
/* Translate back to surface coordinates */
|
||||
@@ -865,23 +867,32 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
dst_y0 += dst->clip_rect.y;
|
||||
dst_y1 += dst->clip_rect.y;
|
||||
|
||||
final_src.x = (int)SDL_floor(src_x0 + 0.5);
|
||||
final_src.y = (int)SDL_floor(src_y0 + 0.5);
|
||||
final_src.w = (int)SDL_floor(src_x1 + 1 + 0.5) - (int)SDL_floor(src_x0 + 0.5);
|
||||
final_src.h = (int)SDL_floor(src_y1 + 1 + 0.5) - (int)SDL_floor(src_y0 + 0.5);
|
||||
final_src.x = (int)SDL_round(src_x0);
|
||||
final_src.y = (int)SDL_round(src_y0);
|
||||
final_src.w = (int)SDL_round(src_x1 - src_x0);
|
||||
final_src.h = (int)SDL_round(src_y1 - src_y0);
|
||||
|
||||
final_dst.x = (int)SDL_floor(dst_x0 + 0.5);
|
||||
final_dst.y = (int)SDL_floor(dst_y0 + 0.5);
|
||||
final_dst.w = (int)SDL_floor(dst_x1 - dst_x0 + 1.5);
|
||||
final_dst.h = (int)SDL_floor(dst_y1 - dst_y0 + 1.5);
|
||||
final_dst.x = (int)SDL_round(dst_x0);
|
||||
final_dst.y = (int)SDL_round(dst_y0);
|
||||
final_dst.w = (int)SDL_round(dst_x1 - dst_x0);
|
||||
final_dst.h = (int)SDL_round(dst_y1 - dst_y0);
|
||||
|
||||
if (final_dst.w < 0)
|
||||
final_dst.w = 0;
|
||||
if (final_dst.h < 0)
|
||||
final_dst.h = 0;
|
||||
/* Clip again */
|
||||
{
|
||||
SDL_Rect tmp;
|
||||
tmp.x = 0;
|
||||
tmp.y = 0;
|
||||
tmp.w = src->w;
|
||||
tmp.h = src->h;
|
||||
SDL_IntersectRect(&tmp, &final_src, &final_src);
|
||||
}
|
||||
|
||||
if (dstrect)
|
||||
/* Clip again */
|
||||
SDL_IntersectRect(&dst->clip_rect, &final_dst, &final_dst);
|
||||
|
||||
if (dstrect) {
|
||||
*dstrect = final_dst;
|
||||
}
|
||||
|
||||
if (final_dst.w == 0 || final_dst.h == 0 ||
|
||||
final_src.w <= 0 || final_src.h <= 0) {
|
||||
@@ -889,7 +900,7 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst);
|
||||
return SDL_PrivateLowerBlitScaled(src, &final_src, dst, &final_dst, scaleMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -899,6 +910,13 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
int
|
||||
SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
return SDL_PrivateLowerBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
static const Uint32 complex_copy_flags = (
|
||||
SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA |
|
||||
@@ -906,17 +924,103 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect,
|
||||
SDL_COPY_COLORKEY
|
||||
);
|
||||
|
||||
if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 ||
|
||||
dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) {
|
||||
return SDL_SetError("Size too large for scaling");
|
||||
}
|
||||
|
||||
if (!(src->map->info.flags & SDL_COPY_NEAREST)) {
|
||||
src->map->info.flags |= SDL_COPY_NEAREST;
|
||||
SDL_InvalidateMap(src->map);
|
||||
}
|
||||
|
||||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
src->format->format == dst->format->format &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
|
||||
return SDL_SoftStretch( src, srcrect, dst, dstrect );
|
||||
if (scaleMode == SDL_ScaleModeNearest) {
|
||||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
src->format->format == dst->format->format &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) {
|
||||
return SDL_SoftStretch( src, srcrect, dst, dstrect );
|
||||
} else {
|
||||
return SDL_LowerBlit( src, srcrect, dst, dstrect );
|
||||
}
|
||||
} else {
|
||||
return SDL_LowerBlit( src, srcrect, dst, dstrect );
|
||||
if ( !(src->map->info.flags & complex_copy_flags) &&
|
||||
src->format->format == dst->format->format &&
|
||||
!SDL_ISPIXELFORMAT_INDEXED(src->format->format) &&
|
||||
src->format->BytesPerPixel == 4 &&
|
||||
src->format->format != SDL_PIXELFORMAT_ARGB2101010) {
|
||||
/* fast path */
|
||||
return SDL_SoftStretchLinear(src, srcrect, dst, dstrect);
|
||||
} else {
|
||||
/* Use intermediate surface(s) */
|
||||
SDL_Surface *tmp1 = NULL;
|
||||
int ret;
|
||||
SDL_Rect srcrect2;
|
||||
int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags);
|
||||
|
||||
Uint32 flags;
|
||||
Uint8 r, g, b;
|
||||
Uint8 alpha;
|
||||
SDL_BlendMode blendMode;
|
||||
|
||||
/* Save source infos */
|
||||
flags = src->flags;
|
||||
SDL_GetSurfaceColorMod(src, &r, &g, &b);
|
||||
SDL_GetSurfaceAlphaMod(src, &alpha);
|
||||
SDL_GetSurfaceBlendMode(src, &blendMode);
|
||||
srcrect2.x = srcrect->x;
|
||||
srcrect2.y = srcrect->y;
|
||||
srcrect2.w = srcrect->w;
|
||||
srcrect2.h = srcrect->h;
|
||||
|
||||
/* Change source format if not appropriate for scaling */
|
||||
if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
SDL_Rect tmprect;
|
||||
int fmt;
|
||||
tmprect.x = 0;
|
||||
tmprect.y = 0;
|
||||
tmprect.w = src->w;
|
||||
tmprect.h = src->h;
|
||||
if (dst->format->BytesPerPixel == 4 && dst->format->format != SDL_PIXELFORMAT_ARGB2101010) {
|
||||
fmt = dst->format->format;
|
||||
} else {
|
||||
fmt = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
tmp1 = SDL_CreateRGBSurfaceWithFormat(flags, src->w, src->h, 0, fmt);
|
||||
SDL_LowerBlit(src, srcrect, tmp1, &tmprect);
|
||||
|
||||
|
||||
srcrect2.x = 0;
|
||||
srcrect2.y = 0;
|
||||
SDL_SetSurfaceColorMod(tmp1, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(tmp1, alpha);
|
||||
SDL_SetSurfaceBlendMode(tmp1, blendMode);
|
||||
|
||||
src = tmp1;
|
||||
}
|
||||
|
||||
/* Intermediate scaling */
|
||||
if (is_complex_copy_flags || src->format->format != dst->format->format) {
|
||||
SDL_Rect tmprect;
|
||||
SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(flags, dstrect->w, dstrect->h, 0, src->format->format);
|
||||
SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL);
|
||||
|
||||
SDL_SetSurfaceColorMod(tmp2, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(tmp2, alpha);
|
||||
SDL_SetSurfaceBlendMode(tmp2, blendMode);
|
||||
|
||||
tmprect.x = 0;
|
||||
tmprect.y = 0;
|
||||
tmprect.w = dstrect->w;
|
||||
tmprect.h = dstrect->h;
|
||||
ret = SDL_LowerBlit(tmp2, &tmprect, dst, dstrect);
|
||||
SDL_FreeSurface(tmp2);
|
||||
} else {
|
||||
ret = SDL_SoftStretchLinear(src, &srcrect2, dst, dstrect);
|
||||
}
|
||||
|
||||
SDL_FreeSurface(tmp1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
7
externals/SDL/src/video/SDL_sysvideo.h
vendored
7
externals/SDL/src/video/SDL_sysvideo.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -229,10 +229,12 @@ struct SDL_VideoDevice
|
||||
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
|
||||
void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable);
|
||||
void (*SetWindowAlwaysOnTop) (_THIS, SDL_Window * window, SDL_bool on_top);
|
||||
void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void (*SetWindowMouseGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void (*SetWindowKeyboardGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void (*DestroyWindow) (_THIS, SDL_Window * window);
|
||||
int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch);
|
||||
int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects);
|
||||
@@ -427,6 +429,7 @@ extern VideoBootStrap PND_bootstrap;
|
||||
extern VideoBootStrap UIKIT_bootstrap;
|
||||
extern VideoBootStrap Android_bootstrap;
|
||||
extern VideoBootStrap PSP_bootstrap;
|
||||
extern VideoBootStrap VITA_bootstrap;
|
||||
extern VideoBootStrap RPI_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_bootstrap;
|
||||
extern VideoBootStrap KMSDRM_LEGACY_bootstrap;
|
||||
|
181
externals/SDL/src/video/SDL_video.c
vendored
181
externals/SDL/src/video/SDL_video.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -94,9 +94,11 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_PSP
|
||||
&PSP_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
&VITA_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_KMSDRM
|
||||
&KMSDRM_bootstrap,
|
||||
&KMSDRM_LEGACY_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RPI
|
||||
&RPI_bootstrap,
|
||||
@@ -1434,9 +1436,17 @@ SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags)
|
||||
if (flags & SDL_WINDOW_FULLSCREEN) {
|
||||
SDL_SetWindowFullscreen(window, flags);
|
||||
}
|
||||
if (flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
if (flags & SDL_WINDOW_MOUSE_GRABBED) {
|
||||
/* We must specifically call SDL_SetWindowGrab() and not
|
||||
SDL_SetWindowMouseGrab() here because older applications may use
|
||||
this flag plus SDL_HINT_GRAB_KEYBOARD to indicate that they want
|
||||
the keyboard grabbed too and SDL_SetWindowMouseGrab() won't do that.
|
||||
*/
|
||||
SDL_SetWindowGrab(window, SDL_TRUE);
|
||||
}
|
||||
if (flags & SDL_WINDOW_KEYBOARD_GRABBED) {
|
||||
SDL_SetWindowKeyboardGrab(window, SDL_TRUE);
|
||||
}
|
||||
if (!(flags & SDL_WINDOW_HIDDEN)) {
|
||||
SDL_ShowWindow(window);
|
||||
}
|
||||
@@ -1446,6 +1456,7 @@ SDL_Window *
|
||||
SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
{
|
||||
SDL_Window *window;
|
||||
Uint32 graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN);
|
||||
|
||||
if (!_this) {
|
||||
/* Initialize the video system if needed */
|
||||
@@ -1473,12 +1484,16 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Some platforms have OpenGL enabled by default */
|
||||
#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__
|
||||
if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !(flags & SDL_WINDOW_METAL) && !SDL_IsVideoContextExternal()) {
|
||||
/* Some platforms have certain graphics backends enabled by default */
|
||||
if (!_this->is_dummy && !graphics_flags && !SDL_IsVideoContextExternal()) {
|
||||
#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__)
|
||||
flags |= SDL_WINDOW_METAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
if (!_this->GL_CreateContext) {
|
||||
SDL_SetError("OpenGL support is either not configured in SDL "
|
||||
@@ -1498,7 +1513,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
"(%s) or platform", _this->name);
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
if (graphics_flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1514,11 +1529,12 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
"(%s) or platform", _this->name);
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
/* 'flags' may have default flags appended, don't check against that. */
|
||||
if (graphics_flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_SetError("Metal and OpenGL not supported on same window");
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_VULKAN) {
|
||||
if (graphics_flags & SDL_WINDOW_VULKAN) {
|
||||
SDL_SetError("Metal and Vulkan not supported on same window. "
|
||||
"To use MoltenVK, set SDL_WINDOW_VULKAN only.");
|
||||
return NULL;
|
||||
@@ -2093,6 +2109,25 @@ SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowAlwaysOnTop(SDL_Window * window, SDL_bool on_top)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
const int want = (on_top != SDL_FALSE); /* normalize the flag. */
|
||||
const int have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0);
|
||||
if ((want != have) && (_this->SetWindowAlwaysOnTop)) {
|
||||
if (want) {
|
||||
window->flags |= SDL_WINDOW_ALWAYS_ON_TOP;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP;
|
||||
}
|
||||
|
||||
_this->SetWindowAlwaysOnTop(_this, window, (SDL_bool) want);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||
{
|
||||
@@ -2635,31 +2670,46 @@ SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red,
|
||||
void
|
||||
SDL_UpdateWindowGrab(SDL_Window * window)
|
||||
{
|
||||
SDL_Window *grabbed_window;
|
||||
SDL_bool grabbed;
|
||||
if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) &&
|
||||
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
|
||||
grabbed = SDL_TRUE;
|
||||
SDL_bool keyboard_grabbed, mouse_grabbed;
|
||||
|
||||
if (window->flags & SDL_WINDOW_INPUT_FOCUS) {
|
||||
if (SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) {
|
||||
mouse_grabbed = SDL_TRUE;
|
||||
} else {
|
||||
mouse_grabbed = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_KEYBOARD_GRABBED) {
|
||||
keyboard_grabbed = SDL_TRUE;
|
||||
} else {
|
||||
keyboard_grabbed = SDL_FALSE;
|
||||
}
|
||||
} else {
|
||||
grabbed = SDL_FALSE;
|
||||
mouse_grabbed = SDL_FALSE;
|
||||
keyboard_grabbed = SDL_FALSE;
|
||||
}
|
||||
|
||||
grabbed_window = _this->grabbed_window;
|
||||
if (grabbed) {
|
||||
if (grabbed_window && (grabbed_window != window)) {
|
||||
if (mouse_grabbed || keyboard_grabbed) {
|
||||
if (_this->grabbed_window && (_this->grabbed_window != window)) {
|
||||
/* stealing a grab from another window! */
|
||||
grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
|
||||
if (_this->SetWindowGrab) {
|
||||
_this->SetWindowGrab(_this, grabbed_window, SDL_FALSE);
|
||||
_this->grabbed_window->flags &= ~(SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED);
|
||||
if (_this->SetWindowMouseGrab) {
|
||||
_this->SetWindowMouseGrab(_this, _this->grabbed_window, SDL_FALSE);
|
||||
}
|
||||
if (_this->SetWindowKeyboardGrab) {
|
||||
_this->SetWindowKeyboardGrab(_this, _this->grabbed_window, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
_this->grabbed_window = window;
|
||||
} else if (grabbed_window == window) {
|
||||
_this->grabbed_window = NULL; /* ungrabbing. */
|
||||
} else if (_this->grabbed_window == window) {
|
||||
_this->grabbed_window = NULL; /* ungrabbing input. */
|
||||
}
|
||||
|
||||
if (_this->SetWindowGrab) {
|
||||
_this->SetWindowGrab(_this, window, grabbed);
|
||||
if (_this->SetWindowMouseGrab) {
|
||||
_this->SetWindowMouseGrab(_this, window, mouse_grabbed);
|
||||
}
|
||||
if (_this->SetWindowKeyboardGrab) {
|
||||
_this->SetWindowKeyboardGrab(_this, window, keyboard_grabbed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2668,13 +2718,41 @@ SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
|
||||
if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
||||
SDL_SetWindowMouseGrab(window, grabbed);
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) {
|
||||
SDL_SetWindowKeyboardGrab(window, grabbed);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowKeyboardGrab(SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
|
||||
if (!!grabbed == !!(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) {
|
||||
return;
|
||||
}
|
||||
if (grabbed) {
|
||||
window->flags |= SDL_WINDOW_INPUT_GRABBED;
|
||||
window->flags |= SDL_WINDOW_KEYBOARD_GRABBED;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_INPUT_GRABBED;
|
||||
window->flags &= ~SDL_WINDOW_KEYBOARD_GRABBED;
|
||||
}
|
||||
SDL_UpdateWindowGrab(window);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SetWindowMouseGrab(SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window,);
|
||||
|
||||
if (!!grabbed == !!(window->flags & SDL_WINDOW_MOUSE_GRABBED)) {
|
||||
return;
|
||||
}
|
||||
if (grabbed) {
|
||||
window->flags |= SDL_WINDOW_MOUSE_GRABBED;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_MOUSE_GRABBED;
|
||||
}
|
||||
SDL_UpdateWindowGrab(window);
|
||||
}
|
||||
@@ -2683,14 +2761,34 @@ SDL_bool
|
||||
SDL_GetWindowGrab(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
||||
SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags & SDL_WINDOW_INPUT_GRABBED) != 0));
|
||||
SDL_assert(!_this->grabbed_window ||
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) ||
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0));
|
||||
return window == _this->grabbed_window;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_GetWindowKeyboardGrab(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
||||
return window == _this->grabbed_window &&
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0);
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_GetWindowMouseGrab(SDL_Window * window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, SDL_FALSE);
|
||||
return window == _this->grabbed_window &&
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0);
|
||||
}
|
||||
|
||||
SDL_Window *
|
||||
SDL_GetGrabbedWindow(void)
|
||||
{
|
||||
SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags & SDL_WINDOW_INPUT_GRABBED) != 0));
|
||||
SDL_assert(!_this->grabbed_window ||
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) ||
|
||||
((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0));
|
||||
return _this->grabbed_window;
|
||||
}
|
||||
|
||||
@@ -3963,14 +4061,20 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||
#if SDL_VIDEO_DRIVER_X11
|
||||
#include "x11/SDL_x11messagebox.h"
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||
#include "wayland/SDL_waylandmessagebox.h"
|
||||
#endif
|
||||
#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_VITA
|
||||
#include "vita/SDL_vitamessagebox.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 || SDL_VIDEO_DRIVER_OS2
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2
|
||||
static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype)
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
@@ -4069,6 +4173,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WAYLAND
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) &&
|
||||
Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_HAIKU
|
||||
if (retval == -1 &&
|
||||
SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) &&
|
||||
@@ -4082,6 +4193,12 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
OS2_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
if (retval == -1 &&
|
||||
VITA_ShowMessageBox(messageboxdata, buttonid) == 0) {
|
||||
retval = 0;
|
||||
}
|
||||
#endif
|
||||
if (retval == -1) {
|
||||
SDL_SetError("No message system available");
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
338
externals/SDL/src/video/SDL_vulkan_utils.c
vendored
338
externals/SDL/src/video/SDL_vulkan_utils.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -23,97 +23,97 @@
|
||||
#include "SDL_vulkan_internal.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
/* !!! FIXME: this file doesn't match coding standards for SDL (brace position, etc). */
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
|
||||
const char *SDL_Vulkan_GetResultString(VkResult result)
|
||||
{
|
||||
switch((int)result)
|
||||
{
|
||||
case VK_SUCCESS:
|
||||
return "VK_SUCCESS";
|
||||
case VK_NOT_READY:
|
||||
return "VK_NOT_READY";
|
||||
case VK_TIMEOUT:
|
||||
return "VK_TIMEOUT";
|
||||
case VK_EVENT_SET:
|
||||
return "VK_EVENT_SET";
|
||||
case VK_EVENT_RESET:
|
||||
return "VK_EVENT_RESET";
|
||||
case VK_INCOMPLETE:
|
||||
return "VK_INCOMPLETE";
|
||||
case VK_ERROR_OUT_OF_HOST_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_HOST_MEMORY";
|
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
|
||||
case VK_ERROR_INITIALIZATION_FAILED:
|
||||
return "VK_ERROR_INITIALIZATION_FAILED";
|
||||
case VK_ERROR_DEVICE_LOST:
|
||||
return "VK_ERROR_DEVICE_LOST";
|
||||
case VK_ERROR_MEMORY_MAP_FAILED:
|
||||
return "VK_ERROR_MEMORY_MAP_FAILED";
|
||||
case VK_ERROR_LAYER_NOT_PRESENT:
|
||||
return "VK_ERROR_LAYER_NOT_PRESENT";
|
||||
case VK_ERROR_EXTENSION_NOT_PRESENT:
|
||||
return "VK_ERROR_EXTENSION_NOT_PRESENT";
|
||||
case VK_ERROR_FEATURE_NOT_PRESENT:
|
||||
return "VK_ERROR_FEATURE_NOT_PRESENT";
|
||||
case VK_ERROR_INCOMPATIBLE_DRIVER:
|
||||
return "VK_ERROR_INCOMPATIBLE_DRIVER";
|
||||
case VK_ERROR_TOO_MANY_OBJECTS:
|
||||
return "VK_ERROR_TOO_MANY_OBJECTS";
|
||||
case VK_ERROR_FORMAT_NOT_SUPPORTED:
|
||||
return "VK_ERROR_FORMAT_NOT_SUPPORTED";
|
||||
case VK_ERROR_FRAGMENTED_POOL:
|
||||
return "VK_ERROR_FRAGMENTED_POOL";
|
||||
case VK_ERROR_UNKNOWN:
|
||||
return "VK_ERROR_UNKNOWN";
|
||||
case VK_ERROR_OUT_OF_POOL_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_POOL_MEMORY";
|
||||
case VK_ERROR_INVALID_EXTERNAL_HANDLE:
|
||||
return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
|
||||
case VK_ERROR_FRAGMENTATION:
|
||||
return "VK_ERROR_FRAGMENTATION";
|
||||
case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS:
|
||||
return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS";
|
||||
case VK_ERROR_SURFACE_LOST_KHR:
|
||||
return "VK_ERROR_SURFACE_LOST_KHR";
|
||||
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
|
||||
return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
|
||||
case VK_SUBOPTIMAL_KHR:
|
||||
return "VK_SUBOPTIMAL_KHR";
|
||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||
return "VK_ERROR_OUT_OF_DATE_KHR";
|
||||
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
|
||||
return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
|
||||
case VK_ERROR_VALIDATION_FAILED_EXT:
|
||||
return "VK_ERROR_VALIDATION_FAILED_EXT";
|
||||
case VK_ERROR_INVALID_SHADER_NV:
|
||||
return "VK_ERROR_INVALID_SHADER_NV";
|
||||
case VK_ERROR_INCOMPATIBLE_VERSION_KHR:
|
||||
return "VK_ERROR_INCOMPATIBLE_VERSION_KHR";
|
||||
case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT:
|
||||
return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT";
|
||||
case VK_ERROR_NOT_PERMITTED_EXT:
|
||||
return "VK_ERROR_NOT_PERMITTED_EXT";
|
||||
case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:
|
||||
return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT";
|
||||
case VK_THREAD_IDLE_KHR:
|
||||
return "VK_THREAD_IDLE_KHR";
|
||||
case VK_THREAD_DONE_KHR:
|
||||
return "VK_THREAD_DONE_KHR";
|
||||
case VK_OPERATION_DEFERRED_KHR:
|
||||
return "VK_OPERATION_DEFERRED_KHR";
|
||||
case VK_OPERATION_NOT_DEFERRED_KHR:
|
||||
return "VK_OPERATION_NOT_DEFERRED_KHR";
|
||||
case VK_PIPELINE_COMPILE_REQUIRED_EXT:
|
||||
return "VK_PIPELINE_COMPILE_REQUIRED_EXT";
|
||||
default:
|
||||
break;
|
||||
switch ((int)result) {
|
||||
case VK_SUCCESS:
|
||||
return "VK_SUCCESS";
|
||||
case VK_NOT_READY:
|
||||
return "VK_NOT_READY";
|
||||
case VK_TIMEOUT:
|
||||
return "VK_TIMEOUT";
|
||||
case VK_EVENT_SET:
|
||||
return "VK_EVENT_SET";
|
||||
case VK_EVENT_RESET:
|
||||
return "VK_EVENT_RESET";
|
||||
case VK_INCOMPLETE:
|
||||
return "VK_INCOMPLETE";
|
||||
case VK_ERROR_OUT_OF_HOST_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_HOST_MEMORY";
|
||||
case VK_ERROR_OUT_OF_DEVICE_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
|
||||
case VK_ERROR_INITIALIZATION_FAILED:
|
||||
return "VK_ERROR_INITIALIZATION_FAILED";
|
||||
case VK_ERROR_DEVICE_LOST:
|
||||
return "VK_ERROR_DEVICE_LOST";
|
||||
case VK_ERROR_MEMORY_MAP_FAILED:
|
||||
return "VK_ERROR_MEMORY_MAP_FAILED";
|
||||
case VK_ERROR_LAYER_NOT_PRESENT:
|
||||
return "VK_ERROR_LAYER_NOT_PRESENT";
|
||||
case VK_ERROR_EXTENSION_NOT_PRESENT:
|
||||
return "VK_ERROR_EXTENSION_NOT_PRESENT";
|
||||
case VK_ERROR_FEATURE_NOT_PRESENT:
|
||||
return "VK_ERROR_FEATURE_NOT_PRESENT";
|
||||
case VK_ERROR_INCOMPATIBLE_DRIVER:
|
||||
return "VK_ERROR_INCOMPATIBLE_DRIVER";
|
||||
case VK_ERROR_TOO_MANY_OBJECTS:
|
||||
return "VK_ERROR_TOO_MANY_OBJECTS";
|
||||
case VK_ERROR_FORMAT_NOT_SUPPORTED:
|
||||
return "VK_ERROR_FORMAT_NOT_SUPPORTED";
|
||||
case VK_ERROR_FRAGMENTED_POOL:
|
||||
return "VK_ERROR_FRAGMENTED_POOL";
|
||||
case VK_ERROR_UNKNOWN:
|
||||
return "VK_ERROR_UNKNOWN";
|
||||
case VK_ERROR_OUT_OF_POOL_MEMORY:
|
||||
return "VK_ERROR_OUT_OF_POOL_MEMORY";
|
||||
case VK_ERROR_INVALID_EXTERNAL_HANDLE:
|
||||
return "VK_ERROR_INVALID_EXTERNAL_HANDLE";
|
||||
case VK_ERROR_FRAGMENTATION:
|
||||
return "VK_ERROR_FRAGMENTATION";
|
||||
case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS:
|
||||
return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS";
|
||||
case VK_ERROR_SURFACE_LOST_KHR:
|
||||
return "VK_ERROR_SURFACE_LOST_KHR";
|
||||
case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
|
||||
return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
|
||||
case VK_SUBOPTIMAL_KHR:
|
||||
return "VK_SUBOPTIMAL_KHR";
|
||||
case VK_ERROR_OUT_OF_DATE_KHR:
|
||||
return "VK_ERROR_OUT_OF_DATE_KHR";
|
||||
case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
|
||||
return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
|
||||
case VK_ERROR_VALIDATION_FAILED_EXT:
|
||||
return "VK_ERROR_VALIDATION_FAILED_EXT";
|
||||
case VK_ERROR_INVALID_SHADER_NV:
|
||||
return "VK_ERROR_INVALID_SHADER_NV";
|
||||
#if VK_HEADER_VERSION >= 135 && VK_HEADER_VERSION < 162
|
||||
case VK_ERROR_INCOMPATIBLE_VERSION_KHR:
|
||||
return "VK_ERROR_INCOMPATIBLE_VERSION_KHR";
|
||||
#endif
|
||||
case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT:
|
||||
return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT";
|
||||
case VK_ERROR_NOT_PERMITTED_EXT:
|
||||
return "VK_ERROR_NOT_PERMITTED_EXT";
|
||||
case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:
|
||||
return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT";
|
||||
case VK_THREAD_IDLE_KHR:
|
||||
return "VK_THREAD_IDLE_KHR";
|
||||
case VK_THREAD_DONE_KHR:
|
||||
return "VK_THREAD_DONE_KHR";
|
||||
case VK_OPERATION_DEFERRED_KHR:
|
||||
return "VK_OPERATION_DEFERRED_KHR";
|
||||
case VK_OPERATION_NOT_DEFERRED_KHR:
|
||||
return "VK_OPERATION_NOT_DEFERRED_KHR";
|
||||
case VK_PIPELINE_COMPILE_REQUIRED_EXT:
|
||||
return "VK_PIPELINE_COMPILE_REQUIRED_EXT";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(result < 0)
|
||||
if (result < 0) {
|
||||
return "VK_ERROR_<Unknown>";
|
||||
}
|
||||
return "VK_<Unknown>";
|
||||
}
|
||||
|
||||
@@ -124,11 +124,9 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
Uint32 count = 0;
|
||||
VkResult result = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
|
||||
VkExtensionProperties *retval;
|
||||
if(result == VK_ERROR_INCOMPATIBLE_DRIVER)
|
||||
{
|
||||
/* Avoid the ERR_MAX_STRLEN limit by passing part of the message
|
||||
* as a string argument.
|
||||
*/
|
||||
|
||||
if (result == VK_ERROR_INCOMPATIBLE_DRIVER) {
|
||||
/* Avoid the ERR_MAX_STRLEN limit by passing part of the message as a string argument. */
|
||||
SDL_SetError(
|
||||
"You probably don't have a working Vulkan driver installed. %s %s %s(%d)",
|
||||
"Getting Vulkan extensions failed:",
|
||||
@@ -136,9 +134,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
SDL_Vulkan_GetResultString(result),
|
||||
(int)result);
|
||||
return NULL;
|
||||
}
|
||||
else if(result != VK_SUCCESS)
|
||||
{
|
||||
} else if (result != VK_SUCCESS) {
|
||||
SDL_SetError(
|
||||
"Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned "
|
||||
"%s(%d)",
|
||||
@@ -146,22 +142,20 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
|
||||
(int)result);
|
||||
return NULL;
|
||||
}
|
||||
if(count == 0)
|
||||
{
|
||||
|
||||
if (count == 0) {
|
||||
retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
retval = SDL_calloc(count, sizeof(VkExtensionProperties));
|
||||
}
|
||||
if(!retval)
|
||||
{
|
||||
|
||||
if (!retval) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = vkEnumerateInstanceExtensionProperties(NULL, &count, retval);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError(
|
||||
"Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned "
|
||||
"%s(%d)",
|
||||
@@ -186,6 +180,7 @@ SDL_bool SDL_Vulkan_GetInstanceExtensions_Helper(unsigned *userCount,
|
||||
SDL_SetError("Output array for SDL_Vulkan_GetInstanceExtensions needs to be at least %d big", nameCount);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < nameCount; i++) {
|
||||
userNames[i] = names[i];
|
||||
}
|
||||
@@ -226,55 +221,47 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
const char *chosenDisplayId;
|
||||
int displayId = 0; /* Counting from physical device 0, display 0 */
|
||||
|
||||
if(!vkEnumeratePhysicalDevices ||
|
||||
if (!vkEnumeratePhysicalDevices ||
|
||||
!vkGetPhysicalDeviceDisplayPropertiesKHR ||
|
||||
!vkGetDisplayModePropertiesKHR ||
|
||||
!vkGetPhysicalDeviceDisplayPlanePropertiesKHR ||
|
||||
!vkGetDisplayPlaneCapabilitiesKHR ||
|
||||
!vkGetDisplayPlaneSupportedDisplaysKHR ||
|
||||
!vkCreateDisplayPlaneSurfaceKHR)
|
||||
{
|
||||
SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME
|
||||
" extension is not enabled in the Vulkan instance.");
|
||||
!vkCreateDisplayPlaneSurfaceKHR) {
|
||||
SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance.");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY")) != NULL)
|
||||
{
|
||||
if ((chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY")) != NULL) {
|
||||
displayId = SDL_atoi(chosenDisplayId);
|
||||
}
|
||||
|
||||
/* Enumerate physical devices */
|
||||
result =
|
||||
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Could not enumerate Vulkan physical devices");
|
||||
goto error;
|
||||
}
|
||||
if(physicalDeviceCount == 0)
|
||||
{
|
||||
|
||||
if (physicalDeviceCount == 0) {
|
||||
SDL_SetError("No Vulkan physical devices");
|
||||
goto error;
|
||||
}
|
||||
|
||||
physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
|
||||
if(!physicalDevices)
|
||||
{
|
||||
if (!physicalDevices) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
result =
|
||||
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
|
||||
result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Error enumerating physical devices");
|
||||
goto error;
|
||||
}
|
||||
|
||||
for(physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount;
|
||||
physicalDeviceIndex++)
|
||||
{
|
||||
VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
|
||||
for (physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount; physicalDeviceIndex++) {
|
||||
VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
|
||||
uint32_t displayPropertiesCount = 0;
|
||||
VkDisplayPropertiesKHR *displayProperties = NULL;
|
||||
uint32_t displayModePropertiesCount = 0;
|
||||
@@ -290,32 +277,27 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
VkDisplayPlaneCapabilitiesKHR planeCaps;
|
||||
|
||||
/* Get information about the physical displays */
|
||||
result =
|
||||
vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL);
|
||||
if (result != VK_SUCCESS || displayPropertiesCount == 0)
|
||||
{
|
||||
result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL);
|
||||
if (result != VK_SUCCESS || displayPropertiesCount == 0) {
|
||||
/* This device has no physical device display properties, move on to next. */
|
||||
continue;
|
||||
}
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display properties for device %u: %u",
|
||||
physicalDeviceIndex, displayPropertiesCount);
|
||||
|
||||
if ( (displayId < 0) || (((uint32_t) displayId) >= displayPropertiesCount) )
|
||||
{
|
||||
if (displayId < 0 || (uint32_t) displayId >= displayPropertiesCount) {
|
||||
/* Display id specified was higher than number of available displays, move to next physical device. */
|
||||
displayId -= displayPropertiesCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount);
|
||||
if(!displayProperties)
|
||||
{
|
||||
if (!displayProperties) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
result =
|
||||
vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, displayProperties);
|
||||
result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, displayProperties);
|
||||
if (result != VK_SUCCESS || displayPropertiesCount == 0) {
|
||||
SDL_free(displayProperties);
|
||||
SDL_SetError("Error enumerating physical device displays");
|
||||
@@ -331,8 +313,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
displayProperties = NULL;
|
||||
|
||||
/* Get display mode properties for the chosen display */
|
||||
result =
|
||||
vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL);
|
||||
result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL);
|
||||
if (result != VK_SUCCESS || displayModePropertiesCount == 0)
|
||||
{
|
||||
SDL_SetError("Error enumerating display modes");
|
||||
@@ -341,14 +322,12 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount);
|
||||
|
||||
displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount);
|
||||
if(!displayModeProperties)
|
||||
{
|
||||
if (!displayModeProperties) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
result =
|
||||
vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, displayModeProperties);
|
||||
result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, displayModeProperties);
|
||||
if (result != VK_SUCCESS || displayModePropertiesCount == 0) {
|
||||
SDL_SetError("Error enumerating display modes");
|
||||
SDL_free(displayModeProperties);
|
||||
@@ -356,18 +335,16 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
}
|
||||
|
||||
/* Try to find a display mode that matches the native resolution */
|
||||
for (i = 0; i < displayModePropertiesCount; ++i)
|
||||
{
|
||||
for (i = 0; i < displayModePropertiesCount; ++i) {
|
||||
if (displayModeProperties[i].parameters.visibleRegion.width == extent.width &&
|
||||
displayModeProperties[i].parameters.visibleRegion.height == extent.height &&
|
||||
displayModeProperties[i].parameters.refreshRate > refreshRate)
|
||||
{
|
||||
displayModeProperties[i].parameters.refreshRate > refreshRate) {
|
||||
bestMatchIndex = i;
|
||||
refreshRate = displayModeProperties[i].parameters.refreshRate;
|
||||
}
|
||||
}
|
||||
if (bestMatchIndex < 0)
|
||||
{
|
||||
|
||||
if (bestMatchIndex < 0) {
|
||||
SDL_SetError("Found no matching display mode");
|
||||
SDL_free(displayModeProperties);
|
||||
goto error;
|
||||
@@ -384,62 +361,53 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
displayModeProperties = NULL;
|
||||
|
||||
/* Try to find a plane index that supports our display */
|
||||
result =
|
||||
vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL);
|
||||
if (result != VK_SUCCESS || displayPlanePropertiesCount == 0)
|
||||
{
|
||||
result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL);
|
||||
if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) {
|
||||
SDL_SetError("Error enumerating display planes");
|
||||
goto error;
|
||||
}
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount);
|
||||
|
||||
displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount);
|
||||
if(!displayPlaneProperties)
|
||||
{
|
||||
if (!displayPlaneProperties) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
result =
|
||||
vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, displayPlaneProperties);
|
||||
if (result != VK_SUCCESS || displayPlanePropertiesCount == 0)
|
||||
{
|
||||
result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, displayPlaneProperties);
|
||||
if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) {
|
||||
SDL_SetError("Error enumerating display plane properties");
|
||||
SDL_free(displayPlaneProperties);
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0; i < displayPlanePropertiesCount; ++i)
|
||||
{
|
||||
for (i = 0; i < displayPlanePropertiesCount; ++i) {
|
||||
uint32_t planeSupportedDisplaysCount = 0;
|
||||
VkDisplayKHR *planeSupportedDisplays = NULL;
|
||||
uint32_t j;
|
||||
|
||||
/* Check if plane is attached to a display, if not, continue. */
|
||||
if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE)
|
||||
if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check supported displays for this plane. */
|
||||
result =
|
||||
vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL);
|
||||
if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0)
|
||||
{
|
||||
result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL);
|
||||
if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) {
|
||||
continue; /* No supported displays, on to next plane. */
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount);
|
||||
|
||||
planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount);
|
||||
if(!planeSupportedDisplays)
|
||||
{
|
||||
if (!planeSupportedDisplays) {
|
||||
SDL_free(displayPlaneProperties);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
result =
|
||||
vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, planeSupportedDisplays);
|
||||
if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0)
|
||||
{
|
||||
result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, planeSupportedDisplays);
|
||||
if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) {
|
||||
SDL_SetError("Error enumerating supported displays, or no supported displays");
|
||||
SDL_free(planeSupportedDisplays);
|
||||
SDL_free(displayPlaneProperties);
|
||||
@@ -447,20 +415,19 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
}
|
||||
|
||||
for (j = 0; j < planeSupportedDisplaysCount && planeSupportedDisplays[j] != display; ++j)
|
||||
;
|
||||
{
|
||||
}
|
||||
|
||||
SDL_free(planeSupportedDisplays);
|
||||
planeSupportedDisplays = NULL;
|
||||
|
||||
if (j == planeSupportedDisplaysCount)
|
||||
{
|
||||
if (j == planeSupportedDisplaysCount) {
|
||||
/* This display is not supported for this plane, move on. */
|
||||
continue;
|
||||
}
|
||||
|
||||
result = vkGetDisplayPlaneCapabilitiesKHR(physicalDevice, createInfo.displayMode, i, &planeCaps);
|
||||
if (result != VK_SUCCESS)
|
||||
{
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("Error getting display plane capabilities");
|
||||
SDL_free(displayPlaneProperties);
|
||||
goto error;
|
||||
@@ -468,8 +435,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
|
||||
/* Check if plane fulfills extent requirements. */
|
||||
if (extent.width >= planeCaps.minDstExtent.width && extent.height >= planeCaps.minDstExtent.height &&
|
||||
extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height)
|
||||
{
|
||||
extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) {
|
||||
/* If it does, choose this plane. */
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Choosing plane %d, minimum extent %dx%d maximum extent %dx%d", i,
|
||||
planeCaps.minDstExtent.width, planeCaps.minDstExtent.height,
|
||||
@@ -479,8 +445,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
}
|
||||
}
|
||||
|
||||
if (planeIndex < 0)
|
||||
{
|
||||
if (planeIndex < 0) {
|
||||
SDL_SetError("No plane supports the selected resolution");
|
||||
SDL_free(displayPlaneProperties);
|
||||
goto error;
|
||||
@@ -509,8 +474,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
SDL_free(physicalDevices);
|
||||
physicalDevices = NULL;
|
||||
|
||||
if (physicalDeviceIndex == physicalDeviceCount)
|
||||
{
|
||||
if (physicalDeviceIndex == physicalDeviceCount) {
|
||||
SDL_SetError("No usable displays found or requested display out of range");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -519,16 +483,14 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
|
||||
createInfo.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
createInfo.globalAlpha = 1.0f;
|
||||
|
||||
result = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo,
|
||||
NULL, surface);
|
||||
if(result != VK_SUCCESS)
|
||||
{
|
||||
SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s",
|
||||
SDL_Vulkan_GetResultString(result));
|
||||
result = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo, NULL, surface);
|
||||
if (result != VK_SUCCESS) {
|
||||
SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result));
|
||||
return SDL_FALSE;
|
||||
}
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Created surface");
|
||||
return SDL_TRUE;
|
||||
|
||||
error:
|
||||
SDL_free(physicalDevices);
|
||||
return SDL_FALSE;
|
||||
|
2
externals/SDL/src/video/SDL_yuv.c
vendored
2
externals/SDL/src/video/SDL_yuv.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
2
externals/SDL/src/video/SDL_yuv_c.h
vendored
2
externals/SDL/src/video/SDL_yuv_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -48,6 +48,16 @@ static void openslES_ResumeDevices(void) {}
|
||||
static void openslES_PauseDevices(void) {}
|
||||
#endif
|
||||
|
||||
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO
|
||||
extern void aaudio_ResumeDevices(void);
|
||||
extern void aaudio_PauseDevices(void);
|
||||
#else
|
||||
static void aaudio_ResumeDevices(void) {}
|
||||
static void aaudio_PauseDevices(void) {}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Number of 'type' events in the event queue */
|
||||
static int
|
||||
SDL_NumberOfEvents(Uint32 type)
|
||||
@@ -110,6 +120,7 @@ Android_PumpEvents_Blocking(_THIS)
|
||||
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
openslES_PauseDevices();
|
||||
aaudio_PauseDevices();
|
||||
|
||||
if (SDL_SemWait(Android_ResumeSem) == 0) {
|
||||
|
||||
@@ -122,6 +133,7 @@ Android_PumpEvents_Blocking(_THIS)
|
||||
|
||||
ANDROIDAUDIO_ResumeDevices();
|
||||
openslES_ResumeDevices();
|
||||
aaudio_ResumeDevices();
|
||||
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
||||
@@ -178,6 +190,7 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
if (videodata->pauseAudio) {
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
openslES_PauseDevices();
|
||||
aaudio_PauseDevices();
|
||||
}
|
||||
|
||||
backup_context = 0;
|
||||
@@ -196,6 +209,7 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
if (videodata->pauseAudio) {
|
||||
ANDROIDAUDIO_ResumeDevices();
|
||||
openslES_ResumeDevices();
|
||||
aaudio_ResumeDevices();
|
||||
}
|
||||
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -69,7 +69,7 @@ Android_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
|
||||
/* The following two calls existed in the original Java code
|
||||
* If you happen to have a device that's affected by their removal,
|
||||
* please report to Bugzilla. -- Gabriel
|
||||
* please report to our bug tracker. -- Gabriel
|
||||
*/
|
||||
|
||||
/*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -64,7 +64,7 @@ int Android_SurfaceWidth = 0;
|
||||
int Android_SurfaceHeight = 0;
|
||||
static int Android_DeviceWidth = 0;
|
||||
static int Android_DeviceHeight = 0;
|
||||
static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN;
|
||||
static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; /* Default SurfaceView format, in case this is queried before being filled */
|
||||
static int Android_ScreenRate = 0;
|
||||
SDL_sem *Android_PauseSem = NULL;
|
||||
SDL_sem *Android_ResumeSem = NULL;
|
||||
@@ -194,7 +194,7 @@ Android_VideoInit(_THIS)
|
||||
return -1;
|
||||
}
|
||||
display = SDL_GetDisplay(display_index);
|
||||
display->orientation = Android_JNI_GetDisplayOrientation();
|
||||
display->orientation = Android_JNI_GetDisplayOrientation();
|
||||
|
||||
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||
|
||||
@@ -222,16 +222,54 @@ Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi
|
||||
}
|
||||
|
||||
void
|
||||
Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate)
|
||||
Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate)
|
||||
{
|
||||
Android_SurfaceWidth = surfaceWidth;
|
||||
Android_SurfaceHeight = surfaceHeight;
|
||||
Android_DeviceWidth = deviceWidth;
|
||||
Android_DeviceHeight = deviceHeight;
|
||||
Android_ScreenFormat = format;
|
||||
Android_ScreenRate = (int)rate;
|
||||
}
|
||||
|
||||
static
|
||||
Uint32 format_to_pixelFormat(int format) {
|
||||
Uint32 pf;
|
||||
if (format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) { /* 1 */
|
||||
pf = SDL_PIXELFORMAT_RGBA8888;
|
||||
} else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) { /* 2 */
|
||||
pf = SDL_PIXELFORMAT_RGBX8888;
|
||||
} else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM) { /* 3 */
|
||||
pf = SDL_PIXELFORMAT_RGB24;
|
||||
} else if (format == AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM) { /* 4*/
|
||||
pf = SDL_PIXELFORMAT_RGB565;
|
||||
} else if (format == 5) {
|
||||
pf = SDL_PIXELFORMAT_BGRA8888;
|
||||
} else if (format == 6) {
|
||||
pf = SDL_PIXELFORMAT_RGBA5551;
|
||||
} else if (format == 7) {
|
||||
pf = SDL_PIXELFORMAT_RGBA4444;
|
||||
} else {
|
||||
pf = SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
return pf;
|
||||
}
|
||||
|
||||
void
|
||||
Android_SetFormat(int format_wanted, int format_got)
|
||||
{
|
||||
Uint32 pf_wanted;
|
||||
Uint32 pf_got;
|
||||
|
||||
pf_wanted = format_to_pixelFormat(format_wanted);
|
||||
pf_got = format_to_pixelFormat(format_got);
|
||||
|
||||
Android_ScreenFormat = pf_got;
|
||||
|
||||
SDL_Log("pixel format wanted %s (%d), got %s (%d)",
|
||||
SDL_GetPixelFormatName(pf_wanted), format_wanted,
|
||||
SDL_GetPixelFormatName(pf_got), format_got);
|
||||
}
|
||||
|
||||
void Android_SendResize(SDL_Window *window)
|
||||
{
|
||||
/*
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -28,7 +28,8 @@
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* 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_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate);
|
||||
extern void Android_SetFormat(int format_wanted, int format_got);
|
||||
extern void Android_SendResize(SDL_Window *window);
|
||||
|
||||
/* Private display data */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
50
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
50
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -36,6 +36,21 @@
|
||||
#define NSAppKitVersionNumber10_8 1187
|
||||
#endif
|
||||
|
||||
static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
|
||||
{
|
||||
SDL_Window *sdlwindow = NULL;
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows) {
|
||||
for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) {
|
||||
NSWindow *nswindow = ((SDL_WindowData *) sdlwindow->driverdata)->nswindow;
|
||||
if (win == nswindow)
|
||||
return sdlwindow;
|
||||
}
|
||||
}
|
||||
|
||||
return sdlwindow;
|
||||
}
|
||||
|
||||
@interface SDLApplication : NSApplication
|
||||
|
||||
- (void)terminate:(id)sender;
|
||||
@@ -158,6 +173,13 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
[center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil];
|
||||
[center removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil];
|
||||
|
||||
/* Remove our URL event handler only if we set it */
|
||||
if ([NSApp delegate] == self) {
|
||||
[[NSAppleEventManager sharedAppleEventManager]
|
||||
removeEventHandlerForEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -169,6 +191,10 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Don't do anything if this was not an SDL window that was closed */
|
||||
if (FindSDLWindowForNSWindow(win) == NULL)
|
||||
return;
|
||||
|
||||
/* HACK: Make the next window in the z-order key when the key window is
|
||||
* closed. The custom event loop and/or windowing code we have seems to
|
||||
* prevent the normal behavior: https://bugzilla.libsdl.org/show_bug.cgi?id=1825
|
||||
@@ -213,6 +239,13 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Don't do anything if the application already has a key window
|
||||
* that is not an SDL window.
|
||||
*/
|
||||
if ([NSApp keyWindow] && FindSDLWindowForNSWindow([NSApp keyWindow]) == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows) {
|
||||
SDL_Window *window = device->windows;
|
||||
@@ -262,12 +295,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
}
|
||||
|
||||
[[NSAppleEventManager sharedAppleEventManager]
|
||||
setEventHandler:self
|
||||
andSelector:@selector(handleURLEvent:withReplyEvent:)
|
||||
forEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
|
||||
/* If we call this before NSApp activation, macOS might print a complaint
|
||||
* about ApplePersistenceIgnoreState. */
|
||||
[SDLApplication registerUserDefaults];
|
||||
@@ -469,6 +496,15 @@ Cocoa_RegisterApp(void)
|
||||
* termination into SDL_Quit, and we can't handle application:openFile:
|
||||
*/
|
||||
if (![NSApp delegate]) {
|
||||
/* Only register the URL event handler if we are being set as the
|
||||
* app delegate to avoid replacing any existing event handler.
|
||||
*/
|
||||
[[NSAppleEventManager sharedAppleEventManager]
|
||||
setEventHandler:appDelegate
|
||||
andSelector:@selector(handleURLEvent:withReplyEvent:)
|
||||
forEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
|
||||
[(NSApplication *)NSApp setDelegate:appDelegate];
|
||||
} else {
|
||||
appDelegate->seenFirstActivate = YES;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -172,8 +172,8 @@ void
|
||||
Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *view = data->nswindow.contentView;
|
||||
SDL_cocoametalview* metalview = [view viewWithTag:METALVIEW_TAG];
|
||||
NSView *contentView = data->sdlContentView;
|
||||
SDL_cocoametalview* metalview = [contentView viewWithTag:METALVIEW_TAG];
|
||||
if (metalview) {
|
||||
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
|
||||
SDL_assert(layer != NULL);
|
||||
@@ -184,7 +184,21 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
*h = layer.drawableSize.height;
|
||||
}
|
||||
} else {
|
||||
SDL_GetWindowSize(window, w, h);
|
||||
/* Fall back to the viewport size. */
|
||||
NSRect viewport = [contentView bounds];
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
/* This gives us the correct viewport for a Retina-enabled view, only
|
||||
* supported on 10.7+. */
|
||||
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
|
||||
viewport = [contentView convertRectToBacking:viewport];
|
||||
}
|
||||
}
|
||||
if (w) {
|
||||
*w = viewport.size.width;
|
||||
}
|
||||
if (h) {
|
||||
*h = viewport.size.height;
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -40,7 +40,6 @@ typedef struct {
|
||||
/* What location we last saw the cursor move to. */
|
||||
CGFloat lastMoveX;
|
||||
CGFloat lastMoveY;
|
||||
void *tapdata;
|
||||
} SDL_MouseData;
|
||||
|
||||
@interface NSCursor (InvisibleCursor)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_cocoamouse.h"
|
||||
#include "SDL_cocoamousetap.h"
|
||||
#include "SDL_cocoavideo.h"
|
||||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
@@ -348,8 +347,6 @@ Cocoa_InitMouse(_THIS)
|
||||
|
||||
SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor());
|
||||
|
||||
Cocoa_InitMouseEventTap(driverdata);
|
||||
|
||||
const NSPoint location = [NSEvent mouseLocation];
|
||||
driverdata->lastMoveX = location.x;
|
||||
driverdata->lastMoveY = location.y;
|
||||
@@ -467,8 +464,6 @@ Cocoa_QuitMouse(_THIS)
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (mouse) {
|
||||
if (mouse->driverdata) {
|
||||
Cocoa_QuitMouseEventTap(((SDL_MouseData*)mouse->driverdata));
|
||||
|
||||
SDL_free(mouse->driverdata);
|
||||
mouse->driverdata = NULL;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -135,7 +135,7 @@
|
||||
if ([NSThread isMainThread]) {
|
||||
[super update];
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; });
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [super update]; });
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
10
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
10
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -92,10 +92,11 @@ Cocoa_CreateDevice(int devindex)
|
||||
device->RestoreWindow = Cocoa_RestoreWindow;
|
||||
device->SetWindowBordered = Cocoa_SetWindowBordered;
|
||||
device->SetWindowResizable = Cocoa_SetWindowResizable;
|
||||
device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop;
|
||||
device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
|
||||
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
|
||||
device->SetWindowGrab = Cocoa_SetWindowGrab;
|
||||
device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab;
|
||||
device->DestroyWindow = Cocoa_DestroyWindow;
|
||||
device->GetWindowWMInfo = Cocoa_GetWindowWMInfo;
|
||||
device->SetWindowHitTest = Cocoa_SetWindowHitTest;
|
||||
@@ -260,7 +261,10 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||
|
||||
void SDL_NSLog(const char *text)
|
||||
{
|
||||
NSLog(@"%s", text);
|
||||
@autoreleasepool {
|
||||
NSString *str = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", str);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -142,10 +142,11 @@ extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
|
||||
extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
|
||||
extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
||||
extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable);
|
||||
extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top);
|
||||
extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||
extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info);
|
||||
extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
||||
|
45
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
45
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "SDL_cocoavideo.h"
|
||||
#include "SDL_cocoashape.h"
|
||||
#include "SDL_cocoamouse.h"
|
||||
#include "SDL_cocoamousetap.h"
|
||||
#include "SDL_cocoaopengl.h"
|
||||
#include "SDL_cocoaopengles.h"
|
||||
|
||||
@@ -161,6 +160,16 @@
|
||||
SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]);
|
||||
NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"];
|
||||
|
||||
/* Code addon to update the mouse location */
|
||||
NSPoint point = [sender draggingLocation];
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
int x = (int)point.x;
|
||||
int y = (int)(sdlwindow->h - point.y);
|
||||
if (x >= 0 && x < sdlwindow->w && y >= 0 && y < sdlwindow->h) {
|
||||
SDL_SendMouseMotion(sdlwindow, mouse->mouseID, 0, x, y);
|
||||
}
|
||||
/* Code addon to update the mouse location */
|
||||
|
||||
for (NSString *path in array) {
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:path];
|
||||
NSNumber *isAlias = nil;
|
||||
@@ -1099,7 +1108,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
x = (int)point.x;
|
||||
y = (int)(window->h - point.y);
|
||||
|
||||
if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
|
||||
if (window->flags & SDL_WINDOW_MOUSE_GRABBED) {
|
||||
if (x < 0 || x >= window->w || y < 0 || y >= window->h) {
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
@@ -1112,13 +1121,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
y = window->h - 1;
|
||||
}
|
||||
|
||||
#if !SDL_MAC_NO_SANDBOX
|
||||
CGPoint cgpoint;
|
||||
|
||||
/* When SDL_MAC_NO_SANDBOX is set, this is handled by
|
||||
* SDL_cocoamousetap.m.
|
||||
*/
|
||||
|
||||
cgpoint.x = window->x + x;
|
||||
cgpoint.y = window->y + y;
|
||||
|
||||
@@ -1126,7 +1129,6 @@ SetWindowStyle(SDL_Window * window, NSUInteger style)
|
||||
CGAssociateMouseAndMouseCursorPosition(YES);
|
||||
|
||||
Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1403,7 +1405,10 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview,
|
||||
{
|
||||
unsigned long style = [nswindow styleMask];
|
||||
|
||||
if (style == NSWindowStyleMaskBorderless) {
|
||||
/* NSWindowStyleMaskBorderless is zero, and it's possible to be
|
||||
Resizeable _and_ borderless, so we can't do a simple bitwise AND
|
||||
of NSWindowStyleMaskBorderless here. */
|
||||
if ((style & ~NSWindowStyleMaskResizable) == NSWindowStyleMaskBorderless) {
|
||||
window->flags |= SDL_WINDOW_BORDERLESS;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_BORDERLESS;
|
||||
@@ -1809,6 +1814,18 @@ Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
if (on_top) {
|
||||
[nswindow setLevel:NSFloatingWindowLevel];
|
||||
} else {
|
||||
[nswindow setLevel:kCGNormalWindowLevel];
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
|
||||
{ @autoreleasepool
|
||||
@@ -1948,14 +1965,10 @@ Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp)
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
/* Enable or disable the event tap as necessary */
|
||||
Cocoa_EnableMouseEventTap(mouse->driverdata, grabbed);
|
||||
|
||||
/* Move the cursor to the nearest point in the window */
|
||||
if (grabbed && data && ![data->listener isMoving]) {
|
||||
int x, y;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -287,9 +287,8 @@ WMPos(DFB_WindowData * p, int x, int y)
|
||||
int
|
||||
DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
|
||||
SDL_Window *grabbed_window = SDL_GetGrabbedWindow();
|
||||
IDirectFBWindow *dfbwin = windata->dfbwin;
|
||||
DFBWindowOptions wopts;
|
||||
|
||||
@@ -327,9 +326,9 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
/* fall through */
|
||||
default:
|
||||
windata->wm_grab = pos;
|
||||
if (gwindata != NULL)
|
||||
SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
|
||||
SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin));
|
||||
if (grabbed_window != NULL)
|
||||
DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE);
|
||||
DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE);
|
||||
windata->wm_lastx = evt->cx;
|
||||
windata->wm_lasty = evt->cy;
|
||||
}
|
||||
@@ -359,9 +358,9 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||
SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
|
||||
}
|
||||
}
|
||||
SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin));
|
||||
if (gwindata != NULL)
|
||||
SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin));
|
||||
DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE);
|
||||
if (grabbed_window != NULL)
|
||||
DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE);
|
||||
windata->wm_grab = WM_POS_NONE;
|
||||
return 1;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -212,7 +212,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
|
||||
case DWET_MOTION:
|
||||
if (ClientXY(windata, &evt->x, &evt->y)) {
|
||||
if (!devdata->use_linux_input) {
|
||||
if (!(sdlwin->flags & SDL_WINDOW_INPUT_GRABBED))
|
||||
if (!(sdlwin->flags & SDL_WINDOW_MOUSE_GRABBED))
|
||||
SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0,
|
||||
evt->x, evt->y, 0);
|
||||
} else {
|
||||
@@ -312,15 +312,16 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
||||
int kbd_idx;
|
||||
Uint32 unicode;
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
SDL_Window* grabbed_window = SDL_GetGrabbedWindow();
|
||||
|
||||
if (!devdata->use_linux_input) {
|
||||
if (ievt->type == DIET_AXISMOTION) {
|
||||
if ((devdata->grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) {
|
||||
if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) {
|
||||
if (ievt->axis == DIAI_X)
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
|
||||
SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1,
|
||||
ievt->axisrel, 0, 0);
|
||||
else if (ievt->axis == DIAI_Y)
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
|
||||
SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, 0,
|
||||
ievt->axisrel, 0);
|
||||
}
|
||||
}
|
||||
@@ -339,7 +340,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
||||
SDL_Mouse *mouse = SDL_GetMouse(ievt->device_id);
|
||||
SDL_Window *window = SDL_GetWindowFromID(mouse->focus);
|
||||
#else
|
||||
SDL_Window *window = devdata->grabbed_window;
|
||||
SDL_Window *window = grabbed_window;
|
||||
#endif
|
||||
if (window) {
|
||||
DFB_WindowData *windata =
|
||||
@@ -359,10 +360,10 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
||||
}
|
||||
} else if (ievt->flags & DIEF_AXISREL) {
|
||||
if (ievt->axis == DIAI_X)
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1,
|
||||
SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1,
|
||||
ievt->axisrel, 0, 0);
|
||||
else if (ievt->axis == DIAI_Y)
|
||||
SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0,
|
||||
SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, 0,
|
||||
ievt->axisrel, 0);
|
||||
}
|
||||
break;
|
||||
@@ -386,19 +387,19 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
||||
break;
|
||||
case DIET_BUTTONPRESS:
|
||||
if (ievt->buttons & DIBM_LEFT)
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 1);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 1);
|
||||
if (ievt->buttons & DIBM_MIDDLE)
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 2);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 2);
|
||||
if (ievt->buttons & DIBM_RIGHT)
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 3);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 3);
|
||||
break;
|
||||
case DIET_BUTTONRELEASE:
|
||||
if (!(ievt->buttons & DIBM_LEFT))
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 1);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 1);
|
||||
if (!(ievt->buttons & DIBM_MIDDLE))
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 2);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 2);
|
||||
if (!(ievt->buttons & DIBM_RIGHT))
|
||||
SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 3);
|
||||
SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 3);
|
||||
break;
|
||||
default:
|
||||
break; /* please gcc */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -113,7 +113,8 @@ DirectFB_CreateDevice(int devindex)
|
||||
device->MaximizeWindow = DirectFB_MaximizeWindow;
|
||||
device->MinimizeWindow = DirectFB_MinimizeWindow;
|
||||
device->RestoreWindow = DirectFB_RestoreWindow;
|
||||
device->SetWindowGrab = DirectFB_SetWindowGrab;
|
||||
device->SetWindowMouseGrab = DirectFB_SetWindowMouseGrab;
|
||||
device->SetWindowKeyboardGrab = DirectFB_SetWindowKeyboardGrab;
|
||||
device->DestroyWindow = DirectFB_DestroyWindow;
|
||||
device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;
|
||||
|
||||
@@ -260,7 +261,6 @@ DirectFB_VideoInit(_THIS)
|
||||
|
||||
devdata->dfb = dfb;
|
||||
devdata->firstwin = NULL;
|
||||
devdata->grabbed_window = NULL;
|
||||
|
||||
_this->driverdata = devdata;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -153,10 +153,6 @@ struct _DFB_DeviceData
|
||||
int use_linux_input;
|
||||
int has_own_wm;
|
||||
|
||||
|
||||
/* window grab */
|
||||
SDL_Window *grabbed_window;
|
||||
|
||||
/* global events */
|
||||
IDirectFBEventBuffer *events;
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2021 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
|
||||
@@ -383,25 +383,26 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
DirectFB_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
|
||||
|
||||
if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) {
|
||||
if (gwindata != NULL)
|
||||
{
|
||||
SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
|
||||
SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin));
|
||||
}
|
||||
if (grabbed) {
|
||||
SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin));
|
||||
SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin));
|
||||
devdata->grabbed_window = window;
|
||||
} else {
|
||||
SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DirectFB_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
SDL_DFB_WINDOWDATA(window);
|
||||
|
||||
if (grabbed) {
|
||||
SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin));
|
||||
} else {
|
||||
SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin));
|
||||
devdata->grabbed_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user