early-access version 2847
This commit is contained in:
32
externals/SDL/src/video/SDL_RLEaccel.c
vendored
32
externals/SDL/src/video/SDL_RLEaccel.c
vendored
@@ -92,6 +92,10 @@
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define PIXEL_COPY(to, from, len, bpp) \
|
||||
SDL_memcpy(to, from, (size_t)(len) * (bpp))
|
||||
|
||||
@@ -1157,13 +1161,13 @@ RLEAlphaSurface(SDL_Surface * surface)
|
||||
ADD_OPAQUE_COUNTS(max_opaque_run, 0);
|
||||
skip -= max_opaque_run;
|
||||
}
|
||||
len = SDL_min(run, max_opaque_run);
|
||||
len = MIN(run, max_opaque_run);
|
||||
ADD_OPAQUE_COUNTS(skip, len);
|
||||
dst += copy_opaque(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
run -= len;
|
||||
while (run) {
|
||||
len = SDL_min(run, max_opaque_run);
|
||||
len = MIN(run, max_opaque_run);
|
||||
ADD_OPAQUE_COUNTS(0, len);
|
||||
dst += copy_opaque(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
@@ -1191,13 +1195,13 @@ RLEAlphaSurface(SDL_Surface * surface)
|
||||
ADD_TRANSL_COUNTS(max_transl_run, 0);
|
||||
skip -= max_transl_run;
|
||||
}
|
||||
len = SDL_min(run, max_transl_run);
|
||||
len = MIN(run, max_transl_run);
|
||||
ADD_TRANSL_COUNTS(skip, len);
|
||||
dst += copy_transl(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
run -= len;
|
||||
while (run) {
|
||||
len = SDL_min(run, max_transl_run);
|
||||
len = MIN(run, max_transl_run);
|
||||
ADD_TRANSL_COUNTS(0, len);
|
||||
dst += copy_transl(dst, src + runstart, len, sf, df);
|
||||
runstart += len;
|
||||
@@ -1218,13 +1222,9 @@ RLEAlphaSurface(SDL_Surface * surface)
|
||||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->pixels = NULL;
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
}
|
||||
|
||||
/* reallocate the buffer to release unused memory */
|
||||
@@ -1359,14 +1359,14 @@ RLEColorkeySurface(SDL_Surface * surface)
|
||||
ADD_COUNTS(maxn, 0);
|
||||
skip -= maxn;
|
||||
}
|
||||
len = SDL_min(run, maxn);
|
||||
len = MIN(run, maxn);
|
||||
ADD_COUNTS(skip, len);
|
||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
||||
dst += len * bpp;
|
||||
run -= len;
|
||||
runstart += len;
|
||||
while (run) {
|
||||
len = SDL_min(run, maxn);
|
||||
len = MIN(run, maxn);
|
||||
ADD_COUNTS(0, len);
|
||||
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
|
||||
dst += len * bpp;
|
||||
@@ -1386,13 +1386,9 @@ RLEColorkeySurface(SDL_Surface * surface)
|
||||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
SDL_SIMDFree(surface->pixels);
|
||||
surface->pixels = NULL;
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
}
|
||||
|
||||
/* reallocate the buffer to release unused memory */
|
||||
|
||||
4
externals/SDL/src/video/SDL_blit.c
vendored
4
externals/SDL/src/video/SDL_blit.c
vendored
@@ -231,7 +231,9 @@ SDL_CalculateBlit(SDL_Surface * surface)
|
||||
if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
|
||||
blit = SDL_BlitCopy;
|
||||
} else if (surface->format->Rloss > 8 || dst->format->Rloss > 8) {
|
||||
blit = SDL_Blit_Slow;
|
||||
/* Greater than 8 bits per channel not supported yet */
|
||||
SDL_InvalidateMap(map);
|
||||
return SDL_SetError("Blit combination not supported");
|
||||
}
|
||||
#if SDL_HAVE_BLIT_0
|
||||
else if (surface->format->BitsPerPixel < 8 &&
|
||||
|
||||
18
externals/SDL/src/video/SDL_blit.h
vendored
18
externals/SDL/src/video/SDL_blit.h
vendored
@@ -269,18 +269,18 @@ do { \
|
||||
{ \
|
||||
switch (bpp) { \
|
||||
case 1: { \
|
||||
Uint8 _pixel; \
|
||||
Uint8 _Pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint8 *)(buf)) = _pixel; \
|
||||
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
|
||||
*((Uint8 *)(buf)) = _Pixel; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
case 2: { \
|
||||
Uint16 _pixel; \
|
||||
Uint16 _Pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint16 *)(buf)) = _pixel; \
|
||||
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
|
||||
*((Uint16 *)(buf)) = _Pixel; \
|
||||
} \
|
||||
break; \
|
||||
\
|
||||
@@ -298,10 +298,10 @@ do { \
|
||||
break; \
|
||||
\
|
||||
case 4: { \
|
||||
Uint32 _pixel; \
|
||||
Uint32 _Pixel; \
|
||||
\
|
||||
PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \
|
||||
*((Uint32 *)(buf)) = _pixel; \
|
||||
PIXEL_FROM_RGB(_Pixel, fmt, r, g, b); \
|
||||
*((Uint32 *)(buf)) = _Pixel; \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
|
||||
83
externals/SDL/src/video/SDL_blit_0.c
vendored
83
externals/SDL/src/video/SDL_blit_0.c
vendored
@@ -452,94 +452,11 @@ static const SDL_BlitFunc colorkey_blit[] = {
|
||||
(SDL_BlitFunc) NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
Blit4bto4(SDL_BlitInfo * info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint8 *src = info->src;
|
||||
Uint32 *dst = (Uint32 *) info->dst;
|
||||
int srcskip = info->src_skip;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint32 *map = (Uint32 *) info->table;
|
||||
int c;
|
||||
|
||||
/* Set up some basic variables */
|
||||
srcskip += width - (width + 1) / 2;
|
||||
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
if ((c & 0x1) == 0) {
|
||||
byte = *src++;
|
||||
}
|
||||
bit = (byte & 0xF0) >> 4;
|
||||
if (1) {
|
||||
*dst = map[bit];
|
||||
}
|
||||
byte <<= 4;
|
||||
dst++;
|
||||
}
|
||||
src += srcskip;
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Blit4bto4Key(SDL_BlitInfo * info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint8 *src = info->src;
|
||||
Uint32 *dst = (Uint32 *) info->dst;
|
||||
int srcskip = info->src_skip;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint32 ckey = info->colorkey;
|
||||
Uint32 *map = (Uint32 *) info->table;
|
||||
int c;
|
||||
|
||||
/* Set up some basic variables */
|
||||
srcskip += width - (width + 1) / 2;
|
||||
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
if ((c & 0x1) == 0) {
|
||||
byte = *src++;
|
||||
}
|
||||
bit = (byte & 0xF0) >> 4;
|
||||
if (bit != ckey) {
|
||||
*dst = map[bit];
|
||||
}
|
||||
byte <<= 4;
|
||||
dst++;
|
||||
}
|
||||
src += srcskip;
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_BlitFunc
|
||||
SDL_CalculateBlit0(SDL_Surface * surface)
|
||||
{
|
||||
int which;
|
||||
|
||||
/* 4bits to 32bits */
|
||||
if (surface->format->BitsPerPixel == 4) {
|
||||
if (surface->map->dst->format->BytesPerPixel == 4) {
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
return Blit4bto4;
|
||||
|
||||
case SDL_COPY_COLORKEY:
|
||||
return Blit4bto4Key;
|
||||
}
|
||||
}
|
||||
/* We don't fully support 4-bit packed pixel modes */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (surface->format->BitsPerPixel != 1) {
|
||||
/* We don't support sub 8-bit packed pixel modes */
|
||||
return (SDL_BlitFunc) NULL;
|
||||
|
||||
44
externals/SDL/src/video/SDL_blit_1.c
vendored
44
externals/SDL/src/video/SDL_blit_1.c
vendored
@@ -50,7 +50,7 @@ Blit1to1(SDL_BlitInfo * info)
|
||||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = map[*src];
|
||||
@@ -58,7 +58,7 @@ Blit1to1(SDL_BlitInfo * info)
|
||||
dst++;
|
||||
src++;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
*dst = map[*src];
|
||||
@@ -103,14 +103,14 @@ Blit1to2(SDL_BlitInfo * info)
|
||||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*(Uint16 *)dst = map[*src++];
|
||||
dst += 2;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ Blit1to3(SDL_BlitInfo * info)
|
||||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
o = *src * 4;
|
||||
@@ -221,7 +221,7 @@ Blit1to3(SDL_BlitInfo * info)
|
||||
src++;
|
||||
dst += 3;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
o = *src * 4;
|
||||
@@ -259,11 +259,11 @@ Blit1to4(SDL_BlitInfo * info)
|
||||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
*dst++ = map[*src++];
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
*dst++ = map[*src++];
|
||||
@@ -299,7 +299,7 @@ Blit1to1Key(SDL_BlitInfo * info)
|
||||
|
||||
if (palmap) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -309,13 +309,13 @@ Blit1to1Key(SDL_BlitInfo * info)
|
||||
src++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
} else {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -325,7 +325,7 @@ Blit1to1Key(SDL_BlitInfo * info)
|
||||
src++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ Blit1to2Key(SDL_BlitInfo * info)
|
||||
dstskip /= 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -358,7 +358,7 @@ Blit1to2Key(SDL_BlitInfo * info)
|
||||
dstp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -378,7 +378,7 @@ Blit1to3Key(SDL_BlitInfo * info)
|
||||
int o;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -391,7 +391,7 @@ Blit1to3Key(SDL_BlitInfo * info)
|
||||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -413,7 +413,7 @@ Blit1to4Key(SDL_BlitInfo * info)
|
||||
dstskip /= 4;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -423,7 +423,7 @@ Blit1to4Key(SDL_BlitInfo * info)
|
||||
dstp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -450,7 +450,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
|
||||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
sR = srcpal[*src].r;
|
||||
@@ -463,7 +463,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
|
||||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( *src != ckey ) {
|
||||
@@ -506,7 +506,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
||||
72
externals/SDL/src/video/SDL_blit_A.c
vendored
72
externals/SDL/src/video/SDL_blit_A.c
vendored
@@ -47,7 +47,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
|
||||
const unsigned A = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
@@ -68,7 +68,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info)
|
||||
unsigned dR, dG, dB;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
|
||||
@@ -114,7 +114,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
|
||||
const unsigned A = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
@@ -164,7 +164,7 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -348,7 +348,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
|
||||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 alpha = *srcp & amask;
|
||||
if (alpha == 0) {
|
||||
@@ -382,7 +382,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -467,14 +467,14 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
|
||||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
|
||||
+ (s & d & 0x00010101)) | 0xff000000;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -500,7 +500,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
|
||||
Uint32 d1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
s = *srcp;
|
||||
d = *dstp;
|
||||
@@ -515,7 +515,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -534,7 +534,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
|
||||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 dalpha;
|
||||
Uint32 d;
|
||||
@@ -569,7 +569,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -587,7 +587,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
|
||||
int dstskip = info->dst_skip >> 2;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 dalpha;
|
||||
Uint32 d;
|
||||
@@ -624,7 +624,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
||||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 alpha;
|
||||
|
||||
@@ -694,7 +694,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -848,7 +848,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
|
||||
bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP_124(
|
||||
{
|
||||
s = *srcp++;
|
||||
@@ -944,7 +944,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
|
||||
srcp += 4;
|
||||
dstp += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -986,7 +986,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
|
||||
bmask = _mm_set_pi32(0x001F001F, 0x001F001F); /* MASKBLUE -> bmask */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP_124(
|
||||
{
|
||||
s = *srcp++;
|
||||
@@ -1082,7 +1082,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
|
||||
srcp += 4;
|
||||
dstp += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -1109,7 +1109,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
|
||||
alpha >>= 3; /* downscale alpha to 5 bits */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
@@ -1124,7 +1124,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
|
||||
d &= 0x07e0f81f;
|
||||
*dstp++ = (Uint16)(d | d >> 16);
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -1148,7 +1148,7 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
|
||||
alpha >>= 3; /* downscale alpha to 5 bits */
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp++;
|
||||
Uint32 d = *dstp;
|
||||
@@ -1163,7 +1163,7 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
|
||||
d &= 0x03e07c1f;
|
||||
*dstp++ = (Uint16)(d | d >> 16);
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -1182,7 +1182,7 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
|
||||
int dstskip = info->dst_skip >> 1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 s = *srcp;
|
||||
unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
|
||||
@@ -1210,7 +1210,7 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
|
||||
srcp++;
|
||||
dstp++;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -1228,7 +1228,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
|
||||
int dstskip = info->dst_skip >> 1;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
unsigned alpha;
|
||||
Uint32 s = *srcp;
|
||||
@@ -1257,7 +1257,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
|
||||
srcp++;
|
||||
dstp++;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -1284,7 +1284,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
|
||||
|
||||
if (sA) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
@@ -1295,7 +1295,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
|
||||
const unsigned sA = info->a;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
|
||||
@@ -1337,7 +1337,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -1366,7 +1366,7 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info)
|
||||
dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
@@ -1379,7 +1379,7 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
||||
158
externals/SDL/src/video/SDL_blit_N.c
vendored
158
externals/SDL/src/video/SDL_blit_N.c
vendored
@@ -128,7 +128,7 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt)
|
||||
* leave alpha with a zero mask, but we should still swizzle the bits.
|
||||
*/
|
||||
/* ARGB */
|
||||
static const struct SDL_PixelFormat default_pixel_format = {
|
||||
const static const struct SDL_PixelFormat default_pixel_format = {
|
||||
0, NULL, 0, 0,
|
||||
{0, 0},
|
||||
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
|
||||
@@ -1008,11 +1008,11 @@ Blit_RGB888_index8(SDL_BlitInfo * info)
|
||||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB332(*dst++, *src);
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
@@ -1044,13 +1044,13 @@ Blit_RGB888_index8(SDL_BlitInfo * info)
|
||||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB332(Pixel, *src);
|
||||
*dst++ = map[Pixel];
|
||||
++src;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
@@ -1118,11 +1118,11 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
|
||||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB101010_RGB332(*dst++, *src);
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
@@ -1154,13 +1154,13 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
|
||||
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB101010_RGB332(Pixel, *src);
|
||||
*dst++ = map[Pixel];
|
||||
++src;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width / 4; c; --c) {
|
||||
/* Pack RGB into 8bit pixel */
|
||||
@@ -1235,13 +1235,13 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info)
|
||||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB555(dst, src);
|
||||
++src;
|
||||
++dst;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -1361,13 +1361,13 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info)
|
||||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
RGB888_RGB565(dst, src);
|
||||
++src;
|
||||
++dst;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -1476,14 +1476,14 @@ Blit_RGB565_32(SDL_BlitInfo * info, const Uint32 * map)
|
||||
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst++ = RGB565_32(dst, src, map);
|
||||
src += 2;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2088,7 +2088,7 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
|
||||
Uint16 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src | mask;
|
||||
@@ -2096,7 +2096,7 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint16 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint16 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
@@ -2132,7 +2132,7 @@ BlitNto1(SDL_BlitInfo * info)
|
||||
if (map == NULL) {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
sR, sG, sB);
|
||||
@@ -2145,7 +2145,7 @@ BlitNto1(SDL_BlitInfo * info)
|
||||
dst++;
|
||||
src += srcbpp;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
@@ -2164,7 +2164,7 @@ BlitNto1(SDL_BlitInfo * info)
|
||||
} else {
|
||||
while (height--) {
|
||||
#ifdef USE_DUFFS_LOOP
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
sR, sG, sB);
|
||||
@@ -2177,7 +2177,7 @@ BlitNto1(SDL_BlitInfo * info)
|
||||
dst++;
|
||||
src += srcbpp;
|
||||
, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#else
|
||||
for (c = width; c; --c) {
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
@@ -2214,7 +2214,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
||||
Uint32 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src | mask;
|
||||
@@ -2222,7 +2222,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
@@ -2231,7 +2231,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
||||
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src & mask;
|
||||
@@ -2239,7 +2239,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
@@ -2259,7 +2259,7 @@ Blit4to4CopyAlpha(SDL_BlitInfo * info)
|
||||
|
||||
/* RGBA->RGBA, COPY_ALPHA */
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
*dst = *src;
|
||||
@@ -2267,7 +2267,7 @@ Blit4to4CopyAlpha(SDL_BlitInfo * info)
|
||||
++src;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src = (Uint32 *) ((Uint8 *) src + srcskip);
|
||||
dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
||||
}
|
||||
@@ -2380,7 +2380,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
@@ -2391,7 +2391,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2408,7 +2408,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
@@ -2417,7 +2417,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2434,7 +2434,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
@@ -2445,7 +2445,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
src += 3;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2454,7 +2454,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 Pixel;
|
||||
@@ -2467,7 +2467,7 @@ BlitNtoN(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2499,7 +2499,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
dst[0] = src[p0];
|
||||
@@ -2509,7 +2509,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2554,7 +2554,7 @@ BlitNto1Key(SDL_BlitInfo * info)
|
||||
|
||||
if (palmap == NULL) {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
@@ -2569,13 +2569,13 @@ BlitNto1Key(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
} else {
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
|
||||
@@ -2590,7 +2590,7 @@ BlitNto1Key(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2615,7 +2615,7 @@ Blit2to2Key(SDL_BlitInfo * info)
|
||||
ckey &= rgbmask;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ( (*srcp & rgbmask) != ckey ) {
|
||||
@@ -2625,7 +2625,7 @@ Blit2to2Key(SDL_BlitInfo * info)
|
||||
srcp++;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
@@ -2662,7 +2662,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
/* RGB->RGBA, SET_ALPHA */
|
||||
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
@@ -2671,7 +2671,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
++dst32;
|
||||
++src32;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
|
||||
dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
|
||||
}
|
||||
@@ -2680,7 +2680,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
/* RGBA->RGB, NO_ALPHA */
|
||||
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
@@ -2689,7 +2689,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
++dst32;
|
||||
++src32;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src32 = (Uint32 *) ((Uint8 *) src32 + srcskip);
|
||||
dst32 = (Uint32 *) ((Uint8 *) dst32 + dstskip);
|
||||
}
|
||||
@@ -2708,7 +2708,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
@@ -2723,7 +2723,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2746,7 +2746,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
@@ -2762,7 +2762,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2784,7 +2784,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
@@ -2800,7 +2800,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
dst += 3;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2816,7 +2816,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
@@ -2828,7 +2828,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 3;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2855,7 +2855,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[0];
|
||||
@@ -2872,7 +2872,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
src += 3;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2881,7 +2881,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 Pixel;
|
||||
@@ -2897,7 +2897,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2938,7 +2938,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
if ((*src32 & rgbmask) != ckey) {
|
||||
@@ -2948,7 +2948,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
++dst32;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src32 = (Uint32 *)((Uint8 *)src32 + srcskip);
|
||||
dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip);
|
||||
}
|
||||
@@ -2967,7 +2967,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL);
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *src32 = (Uint32*)src;
|
||||
@@ -2980,7 +2980,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -2989,7 +2989,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
#endif
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
@@ -3000,7 +3000,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3022,7 +3022,7 @@ Blit2101010toN(SDL_BlitInfo * info)
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Pixel = *(Uint32 *)src;
|
||||
@@ -3032,7 +3032,7 @@ Blit2101010toN(SDL_BlitInfo * info)
|
||||
src += 4;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3054,7 +3054,7 @@ BlitNto2101010(SDL_BlitInfo * info)
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
|
||||
@@ -3064,7 +3064,7 @@ BlitNto2101010(SDL_BlitInfo * info)
|
||||
src += srcbpp;
|
||||
},
|
||||
width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3096,7 +3096,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
||||
int i2 = srcbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
@@ -3107,7 +3107,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
||||
dst += 4;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3125,7 +3125,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
||||
int j2 = dstbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[i0];
|
||||
@@ -3137,7 +3137,7 @@ Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3169,7 +3169,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
#else
|
||||
int i0 = 3, i1 = 2, i2 = 1, i3 = 0;
|
||||
#endif
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
@@ -3182,7 +3182,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3197,7 +3197,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
int i2 = srcbpp - 1 - 2;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint32 *dst32 = (Uint32*)dst;
|
||||
@@ -3209,7 +3209,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
dst += 4;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
@@ -3228,7 +3228,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
int j2 = dstbpp - 1 - 0;
|
||||
#endif
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP(
|
||||
{
|
||||
Uint8 s0 = src[i0];
|
||||
@@ -3241,7 +3241,7 @@ Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo * info)
|
||||
dst += dstbpp;
|
||||
src += srcbpp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
|
||||
28
externals/SDL/src/video/SDL_blit_auto.c
vendored
28
externals/SDL/src/video/SDL_blit_auto.c
vendored
@@ -23,7 +23,7 @@
|
||||
|
||||
#if SDL_HAVE_BLIT_AUTO
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_blit.h"
|
||||
@@ -756,6 +756,7 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
const Uint32 A = 0xFF;
|
||||
Uint32 R, G, B;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -775,7 +776,8 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel |= (A << 24);
|
||||
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
||||
pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -2230,6 +2232,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
||||
static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
Uint32 R, G, B;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -2249,7 +2252,8 @@ static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel &= 0xFFFFFF;
|
||||
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
|
||||
pixel = (R << 16) | (G << 8) | B;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -3391,6 +3395,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
||||
static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
Uint32 R, G, B;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -3410,7 +3415,8 @@ static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel >>= 8;
|
||||
R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
|
||||
pixel = (R << 16) | (G << 8) | B;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -4157,6 +4163,7 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
||||
static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
Uint32 R, G, B, A;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -4176,7 +4183,8 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel = (pixel >> 8) | (pixel << 24);
|
||||
R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
|
||||
pixel = (A << 24) | (R << 16) | (G << 8) | B;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -4939,6 +4947,7 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
||||
static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
Uint32 R, G, B;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -4958,7 +4967,8 @@ static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel &= 0xFFFFFF;
|
||||
B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
|
||||
pixel = (B << 16) | (G << 8) | R;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -6105,6 +6115,7 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
|
||||
static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
|
||||
{
|
||||
Uint32 pixel;
|
||||
Uint32 R, G, B;
|
||||
int srcy, srcx;
|
||||
Uint32 posy, posx;
|
||||
int incy, incx;
|
||||
@@ -6124,7 +6135,8 @@ static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
|
||||
srcx = posx >> 16;
|
||||
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
|
||||
pixel = *src;
|
||||
pixel >>= 8;
|
||||
B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
|
||||
pixel = (B << 16) | (G << 8) | R;
|
||||
*dst = pixel;
|
||||
posx += incx;
|
||||
++dst;
|
||||
@@ -7014,7 +7026,7 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
|
||||
{ 0, 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* SDL_HAVE_BLIT_AUTO */
|
||||
|
||||
|
||||
59
externals/SDL/src/video/SDL_blit_slow.c
vendored
59
externals/SDL/src/video/SDL_blit_slow.c
vendored
@@ -24,21 +24,6 @@
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_blit_slow.h"
|
||||
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
if (pf->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return FORMAT_2101010;
|
||||
} else if (pf->Amask) {
|
||||
return FORMAT_ALPHA;
|
||||
} else {
|
||||
return FORMAT_NO_ALPHA;
|
||||
}
|
||||
}
|
||||
|
||||
/* The ONE TRUE BLITTER
|
||||
* This puppy has to handle all the unoptimized cases - yes, it's slow.
|
||||
*/
|
||||
@@ -61,14 +46,9 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
SDL_PixelFormat *dst_fmt = info->dst_fmt;
|
||||
int srcbpp = src_fmt->BytesPerPixel;
|
||||
int dstbpp = dst_fmt->BytesPerPixel;
|
||||
int srcfmt_val;
|
||||
int dstfmt_val;
|
||||
Uint32 rgbmask = ~src_fmt->Amask;
|
||||
Uint32 ckey = info->colorkey & rgbmask;
|
||||
|
||||
srcfmt_val = detect_format(src_fmt);
|
||||
dstfmt_val = detect_format(dst_fmt);
|
||||
|
||||
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 */
|
||||
@@ -82,18 +62,14 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
while (n--) {
|
||||
srcx = posx >> 16;
|
||||
src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
|
||||
|
||||
if (FORMAT_HAS_ALPHA(srcfmt_val)) {
|
||||
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB, srcA);
|
||||
} else if (FORMAT_HAS_NO_ALPHA(srcfmt_val)) {
|
||||
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB);
|
||||
srcA = 0xFF;
|
||||
if (src_fmt->Amask) {
|
||||
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
|
||||
srcB, srcA);
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
srcpixel = *((Uint32 *)(src));
|
||||
RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA);
|
||||
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
|
||||
srcB);
|
||||
srcA = 0xFF;
|
||||
}
|
||||
|
||||
if (flags & SDL_COPY_COLORKEY) {
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
if (srcbpp == 3) {
|
||||
@@ -106,15 +82,13 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
|
||||
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
|
||||
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
|
||||
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
|
||||
dstA = 0xFF;
|
||||
if (dst_fmt->Amask) {
|
||||
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
|
||||
dstB, dstA);
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
dstpixel = *((Uint32 *)(dst));
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
|
||||
dstB);
|
||||
dstA = 0xFF;
|
||||
}
|
||||
|
||||
if (flags & SDL_COPY_MODULATE_COLOR) {
|
||||
@@ -177,15 +151,10 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
|
||||
dstA = 255;
|
||||
break;
|
||||
}
|
||||
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
|
||||
if (dst_fmt->Amask) {
|
||||
ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
|
||||
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
|
||||
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
Uint32 pixel;
|
||||
ARGB2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA);
|
||||
*(Uint32 *)dst = pixel;
|
||||
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
|
||||
}
|
||||
posx += incx;
|
||||
dst += dstbpp;
|
||||
|
||||
37
externals/SDL/src/video/SDL_bmp.c
vendored
37
externals/SDL/src/video/SDL_bmp.c
vendored
@@ -53,7 +53,7 @@
|
||||
#define LCS_WINDOWS_COLOR_SPACE 0x57696E20
|
||||
#endif
|
||||
|
||||
static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
|
||||
static int readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
|
||||
{
|
||||
/*
|
||||
| Sets the surface pixels from src. A bmp image is upside down.
|
||||
@@ -70,14 +70,14 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8
|
||||
#define COPY_PIXEL(x) spot = &bits[ofs++]; if(spot >= start && spot < end) *spot = (x)
|
||||
|
||||
for (;;) {
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
|
||||
/*
|
||||
| encoded mode starts with a run length, and then a byte
|
||||
| with two colour indexes to alternate between for the run
|
||||
*/
|
||||
if (ch) {
|
||||
Uint8 pixel;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return 1;
|
||||
if (isRle8) { /* 256-color bitmap, compressed */
|
||||
do {
|
||||
COPY_PIXEL(pixel);
|
||||
@@ -98,18 +98,18 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8
|
||||
| a cursor move, or some absolute data.
|
||||
| zero tag may be absolute mode or an escape
|
||||
*/
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
|
||||
switch (ch) {
|
||||
case 0: /* end of line */
|
||||
ofs = 0;
|
||||
bits -= pitch; /* go to previous */
|
||||
break;
|
||||
case 1: /* end of bitmap */
|
||||
return SDL_FALSE; /* success! */
|
||||
return 0; /* success! */
|
||||
case 2: /* delta */
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
|
||||
ofs += ch;
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
|
||||
bits -= (ch * pitch);
|
||||
break;
|
||||
default: /* no compression */
|
||||
@@ -117,14 +117,14 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8
|
||||
needsPad = (ch & 1);
|
||||
do {
|
||||
Uint8 pixel;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return 1;
|
||||
COPY_PIXEL(pixel);
|
||||
} while (--ch);
|
||||
} else {
|
||||
needsPad = (((ch+1)>>1) & 1); /* (ch+1)>>1: bytes size */
|
||||
for (;;) {
|
||||
Uint8 pixel;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) return 1;
|
||||
COPY_PIXEL(pixel >> 4);
|
||||
if (!--ch) break;
|
||||
COPY_PIXEL(pixel & 0x0F);
|
||||
@@ -132,7 +132,7 @@ static SDL_bool readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8
|
||||
}
|
||||
}
|
||||
/* pad at even boundary */
|
||||
if (needsPad && !SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
|
||||
if (needsPad && !SDL_RWread(src, &ch, 1, 1)) return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -213,17 +213,12 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||
surface = NULL;
|
||||
was_error = SDL_FALSE;
|
||||
if (src == NULL) {
|
||||
SDL_InvalidParamError("src");
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Read in the BMP file header */
|
||||
fp_offset = SDL_RWtell(src);
|
||||
if (fp_offset < 0) {
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
SDL_ClearError();
|
||||
if (SDL_RWread(src, magic, 1, 2) != 2) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
@@ -412,12 +407,6 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (biBitCount >= 32) { /* we shift biClrUsed by this value later. */
|
||||
SDL_SetError("Unsupported or incorrect biBitCount field");
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (biClrUsed == 0) {
|
||||
biClrUsed = 1 << biBitCount;
|
||||
}
|
||||
@@ -462,8 +451,8 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||
goto done;
|
||||
}
|
||||
if ((biCompression == BI_RLE4) || (biCompression == BI_RLE8)) {
|
||||
was_error = readRlePixels(surface, src, biCompression == BI_RLE8);
|
||||
if (was_error) SDL_Error(SDL_EFREAD);
|
||||
was_error = (SDL_bool)readRlePixels(surface, src, biCompression == BI_RLE8);
|
||||
if (was_error) SDL_SetError("Error reading from BMP");
|
||||
goto done;
|
||||
}
|
||||
top = (Uint8 *)surface->pixels;
|
||||
@@ -495,7 +484,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||
for (i = 0; i < surface->w; ++i) {
|
||||
if (i % (8 / ExpandBMP) == 0) {
|
||||
if (!SDL_RWread(src, &pixel, 1, 1)) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_SetError("Error reading from BMP");
|
||||
was_error = SDL_TRUE;
|
||||
goto done;
|
||||
}
|
||||
|
||||
102
externals/SDL/src/video/SDL_egl.c
vendored
102
externals/SDL/src/video/SDL_egl.c
vendored
@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
#include <android/native_window.h>
|
||||
#include "../core/android/SDL_android.h"
|
||||
#include "../video/android/SDL_androidvideo.h"
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RPI
|
||||
@@ -98,7 +99,7 @@
|
||||
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
|
||||
#endif /* SDL_VIDEO_DRIVER_RPI */
|
||||
|
||||
#if SDL_VIDEO_OPENGL && !SDL_VIDEO_VITA_PVR_OGL
|
||||
#if SDL_VIDEO_OPENGL
|
||||
#include "SDL_opengl.h"
|
||||
#endif
|
||||
|
||||
@@ -114,7 +115,7 @@
|
||||
_this->egl_data->NAME = (void *)NAME;
|
||||
#else
|
||||
#define LOAD_FUNC(NAME) \
|
||||
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \
|
||||
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
|
||||
if (!_this->egl_data->NAME) \
|
||||
{ \
|
||||
return SDL_SetError("Could not retrieve EGL function " #NAME); \
|
||||
@@ -250,12 +251,12 @@ SDL_EGL_GetProcAddress(_THIS, const char *proc)
|
||||
/* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */
|
||||
if (!retval) {
|
||||
static char procname[64];
|
||||
retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc);
|
||||
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc);
|
||||
/* just in case you need an underscore prepended... */
|
||||
if (!retval && (SDL_strlen(proc) < (sizeof (procname) - 1))) {
|
||||
procname[0] = '_';
|
||||
SDL_strlcpy(procname + 1, proc, sizeof (procname) - 1);
|
||||
retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, procname);
|
||||
retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -280,14 +281,14 @@ SDL_EGL_UnloadLibrary(_THIS)
|
||||
_this->egl_data->egl_display = NULL;
|
||||
}
|
||||
|
||||
if (_this->egl_data->dll_handle) {
|
||||
SDL_UnloadObject(_this->egl_data->dll_handle);
|
||||
_this->egl_data->dll_handle = NULL;
|
||||
}
|
||||
if (_this->egl_data->egl_dll_handle) {
|
||||
SDL_UnloadObject(_this->egl_data->egl_dll_handle);
|
||||
_this->egl_data->egl_dll_handle = NULL;
|
||||
}
|
||||
if (_this->egl_data->opengl_dll_handle) {
|
||||
SDL_UnloadObject(_this->egl_data->opengl_dll_handle);
|
||||
_this->egl_data->opengl_dll_handle = NULL;
|
||||
}
|
||||
|
||||
SDL_free(_this->egl_data);
|
||||
_this->egl_data = NULL;
|
||||
@@ -297,7 +298,7 @@ SDL_EGL_UnloadLibrary(_THIS)
|
||||
int
|
||||
SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
{
|
||||
void *egl_dll_handle = NULL, *opengl_dll_handle = NULL;
|
||||
void *dll_handle = NULL, *egl_dll_handle = NULL; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */
|
||||
const char *path = NULL;
|
||||
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
|
||||
const char *d3dcompiler;
|
||||
@@ -349,32 +350,32 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
/* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */
|
||||
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
|
||||
if (path != NULL) {
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
|
||||
if (opengl_dll_handle == NULL) {
|
||||
if (egl_dll_handle == NULL) {
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
if (_this->gl_config.major_version > 1) {
|
||||
path = DEFAULT_OGL_ES2;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
#ifdef ALT_OGL_ES2
|
||||
if (opengl_dll_handle == NULL && !vc4) {
|
||||
if (egl_dll_handle == NULL && !vc4) {
|
||||
path = ALT_OGL_ES2;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
path = DEFAULT_OGL_ES;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
if (opengl_dll_handle == NULL) {
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
if (egl_dll_handle == NULL) {
|
||||
path = DEFAULT_OGL_ES_PVR;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#ifdef ALT_OGL_ES2
|
||||
if (opengl_dll_handle == NULL && !vc4) {
|
||||
if (egl_dll_handle == NULL && !vc4) {
|
||||
path = ALT_OGL_ES2;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -382,47 +383,47 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
#ifdef DEFAULT_OGL
|
||||
else {
|
||||
path = DEFAULT_OGL;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
#ifdef ALT_OGL
|
||||
if (opengl_dll_handle == NULL) {
|
||||
if (egl_dll_handle == NULL) {
|
||||
path = ALT_OGL;
|
||||
opengl_dll_handle = SDL_LoadObject(path);
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
|
||||
_this->egl_data->egl_dll_handle = egl_dll_handle;
|
||||
|
||||
if (opengl_dll_handle == NULL) {
|
||||
if (egl_dll_handle == NULL) {
|
||||
return SDL_SetError("Could not initialize OpenGL / GLES library");
|
||||
}
|
||||
|
||||
/* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */
|
||||
if (egl_path != NULL) {
|
||||
egl_dll_handle = SDL_LoadObject(egl_path);
|
||||
dll_handle = SDL_LoadObject(egl_path);
|
||||
}
|
||||
/* Try loading a EGL symbol, if it does not work try the default library paths */
|
||||
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (egl_dll_handle != NULL) {
|
||||
SDL_UnloadObject(egl_dll_handle);
|
||||
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (dll_handle != NULL) {
|
||||
SDL_UnloadObject(dll_handle);
|
||||
}
|
||||
path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
|
||||
if (path == NULL) {
|
||||
path = DEFAULT_EGL;
|
||||
}
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
dll_handle = SDL_LoadObject(path);
|
||||
|
||||
#ifdef ALT_EGL
|
||||
if (egl_dll_handle == NULL && !vc4) {
|
||||
if (dll_handle == NULL && !vc4) {
|
||||
path = ALT_EGL;
|
||||
egl_dll_handle = SDL_LoadObject(path);
|
||||
dll_handle = SDL_LoadObject(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (egl_dll_handle != NULL) {
|
||||
SDL_UnloadObject(egl_dll_handle);
|
||||
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
|
||||
if (dll_handle != NULL) {
|
||||
SDL_UnloadObject(dll_handle);
|
||||
}
|
||||
return SDL_SetError("Could not load EGL library");
|
||||
}
|
||||
@@ -430,9 +431,9 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
|
||||
}
|
||||
#endif
|
||||
|
||||
_this->egl_data->egl_dll_handle = egl_dll_handle;
|
||||
_this->egl_data->dll_handle = dll_handle;
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
|
||||
_this->egl_data->egl_dll_handle = egl_dll_handle;
|
||||
#endif
|
||||
|
||||
/* Load new function pointers */
|
||||
@@ -529,7 +530,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
|
||||
}
|
||||
#endif
|
||||
/* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */
|
||||
if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) {
|
||||
if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
|
||||
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
|
||||
}
|
||||
if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
|
||||
@@ -908,7 +909,8 @@ SDL_EGL_ChooseConfig(_THIS)
|
||||
int ret;
|
||||
|
||||
if (!_this->egl_data) {
|
||||
return SDL_SetError("EGL not initialized");
|
||||
/* 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 */
|
||||
@@ -941,7 +943,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
|
||||
|
||||
if (!_this->egl_data) {
|
||||
SDL_SetError("EGL not initialized");
|
||||
/* The EGL library wasn't loaded, SDL_GetError() should have info */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1042,8 +1044,16 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
_this->egl_data->egl_swapinterval = 0;
|
||||
|
||||
if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) {
|
||||
/* Delete the context */
|
||||
/* Save the SDL error set by SDL_EGL_MakeCurrent */
|
||||
char errorText[1024];
|
||||
SDL_strlcpy(errorText, SDL_GetError(), SDL_arraysize(errorText));
|
||||
|
||||
/* Delete the context, which may alter the value returned by SDL_GetError() */
|
||||
SDL_EGL_DeleteContext(_this, egl_context);
|
||||
|
||||
/* Restore the SDL error */
|
||||
SDL_SetError("%s", errorText);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1071,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
|
||||
if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) {
|
||||
_this->gl_allow_no_surface = SDL_TRUE;
|
||||
}
|
||||
#if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA)
|
||||
#if SDL_VIDEO_OPENGL
|
||||
} else {
|
||||
/* Desktop OpenGL supports it by default from version 3.0 on. */
|
||||
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
|
||||
@@ -1086,7 +1096,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
|
||||
EGLContext egl_context = (EGLContext) context;
|
||||
|
||||
if (!_this->egl_data) {
|
||||
return SDL_SetError("EGL not initialized");
|
||||
return SDL_SetError("OpenGL not initialized");
|
||||
}
|
||||
|
||||
if (!_this->egl_data->eglMakeCurrent) {
|
||||
@@ -1094,7 +1104,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
|
||||
/* Can't do the nothing there is to do? Probably trying to cleanup a failed startup, just return. */
|
||||
return 0;
|
||||
} else {
|
||||
return SDL_SetError("EGL not initialized"); /* something clearly went wrong somewhere. */
|
||||
return SDL_SetError("OpenGL not initialized"); /* something clearly went wrong somewhere. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1250,12 +1260,10 @@ EGLSurface
|
||||
SDL_EGL_CreateOffscreenSurface(_THIS, int width, int height)
|
||||
{
|
||||
EGLint attributes[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
EGL_WIDTH, width,
|
||||
EGL_HEIGHT, height,
|
||||
EGL_NONE
|
||||
};
|
||||
attributes[1] = width;
|
||||
attributes[3] = height;
|
||||
|
||||
if (SDL_EGL_ChooseConfig(_this) != 0) {
|
||||
return EGL_NO_SURFACE;
|
||||
|
||||
2
externals/SDL/src/video/SDL_egl_c.h
vendored
2
externals/SDL/src/video/SDL_egl_c.h
vendored
@@ -33,7 +33,7 @@
|
||||
|
||||
typedef struct SDL_EGL_VideoData
|
||||
{
|
||||
void *opengl_dll_handle, *egl_dll_handle;
|
||||
void *egl_dll_handle, *dll_handle;
|
||||
EGLDisplay egl_display;
|
||||
EGLConfig egl_config;
|
||||
int egl_swapinterval;
|
||||
|
||||
34
externals/SDL/src/video/SDL_fillrect.c
vendored
34
externals/SDL/src/video/SDL_fillrect.c
vendored
@@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
#ifdef __SSE__
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#define SSE_BEGIN \
|
||||
@@ -128,7 +128,7 @@ SDL_FillRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
||||
DEFINE_SSE_FILLRECT(2, Uint16)
|
||||
DEFINE_SSE_FILLRECT(4, Uint32)
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
#endif /* __SSE__ */
|
||||
|
||||
static void
|
||||
@@ -238,7 +238,7 @@ int
|
||||
SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_FillRect(): dst");
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
@@ -306,7 +306,12 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
int i;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_FillRects(): dst");
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_FillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Nothing to do */
|
||||
@@ -316,28 +321,11 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
|
||||
/* Perform software fill */
|
||||
if (!dst->pixels) {
|
||||
return SDL_SetError("SDL_FillRects(): You must lock the surface");
|
||||
return SDL_SetError("SDL_FillRect(): You must lock the surface");
|
||||
}
|
||||
|
||||
if (!rects) {
|
||||
return SDL_InvalidParamError("SDL_FillRects(): rects");
|
||||
}
|
||||
|
||||
/* This function doesn't usually work on surfaces < 8 bpp
|
||||
* Except: support for 4bits, when filling full size.
|
||||
*/
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
if (count == 1) {
|
||||
const SDL_Rect *r = &rects[0];
|
||||
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->w == dst->h) {
|
||||
if (dst->format->BitsPerPixel == 4) {
|
||||
Uint8 b = (((Uint8) color << 4) | (Uint8) color);
|
||||
SDL_memset(dst->pixels, b, dst->h * dst->pitch);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SDL_SetError("SDL_FillRects(): Unsupported surface format");
|
||||
return SDL_SetError("SDL_FillRects() passed NULL rects");
|
||||
}
|
||||
|
||||
#if SDL_ARM_NEON_BLITTERS
|
||||
|
||||
43
externals/SDL/src/video/SDL_pixels.c
vendored
43
externals/SDL/src/video/SDL_pixels.c
vendored
@@ -28,7 +28,6 @@
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
#include "../SDL_list.h"
|
||||
|
||||
|
||||
/* Lookup tables to expand partial bytes to the full 0..255 range */
|
||||
@@ -678,7 +677,7 @@ int
|
||||
SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette)
|
||||
{
|
||||
if (!format) {
|
||||
return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format");
|
||||
return SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format");
|
||||
}
|
||||
|
||||
if (palette && palette->ncolors > (1 << format->BitsPerPixel)) {
|
||||
@@ -1025,6 +1024,12 @@ SDL_AllocBlitMap(void)
|
||||
}
|
||||
|
||||
|
||||
typedef struct SDL_ListNode
|
||||
{
|
||||
void *entry;
|
||||
struct SDL_ListNode *next;
|
||||
} SDL_ListNode;
|
||||
|
||||
void
|
||||
SDL_InvalidateAllBlitMap(SDL_Surface *surface)
|
||||
{
|
||||
@@ -1040,6 +1045,40 @@ SDL_InvalidateAllBlitMap(SDL_Surface *surface)
|
||||
}
|
||||
}
|
||||
|
||||
static void SDL_ListAdd(SDL_ListNode **head, void *ent);
|
||||
static void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
||||
|
||||
void
|
||||
SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode *node = SDL_malloc(sizeof (*node));
|
||||
|
||||
if (node == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
|
||||
node->entry = ent;
|
||||
node->next = *head;
|
||||
*head = node;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ListRemove(SDL_ListNode **head, void *ent)
|
||||
{
|
||||
SDL_ListNode **ptr = head;
|
||||
|
||||
while (*ptr) {
|
||||
if ((*ptr)->entry == ent) {
|
||||
SDL_ListNode *tmp = *ptr;
|
||||
*ptr = (*ptr)->next;
|
||||
SDL_free(tmp);
|
||||
return;
|
||||
}
|
||||
ptr = &(*ptr)->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_InvalidateMap(SDL_BlitMap * map)
|
||||
{
|
||||
|
||||
491
externals/SDL/src/video/SDL_rect.c
vendored
491
externals/SDL/src/video/SDL_rect.c
vendored
@@ -23,8 +23,447 @@
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_rect_c.h"
|
||||
|
||||
/* There's no float version of this at the moment, because it's not a public API
|
||||
and internally we only need the int version. */
|
||||
SDL_bool
|
||||
SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
if (!A) {
|
||||
SDL_InvalidParamError("A");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!B) {
|
||||
SDL_InvalidParamError("B");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Special cases for empty rects */
|
||||
if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Horizontal intersection */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
if (Amax <= Amin)
|
||||
return SDL_FALSE;
|
||||
|
||||
/* Vertical intersection */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
if (Amax <= Amin)
|
||||
return SDL_FALSE;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
if (!A) {
|
||||
SDL_InvalidParamError("A");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!B) {
|
||||
SDL_InvalidParamError("B");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
SDL_InvalidParamError("result");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Special cases for empty rects */
|
||||
if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
|
||||
result->w = 0;
|
||||
result->h = 0;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Horizontal intersection */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
result->x = Amin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
result->w = Amax - Amin;
|
||||
|
||||
/* Vertical intersection */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
result->y = Amin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
result->h = Amax - Amin;
|
||||
|
||||
return !SDL_RectEmpty(result);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
if (!A) {
|
||||
SDL_InvalidParamError("A");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!B) {
|
||||
SDL_InvalidParamError("B");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
SDL_InvalidParamError("result");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Special cases for empty Rects */
|
||||
if (SDL_RectEmpty(A)) {
|
||||
if (SDL_RectEmpty(B)) {
|
||||
/* A and B empty */
|
||||
return;
|
||||
} else {
|
||||
/* A empty, B not empty */
|
||||
*result = *B;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (SDL_RectEmpty(B)) {
|
||||
/* A not empty, B empty */
|
||||
*result = *A;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Horizontal union */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin < Amin)
|
||||
Amin = Bmin;
|
||||
result->x = Amin;
|
||||
if (Bmax > Amax)
|
||||
Amax = Bmax;
|
||||
result->w = Amax - Amin;
|
||||
|
||||
/* Vertical union */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin < Amin)
|
||||
Amin = Bmin;
|
||||
result->y = Amin;
|
||||
if (Bmax > Amax)
|
||||
Amax = Bmax;
|
||||
result->h = Amax - Amin;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip,
|
||||
SDL_Rect * result)
|
||||
{
|
||||
int minx = 0;
|
||||
int miny = 0;
|
||||
int maxx = 0;
|
||||
int maxy = 0;
|
||||
int x, y, i;
|
||||
|
||||
if (!points) {
|
||||
SDL_InvalidParamError("points");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (count < 1) {
|
||||
SDL_InvalidParamError("count");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (clip) {
|
||||
SDL_bool added = SDL_FALSE;
|
||||
const int clip_minx = clip->x;
|
||||
const int clip_miny = clip->y;
|
||||
const int clip_maxx = clip->x+clip->w-1;
|
||||
const int clip_maxy = clip->y+clip->h-1;
|
||||
|
||||
/* Special case for empty rectangle */
|
||||
if (SDL_RectEmpty(clip)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < clip_minx || x > clip_maxx ||
|
||||
y < clip_miny || y > clip_maxy) {
|
||||
continue;
|
||||
}
|
||||
if (!added) {
|
||||
/* Special case: if no result was requested, we are done */
|
||||
if (result == NULL) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* First point added */
|
||||
minx = maxx = x;
|
||||
miny = maxy = y;
|
||||
added = SDL_TRUE;
|
||||
continue;
|
||||
}
|
||||
if (x < minx) {
|
||||
minx = x;
|
||||
} else if (x > maxx) {
|
||||
maxx = x;
|
||||
}
|
||||
if (y < miny) {
|
||||
miny = y;
|
||||
} else if (y > maxy) {
|
||||
maxy = y;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
} else {
|
||||
/* Special case: if no result was requested, we are done */
|
||||
if (result == NULL) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* No clipping, always add the first point */
|
||||
minx = maxx = points[0].x;
|
||||
miny = maxy = points[0].y;
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx) {
|
||||
minx = x;
|
||||
} else if (x > maxx) {
|
||||
maxx = x;
|
||||
}
|
||||
if (y < miny) {
|
||||
miny = y;
|
||||
} else if (y > maxy) {
|
||||
maxy = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result->x = minx;
|
||||
result->y = miny;
|
||||
result->w = (maxx-minx)+1;
|
||||
result->h = (maxy-miny)+1;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Use the Cohen-Sutherland algorithm for line clipping */
|
||||
#define CODE_BOTTOM 1
|
||||
#define CODE_TOP 2
|
||||
#define CODE_LEFT 4
|
||||
#define CODE_RIGHT 8
|
||||
|
||||
static int
|
||||
ComputeOutCode(const SDL_Rect * rect, int x, int y)
|
||||
{
|
||||
int code = 0;
|
||||
if (y < rect->y) {
|
||||
code |= CODE_TOP;
|
||||
} else if (y >= rect->y + rect->h) {
|
||||
code |= CODE_BOTTOM;
|
||||
}
|
||||
if (x < rect->x) {
|
||||
code |= CODE_LEFT;
|
||||
} else if (x >= rect->x + rect->w) {
|
||||
code |= CODE_RIGHT;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2,
|
||||
int *Y2)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
int rectx1;
|
||||
int recty1;
|
||||
int rectx2;
|
||||
int recty2;
|
||||
int outcode1, outcode2;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError("rect");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!X1) {
|
||||
SDL_InvalidParamError("X1");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!Y1) {
|
||||
SDL_InvalidParamError("Y1");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!X2) {
|
||||
SDL_InvalidParamError("X2");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!Y2) {
|
||||
SDL_InvalidParamError("Y2");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Special case for empty rect */
|
||||
if (SDL_RectEmpty(rect)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
x1 = *X1;
|
||||
y1 = *Y1;
|
||||
x2 = *X2;
|
||||
y2 = *Y2;
|
||||
rectx1 = rect->x;
|
||||
recty1 = rect->y;
|
||||
rectx2 = rect->x + rect->w - 1;
|
||||
recty2 = rect->y + rect->h - 1;
|
||||
|
||||
/* Check to see if entire line is inside rect */
|
||||
if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 &&
|
||||
y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check to see if entire line is to one side of rect */
|
||||
if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) ||
|
||||
(y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (y1 == y2) {
|
||||
/* Horizontal line, easy to clip */
|
||||
if (x1 < rectx1) {
|
||||
*X1 = rectx1;
|
||||
} else if (x1 > rectx2) {
|
||||
*X1 = rectx2;
|
||||
}
|
||||
if (x2 < rectx1) {
|
||||
*X2 = rectx1;
|
||||
} else if (x2 > rectx2) {
|
||||
*X2 = rectx2;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (x1 == x2) {
|
||||
/* Vertical line, easy to clip */
|
||||
if (y1 < recty1) {
|
||||
*Y1 = recty1;
|
||||
} else if (y1 > recty2) {
|
||||
*Y1 = recty2;
|
||||
}
|
||||
if (y2 < recty1) {
|
||||
*Y2 = recty1;
|
||||
} else if (y2 > recty2) {
|
||||
*Y2 = recty2;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* More complicated Cohen-Sutherland algorithm */
|
||||
outcode1 = ComputeOutCode(rect, x1, y1);
|
||||
outcode2 = ComputeOutCode(rect, x2, y2);
|
||||
while (outcode1 || outcode2) {
|
||||
if (outcode1 & outcode2) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (outcode1) {
|
||||
if (outcode1 & CODE_TOP) {
|
||||
y = recty1;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode1 & CODE_BOTTOM) {
|
||||
y = recty2;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode1 & CODE_LEFT) {
|
||||
x = rectx1;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
} else if (outcode1 & CODE_RIGHT) {
|
||||
x = rectx2;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
}
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
outcode1 = ComputeOutCode(rect, x, y);
|
||||
} else {
|
||||
if (outcode2 & CODE_TOP) {
|
||||
y = recty1;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode2 & CODE_BOTTOM) {
|
||||
y = recty2;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode2 & CODE_LEFT) {
|
||||
/* If this assertion ever fires, here's the static analysis that warned about it:
|
||||
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */
|
||||
SDL_assert(x2 != x1); /* if equal: division by zero. */
|
||||
x = rectx1;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
} else if (outcode2 & CODE_RIGHT) {
|
||||
/* If this assertion ever fires, here's the static analysis that warned about it:
|
||||
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */
|
||||
SDL_assert(x2 != x1); /* if equal: division by zero. */
|
||||
x = rectx2;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
}
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
outcode2 = ComputeOutCode(rect, x, y);
|
||||
}
|
||||
}
|
||||
*X1 = x1;
|
||||
*Y1 = y1;
|
||||
*X2 = x2;
|
||||
*Y2 = y2;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_GetSpanEnclosingRect(int width, int height,
|
||||
int numrects, const SDL_Rect * rects, SDL_Rect *span)
|
||||
@@ -36,16 +475,24 @@ SDL_GetSpanEnclosingRect(int width, int height,
|
||||
if (width < 1) {
|
||||
SDL_InvalidParamError("width");
|
||||
return SDL_FALSE;
|
||||
} else if (height < 1) {
|
||||
}
|
||||
|
||||
if (height < 1) {
|
||||
SDL_InvalidParamError("height");
|
||||
return SDL_FALSE;
|
||||
} else if (!rects) {
|
||||
}
|
||||
|
||||
if (!rects) {
|
||||
SDL_InvalidParamError("rects");
|
||||
return SDL_FALSE;
|
||||
} else if (!span) {
|
||||
}
|
||||
|
||||
if (!span) {
|
||||
SDL_InvalidParamError("span");
|
||||
return SDL_FALSE;
|
||||
} else if (numrects < 1) {
|
||||
}
|
||||
|
||||
if (numrects < 1) {
|
||||
SDL_InvalidParamError("numrects");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
@@ -80,36 +527,4 @@ SDL_GetSpanEnclosingRect(int width, int height,
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h */
|
||||
#define CODE_BOTTOM 1
|
||||
#define CODE_TOP 2
|
||||
#define CODE_LEFT 4
|
||||
#define CODE_RIGHT 8
|
||||
|
||||
/* Same code twice, for float and int versions... */
|
||||
#define RECTTYPE SDL_Rect
|
||||
#define POINTTYPE SDL_Point
|
||||
#define SCALARTYPE int
|
||||
#define COMPUTEOUTCODE ComputeOutCode
|
||||
#define SDL_HASINTERSECTION SDL_HasIntersection
|
||||
#define SDL_INTERSECTRECT SDL_IntersectRect
|
||||
#define SDL_RECTEMPTY SDL_RectEmpty
|
||||
#define SDL_UNIONRECT SDL_UnionRect
|
||||
#define SDL_ENCLOSEPOINTS SDL_EnclosePoints
|
||||
#define SDL_INTERSECTRECTANDLINE SDL_IntersectRectAndLine
|
||||
#include "SDL_rect_impl.h"
|
||||
|
||||
#define RECTTYPE SDL_FRect
|
||||
#define POINTTYPE SDL_FPoint
|
||||
#define SCALARTYPE float
|
||||
#define COMPUTEOUTCODE ComputeOutCodeF
|
||||
#define SDL_HASINTERSECTION SDL_HasIntersectionF
|
||||
#define SDL_INTERSECTRECT SDL_IntersectFRect
|
||||
#define SDL_RECTEMPTY SDL_FRectEmpty
|
||||
#define SDL_UNIONRECT SDL_UnionFRect
|
||||
#define SDL_ENCLOSEPOINTS SDL_EncloseFPoints
|
||||
#define SDL_INTERSECTRECTANDLINE SDL_IntersectFRectAndLine
|
||||
#include "SDL_rect_impl.h"
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
113
externals/SDL/src/video/SDL_surface.c
vendored
113
externals/SDL/src/video/SDL_surface.c
vendored
@@ -33,43 +33,25 @@
|
||||
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
|
||||
sizeof(int) == sizeof(Sint32) && sizeof(size_t) >= sizeof(Sint32));
|
||||
|
||||
SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32);
|
||||
|
||||
/* Public routines */
|
||||
|
||||
/*
|
||||
* Calculate the pad-aligned scanline width of a surface.
|
||||
* Return SDL_SIZE_MAX on overflow.
|
||||
* Calculate the pad-aligned scanline width of a surface
|
||||
*/
|
||||
static size_t
|
||||
SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
|
||||
static Sint64
|
||||
SDL_CalculatePitch(Uint32 format, int width)
|
||||
{
|
||||
size_t pitch;
|
||||
Sint64 pitch;
|
||||
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_BITSPERPIXEL(format) >= 8) {
|
||||
if (SDL_size_mul_overflow(width, SDL_BYTESPERPIXEL(format), &pitch)) {
|
||||
return SDL_SIZE_MAX;
|
||||
}
|
||||
pitch = ((Sint64)width * SDL_BYTESPERPIXEL(format));
|
||||
} else {
|
||||
if (SDL_size_mul_overflow(width, SDL_BITSPERPIXEL(format), &pitch)) {
|
||||
return SDL_SIZE_MAX;
|
||||
}
|
||||
if (SDL_size_add_overflow(pitch, 7, &pitch)) {
|
||||
return SDL_SIZE_MAX;
|
||||
}
|
||||
pitch /= 8;
|
||||
}
|
||||
if (!minimal) {
|
||||
/* 4-byte aligning for speed */
|
||||
if (SDL_size_add_overflow(pitch, 3, &pitch)) {
|
||||
return SDL_SIZE_MAX;
|
||||
}
|
||||
pitch &= ~3;
|
||||
pitch = (((Sint64)width * SDL_BITSPERPIXEL(format)) + 7) / 8;
|
||||
}
|
||||
pitch = (pitch + 3) & ~3; /* 4-byte aligning for speed */
|
||||
return pitch;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused flags and depth parameters */
|
||||
/*
|
||||
* Create an empty RGB surface of the appropriate depth using the given
|
||||
* enum SDL_PIXELFORMAT_* format
|
||||
@@ -78,24 +60,14 @@ SDL_Surface *
|
||||
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 format)
|
||||
{
|
||||
size_t pitch;
|
||||
Sint64 pitch;
|
||||
SDL_Surface *surface;
|
||||
|
||||
/* The flags are no longer used, make the compiler happy */
|
||||
(void)flags;
|
||||
|
||||
if (width < 0) {
|
||||
SDL_InvalidParamError("width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (height < 0) {
|
||||
SDL_InvalidParamError("height");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pitch = SDL_CalculatePitch(format, width, SDL_FALSE);
|
||||
if (pitch > SDL_MAX_SINT32) {
|
||||
pitch = SDL_CalculatePitch(format, width);
|
||||
if (pitch < 0 || pitch > SDL_MAX_SINT32) {
|
||||
/* Overflow... */
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -141,15 +113,15 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
/* Get the pixels */
|
||||
if (surface->w && surface->h) {
|
||||
/* Assumptions checked in surface_size_assumptions assert above */
|
||||
size_t size;
|
||||
if (SDL_size_mul_overflow(surface->h, surface->pitch, &size)) {
|
||||
Sint64 size = ((Sint64)surface->h * surface->pitch);
|
||||
if (size < 0 || size > SDL_MAX_SINT32) {
|
||||
/* Overflow... */
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface->pixels = SDL_SIMDAlloc(size);
|
||||
surface->pixels = SDL_SIMDAlloc((size_t)size);
|
||||
if (!surface->pixels) {
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_OutOfMemory();
|
||||
@@ -157,7 +129,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
}
|
||||
surface->flags |= SDL_SIMD_ALIGNED;
|
||||
/* This is important for bitmaps */
|
||||
SDL_memset(surface->pixels, 0, size);
|
||||
SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
|
||||
}
|
||||
|
||||
/* Allocate an empty mapping */
|
||||
@@ -177,7 +149,6 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused flags parameter */
|
||||
/*
|
||||
* Create an empty RGB surface of the appropriate depth
|
||||
*/
|
||||
@@ -208,34 +179,8 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
Uint32 Amask)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
Uint32 format;
|
||||
size_t minimalPitch;
|
||||
|
||||
if (width < 0) {
|
||||
SDL_InvalidParamError("width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (height < 0) {
|
||||
SDL_InvalidParamError("height");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask);
|
||||
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
SDL_SetError("Unknown pixel format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE);
|
||||
|
||||
if (pitch < 0 || ((size_t) pitch) < minimalPitch) {
|
||||
SDL_InvalidParamError("pitch");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
|
||||
surface = SDL_CreateRGBSurface(0, 0, 0, depth, Rmask, Gmask, Bmask, Amask);
|
||||
if (surface != NULL) {
|
||||
surface->flags |= SDL_PREALLOC;
|
||||
surface->pixels = pixels;
|
||||
@@ -247,7 +192,6 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
return surface;
|
||||
}
|
||||
|
||||
/* TODO: In SDL 3, drop the unused depth parameter */
|
||||
/*
|
||||
* Create an RGB surface from an existing memory buffer using the given given
|
||||
* enum SDL_PIXELFORMAT_* format
|
||||
@@ -258,24 +202,6 @@ SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
|
||||
Uint32 format)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
size_t minimalPitch;
|
||||
|
||||
if (width < 0) {
|
||||
SDL_InvalidParamError("width");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (height < 0) {
|
||||
SDL_InvalidParamError("height");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
minimalPitch = SDL_CalculatePitch(format, width, SDL_TRUE);
|
||||
|
||||
if (pitch < 0 || ((size_t) pitch) < minimalPitch) {
|
||||
SDL_InvalidParamError("pitch");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
|
||||
if (surface != NULL) {
|
||||
@@ -293,7 +219,7 @@ int
|
||||
SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
|
||||
{
|
||||
if (!surface) {
|
||||
return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface");
|
||||
return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
|
||||
}
|
||||
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
|
||||
return -1;
|
||||
@@ -720,7 +646,7 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
return SDL_InvalidParamError("SDL_UpperBlit(): src/dst");
|
||||
return SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
@@ -831,7 +757,7 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if (!src || !dst) {
|
||||
return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst");
|
||||
return SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface");
|
||||
}
|
||||
if (src->locked || dst->locked) {
|
||||
return SDL_SetError("Surfaces must not be locked during blit");
|
||||
@@ -1478,7 +1404,8 @@ int SDL_ConvertPixels(int width, int height,
|
||||
}
|
||||
#else
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
|
||||
return SDL_SetError("SDL not built with YUV support");
|
||||
SDL_SetError("SDL not built with YUV support");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
10
externals/SDL/src/video/SDL_sysvideo.h
vendored
10
externals/SDL/src/video/SDL_sysvideo.h
vendored
@@ -237,7 +237,6 @@ struct SDL_VideoDevice
|
||||
int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
|
||||
int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
void* (*GetWindowICCProfile) (_THIS, SDL_Window * window, size_t* size);
|
||||
int (*GetWindowDisplayIndex)(_THIS, SDL_Window * window);
|
||||
void (*SetWindowMouseRect)(_THIS, SDL_Window * window);
|
||||
void (*SetWindowMouseGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
void (*SetWindowKeyboardGrab) (_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
@@ -308,8 +307,6 @@ struct SDL_VideoDevice
|
||||
void (*StartTextInput) (_THIS);
|
||||
void (*StopTextInput) (_THIS);
|
||||
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
|
||||
void (*ClearComposition) (_THIS);
|
||||
SDL_bool (*IsTextInputShown) (_THIS);
|
||||
|
||||
/* Screen keyboard */
|
||||
SDL_bool (*HasScreenKeyboardSupport) (_THIS);
|
||||
@@ -333,8 +330,6 @@ struct SDL_VideoDevice
|
||||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_threadID thread;
|
||||
SDL_bool checked_texture_framebuffer;
|
||||
SDL_bool is_dummy;
|
||||
SDL_bool suspend_screensaver;
|
||||
SDL_Window *wakeup_window;
|
||||
@@ -347,7 +342,6 @@ struct SDL_VideoDevice
|
||||
Uint32 next_object_id;
|
||||
char *clipboard_text;
|
||||
SDL_bool setting_display_mode;
|
||||
SDL_bool disable_display_mode_switching;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the GL drivers */
|
||||
@@ -458,12 +452,9 @@ extern VideoBootStrap VIVANTE_bootstrap;
|
||||
extern VideoBootStrap Emscripten_bootstrap;
|
||||
extern VideoBootStrap QNX_bootstrap;
|
||||
extern VideoBootStrap OFFSCREEN_bootstrap;
|
||||
extern VideoBootStrap NGAGE_bootstrap;
|
||||
extern VideoBootStrap OS2DIVE_bootstrap;
|
||||
extern VideoBootStrap OS2VMAN_bootstrap;
|
||||
|
||||
/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
|
||||
extern SDL_bool SDL_OnVideoThread(void);
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display, SDL_bool send_event);
|
||||
@@ -477,7 +468,6 @@ extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
|
||||
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
||||
extern void *SDL_GetDisplayDriverData( int displayIndex );
|
||||
extern SDL_bool SDL_IsVideoContextExternal(void);
|
||||
extern int SDL_GetMessageBoxCount(void);
|
||||
|
||||
extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor);
|
||||
|
||||
|
||||
520
externals/SDL/src/video/SDL_video.c
vendored
520
externals/SDL/src/video/SDL_video.c
vendored
@@ -118,9 +118,6 @@ static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_OFFSCREEN
|
||||
&OFFSCREEN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
&NGAGE_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
&OS2DIVE_bootstrap,
|
||||
&OS2VMAN_bootstrap,
|
||||
@@ -131,6 +128,8 @@ static VideoBootStrap *bootstrap[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static SDL_VideoDevice *_this = NULL;
|
||||
|
||||
#define CHECK_WINDOW_MAGIC(window, retval) \
|
||||
if (!_this) { \
|
||||
SDL_UninitializedVideo(); \
|
||||
@@ -173,58 +172,129 @@ typedef struct {
|
||||
int bytes_per_pixel;
|
||||
} SDL_WindowTextureData;
|
||||
|
||||
static SDL_bool
|
||||
ShouldUseTextureFramebuffer()
|
||||
{
|
||||
const char *hint;
|
||||
|
||||
/* If there's no native framebuffer support then there's no option */
|
||||
if (!_this->CreateWindowFramebuffer) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* If this is the dummy driver there is no texture support */
|
||||
if (_this->is_dummy) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* See if the user or application wants a specific behavior */
|
||||
hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint) {
|
||||
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Each platform has different performance characteristics */
|
||||
#if defined(__WIN32__)
|
||||
/* GDI BitBlt() is way faster than Direct3D dynamic textures right now.
|
||||
*/
|
||||
return SDL_FALSE;
|
||||
|
||||
#elif defined(__MACOSX__)
|
||||
/* Mac OS X uses OpenGL as the native fast path (for cocoa and X11) */
|
||||
return SDL_TRUE;
|
||||
|
||||
#elif defined(__LINUX__)
|
||||
/* Properly configured OpenGL drivers are faster than MIT-SHM */
|
||||
#if SDL_VIDEO_OPENGL
|
||||
/* Ugh, find a way to cache this value! */
|
||||
{
|
||||
SDL_Window *window;
|
||||
SDL_GLContext context;
|
||||
SDL_bool hasAcceleratedOpenGL = SDL_FALSE;
|
||||
|
||||
window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN);
|
||||
if (window) {
|
||||
context = SDL_GL_CreateContext(window);
|
||||
if (context) {
|
||||
const GLubyte *(APIENTRY * glGetStringFunc) (GLenum);
|
||||
const char *vendor = NULL;
|
||||
|
||||
glGetStringFunc = SDL_GL_GetProcAddress("glGetString");
|
||||
if (glGetStringFunc) {
|
||||
vendor = (const char *) glGetStringFunc(GL_VENDOR);
|
||||
}
|
||||
/* Add more vendors here at will... */
|
||||
if (vendor &&
|
||||
(SDL_strstr(vendor, "ATI Technologies") ||
|
||||
SDL_strstr(vendor, "NVIDIA"))) {
|
||||
hasAcceleratedOpenGL = SDL_TRUE;
|
||||
}
|
||||
SDL_GL_DeleteContext(context);
|
||||
}
|
||||
SDL_DestroyWindow(window);
|
||||
}
|
||||
return hasAcceleratedOpenGL;
|
||||
}
|
||||
#elif SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||
/* Let's be optimistic about this! */
|
||||
return SDL_TRUE;
|
||||
#else
|
||||
return SDL_FALSE;
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* Play it safe, assume that if there is a framebuffer driver that it's
|
||||
optimized for the current platform.
|
||||
*/
|
||||
return SDL_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
SDL_WindowTextureData *data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
||||
int i;
|
||||
SDL_WindowTextureData *data;
|
||||
|
||||
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
|
||||
if (!data) {
|
||||
SDL_Renderer *renderer = NULL;
|
||||
int i;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
const SDL_bool specific_accelerated_renderer = (
|
||||
hint && *hint != '0' && *hint != '1' &&
|
||||
SDL_strcasecmp(hint, "true") != 0 &&
|
||||
SDL_strcasecmp(hint, "false") != 0 &&
|
||||
SDL_strcasecmp(hint, "software") != 0
|
||||
);
|
||||
|
||||
/* Check to see if there's a specific driver requested */
|
||||
if (specific_accelerated_renderer) {
|
||||
if (hint && *hint != '0' && *hint != '1' &&
|
||||
SDL_strcasecmp(hint, "true") != 0 &&
|
||||
SDL_strcasecmp(hint, "false") != 0 &&
|
||||
SDL_strcasecmp(hint, "software") != 0) {
|
||||
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
|
||||
SDL_RendererInfo info;
|
||||
SDL_GetRenderDriverInfo(i, &info);
|
||||
if (SDL_strcasecmp(info.name, hint) == 0) {
|
||||
renderer = SDL_CreateRenderer(window, i, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) {
|
||||
if (renderer) { SDL_DestroyRenderer(renderer); }
|
||||
return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available");
|
||||
}
|
||||
/* if it was specifically requested, even if SDL_RENDERER_ACCELERATED isn't set, we'll accept this renderer. */
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!renderer) {
|
||||
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
|
||||
SDL_RendererInfo info;
|
||||
SDL_GetRenderDriverInfo(i, &info);
|
||||
if (SDL_strcmp(info.name, "software") != 0) {
|
||||
renderer = SDL_CreateRenderer(window, i, 0);
|
||||
if (renderer && (SDL_GetRendererInfo(renderer, &info) == 0) && (info.flags & SDL_RENDERER_ACCELERATED)) {
|
||||
break; /* this will work. */
|
||||
}
|
||||
if (renderer) { /* wasn't accelerated, etc, skip it. */
|
||||
SDL_DestroyRenderer(renderer);
|
||||
renderer = NULL;
|
||||
if (renderer) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!renderer) {
|
||||
return SDL_SetError("No hardware accelerated renderers available");
|
||||
}
|
||||
}
|
||||
|
||||
SDL_assert(renderer != NULL); /* should have explicitly checked this above. */
|
||||
if (!renderer) {
|
||||
return SDL_SetError("No hardware accelerated renderers available");
|
||||
}
|
||||
|
||||
/* Create the data after we successfully create the renderer (bug #1116) */
|
||||
data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
|
||||
@@ -235,10 +305,6 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
||||
SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data);
|
||||
|
||||
data->renderer = renderer;
|
||||
} else {
|
||||
if (SDL_GetRendererInfo(data->renderer, &info) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free any old texture and pixel data */
|
||||
@@ -249,14 +315,23 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
||||
SDL_free(data->pixels);
|
||||
data->pixels = NULL;
|
||||
|
||||
/* Find the first format without an alpha channel */
|
||||
*format = info.texture_formats[0];
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
Uint32 i;
|
||||
|
||||
for (i = 0; i < (int) info.num_texture_formats; ++i) {
|
||||
if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
|
||||
!SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
|
||||
*format = info.texture_formats[i];
|
||||
break;
|
||||
if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Find the first format without an alpha channel */
|
||||
*format = info.texture_formats[0];
|
||||
|
||||
for (i = 0; i < info.num_texture_formats; ++i) {
|
||||
if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) &&
|
||||
!SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) {
|
||||
*format = info.texture_formats[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +339,6 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
window->w, window->h);
|
||||
if (!data->texture) {
|
||||
/* codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_WINDOWTEXTUREDATA and not leaked here. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -290,9 +364,6 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
||||
return 0;
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *_this = NULL;
|
||||
static SDL_atomic_t SDL_messagebox_count;
|
||||
|
||||
static int
|
||||
SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||
{
|
||||
@@ -342,7 +413,8 @@ SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
|
||||
static int
|
||||
cmpmodes(const void *A, const void *B)
|
||||
{
|
||||
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
|
||||
@@ -429,7 +501,7 @@ SDL_VideoInit(const char *driver_name)
|
||||
i = index = 0;
|
||||
video = NULL;
|
||||
if (driver_name == NULL) {
|
||||
driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER);
|
||||
driver_name = SDL_getenv("SDL_VIDEODRIVER");
|
||||
}
|
||||
if (driver_name != NULL && *driver_name != 0) {
|
||||
const char *driver_attempt = driver_name;
|
||||
@@ -470,7 +542,6 @@ SDL_VideoInit(const char *driver_name)
|
||||
_this = video;
|
||||
_this->name = bootstrap[i]->name;
|
||||
_this->next_object_id = 1;
|
||||
_this->thread = SDL_ThreadID();
|
||||
|
||||
|
||||
/* Set some very sane GL defaults */
|
||||
@@ -493,6 +564,13 @@ SDL_VideoInit(const char *driver_name)
|
||||
return SDL_SetError("The video driver did not add any displays");
|
||||
}
|
||||
|
||||
/* Add the renderer framebuffer emulation if desired */
|
||||
if (ShouldUseTextureFramebuffer()) {
|
||||
_this->CreateWindowFramebuffer = SDL_CreateWindowTexture;
|
||||
_this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture;
|
||||
_this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture;
|
||||
}
|
||||
|
||||
/* Disable the screen saver by default. This is a change from <= 2.0.1,
|
||||
but most things using SDL are games or media players; you wouldn't
|
||||
want a screensaver to trigger if you're playing exclusively with a
|
||||
@@ -550,12 +628,6 @@ SDL_GetVideoDevice(void)
|
||||
return _this;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_OnVideoThread()
|
||||
{
|
||||
return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
|
||||
{
|
||||
@@ -898,7 +970,7 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
|
||||
SDL_DisplayMode *current, *match;
|
||||
|
||||
if (!mode || !closest) {
|
||||
SDL_InvalidParamError("mode/closest");
|
||||
SDL_SetError("Missing desired mode or closest mode parameter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1071,64 +1143,61 @@ SDL_GetDisplay(int displayIndex)
|
||||
int
|
||||
SDL_GetWindowDisplayIndex(SDL_Window * window)
|
||||
{
|
||||
int displayIndex;
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
int closest_dist = 0x7FFFFFFF;
|
||||
SDL_Point center;
|
||||
SDL_Point delta;
|
||||
SDL_Rect rect;
|
||||
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
if (_this->GetWindowDisplayIndex) {
|
||||
return _this->GetWindowDisplayIndex(_this, window);
|
||||
} else {
|
||||
int displayIndex;
|
||||
int i, dist;
|
||||
int closest = -1;
|
||||
int closest_dist = 0x7FFFFFFF;
|
||||
SDL_Point center;
|
||||
SDL_Point delta;
|
||||
SDL_Rect rect;
|
||||
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
displayIndex = (window->x & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
|
||||
displayIndex = (window->x & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
displayIndex = (window->y & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
|
||||
/* Find the display containing the window */
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
if (display->fullscreen_window == window) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
center.x = window->x + window->w / 2;
|
||||
center.y = window->y + window->h / 2;
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_GetDisplayBounds(i, &rect);
|
||||
if (SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
delta.x = center.x - (rect.x + rect.w / 2);
|
||||
delta.y = center.y - (rect.y + rect.h / 2);
|
||||
dist = (delta.x*delta.x + delta.y*delta.y);
|
||||
if (dist < closest_dist) {
|
||||
closest = i;
|
||||
closest_dist = dist;
|
||||
}
|
||||
}
|
||||
if (closest < 0) {
|
||||
SDL_SetError("Couldn't find any displays");
|
||||
}
|
||||
return closest;
|
||||
return displayIndex;
|
||||
}
|
||||
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
|
||||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
|
||||
displayIndex = (window->y & 0xFFFF);
|
||||
if (displayIndex >= _this->num_displays) {
|
||||
displayIndex = 0;
|
||||
}
|
||||
return displayIndex;
|
||||
}
|
||||
|
||||
/* Find the display containing the window */
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
if (display->fullscreen_window == window) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
center.x = window->x + window->w / 2;
|
||||
center.y = window->y + window->h / 2;
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_GetDisplayBounds(i, &rect);
|
||||
if (SDL_EnclosePoints(¢er, 1, &rect, NULL)) {
|
||||
return i;
|
||||
}
|
||||
|
||||
delta.x = center.x - (rect.x + rect.w / 2);
|
||||
delta.y = center.y - (rect.y + rect.h / 2);
|
||||
dist = (delta.x*delta.x + delta.y*delta.y);
|
||||
if (dist < closest_dist) {
|
||||
closest = i;
|
||||
closest_dist = dist;
|
||||
}
|
||||
}
|
||||
if (closest < 0) {
|
||||
SDL_SetError("Couldn't find any displays");
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
SDL_VideoDisplay *
|
||||
@@ -1199,7 +1268,6 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
||||
} else if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
|
||||
&fullscreen_mode,
|
||||
&fullscreen_mode)) {
|
||||
SDL_zerop(mode);
|
||||
return SDL_SetError("Couldn't find display mode match");
|
||||
}
|
||||
|
||||
@@ -1353,17 +1421,14 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||
resized = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Don't try to change the display mode if the driver doesn't want it. */
|
||||
if (_this->disable_display_mode_switching == SDL_FALSE) {
|
||||
/* only do the mode change if we want exclusive fullscreen */
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
/* only do the mode change if we want exclusive fullscreen */
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||
if (SDL_SetDisplayModeForDisplay(display, &fullscreen_mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (SDL_SetDisplayModeForDisplay(display, NULL) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1374,17 +1439,12 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
|
||||
|
||||
/* Generate a mode change event here */
|
||||
if (resized) {
|
||||
#if !defined(ANDROID) && !defined(WIN32)
|
||||
#ifndef ANDROID
|
||||
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
|
||||
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
|
||||
* use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
|
||||
* Android's SetWindowFullscreen will generate the window event for us with the proper final size.
|
||||
*/
|
||||
|
||||
/* This is also unnecessary on Win32 (WIN_SetWindowFullscreen calls SetWindowPos,
|
||||
* WM_WINDOWPOSCHANGED will send SDL_WINDOWEVENT_RESIZED). Also, on Windows with DPI scaling enabled,
|
||||
* we're keeping modes in pixels, but window sizes in dpi-scaled points, so this would be a unit mismatch.
|
||||
*/
|
||||
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
|
||||
fullscreen_mode.w, fullscreen_mode.h);
|
||||
#endif
|
||||
@@ -1516,16 +1576,12 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
}
|
||||
|
||||
/* Some platforms have certain graphics backends enabled by default */
|
||||
if (!graphics_flags && !SDL_IsVideoContextExternal()) {
|
||||
if (!_this->is_dummy && !graphics_flags && !SDL_IsVideoContextExternal()) {
|
||||
#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__
|
||||
if (_this->GL_CreateContext != NULL) {
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__)
|
||||
if (_this->Metal_CreateView != NULL) {
|
||||
flags |= SDL_WINDOW_METAL;
|
||||
}
|
||||
flags |= SDL_WINDOW_METAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1700,7 +1756,6 @@ SDL_Window *
|
||||
SDL_CreateWindowFrom(const void *data)
|
||||
{
|
||||
SDL_Window *window;
|
||||
Uint32 flags = SDL_WINDOW_FOREIGN;
|
||||
|
||||
if (!_this) {
|
||||
SDL_UninitializedVideo();
|
||||
@@ -1710,37 +1765,6 @@ SDL_CreateWindowFrom(const void *data)
|
||||
SDL_Unsupported();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL, SDL_FALSE)) {
|
||||
if (!_this->GL_CreateContext) {
|
||||
SDL_SetError("OpenGL support is either not configured in SDL "
|
||||
"or not available in current SDL video driver "
|
||||
"(%s) or platform", _this->name);
|
||||
return NULL;
|
||||
}
|
||||
if (SDL_GL_LoadLibrary(NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN, SDL_FALSE)) {
|
||||
if (!_this->Vulkan_CreateSurface) {
|
||||
SDL_SetError("Vulkan support is either not configured in SDL "
|
||||
"or not available in current SDL video driver "
|
||||
"(%s) or platform", _this->name);
|
||||
return NULL;
|
||||
}
|
||||
if (flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return NULL;
|
||||
}
|
||||
if (SDL_Vulkan_LoadLibrary(NULL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
flags |= SDL_WINDOW_VULKAN;
|
||||
}
|
||||
|
||||
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
|
||||
if (!window) {
|
||||
SDL_OutOfMemory();
|
||||
@@ -1748,7 +1772,7 @@ SDL_CreateWindowFrom(const void *data)
|
||||
}
|
||||
window->magic = &_this->window_magic;
|
||||
window->id = _this->next_object_id++;
|
||||
window->flags = flags;
|
||||
window->flags = SDL_WINDOW_FOREIGN;
|
||||
window->last_fullscreen_flags = window->flags;
|
||||
window->is_destroying = SDL_FALSE;
|
||||
window->opacity = 1.0f;
|
||||
@@ -1794,9 +1818,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
|
||||
/* Restore video mode, etc. */
|
||||
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
|
||||
SDL_HideWindow(window);
|
||||
}
|
||||
SDL_HideWindow(window);
|
||||
|
||||
/* Tear down the old native window */
|
||||
if (window->surface) {
|
||||
@@ -1805,13 +1827,9 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
|
||||
if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
}
|
||||
@@ -1827,6 +1845,17 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
need_gl_load = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_METAL) != (flags & SDL_WINDOW_METAL)) {
|
||||
if (flags & SDL_WINDOW_METAL) {
|
||||
need_gl_load = SDL_TRUE;
|
||||
} else {
|
||||
need_gl_unload = SDL_TRUE;
|
||||
}
|
||||
} else if (window->flags & SDL_WINDOW_METAL) {
|
||||
need_gl_unload = SDL_TRUE;
|
||||
need_gl_load = SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) {
|
||||
if (flags & SDL_WINDOW_VULKAN) {
|
||||
need_vulkan_load = SDL_TRUE;
|
||||
@@ -1839,15 +1868,18 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
|
||||
return SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
SDL_SetError("Vulkan and OpenGL not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
|
||||
return SDL_SetError("Metal and OpenGL not supported on same window");
|
||||
SDL_SetError("Metal and OpenGL not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
|
||||
return SDL_SetError("Metal and Vulkan not supported on same window");
|
||||
SDL_SetError("Metal and Vulkan not supported on same window");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (need_gl_unload) {
|
||||
@@ -2241,14 +2273,12 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
|
||||
SDL_UpdateFullscreenMode(window, SDL_TRUE);
|
||||
}
|
||||
} else {
|
||||
int old_w = window->w;
|
||||
int old_h = window->h;
|
||||
window->w = w;
|
||||
window->h = h;
|
||||
if (_this->SetWindowSize) {
|
||||
_this->SetWindowSize(_this, window);
|
||||
}
|
||||
if (window->w != old_w || window->h != old_h) {
|
||||
if (window->w == w && window->h == h) {
|
||||
/* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
|
||||
SDL_OnWindowResized(window);
|
||||
}
|
||||
@@ -2509,71 +2539,18 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
|
||||
static SDL_Surface *
|
||||
SDL_CreateWindowFramebuffer(SDL_Window * window)
|
||||
{
|
||||
Uint32 format = 0;
|
||||
void *pixels = NULL;
|
||||
int pitch = 0;
|
||||
Uint32 format;
|
||||
void *pixels;
|
||||
int pitch;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
SDL_bool created_framebuffer = SDL_FALSE;
|
||||
|
||||
/* This will switch the video backend from using a software surface to
|
||||
using a GPU texture through the 2D render API, if we think this would
|
||||
be more efficient. This only checks once, on demand. */
|
||||
if (!_this->checked_texture_framebuffer) {
|
||||
SDL_bool attempt_texture_framebuffer = SDL_TRUE;
|
||||
|
||||
/* See if the user or application wants to specifically disable the framebuffer */
|
||||
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint) {
|
||||
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
|
||||
#if defined(__WIN32__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
|
||||
else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
else {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (attempt_texture_framebuffer) {
|
||||
if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) == -1) {
|
||||
/* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc),
|
||||
!!! FIXME: we probably need to clean this up so it doesn't interfere with
|
||||
!!! FIXME: a software fallback at the system level (can we blit to an
|
||||
!!! FIXME: OpenGL window? etc). */
|
||||
} else {
|
||||
/* future attempts will just try to use a texture framebuffer. */
|
||||
/* !!! FIXME: maybe we shouldn't override these but check if we used a texture
|
||||
!!! FIXME: framebuffer at the right places; is it feasible we could have an
|
||||
!!! FIXME: accelerated OpenGL window and a second ends up in software? */
|
||||
_this->CreateWindowFramebuffer = SDL_CreateWindowTexture;
|
||||
_this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture;
|
||||
_this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture;
|
||||
created_framebuffer = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
_this->checked_texture_framebuffer = SDL_TRUE; /* don't check this again. */
|
||||
if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!created_framebuffer) {
|
||||
if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (window->surface) {
|
||||
@@ -2631,8 +2608,6 @@ SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects,
|
||||
return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface");
|
||||
}
|
||||
|
||||
SDL_assert(_this->checked_texture_framebuffer); /* we should have done this before we had a valid surface. */
|
||||
|
||||
return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
|
||||
}
|
||||
|
||||
@@ -3051,7 +3026,7 @@ SDL_OnWindowFocusGained(SDL_Window * window)
|
||||
if (mouse && mouse->relative_mode) {
|
||||
SDL_SetMouseFocus(window);
|
||||
if (mouse->relative_mode_warp) {
|
||||
SDL_PerformWarpMouseInWindow(window, window->w/2, window->h/2, SDL_TRUE);
|
||||
SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3087,8 +3062,7 @@ ShouldMinimizeOnFocusLoss(SDL_Window * window)
|
||||
/* Real fullscreen windows should minimize on focus loss so the desktop video mode is restored */
|
||||
hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS);
|
||||
if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) {
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP ||
|
||||
_this->disable_display_mode_switching == SDL_TRUE) {
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) {
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
@@ -3139,9 +3113,7 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
window->is_destroying = SDL_TRUE;
|
||||
|
||||
/* Restore video mode, etc. */
|
||||
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
|
||||
SDL_HideWindow(window);
|
||||
}
|
||||
SDL_HideWindow(window);
|
||||
|
||||
/* Make sure this window no longer has focus */
|
||||
if (SDL_GetKeyboardFocus() == window) {
|
||||
@@ -3164,10 +3136,8 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
}
|
||||
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
if (_this->DestroyWindow) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
@@ -3952,10 +3922,6 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (!_this) {
|
||||
return SDL_UninitializedVideo();
|
||||
}
|
||||
|
||||
if (window == SDL_GL_GetCurrentWindow() &&
|
||||
ctx == SDL_GL_GetCurrentContext()) {
|
||||
/* We're already current. */
|
||||
@@ -4213,24 +4179,6 @@ SDL_StartTextInput(void)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ClearComposition(void)
|
||||
{
|
||||
if (_this && _this->ClearComposition) {
|
||||
_this->ClearComposition(_this);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IsTextInputShown(void)
|
||||
{
|
||||
if (_this && _this->IsTextInputShown) {
|
||||
return _this->IsTextInputShown(_this);
|
||||
}
|
||||
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IsTextInputActive(void)
|
||||
{
|
||||
@@ -4284,12 +4232,6 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_GetMessageBoxCount(void)
|
||||
{
|
||||
return SDL_AtomicGet(&SDL_messagebox_count);
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
#include "android/SDL_androidmessagebox.h"
|
||||
#endif
|
||||
@@ -4350,6 +4292,7 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
int retval = -1;
|
||||
SDL_bool relative_mode;
|
||||
int show_cursor_prev;
|
||||
SDL_bool mouse_captured;
|
||||
SDL_Window *current_window;
|
||||
SDL_MessageBoxData mbdata;
|
||||
|
||||
@@ -4359,11 +4302,10 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
return SDL_SetError("Invalid number of buttons");
|
||||
}
|
||||
|
||||
(void)SDL_AtomicIncRef(&SDL_messagebox_count);
|
||||
|
||||
current_window = SDL_GetKeyboardFocus();
|
||||
mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
|
||||
relative_mode = SDL_GetRelativeMouseMode();
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
SDL_CaptureMouse(SDL_FALSE);
|
||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
show_cursor_prev = SDL_ShowCursor(1);
|
||||
SDL_ResetKeyboard();
|
||||
@@ -4467,15 +4409,15 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
}
|
||||
}
|
||||
|
||||
(void)SDL_AtomicDecRef(&SDL_messagebox_count);
|
||||
|
||||
if (current_window) {
|
||||
SDL_RaiseWindow(current_window);
|
||||
if (mouse_captured) {
|
||||
SDL_CaptureMouse(SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_ShowCursor(show_cursor_prev);
|
||||
SDL_SetRelativeMouseMode(relative_mode);
|
||||
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
#if SDL_LOADSO_DISABLED || SDL_LOADSO_DUMMY
|
||||
#error You should not be here.
|
||||
#if defined(SDL_LOADSO_DISABLED)
|
||||
#undef SDL_VIDEO_VULKAN
|
||||
#define SDL_VIDEO_VULKAN 0
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
#define VK_USE_PLATFORM_ANDROID_KHR
|
||||
#endif
|
||||
|
||||
46
externals/SDL/src/video/SDL_yuv.c
vendored
46
externals/SDL/src/video/SDL_yuv.c
vendored
@@ -290,48 +290,6 @@ static SDL_bool yuv_rgb_sse(
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_bool yuv_rgb_lsx(
|
||||
Uint32 src_format, Uint32 dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
YCbCrType yuv_type)
|
||||
{
|
||||
#ifdef __loongarch_sx
|
||||
if (!SDL_HasLSX()) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (src_format == SDL_PIXELFORMAT_YV12 ||
|
||||
src_format == SDL_PIXELFORMAT_IYUV) {
|
||||
|
||||
switch (dst_format) {
|
||||
case SDL_PIXELFORMAT_RGB24:
|
||||
yuv420_rgb24_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
|
||||
return SDL_TRUE;
|
||||
case SDL_PIXELFORMAT_RGBX8888:
|
||||
case SDL_PIXELFORMAT_RGBA8888:
|
||||
yuv420_rgba_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
|
||||
return SDL_TRUE;
|
||||
case SDL_PIXELFORMAT_BGRX8888:
|
||||
case SDL_PIXELFORMAT_BGRA8888:
|
||||
yuv420_bgra_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
|
||||
return SDL_TRUE;
|
||||
case SDL_PIXELFORMAT_RGB888:
|
||||
case SDL_PIXELFORMAT_ARGB8888:
|
||||
yuv420_argb_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
|
||||
return SDL_TRUE;
|
||||
case SDL_PIXELFORMAT_BGR888:
|
||||
case SDL_PIXELFORMAT_ABGR8888:
|
||||
yuv420_abgr_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
|
||||
return SDL_TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_bool yuv_rgb_std(
|
||||
Uint32 src_format, Uint32 dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
@@ -459,10 +417,6 @@ SDL_ConvertPixels_YUV_to_RGB(int width, int height,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (yuv_rgb_lsx(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (yuv_rgb_std(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ SDL_NumberOfEvents(Uint32 type)
|
||||
return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type);
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
static void
|
||||
android_egl_context_restore(SDL_Window *window)
|
||||
{
|
||||
@@ -97,7 +96,7 @@ android_egl_context_backup(SDL_Window *window)
|
||||
data->backup_done = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume
|
||||
@@ -114,14 +113,12 @@ Android_PumpEvents_Blocking(_THIS)
|
||||
if (videodata->isPaused) {
|
||||
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
/* Make sure this is the last thing we do before pausing */
|
||||
if (!isContextExternal) {
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
android_egl_context_backup(Android_Window);
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
openslES_PauseDevices();
|
||||
@@ -141,13 +138,11 @@ Android_PumpEvents_Blocking(_THIS)
|
||||
aaudio_ResumeDevices();
|
||||
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
android_egl_context_restore(Android_Window);
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
||||
if (SDL_IsTextInputActive()) {
|
||||
@@ -193,13 +188,11 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
|
||||
if (backup_context) {
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (!isContextExternal) {
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
android_egl_context_backup(Android_Window);
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (videodata->pauseAudio) {
|
||||
ANDROIDAUDIO_PauseDevices();
|
||||
@@ -226,14 +219,12 @@ Android_PumpEvents_NonBlocking(_THIS)
|
||||
aaudio_ResumeDevices();
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
/* Restore the GL Context from here, as this operation is thread dependent */
|
||||
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
android_egl_context_restore(Android_Window);
|
||||
SDL_UnlockMutex(Android_ActivityMutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make sure SW Keyboard is restored when an app becomes foreground */
|
||||
if (SDL_IsTextInputActive()) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_ANDROID && SDL_VIDEO_OPENGL_EGL
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
|
||||
/* Android SDL video driver implementation */
|
||||
|
||||
|
||||
@@ -41,12 +41,12 @@ void Android_InitKeyboard(void)
|
||||
|
||||
static SDL_Scancode Android_Keycodes[] = {
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
|
||||
SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */
|
||||
SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
|
||||
SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
|
||||
SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
|
||||
SDL_SCANCODE_CALL, /* AKEYCODE_CALL */
|
||||
SDL_SCANCODE_ENDCALL, /* AKEYCODE_ENDCALL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
|
||||
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
|
||||
SDL_SCANCODE_0, /* AKEYCODE_0 */
|
||||
SDL_SCANCODE_1, /* AKEYCODE_1 */
|
||||
SDL_SCANCODE_2, /* AKEYCODE_2 */
|
||||
|
||||
@@ -122,14 +122,12 @@ Android_CreateDevice(int devindex)
|
||||
device->SetWindowTitle = Android_SetWindowTitle;
|
||||
device->SetWindowFullscreen = Android_SetWindowFullscreen;
|
||||
device->MinimizeWindow = Android_MinimizeWindow;
|
||||
device->SetWindowResizable = Android_SetWindowResizable;
|
||||
device->DestroyWindow = Android_DestroyWindow;
|
||||
device->GetWindowWMInfo = Android_GetWindowWMInfo;
|
||||
|
||||
device->free = Android_DeleteDevice;
|
||||
|
||||
/* GL pointers */
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
device->GL_LoadLibrary = Android_GLES_LoadLibrary;
|
||||
device->GL_GetProcAddress = Android_GLES_GetProcAddress;
|
||||
device->GL_UnloadLibrary = Android_GLES_UnloadLibrary;
|
||||
@@ -139,7 +137,6 @@ Android_CreateDevice(int devindex)
|
||||
device->GL_GetSwapInterval = Android_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = Android_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = Android_GLES_DeleteContext;
|
||||
#endif
|
||||
|
||||
#if SDL_VIDEO_VULKAN
|
||||
device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary;
|
||||
|
||||
@@ -81,7 +81,6 @@ Android_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
/* Do not create EGLSurface for Vulkan window since it will then make the window
|
||||
incompatible with vkCreateAndroidSurfaceKHR */
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if ((window->flags & SDL_WINDOW_OPENGL) != 0) {
|
||||
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
|
||||
|
||||
@@ -92,7 +91,6 @@ Android_CreateWindow(_THIS, SDL_Window * window)
|
||||
goto endfunction;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
window->driverdata = data;
|
||||
Android_Window = window;
|
||||
@@ -116,8 +114,6 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
|
||||
SDL_LockMutex(Android_ActivityMutex);
|
||||
|
||||
if (window == Android_Window) {
|
||||
SDL_WindowData *data;
|
||||
int old_w, old_h, new_w, new_h;
|
||||
|
||||
/* If the window is being destroyed don't change visible state */
|
||||
if (!window->is_destroying) {
|
||||
@@ -134,7 +130,8 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
|
||||
goto endfunction;
|
||||
}
|
||||
|
||||
data = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
|
||||
if (!data || !data->native_window) {
|
||||
if (data && !data->native_window) {
|
||||
SDL_SetError("Missing native window");
|
||||
@@ -142,11 +139,11 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
|
||||
goto endfunction;
|
||||
}
|
||||
|
||||
old_w = window->w;
|
||||
old_h = window->h;
|
||||
int old_w = window->w;
|
||||
int old_h = window->h;
|
||||
|
||||
new_w = ANativeWindow_getWidth(data->native_window);
|
||||
new_h = ANativeWindow_getHeight(data->native_window);
|
||||
int new_w = ANativeWindow_getWidth(data->native_window);
|
||||
int new_h = ANativeWindow_getHeight(data->native_window);
|
||||
|
||||
if (new_w < 0 || new_h < 0) {
|
||||
SDL_SetError("ANativeWindow_getWidth/Height() fails");
|
||||
@@ -168,12 +165,6 @@ Android_MinimizeWindow(_THIS, SDL_Window *window)
|
||||
Android_JNI_MinizeWindow();
|
||||
}
|
||||
|
||||
void Android_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
|
||||
{
|
||||
/* Set orientation */
|
||||
Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS));
|
||||
}
|
||||
|
||||
void
|
||||
Android_DestroyWindow(_THIS, SDL_Window *window)
|
||||
{
|
||||
@@ -184,13 +175,9 @@ Android_DestroyWindow(_THIS, SDL_Window *window)
|
||||
|
||||
if (window->driverdata) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
if (data->egl_surface != EGL_NO_SURFACE) {
|
||||
SDL_EGL_DestroySurface(_this, data->egl_surface);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data->native_window) {
|
||||
ANativeWindow_release(data->native_window);
|
||||
}
|
||||
@@ -207,18 +194,15 @@ Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (info->version.major == SDL_MAJOR_VERSION) {
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_ANDROID;
|
||||
info->info.android.window = data->native_window;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
info->info.android.surface = data->egl_surface;
|
||||
#endif
|
||||
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ extern int Android_CreateWindow(_THIS, SDL_Window *window);
|
||||
extern void Android_SetWindowTitle(_THIS, SDL_Window *window);
|
||||
extern void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
|
||||
extern void Android_MinimizeWindow(_THIS, SDL_Window *window);
|
||||
extern void Android_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable);
|
||||
|
||||
extern void Android_DestroyWindow(_THIS, SDL_Window *window);
|
||||
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
|
||||
@@ -38,10 +37,8 @@ extern SDL_Window *Android_Window;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
EGLContext egl_context; /* We use this to preserve the context when losing focus */
|
||||
#endif
|
||||
SDL_bool backup_done;
|
||||
ANativeWindow *native_window;
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#define SDL_cocoaclipboard_h_
|
||||
|
||||
/* Forward declaration */
|
||||
@class SDL_VideoData;
|
||||
struct SDL_VideoData;
|
||||
|
||||
extern int Cocoa_SetClipboardText(_THIS, const char *text);
|
||||
extern char *Cocoa_GetClipboardText(_THIS);
|
||||
extern SDL_bool Cocoa_HasClipboardText(_THIS);
|
||||
extern void Cocoa_CheckClipboardUpdate(SDL_VideoData * data);
|
||||
extern void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data);
|
||||
|
||||
#endif /* SDL_cocoaclipboard_h_ */
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ int
|
||||
Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
NSPasteboard *pasteboard;
|
||||
NSString *format = NSPasteboardTypeString;
|
||||
NSString *nsstr = [NSString stringWithUTF8String:text];
|
||||
@@ -38,7 +38,7 @@ Cocoa_SetClipboardText(_THIS, const char *text)
|
||||
}
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
data.clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil];
|
||||
[pasteboard setString:nsstr forType:format];
|
||||
|
||||
return 0;
|
||||
@@ -86,7 +86,7 @@ Cocoa_HasClipboardText(_THIS)
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_CheckClipboardUpdate(SDL_VideoData * data)
|
||||
Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSPasteboard *pasteboard;
|
||||
@@ -94,11 +94,11 @@ Cocoa_CheckClipboardUpdate(SDL_VideoData * data)
|
||||
|
||||
pasteboard = [NSPasteboard generalPasteboard];
|
||||
count = [pasteboard changeCount];
|
||||
if (count != data.clipboard_count) {
|
||||
if (data.clipboard_count) {
|
||||
if (count != data->clipboard_count) {
|
||||
if (data->clipboard_count) {
|
||||
SDL_SendClipboardUpdate();
|
||||
}
|
||||
data.clipboard_count = count;
|
||||
data->clipboard_count = count;
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
64
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
64
externals/SDL/src/video/cocoa/SDL_cocoaevents.m
vendored
@@ -45,7 +45,7 @@ static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win)
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
if (device && device->windows) {
|
||||
for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) {
|
||||
NSWindow *nswindow = ((__bridge SDL_WindowData *) sdlwindow->driverdata).nswindow;
|
||||
NSWindow *nswindow = ((SDL_WindowData *) sdlwindow->driverdata)->nswindow;
|
||||
if (win == nswindow)
|
||||
return sdlwindow;
|
||||
}
|
||||
@@ -121,6 +121,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
|
||||
nil];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
||||
[appDefaults release];
|
||||
}
|
||||
|
||||
@end // SDLApplication
|
||||
@@ -181,6 +182,8 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
removeEventHandlerForEventClass:kInternetEventClass
|
||||
andEventID:kAEGetURL];
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification;
|
||||
@@ -371,6 +374,9 @@ CreateApplicationMenus(void)
|
||||
/* Create the main menu bar */
|
||||
[NSApp setMainMenu:mainMenu];
|
||||
|
||||
[mainMenu release]; /* we're done with it, let NSApp own it. */
|
||||
mainMenu = nil;
|
||||
|
||||
/* Create the application menu */
|
||||
appName = GetApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
@@ -390,6 +396,7 @@ CreateApplicationMenus(void)
|
||||
[menuItem setSubmenu:serviceMenu];
|
||||
|
||||
[NSApp setServicesMenu:serviceMenu];
|
||||
[serviceMenu release];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
@@ -410,9 +417,12 @@ CreateApplicationMenus(void)
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
[appleMenu release];
|
||||
|
||||
|
||||
/* Create the window menu */
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
@@ -424,21 +434,26 @@ CreateApplicationMenus(void)
|
||||
|
||||
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
||||
|
||||
/* Add the fullscreen toggle menu option. */
|
||||
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||
* But if not, then just fallback to Toggle Full Screen.
|
||||
*/
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
[windowMenu addItem:menuItem];
|
||||
/* Add the fullscreen toggle menu option, if supported */
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||
* But if not, then just fallback to Toggle Full Screen.
|
||||
*/
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
[windowMenu addItem:menuItem];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:windowMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Tell the application object that this is now the window menu */
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
[windowMenu release];
|
||||
}
|
||||
|
||||
void
|
||||
@@ -503,6 +518,19 @@ Cocoa_RegisterApp(void)
|
||||
int
|
||||
Cocoa_PumpEventsUntilDate(_THIS, NSDate *expiration, bool accumulate)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||
/* Update activity every 30 seconds to prevent screensaver */
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
if (_this->suspend_screensaver && !data->screensaver_use_iopm) {
|
||||
Uint32 now = SDL_GetTicks();
|
||||
if (!data->screensaver_activity ||
|
||||
SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) {
|
||||
UpdateSystemActivity(UsrActivity);
|
||||
data->screensaver_activity = now;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( ; ; ) {
|
||||
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES ];
|
||||
if ( event == nil ) {
|
||||
@@ -548,7 +576,7 @@ Cocoa_PumpEvents(_THIS)
|
||||
void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
NSEvent* event = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
|
||||
location: NSMakePoint(0,0)
|
||||
@@ -567,11 +595,15 @@ void
|
||||
Cocoa_SuspendScreenSaver(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||
|
||||
if (data.screensaver_assertion) {
|
||||
IOPMAssertionRelease(data.screensaver_assertion);
|
||||
data.screensaver_assertion = kIOPMNullAssertionID;
|
||||
if (!data->screensaver_use_iopm) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->screensaver_assertion) {
|
||||
IOPMAssertionRelease(data->screensaver_assertion);
|
||||
data->screensaver_assertion = 0;
|
||||
}
|
||||
|
||||
if (_this->suspend_screensaver) {
|
||||
@@ -580,13 +612,11 @@ Cocoa_SuspendScreenSaver(_THIS)
|
||||
* seen by OS X power users. there's an additional optional human-readable
|
||||
* (localized) reason parameter which we don't set.
|
||||
*/
|
||||
IOPMAssertionID assertion = kIOPMNullAssertionID;
|
||||
NSString *name = [GetApplicationName() stringByAppendingString:@" using SDL_DisableScreenSaver"];
|
||||
IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep,
|
||||
(__bridge CFStringRef) name,
|
||||
(CFStringRef) name,
|
||||
NULL, NULL, NULL, 0, NULL,
|
||||
&assertion);
|
||||
data.screensaver_assertion = assertion;
|
||||
&data->screensaver_assertion);
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
@@ -104,7 +104,8 @@
|
||||
}
|
||||
|
||||
if (_markedText != aString) {
|
||||
_markedText = aString;
|
||||
[_markedText release];
|
||||
_markedText = [aString retain];
|
||||
}
|
||||
|
||||
_selectedRange = selectedRange;
|
||||
@@ -119,6 +120,7 @@
|
||||
|
||||
- (void)unmarkText
|
||||
{
|
||||
[_markedText release];
|
||||
_markedText = nil;
|
||||
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
@@ -140,7 +142,14 @@
|
||||
aRange.location, aRange.length, windowHeight,
|
||||
NSStringFromRect(rect));
|
||||
|
||||
rect = [window convertRectToScreen:rect];
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
||||
if (![window respondsToSelector:@selector(convertRectToScreen:)]) {
|
||||
rect.origin = [window convertBaseToScreen:rect.origin];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rect = [window convertRectToScreen:rect];
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
@@ -372,14 +381,14 @@ DoSidedModifiers(unsigned short scancode,
|
||||
static void
|
||||
HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (modifierFlags == data.modifierFlags) {
|
||||
if (modifierFlags == data->modifierFlags) {
|
||||
return;
|
||||
}
|
||||
|
||||
DoSidedModifiers(scancode, data.modifierFlags, modifierFlags);
|
||||
data.modifierFlags = modifierFlags;
|
||||
DoSidedModifiers(scancode, data->modifierFlags, modifierFlags);
|
||||
data->modifierFlags = modifierFlags;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -393,10 +402,10 @@ UpdateKeymap(SDL_VideoData *data, SDL_bool send_event)
|
||||
|
||||
/* See if the keymap needs to be updated */
|
||||
key_layout = TISCopyCurrentKeyboardLayoutInputSource();
|
||||
if (key_layout == data.key_layout) {
|
||||
if (key_layout == data->key_layout) {
|
||||
return;
|
||||
}
|
||||
data.key_layout = key_layout;
|
||||
data->key_layout = key_layout;
|
||||
|
||||
SDL_GetDefaultKeymap(keymap);
|
||||
|
||||
@@ -452,7 +461,7 @@ cleanup:
|
||||
void
|
||||
Cocoa_InitKeyboard(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
UpdateKeymap(data, SDL_FALSE);
|
||||
|
||||
@@ -464,19 +473,19 @@ Cocoa_InitKeyboard(_THIS)
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option");
|
||||
SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command");
|
||||
|
||||
data.modifierFlags = (unsigned int)[NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) != 0);
|
||||
data->modifierFlags = (unsigned int)[NSEvent modifierFlags];
|
||||
SDL_ToggleModState(KMOD_CAPS, (data->modifierFlags & NSEventModifierFlagCapsLock) != 0);
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_StartTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
NSWindow *nswindow = nil;
|
||||
if (window) {
|
||||
nswindow = ((__bridge SDL_WindowData*)window->driverdata).nswindow;
|
||||
nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
|
||||
}
|
||||
|
||||
NSView *parentView = [nswindow contentView];
|
||||
@@ -486,16 +495,16 @@ Cocoa_StartTextInput(_THIS)
|
||||
* than one copy. When we switched to another window and requesting for
|
||||
* text input, simply remove the field editor from its superview then add
|
||||
* it to the front most window's content view */
|
||||
if (!data.fieldEdit) {
|
||||
data.fieldEdit =
|
||||
if (!data->fieldEdit) {
|
||||
data->fieldEdit =
|
||||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
}
|
||||
|
||||
if (![[data.fieldEdit superview] isEqual:parentView]) {
|
||||
if (![[data->fieldEdit superview] isEqual:parentView]) {
|
||||
/* DEBUG_IME(@"add fieldEdit to window contentView"); */
|
||||
[data.fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data.fieldEdit];
|
||||
[nswindow makeFirstResponder: data.fieldEdit];
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[parentView addSubview: data->fieldEdit];
|
||||
[nswindow makeFirstResponder: data->fieldEdit];
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -503,31 +512,32 @@ void
|
||||
Cocoa_StopTextInput(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (data && data.fieldEdit) {
|
||||
[data.fieldEdit removeFromSuperview];
|
||||
data.fieldEdit = nil;
|
||||
if (data && data->fieldEdit) {
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
[data->fieldEdit release];
|
||||
data->fieldEdit = nil;
|
||||
}
|
||||
}}
|
||||
|
||||
void
|
||||
Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (!rect) {
|
||||
SDL_InvalidParamError("rect");
|
||||
return;
|
||||
}
|
||||
|
||||
[data.fieldEdit setInputRect:rect];
|
||||
[data->fieldEdit setInputRect:rect];
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
{
|
||||
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *) _this->driverdata) : nil;
|
||||
SDL_VideoData *data = _this ? ((SDL_VideoData *) _this->driverdata) : NULL;
|
||||
if (!data) {
|
||||
return; /* can happen when returning from fullscreen Space on shutdown */
|
||||
}
|
||||
@@ -565,7 +575,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
#endif
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
/* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
|
||||
[data.fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
[data->fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
#if 0
|
||||
text = [[event characters] UTF8String];
|
||||
if(text && *text) {
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
|
||||
/* Retain the NSWindow because we'll show the alert later on the main thread */
|
||||
if (window) {
|
||||
nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
|
||||
nswindow = [((SDL_WindowData *) window->driverdata)->nswindow retain];
|
||||
} else {
|
||||
nswindow = nil;
|
||||
nswindow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
#ifdef MAC_OS_X_VERSION_10_9
|
||||
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
|
||||
[alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) {
|
||||
self->clicked = returnCode;
|
||||
clicked = returnCode;
|
||||
}];
|
||||
} else
|
||||
#endif
|
||||
@@ -75,7 +75,7 @@
|
||||
SDL_Delay(100);
|
||||
}
|
||||
|
||||
nswindow = nil;
|
||||
[nswindow release];
|
||||
} else {
|
||||
clicked = [alert runModal];
|
||||
}
|
||||
@@ -94,7 +94,7 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
|
||||
{
|
||||
Cocoa_RegisterApp();
|
||||
|
||||
NSAlert* alert = [[NSAlert alloc] init];
|
||||
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
|
||||
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) {
|
||||
[alert setAlertStyle:NSAlertStyleCritical];
|
||||
@@ -129,7 +129,7 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
|
||||
}
|
||||
}
|
||||
|
||||
SDLMessageBoxPresenter* presenter = [[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window];
|
||||
SDLMessageBoxPresenter* presenter = [[[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window] autorelease];
|
||||
|
||||
[presenter showAlert:alert];
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||
/* Allow resize. */
|
||||
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
|
||||
SDL_AddEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
|
||||
SDL_AddEventWatch(SDL_MetalViewEventWatch, self);
|
||||
|
||||
[self updateDrawableSize];
|
||||
}
|
||||
@@ -99,7 +99,8 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
SDL_DelEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
|
||||
SDL_DelEventWatch(SDL_MetalViewEventWatch, self);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSInteger)tag
|
||||
@@ -134,7 +135,7 @@ SDL_MetalView
|
||||
Cocoa_Metal_CreateView(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData* data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *view = data.nswindow.contentView;
|
||||
NSView *view = data->nswindow.contentView;
|
||||
BOOL highDPI = (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) != 0;
|
||||
Uint32 windowID = SDL_GetWindowID(window);
|
||||
SDL_cocoametalview *newview;
|
||||
@@ -150,6 +151,7 @@ Cocoa_Metal_CreateView(_THIS, SDL_Window * window)
|
||||
[view addSubview:newview];
|
||||
|
||||
metalview = (SDL_MetalView)CFBridgingRetain(newview);
|
||||
[newview release];
|
||||
|
||||
return metalview;
|
||||
}}
|
||||
@@ -172,7 +174,7 @@ void
|
||||
Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *contentView = data.sdlContentView;
|
||||
NSView *contentView = data->sdlContentView;
|
||||
SDL_cocoametalview* metalview = [contentView viewWithTag:SDL_METALVIEW_TAG];
|
||||
if (metalview) {
|
||||
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
|
||||
@@ -187,8 +189,11 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * 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. */
|
||||
viewport = [contentView convertRectToBacking:viewport];
|
||||
/* 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;
|
||||
|
||||
37
externals/SDL/src/video/cocoa/SDL_cocoamodes.m
vendored
37
externals/SDL/src/video/cocoa/SDL_cocoamodes.m
vendored
@@ -31,17 +31,34 @@
|
||||
#include <CoreVideo/CVBase.h>
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
|
||||
/* we need this for ShowMenuBar() and HideMenuBar(). */
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */
|
||||
#include <AvailabilityMacros.h>
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_13
|
||||
#define NSAppKitVersionNumber10_12 1504
|
||||
#endif
|
||||
#if (IOGRAPHICSTYPES_REV < 40)
|
||||
#define kDisplayModeNativeFlag 0x02000000
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
Cocoa_ToggleMenuBar(const BOOL show)
|
||||
{
|
||||
/* !!! FIXME: keep an eye on this.
|
||||
* ShowMenuBar/HideMenuBar is officially unavailable for 64-bit binaries.
|
||||
* It happens to work, as of 10.7, but we're going to see if
|
||||
* we can just simply do without it on newer OSes...
|
||||
*/
|
||||
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 1070) && !defined(__LP64__)
|
||||
if (show) {
|
||||
ShowMenuBar();
|
||||
} else {
|
||||
HideMenuBar();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
CG_SetError(const char *prefix, CGDisplayErr result)
|
||||
{
|
||||
@@ -286,7 +303,7 @@ Cocoa_GetDisplayName(CGDirectDisplayID displayID)
|
||||
/* This API is deprecated in 10.9 with no good replacement (as of 10.15). */
|
||||
io_service_t servicePort = CGDisplayIOServicePort(displayID);
|
||||
CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName);
|
||||
NSDictionary *localizedNames = [(__bridge NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
NSDictionary *localizedNames = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
|
||||
const char* displayName = NULL;
|
||||
|
||||
if ([localizedNames count] > 0) {
|
||||
@@ -477,7 +494,7 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
|
||||
CFRelease(dmOptions);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||
// fallback for 10.7
|
||||
scaleFactor = [screen backingScaleFactor];
|
||||
displayNativeSize.width = displayNativeSize.width * scaleFactor;
|
||||
@@ -626,6 +643,10 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
} else {
|
||||
CGDisplayRelease(displaydata->display);
|
||||
}
|
||||
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
Cocoa_ToggleMenuBar(YES);
|
||||
}
|
||||
} else {
|
||||
/* Put up the blanking window (a window above all other windows) */
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
@@ -645,6 +666,11 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
CG_SetError("CGDisplaySwitchToMode()", result);
|
||||
goto ERR_NO_SWITCH;
|
||||
}
|
||||
|
||||
/* Hide the menu bar so it doesn't intercept events */
|
||||
if (CGDisplayIsMain(displaydata->display)) {
|
||||
Cocoa_ToggleMenuBar(NO);
|
||||
}
|
||||
}
|
||||
|
||||
/* Fade in again (asynchronously) */
|
||||
@@ -691,6 +717,7 @@ Cocoa_QuitModes(_THIS)
|
||||
CFRelease(mode->modes);
|
||||
}
|
||||
}
|
||||
Cocoa_ToggleMenuBar(YES);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
139
externals/SDL/src/video/cocoa/SDL_cocoamouse.m
vendored
139
externals/SDL/src/video/cocoa/SDL_cocoamouse.m
vendored
@@ -53,7 +53,7 @@
|
||||
NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0]
|
||||
length:sizeof(cursorBytes)
|
||||
freeWhenDone:NO];
|
||||
NSImage *cursorImage = [[NSImage alloc] initWithData:cursorData];
|
||||
NSImage *cursorImage = [[[NSImage alloc] initWithData:cursorData] autorelease];
|
||||
invisibleCursor = [[NSCursor alloc] initWithImage:cursorImage
|
||||
hotSpot:NSZeroPoint];
|
||||
}
|
||||
@@ -75,7 +75,8 @@ Cocoa_CreateDefaultCursor()
|
||||
if (nscursor) {
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
cursor->driverdata = nscursor;
|
||||
[nscursor retain];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,52 +99,15 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
if (nscursor) {
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
cursor->driverdata = nscursor;
|
||||
} else {
|
||||
[nscursor release];
|
||||
}
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}}
|
||||
|
||||
/* there are .pdf files of some of the cursors we need, installed by default on macOS, but not available through NSCursor.
|
||||
If we can load them ourselves, use them, otherwise fallback to something standard but not super-great.
|
||||
Since these are under /System, they should be available even to sandboxed apps. */
|
||||
static NSCursor *
|
||||
LoadHiddenSystemCursor(NSString *cursorName, SEL fallback)
|
||||
{
|
||||
NSString *cursorPath = [@"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors" stringByAppendingPathComponent:cursorName];
|
||||
NSImage *image = [[NSImage alloc] initWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"cursor.pdf"]];
|
||||
if ((image == nil) || (image.valid == NO)) {
|
||||
return [NSCursor performSelector:fallback];
|
||||
}
|
||||
|
||||
NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"info.plist"]];
|
||||
|
||||
/* we can't do animation atm. :/ */
|
||||
const int frames = [[info valueForKey:@"frames"] integerValue];
|
||||
if (frames > 1) {
|
||||
const NSSize cropped_size = NSMakeSize(image.size.width, (int) (image.size.height / frames));
|
||||
NSImage *cropped = [[NSImage alloc] initWithSize:cropped_size];
|
||||
if (cropped == nil) {
|
||||
return [NSCursor performSelector:fallback];
|
||||
}
|
||||
|
||||
#ifdef MAC_OS_VERSION_12_0 /* same value as deprecated symbol. */
|
||||
const NSCompositingOperation operation = NSCompositingOperationCopy;
|
||||
#else
|
||||
const NSCompositingOperation operation = NSCompositeCopy;
|
||||
#endif
|
||||
[cropped lockFocus];
|
||||
const NSRect cropped_rect = NSMakeRect(0, 0, cropped_size.width, cropped_size.height);
|
||||
[image drawInRect:cropped_rect fromRect:cropped_rect operation:operation fraction:1];
|
||||
[cropped unlockFocus];
|
||||
image = cropped;
|
||||
}
|
||||
|
||||
NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint([[info valueForKey:@"hotx"] doubleValue], [[info valueForKey:@"hoty"] doubleValue])];
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
{ @autoreleasepool
|
||||
@@ -158,29 +122,27 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
case SDL_SYSTEM_CURSOR_IBEAM:
|
||||
nscursor = [NSCursor IBeamCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT:
|
||||
nscursor = [NSCursor arrowCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_CROSSHAIR:
|
||||
nscursor = [NSCursor crosshairCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAIT: /* !!! FIXME: this is more like WAITARROW */
|
||||
nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW: /* !!! FIXME: this is meant to be animated */
|
||||
nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor));
|
||||
case SDL_SYSTEM_CURSOR_WAITARROW:
|
||||
nscursor = [NSCursor arrowCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENWSE:
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor));
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENESW:
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor));
|
||||
nscursor = [NSCursor closedHandCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEWE:
|
||||
nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor));
|
||||
nscursor = [NSCursor resizeLeftRightCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZENS:
|
||||
nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor));
|
||||
nscursor = [NSCursor resizeUpDownCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_SIZEALL:
|
||||
nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor));
|
||||
nscursor = [NSCursor closedHandCursor];
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_NO:
|
||||
nscursor = [NSCursor operationNotAllowedCursor];
|
||||
@@ -197,7 +159,8 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
|
||||
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
/* We'll free it later, so retain it here */
|
||||
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
|
||||
[nscursor retain];
|
||||
cursor->driverdata = nscursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +171,9 @@ static void
|
||||
Cocoa_FreeCursor(SDL_Cursor * cursor)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
CFBridgingRelease(cursor->driverdata);
|
||||
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
|
||||
|
||||
[nscursor release];
|
||||
SDL_free(cursor);
|
||||
}}
|
||||
|
||||
@@ -219,11 +184,11 @@ Cocoa_ShowCursor(SDL_Cursor * cursor)
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
SDL_Window *window = (device ? device->windows : NULL);
|
||||
for (; window != NULL; window = window->next) {
|
||||
SDL_WindowData *driverdata = (__bridge SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata;
|
||||
if (driverdata) {
|
||||
[driverdata.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
||||
withObject:[driverdata.nswindow contentView]
|
||||
waitUntilDone:NO];
|
||||
[driverdata->nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:)
|
||||
withObject:[driverdata->nswindow contentView]
|
||||
waitUntilDone:NO];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -249,10 +214,10 @@ Cocoa_WarpMouseGlobal(int x, int y)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (mouse->focus) {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *) mouse->focus->driverdata;
|
||||
if ([data.listener isMovingOrFocusClickPending]) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
|
||||
if ([data->listener isMovingOrFocusClickPending]) {
|
||||
DLog("Postponing warp, window being moved or focused.");
|
||||
[data.listener setPendingMoveX:x Y:y];
|
||||
[data->listener setPendingMoveX:x Y:y];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -288,12 +253,28 @@ Cocoa_WarpMouseGlobal(int x, int y)
|
||||
static void
|
||||
Cocoa_WarpMouse(SDL_Window * window, int x, int y)
|
||||
{
|
||||
Cocoa_WarpMouseGlobal(window->x + x, window->y + y);
|
||||
Cocoa_WarpMouseGlobal(x + window->x, y + window->y);
|
||||
}
|
||||
|
||||
static int
|
||||
Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
||||
{
|
||||
/* We will re-apply the relative mode when the window gets focus, if it
|
||||
* doesn't have focus right now.
|
||||
*/
|
||||
SDL_Window *window = SDL_GetMouseFocus();
|
||||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We will re-apply the relative mode when the window finishes being moved,
|
||||
* if it is being moved right now.
|
||||
*/
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
if ([data->listener isMovingOrFocusClickPending]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CGError result;
|
||||
if (enabled) {
|
||||
DLog("Turning on.");
|
||||
@@ -306,22 +287,6 @@ Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
||||
return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed");
|
||||
}
|
||||
|
||||
/* We will re-apply the non-relative mode when the window gets focus, if it
|
||||
* doesn't have focus right now.
|
||||
*/
|
||||
SDL_Window *window = SDL_GetKeyboardFocus();
|
||||
if (!window) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We will re-apply the non-relative mode when the window finishes being moved,
|
||||
* if it is being moved right now.
|
||||
*/
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *) window->driverdata;
|
||||
if ([data.listener isMovingOrFocusClickPending]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The hide/unhide calls are redundant most of the time, but they fix
|
||||
* https://bugzilla.libsdl.org/show_bug.cgi?id=2550
|
||||
*/
|
||||
@@ -395,18 +360,18 @@ Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event)
|
||||
NSWindow *nswindow = [event window];
|
||||
|
||||
for (window = _this->windows; window; window = window->next) {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
if (data && data.nswindow == nswindow) {
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
if (data && data->nswindow == nswindow) {
|
||||
switch ([event type]) {
|
||||
case NSEventTypeLeftMouseDown:
|
||||
case NSEventTypeRightMouseDown:
|
||||
case NSEventTypeOtherMouseDown:
|
||||
[data.listener setFocusClickPending:[event buttonNumber]];
|
||||
[data->listener setFocusClickPending:[event buttonNumber]];
|
||||
break;
|
||||
case NSEventTypeLeftMouseUp:
|
||||
case NSEventTypeRightMouseUp:
|
||||
case NSEventTypeOtherMouseUp:
|
||||
[data.listener clearFocusClickPending:[event buttonNumber]];
|
||||
[data->listener clearFocusClickPending:[event buttonNumber]];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -502,13 +467,15 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
|
||||
CGFloat y = [event deltaY];
|
||||
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
|
||||
|
||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
|
||||
if ([event isDirectionInvertedFromDevice] == YES) {
|
||||
direction = SDL_MOUSEWHEEL_FLIPPED;
|
||||
}
|
||||
}
|
||||
|
||||
/* For discrete scroll events from conventional mice, always send a full tick.
|
||||
For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */
|
||||
if (![event hasPreciseScrollingDeltas]) {
|
||||
if (![event respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
|
||||
if (x > 0) {
|
||||
x = SDL_ceil(x);
|
||||
} else if (x < 0) {
|
||||
|
||||
81
externals/SDL/src/video/cocoa/SDL_cocoaopengl.m
vendored
81
externals/SDL/src/video/cocoa/SDL_cocoaopengl.m
vendored
@@ -82,10 +82,10 @@
|
||||
- (void)setWindow:(SDL_Window *)newWindow
|
||||
{
|
||||
if (self->window) {
|
||||
SDL_WindowData *oldwindowdata = (__bridge SDL_WindowData *)self->window->driverdata;
|
||||
SDL_WindowData *oldwindowdata = (SDL_WindowData *)self->window->driverdata;
|
||||
|
||||
/* Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. */
|
||||
NSMutableArray *contexts = oldwindowdata.nscontexts;
|
||||
NSMutableArray *contexts = oldwindowdata->nscontexts;
|
||||
@synchronized (contexts) {
|
||||
[contexts removeObject:self];
|
||||
}
|
||||
@@ -94,11 +94,11 @@
|
||||
self->window = newWindow;
|
||||
|
||||
if (newWindow) {
|
||||
SDL_WindowData *windowdata = (__bridge SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata.sdlContentView;
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *)newWindow->driverdata;
|
||||
NSView *contentview = windowdata->sdlContentView;
|
||||
|
||||
/* Now sign up for scheduled updates for the new window. */
|
||||
NSMutableArray *contexts = windowdata.nscontexts;
|
||||
NSMutableArray *contexts = windowdata->nscontexts;
|
||||
@synchronized (contexts) {
|
||||
[contexts addObject:self];
|
||||
}
|
||||
@@ -180,10 +180,10 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata;
|
||||
SDL_bool lion_or_later = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
||||
NSOpenGLPixelFormatAttribute attr[32];
|
||||
NSOpenGLPixelFormat *fmt;
|
||||
SDLOpenGLContext *context;
|
||||
SDL_GLContext sdlcontext;
|
||||
NSOpenGLContext *share_context = nil;
|
||||
int i = 0;
|
||||
const char *glversion;
|
||||
@@ -213,15 +213,22 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && !lion_or_later) {
|
||||
SDL_SetError ("OpenGL Core Profile is not supported on this platform version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
attr[i++] = NSOpenGLPFAAllowOfflineRenderers;
|
||||
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||
profile = NSOpenGLProfileVersion3_2Core;
|
||||
/* specify a profile if we're on Lion (10.7) or later. */
|
||||
if (lion_or_later) {
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy;
|
||||
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||
profile = NSOpenGLProfileVersion3_2Core;
|
||||
}
|
||||
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
||||
attr[i++] = profile;
|
||||
}
|
||||
attr[i++] = NSOpenGLPFAOpenGLProfile;
|
||||
attr[i++] = profile;
|
||||
|
||||
attr[i++] = NSOpenGLPFAColorSize;
|
||||
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
|
||||
@@ -281,20 +288,20 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
share_context = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
share_context = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
}
|
||||
|
||||
context = [[SDLOpenGLContext alloc] initWithFormat:fmt shareContext:share_context];
|
||||
|
||||
[fmt release];
|
||||
|
||||
if (context == nil) {
|
||||
SDL_SetError("Failed creating OpenGL context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sdlcontext = (SDL_GLContext)CFBridgingRetain(context);
|
||||
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError("Failed making OpenGL context current");
|
||||
return NULL;
|
||||
}
|
||||
@@ -308,27 +315,27 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
|
||||
glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
|
||||
if (!glGetStringFunc) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError ("Failed getting OpenGL glGetString entry point");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glversion = (const char *)glGetStringFunc(GL_VERSION);
|
||||
if (glversion == NULL) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError ("Failed getting OpenGL context version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError ("Failed parsing OpenGL context version");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((glversion_major < _this->gl_config.major_version) ||
|
||||
((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) {
|
||||
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
|
||||
Cocoa_GL_DeleteContext(_this, context);
|
||||
SDL_SetError ("Failed creating OpenGL context at version requested");
|
||||
return NULL;
|
||||
}
|
||||
@@ -339,7 +346,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
/*_this->gl_config.major_version = glversion_major;*/
|
||||
/*_this->gl_config.minor_version = glversion_minor;*/
|
||||
}
|
||||
return sdlcontext;
|
||||
return context;
|
||||
}}
|
||||
|
||||
int
|
||||
@@ -347,7 +354,7 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
if (context) {
|
||||
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
if ([nscontext window] != window) {
|
||||
[nscontext setWindow:window];
|
||||
[nscontext updateIfNeeded];
|
||||
@@ -362,15 +369,17 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
|
||||
void
|
||||
Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_WindowData *windata = (__bridge SDL_WindowData *) window->driverdata;
|
||||
NSView *contentView = windata.sdlContentView;
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
NSView *contentView = windata->sdlContentView;
|
||||
NSRect viewport = [contentView bounds];
|
||||
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
/* This gives us the correct viewport for a Retina-enabled view. */
|
||||
viewport = [contentView convertRectToBacking:viewport];
|
||||
/* 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) {
|
||||
@@ -380,7 +389,7 @@ Cocoa_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
if (h) {
|
||||
*h = viewport.size.height;
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||
@@ -394,7 +403,7 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
|
||||
return SDL_SetError("Late swap tearing currently unsupported");
|
||||
}
|
||||
|
||||
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
value = interval;
|
||||
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
@@ -414,7 +423,7 @@ Cocoa_GL_GetSwapInterval(_THIS)
|
||||
GLint value;
|
||||
int status = 0;
|
||||
|
||||
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
if (nscontext != nil) {
|
||||
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||
status = (int)value;
|
||||
@@ -427,15 +436,15 @@ int
|
||||
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDLOpenGLContext* nscontext = (__bridge SDLOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
SDL_VideoData *videodata = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
/* on 10.14 ("Mojave") and later, this deadlocks if two contexts in two
|
||||
threads try to swap at the same time, so put a mutex around it. */
|
||||
SDL_LockMutex(videodata.swaplock);
|
||||
SDL_LockMutex(videodata->swaplock);
|
||||
[nscontext flushBuffer];
|
||||
[nscontext updateIfNeeded];
|
||||
SDL_UnlockMutex(videodata.swaplock);
|
||||
SDL_UnlockMutex(videodata->swaplock);
|
||||
return 0;
|
||||
}}
|
||||
|
||||
@@ -443,8 +452,10 @@ void
|
||||
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)CFBridgingRelease(context);
|
||||
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
|
||||
|
||||
[nscontext setWindow:NULL];
|
||||
[nscontext release];
|
||||
}}
|
||||
|
||||
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
/* EGL implementation of SDL OpenGL support */
|
||||
|
||||
int
|
||||
Cocoa_GLES_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
Cocoa_GLES_LoadLibrary(_THIS, const char *path) {
|
||||
|
||||
/* If the profile requested is not GL ES, switch over to WIN_GL functions */
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
@@ -59,10 +59,9 @@ Cocoa_GLES_LoadLibrary(_THIS, const char *path)
|
||||
|
||||
SDL_GLContext
|
||||
Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_GLContext context;
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_CGL
|
||||
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
|
||||
@@ -86,37 +85,25 @@ Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
|
||||
}
|
||||
#endif
|
||||
|
||||
context = SDL_EGL_CreateContext(_this, data.egl_surface);
|
||||
context = SDL_EGL_CreateContext(_this, data->egl_surface);
|
||||
return context;
|
||||
}}
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_GLES_DeleteContext(_THIS, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_EGL_DeleteContext(_this, context);
|
||||
Cocoa_GLES_UnloadLibrary(_this);
|
||||
}}
|
||||
}
|
||||
|
||||
int
|
||||
Cocoa_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
return SDL_EGL_SwapBuffers(_this, ((__bridge SDL_WindowData *) window->driverdata).egl_surface);
|
||||
}}
|
||||
|
||||
int
|
||||
Cocoa_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
return SDL_EGL_MakeCurrent(_this, window ? ((__bridge SDL_WindowData *) window->driverdata).egl_surface : EGL_NO_SURFACE, context);
|
||||
}}
|
||||
SDL_EGL_SwapWindow_impl(Cocoa)
|
||||
SDL_EGL_MakeCurrent_impl(Cocoa)
|
||||
|
||||
int
|
||||
Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
/* The current context is lost in here; save it and reset it. */
|
||||
SDL_WindowData *windowdata = (__bridge SDL_WindowData *) window->driverdata;
|
||||
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
|
||||
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
|
||||
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
|
||||
|
||||
@@ -134,10 +121,10 @@ Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
/* Create the GLES window surface */
|
||||
NSView* v = windowdata.nswindow.contentView;
|
||||
windowdata.egl_surface = SDL_EGL_CreateSurface(_this, (__bridge NativeWindowType)[v layer]);
|
||||
NSView* v = windowdata->nswindow.contentView;
|
||||
windowdata->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)[v layer]);
|
||||
|
||||
if (windowdata.egl_surface == EGL_NO_SURFACE) {
|
||||
if (windowdata->egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create GLES window surface");
|
||||
}
|
||||
|
||||
|
||||
17
externals/SDL/src/video/cocoa/SDL_cocoashape.m
vendored
17
externals/SDL/src/video/cocoa/SDL_cocoashape.m
vendored
@@ -29,12 +29,11 @@
|
||||
|
||||
SDL_WindowShaper*
|
||||
Cocoa_CreateShaper(SDL_Window* window)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_WindowData* windata = (__bridge SDL_WindowData*)window->driverdata;
|
||||
[windata.nswindow setOpaque:NO];
|
||||
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
|
||||
[windata->nswindow setOpaque:NO];
|
||||
|
||||
[windata.nswindow setStyleMask:NSWindowStyleMaskBorderless];
|
||||
[windata->nswindow setStyleMask:NSWindowStyleMaskBorderless];
|
||||
|
||||
SDL_WindowShaper* result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper));
|
||||
result->window = window;
|
||||
@@ -45,14 +44,14 @@ Cocoa_CreateShaper(SDL_Window* window)
|
||||
|
||||
SDL_ShapeData* data = (SDL_ShapeData *)SDL_malloc(sizeof(SDL_ShapeData));
|
||||
result->driverdata = data;
|
||||
data->context = [windata.nswindow graphicsContext];
|
||||
data->context = [windata->nswindow graphicsContext];
|
||||
data->saved = SDL_FALSE;
|
||||
data->shape = NULL;
|
||||
|
||||
int resized_properly = Cocoa_ResizeWindowShape(window);
|
||||
SDL_assert(resized_properly == 0);
|
||||
return result;
|
||||
}}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
NSView* view;
|
||||
@@ -75,7 +74,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
|
||||
SDL_WindowData* windata = (__bridge SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
|
||||
SDL_CocoaClosure closure;
|
||||
if(data->saved == SDL_TRUE) {
|
||||
[data->context restoreGraphicsState];
|
||||
@@ -87,10 +86,10 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
|
||||
[NSGraphicsContext setCurrentContext:data->context];
|
||||
|
||||
[[NSColor clearColor] set];
|
||||
NSRectFill([windata.sdlContentView frame]);
|
||||
NSRectFill([windata->sdlContentView frame]);
|
||||
data->shape = SDL_CalculateShapeTree(*shape_mode,shape);
|
||||
|
||||
closure.view = windata.sdlContentView;
|
||||
closure.view = windata->sdlContentView;
|
||||
closure.path = [NSBezierPath bezierPath];
|
||||
closure.window = shaper->window;
|
||||
SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure);
|
||||
|
||||
21
externals/SDL/src/video/cocoa/SDL_cocoavideo.h
vendored
21
externals/SDL/src/video/cocoa/SDL_cocoavideo.h
vendored
@@ -97,15 +97,18 @@ DECLARE_ALERT_STYLE(Critical);
|
||||
|
||||
@class SDLTranslatorResponder;
|
||||
|
||||
@interface SDL_VideoData : NSObject
|
||||
@property (nonatomic) int allow_spaces;
|
||||
@property (nonatomic) unsigned int modifierFlags;
|
||||
@property (nonatomic) void *key_layout;
|
||||
@property (nonatomic) SDLTranslatorResponder *fieldEdit;
|
||||
@property (nonatomic) NSInteger clipboard_count;
|
||||
@property (nonatomic) IOPMAssertionID screensaver_assertion;
|
||||
@property (nonatomic) SDL_mutex *swaplock;
|
||||
@end
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int allow_spaces;
|
||||
unsigned int modifierFlags;
|
||||
void *key_layout;
|
||||
SDLTranslatorResponder *fieldEdit;
|
||||
NSInteger clipboard_count;
|
||||
Uint32 screensaver_activity;
|
||||
BOOL screensaver_use_iopm;
|
||||
IOPMAssertionID screensaver_assertion;
|
||||
SDL_mutex *swaplock;
|
||||
} SDL_VideoData;
|
||||
|
||||
/* Utility functions */
|
||||
extern NSImage * Cocoa_CreateImage(SDL_Surface * surface);
|
||||
|
||||
63
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
63
externals/SDL/src/video/cocoa/SDL_cocoavideo.m
vendored
@@ -22,10 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
#error SDL must be built with Objective-C ARC (automatic reference counting) enabled
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_cocoavideo.h"
|
||||
@@ -33,10 +29,6 @@
|
||||
#include "SDL_cocoavulkan.h"
|
||||
#include "SDL_cocoametalview.h"
|
||||
|
||||
@implementation SDL_VideoData
|
||||
|
||||
@end
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int Cocoa_VideoInit(_THIS);
|
||||
static void Cocoa_VideoQuit(_THIS);
|
||||
@@ -45,18 +37,16 @@ static void Cocoa_VideoQuit(_THIS);
|
||||
|
||||
static void
|
||||
Cocoa_DeleteDevice(SDL_VideoDevice * device)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
CFBridgingRelease(device->driverdata);
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}}
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *
|
||||
Cocoa_CreateDevice(int devindex)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
SDL_VideoData *data;
|
||||
@@ -66,16 +56,16 @@ Cocoa_CreateDevice(int devindex)
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||
if (device) {
|
||||
data = [[SDL_VideoData alloc] init];
|
||||
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
|
||||
} else {
|
||||
data = nil;
|
||||
data = NULL;
|
||||
}
|
||||
if (!data) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(device);
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = (void *)CFBridgingRetain(data);
|
||||
device->driverdata = data;
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
/* Set the function pointers */
|
||||
@@ -113,7 +103,6 @@ Cocoa_CreateDevice(int devindex)
|
||||
device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
|
||||
device->GetWindowICCProfile = Cocoa_GetWindowICCProfile;
|
||||
device->GetWindowDisplayIndex = Cocoa_GetWindowDisplayIndex;
|
||||
device->SetWindowMouseRect = Cocoa_SetWindowMouseRect;
|
||||
device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab;
|
||||
device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab;
|
||||
@@ -176,7 +165,7 @@ Cocoa_CreateDevice(int devindex)
|
||||
device->free = Cocoa_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}}
|
||||
}
|
||||
|
||||
VideoBootStrap COCOA_bootstrap = {
|
||||
"cocoa", "SDL Cocoa video driver",
|
||||
@@ -186,9 +175,8 @@ VideoBootStrap COCOA_bootstrap = {
|
||||
|
||||
int
|
||||
Cocoa_VideoInit(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
Cocoa_InitModes(_this);
|
||||
Cocoa_InitKeyboard(_this);
|
||||
@@ -196,27 +184,29 @@ Cocoa_VideoInit(_THIS)
|
||||
return -1;
|
||||
}
|
||||
|
||||
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
|
||||
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
|
||||
|
||||
data.swaplock = SDL_CreateMutex();
|
||||
if (!data.swaplock) {
|
||||
/* The IOPM assertion API can disable the screensaver as of 10.7. */
|
||||
data->screensaver_use_iopm = floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
|
||||
|
||||
data->swaplock = SDL_CreateMutex();
|
||||
if (!data->swaplock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}}
|
||||
}
|
||||
|
||||
void
|
||||
Cocoa_VideoQuit(_THIS)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
Cocoa_QuitModes(_this);
|
||||
Cocoa_QuitKeyboard(_this);
|
||||
Cocoa_QuitMouse(_this);
|
||||
SDL_DestroyMutex(data.swaplock);
|
||||
data.swaplock = NULL;
|
||||
}}
|
||||
SDL_DestroyMutex(data->swaplock);
|
||||
data->swaplock = NULL;
|
||||
}
|
||||
|
||||
/* This function assumes that it's called from within an autorelease pool */
|
||||
NSImage *
|
||||
@@ -233,7 +223,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||
return nil;
|
||||
}
|
||||
|
||||
imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
|
||||
imgrep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
|
||||
pixelsWide: converted->w
|
||||
pixelsHigh: converted->h
|
||||
bitsPerSample: 8
|
||||
@@ -242,7 +232,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||
isPlanar: NO
|
||||
colorSpaceName: NSDeviceRGBColorSpace
|
||||
bytesPerRow: converted->pitch
|
||||
bitsPerPixel: converted->format->BitsPerPixel];
|
||||
bitsPerPixel: converted->format->BitsPerPixel] autorelease];
|
||||
if (imgrep == nil) {
|
||||
SDL_FreeSurface(converted);
|
||||
return nil;
|
||||
@@ -262,7 +252,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||
pixels += 4;
|
||||
}
|
||||
|
||||
img = [[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)];
|
||||
img = [[[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)] autorelease];
|
||||
if (img != nil) {
|
||||
[img addRepresentation: imgrep];
|
||||
}
|
||||
@@ -279,16 +269,11 @@ Cocoa_CreateImage(SDL_Surface * surface)
|
||||
* versions remain identical!
|
||||
*/
|
||||
|
||||
void SDL_NSLog(const char *prefix, const char *text)
|
||||
void SDL_NSLog(const char *text)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *nsText = [NSString stringWithUTF8String:text];
|
||||
if (prefix) {
|
||||
NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
|
||||
NSLog(@"%@: %@", nsPrefix, nsText);
|
||||
} else {
|
||||
NSLog(@"%@", nsText);
|
||||
}
|
||||
NSString *str = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
34
externals/SDL/src/video/cocoa/SDL_cocoawindow.h
vendored
34
externals/SDL/src/video/cocoa/SDL_cocoawindow.h
vendored
@@ -29,7 +29,7 @@
|
||||
#include "../SDL_egl_c.h"
|
||||
#endif
|
||||
|
||||
@class SDL_WindowData;
|
||||
typedef struct SDL_WindowData SDL_WindowData;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -40,10 +40,7 @@ typedef enum
|
||||
} PendingWindowOperation;
|
||||
|
||||
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
|
||||
/* SDL_WindowData owns this Listener and has a strong reference to it.
|
||||
* To avoid reference cycles, we could have either a weak or an
|
||||
* unretained ref to the WindowData. */
|
||||
__weak SDL_WindowData *_data;
|
||||
SDL_WindowData *_data;
|
||||
BOOL observingVisible;
|
||||
BOOL wasCtrlLeft;
|
||||
BOOL wasVisible;
|
||||
@@ -117,22 +114,22 @@ typedef enum
|
||||
/* *INDENT-ON* */
|
||||
|
||||
@class SDLOpenGLContext;
|
||||
@class SDL_VideoData;
|
||||
|
||||
@interface SDL_WindowData : NSObject
|
||||
@property (nonatomic) SDL_Window *window;
|
||||
@property (nonatomic) NSWindow *nswindow;
|
||||
@property (nonatomic) NSView *sdlContentView;
|
||||
@property (nonatomic) NSMutableArray *nscontexts;
|
||||
@property (nonatomic) SDL_bool created;
|
||||
@property (nonatomic) SDL_bool inWindowFullscreenTransition;
|
||||
@property (nonatomic) NSInteger flash_request;
|
||||
@property (nonatomic) Cocoa_WindowListener *listener;
|
||||
@property (nonatomic) SDL_VideoData *videodata;
|
||||
struct SDL_WindowData
|
||||
{
|
||||
SDL_Window *window;
|
||||
NSWindow *nswindow;
|
||||
NSView *sdlContentView;
|
||||
NSMutableArray *nscontexts;
|
||||
SDL_bool created;
|
||||
SDL_bool inWindowFullscreenTransition;
|
||||
NSInteger flash_request;
|
||||
Cocoa_WindowListener *listener;
|
||||
struct SDL_VideoData *videodata;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
@property (nonatomic) EGLSurface egl_surface;
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
@end
|
||||
};
|
||||
|
||||
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
|
||||
@@ -156,7 +153,6 @@ extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_t
|
||||
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 void* Cocoa_GetWindowICCProfile(_THIS, SDL_Window * window, size_t * size);
|
||||
extern int Cocoa_GetWindowDisplayIndex(_THIS, SDL_Window * window);
|
||||
extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
|
||||
extern void Cocoa_SetWindowMouseRect(_THIS, SDL_Window * window);
|
||||
extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
|
||||
430
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
430
externals/SDL/src/video/cocoa/SDL_cocoawindow.m
vendored
File diff suppressed because it is too large
Load Diff
@@ -482,15 +482,16 @@ DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (info->version.major == SDL_MAJOR_VERSION) {
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_DIRECTFB;
|
||||
info->info.dfb.dfb = devdata->dfb;
|
||||
info->info.dfb.window = windata->dfbwin;
|
||||
info->info.dfb.surface = windata->surface;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,17 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
|
||||
SDL_Surface *surface;
|
||||
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
|
||||
int w, h;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
SDL_DUMMY_DestroyWindowFramebuffer(_this, window);
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE);
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* Create a new one */
|
||||
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include "SDL_nullvideo.h"
|
||||
#include "SDL_nullevents_c.h"
|
||||
#include "SDL_nullframebuffer_c.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#define DUMMYVID_DRIVER_NAME "dummy"
|
||||
|
||||
@@ -60,7 +59,7 @@ static void DUMMY_VideoQuit(_THIS);
|
||||
static int
|
||||
DUMMY_Available(void)
|
||||
{
|
||||
const char *envr = SDL_GetHint(SDL_HINT_VIDEODRIVER);
|
||||
const char *envr = SDL_getenv("SDL_VIDEODRIVER");
|
||||
if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ static EM_BOOL
|
||||
Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData)
|
||||
{
|
||||
Uint32 scancode;
|
||||
SDL_bool prevent_default = SDL_FALSE;
|
||||
SDL_bool prevent_default;
|
||||
SDL_bool is_nav_key;
|
||||
|
||||
/* .keyCode is deprecated, but still the most reliable way to get keys */
|
||||
@@ -577,10 +577,12 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevent_default = SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKey(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_PRESSED : SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
|
||||
prevent_default = SDL_GetEventState(eventType == EMSCRIPTEN_EVENT_KEYDOWN ? SDL_KEYDOWN : SDL_KEYUP) == SDL_ENABLE;
|
||||
|
||||
/* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress
|
||||
* we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX
|
||||
*/
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "SDL_emscriptenframebuffer.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#include <emscripten/threading.h>
|
||||
|
||||
|
||||
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
|
||||
{
|
||||
@@ -71,7 +69,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
|
||||
|
||||
/* Send the data to the display */
|
||||
|
||||
MAIN_THREAD_EM_ASM({
|
||||
EM_ASM_INT({
|
||||
var w = $0;
|
||||
var h = $1;
|
||||
var pixels = $2;
|
||||
@@ -156,6 +154,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
|
||||
}
|
||||
|
||||
SDL2.ctx.putImageData(SDL2.image, 0, 0);
|
||||
return 0;
|
||||
}, surface->w, surface->h, surface->pixels);
|
||||
|
||||
if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, SDL_TRUE)) {
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
#include <emscripten/threading.h>
|
||||
|
||||
#include "SDL_emscriptenmouse.h"
|
||||
#include "SDL_emscriptenvideo.h"
|
||||
@@ -63,7 +62,6 @@ Emscripten_CreateDefaultCursor()
|
||||
return Emscripten_CreateCursorFromString("default", SDL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
static SDL_Cursor*
|
||||
Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
||||
{
|
||||
@@ -76,7 +74,7 @@ Emscripten_CreateCursor(SDL_Surface* surface, int hot_x, int hot_y)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cursor_url = (const char *)MAIN_THREAD_EM_ASM_INT({
|
||||
cursor_url = (const char *)EM_ASM_INT({
|
||||
var w = $0;
|
||||
var h = $1;
|
||||
var hot_x = $2;
|
||||
@@ -208,15 +206,16 @@ Emscripten_ShowCursor(SDL_Cursor* cursor)
|
||||
curdata = (Emscripten_CursorData *) cursor->driverdata;
|
||||
|
||||
if(curdata->system_cursor) {
|
||||
MAIN_THREAD_EM_ASM({
|
||||
EM_ASM_INT({
|
||||
if (Module['canvas']) {
|
||||
Module['canvas'].style['cursor'] = UTF8ToString($0);
|
||||
}
|
||||
return 0;
|
||||
}, curdata->system_cursor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
MAIN_THREAD_EM_ASM(
|
||||
EM_ASM(
|
||||
if (Module['canvas']) {
|
||||
Module['canvas'].style['cursor'] = 'none';
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ static int Emscripten_VideoInit(_THIS);
|
||||
static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
static void Emscripten_VideoQuit(_THIS);
|
||||
static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
static int Emscripten_CreateWindow(_THIS, SDL_Window * window);
|
||||
static void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
|
||||
@@ -83,7 +82,6 @@ Emscripten_CreateDevice(int devindex)
|
||||
device->VideoInit = Emscripten_VideoInit;
|
||||
device->VideoQuit = Emscripten_VideoQuit;
|
||||
device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds;
|
||||
device->GetDisplayDPI = Emscripten_GetDisplayDPI;
|
||||
device->SetDisplayMode = Emscripten_SetDisplayMode;
|
||||
|
||||
|
||||
@@ -174,37 +172,16 @@ Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect *
|
||||
if (rect) {
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = MAIN_THREAD_EM_ASM_INT({
|
||||
rect->w = EM_ASM_INT_V({
|
||||
return window.innerWidth;
|
||||
});
|
||||
rect->h = MAIN_THREAD_EM_ASM_INT({
|
||||
rect->h = EM_ASM_INT_V({
|
||||
return window.innerHeight;
|
||||
});
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * hdpi_out, float * vdpi_out)
|
||||
{
|
||||
const float dpi_reference = 96.0f;
|
||||
float dpi;
|
||||
|
||||
dpi = (float)emscripten_get_device_pixel_ratio() * dpi_reference;
|
||||
|
||||
if (ddpi_out) {
|
||||
*ddpi_out = dpi;
|
||||
}
|
||||
if (hdpi_out) {
|
||||
*hdpi_out = dpi;
|
||||
}
|
||||
if (vdpi_out) {
|
||||
*vdpi_out = dpi;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
Emscripten_PumpEvents(_THIS)
|
||||
{
|
||||
|
||||
416
externals/SDL/src/video/haiku/SDL_BWin.h
vendored
416
externals/SDL/src/video/haiku/SDL_BWin.h
vendored
@@ -39,6 +39,7 @@ extern "C" {
|
||||
#include <AppKit.h>
|
||||
#include <Cursor.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include <game/DirectWindow.h>
|
||||
#if SDL_VIDEO_OPENGL
|
||||
#include <opengl/GLView.h>
|
||||
#endif
|
||||
@@ -57,48 +58,19 @@ enum WinCommands {
|
||||
BWIN_SET_TITLE,
|
||||
BWIN_SET_BORDERED,
|
||||
BWIN_SET_RESIZABLE,
|
||||
BWIN_FULLSCREEN,
|
||||
BWIN_UPDATE_FRAMEBUFFER,
|
||||
BWIN_MINIMUM_SIZE_WINDOW
|
||||
BWIN_FULLSCREEN
|
||||
};
|
||||
|
||||
// non-OpenGL framebuffer view
|
||||
class SDL_BView: public BView
|
||||
{
|
||||
public:
|
||||
SDL_BView(BRect frame, const char* name, uint32 resizingMode)
|
||||
: BView(frame, name, resizingMode, B_WILL_DRAW),
|
||||
fBitmap(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void Draw(BRect dirty)
|
||||
{
|
||||
if (fBitmap != NULL)
|
||||
DrawBitmap(fBitmap, B_ORIGIN);
|
||||
}
|
||||
|
||||
void SetBitmap(BBitmap *bitmap)
|
||||
{
|
||||
fBitmap = bitmap;
|
||||
}
|
||||
|
||||
private:
|
||||
BBitmap *fBitmap;
|
||||
};
|
||||
|
||||
class SDL_BWin: public BWindow
|
||||
class SDL_BWin:public BDirectWindow
|
||||
{
|
||||
public:
|
||||
/* Constructor/Destructor */
|
||||
SDL_BWin(BRect bounds, window_look look, uint32 flags)
|
||||
: BWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
|
||||
: BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
|
||||
{
|
||||
_last_buttons = 0;
|
||||
|
||||
_cur_view = NULL;
|
||||
_SDL_View = NULL;
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
_SDL_GLView = NULL;
|
||||
_gl_type = 0;
|
||||
@@ -107,88 +79,59 @@ class SDL_BWin: public BWindow
|
||||
_inhibit_resize = false;
|
||||
_mouse_focused = false;
|
||||
_prev_frame = NULL;
|
||||
_fullscreen = NULL;
|
||||
|
||||
/* Handle framebuffer stuff */
|
||||
_connected = _connection_disabled = false;
|
||||
_buffer_created = _buffer_dirty = false;
|
||||
_trash_window_buffer = false;
|
||||
_buffer_locker = new BLocker();
|
||||
_bitmap = NULL;
|
||||
_clips = NULL;
|
||||
_num_clips = 0;
|
||||
|
||||
#ifdef DRAWTHREAD
|
||||
_draw_thread_id = spawn_thread(HAIKU_DrawThread, "drawing_thread",
|
||||
B_NORMAL_PRIORITY, (void*) this);
|
||||
resume_thread(_draw_thread_id);
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual ~ SDL_BWin()
|
||||
{
|
||||
Lock();
|
||||
|
||||
if (_SDL_View != NULL && _SDL_View != _cur_view) {
|
||||
delete _SDL_View;
|
||||
_SDL_View = NULL;
|
||||
}
|
||||
_connection_disabled = true;
|
||||
int32 result;
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
if (_SDL_GLView) {
|
||||
if (((SDL_BApp*)be_app)->GetCurrentContext() == _SDL_GLView)
|
||||
((SDL_BApp*)be_app)->SetCurrentContext(NULL);
|
||||
if (_SDL_GLView == _cur_view)
|
||||
RemoveChild(_SDL_GLView);
|
||||
_SDL_GLView = NULL;
|
||||
// _SDL_GLView deleted by HAIKU_GL_DeleteContext
|
||||
_SDL_GLView->UnlockGL();
|
||||
RemoveChild(_SDL_GLView); /* Why was this outside the if
|
||||
statement before? */
|
||||
}
|
||||
|
||||
#endif
|
||||
Unlock();
|
||||
#if SDL_VIDEO_OPENGL
|
||||
if (_SDL_GLView) {
|
||||
delete _SDL_GLView;
|
||||
}
|
||||
#endif
|
||||
|
||||
delete _prev_frame;
|
||||
|
||||
/* Clean up framebuffer stuff */
|
||||
_buffer_locker->Lock();
|
||||
#ifdef DRAWTHREAD
|
||||
wait_for_thread(_draw_thread_id, &result);
|
||||
#endif
|
||||
SDL_free(_clips);
|
||||
delete _buffer_locker;
|
||||
}
|
||||
|
||||
void SetCurrentView(BView *view)
|
||||
{
|
||||
if (_cur_view != view) {
|
||||
if (_cur_view != NULL)
|
||||
RemoveChild(_cur_view);
|
||||
_cur_view = view;
|
||||
if (_cur_view != NULL)
|
||||
AddChild(_cur_view);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateCurrentView()
|
||||
{
|
||||
if (_SDL_GLView != NULL) {
|
||||
SetCurrentView(_SDL_GLView);
|
||||
} else if (_SDL_View != NULL) {
|
||||
SetCurrentView(_SDL_View);
|
||||
} else {
|
||||
SetCurrentView(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_BView *CreateView() {
|
||||
Lock();
|
||||
if (_SDL_View == NULL) {
|
||||
_SDL_View = new SDL_BView(Bounds(), "SDL View", B_FOLLOW_ALL_SIDES);
|
||||
UpdateCurrentView();
|
||||
}
|
||||
Unlock();
|
||||
return _SDL_View;
|
||||
}
|
||||
|
||||
void RemoveView() {
|
||||
Lock();
|
||||
if(_SDL_View != NULL) {
|
||||
SDL_BView *oldView = _SDL_View;
|
||||
_SDL_View = NULL;
|
||||
UpdateCurrentView();
|
||||
delete oldView;
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
/* * * * * OpenGL functionality * * * * */
|
||||
#if SDL_VIDEO_OPENGL
|
||||
BGLView *CreateGLView(Uint32 gl_flags) {
|
||||
virtual BGLView *CreateGLView(Uint32 gl_flags) {
|
||||
Lock();
|
||||
if (_SDL_GLView == NULL) {
|
||||
_SDL_GLView = new BGLView(Bounds(), "SDL GLView",
|
||||
@@ -196,29 +139,92 @@ class SDL_BWin: public BWindow
|
||||
(B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
gl_flags);
|
||||
_gl_type = gl_flags;
|
||||
UpdateCurrentView();
|
||||
}
|
||||
AddChild(_SDL_GLView);
|
||||
_SDL_GLView->EnableDirectMode(false); /* Disable direct mode */
|
||||
_SDL_GLView->LockGL(); /* "New" GLViews are created */
|
||||
Unlock();
|
||||
return _SDL_GLView;
|
||||
return (_SDL_GLView);
|
||||
}
|
||||
|
||||
void RemoveGLView() {
|
||||
virtual void RemoveGLView() {
|
||||
Lock();
|
||||
if(_SDL_GLView != NULL) {
|
||||
if (((SDL_BApp*)be_app)->GetCurrentContext() == _SDL_GLView)
|
||||
((SDL_BApp*)be_app)->SetCurrentContext(NULL);
|
||||
_SDL_GLView = NULL;
|
||||
UpdateCurrentView();
|
||||
// _SDL_GLView deleted by HAIKU_GL_DeleteContext
|
||||
if(_SDL_GLView) {
|
||||
_SDL_GLView->UnlockGL();
|
||||
RemoveChild(_SDL_GLView);
|
||||
}
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void SwapBuffers(void) {
|
||||
virtual void SwapBuffers(void) {
|
||||
_SDL_GLView->UnlockGL();
|
||||
_SDL_GLView->LockGL();
|
||||
_SDL_GLView->SwapBuffers();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* * * * * Framebuffering* * * * */
|
||||
virtual void DirectConnected(direct_buffer_info *info) {
|
||||
if(!_connected && _connection_disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine if the pixel buffer is usable after this update */
|
||||
_trash_window_buffer = _trash_window_buffer
|
||||
|| ((info->buffer_state & B_BUFFER_RESIZED)
|
||||
|| (info->buffer_state & B_BUFFER_RESET)
|
||||
|| (info->driver_state == B_MODE_CHANGED));
|
||||
LockBuffer();
|
||||
|
||||
switch(info->buffer_state & B_DIRECT_MODE_MASK) {
|
||||
case B_DIRECT_START:
|
||||
_connected = true;
|
||||
|
||||
case B_DIRECT_MODIFY:
|
||||
if (info->clip_list_count > _num_clips)
|
||||
{
|
||||
if(_clips) {
|
||||
SDL_free(_clips);
|
||||
_clips = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
_num_clips = info->clip_list_count;
|
||||
if (_clips == NULL)
|
||||
_clips = (clipping_rect *)SDL_malloc(_num_clips*sizeof(clipping_rect));
|
||||
if(_clips) {
|
||||
SDL_memcpy(_clips, info->clip_list,
|
||||
_num_clips*sizeof(clipping_rect));
|
||||
|
||||
_bits = (uint8*) info->bits;
|
||||
_row_bytes = info->bytes_per_row;
|
||||
_bounds = info->window_bounds;
|
||||
_bytes_per_px = info->bits_per_pixel / 8;
|
||||
_buffer_dirty = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case B_DIRECT_STOP:
|
||||
_connected = false;
|
||||
break;
|
||||
}
|
||||
#if SDL_VIDEO_OPENGL
|
||||
if(_SDL_GLView) {
|
||||
_SDL_GLView->DirectConnected(info);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Call the base object directconnected */
|
||||
BDirectWindow::DirectConnected(info);
|
||||
|
||||
UnlockBuffer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* * * * * Event sending * * * * */
|
||||
/* Hook functions */
|
||||
virtual void FrameMoved(BPoint origin) {
|
||||
@@ -229,10 +235,10 @@ class SDL_BWin: public BWindow
|
||||
_PostWindowEvent(msg);
|
||||
|
||||
/* Perform normal hook operations */
|
||||
BWindow::FrameMoved(origin);
|
||||
BDirectWindow::FrameMoved(origin);
|
||||
}
|
||||
|
||||
void FrameResized(float width, float height) {
|
||||
virtual void FrameResized(float width, float height) {
|
||||
/* Post a message to the BApp so that it can handle the window event */
|
||||
BMessage msg(BAPP_WINDOW_RESIZED);
|
||||
|
||||
@@ -241,10 +247,10 @@ class SDL_BWin: public BWindow
|
||||
_PostWindowEvent(msg);
|
||||
|
||||
/* Perform normal hook operations */
|
||||
BWindow::FrameResized(width, height);
|
||||
BDirectWindow::FrameResized(width, height);
|
||||
}
|
||||
|
||||
bool QuitRequested() {
|
||||
virtual bool QuitRequested() {
|
||||
BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
|
||||
_PostWindowEvent(msg);
|
||||
|
||||
@@ -252,13 +258,13 @@ class SDL_BWin: public BWindow
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowActivated(bool active) {
|
||||
virtual void WindowActivated(bool active) {
|
||||
BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
|
||||
msg.AddBool("focusGained", active);
|
||||
_PostWindowEvent(msg);
|
||||
}
|
||||
|
||||
void Zoom(BPoint origin,
|
||||
virtual void Zoom(BPoint origin,
|
||||
float width,
|
||||
float height) {
|
||||
BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
|
||||
@@ -269,13 +275,13 @@ class SDL_BWin: public BWindow
|
||||
_prev_frame = new BRect(Frame());
|
||||
|
||||
/* Perform normal hook operations */
|
||||
BWindow::Zoom(origin, width, height);
|
||||
BDirectWindow::Zoom(origin, width, height);
|
||||
}
|
||||
|
||||
/* Member functions */
|
||||
void Show() {
|
||||
virtual void Show() {
|
||||
while(IsHidden()) {
|
||||
BWindow::Show();
|
||||
BDirectWindow::Show();
|
||||
}
|
||||
_shown = true;
|
||||
|
||||
@@ -283,33 +289,25 @@ class SDL_BWin: public BWindow
|
||||
_PostWindowEvent(msg);
|
||||
}
|
||||
|
||||
void Hide() {
|
||||
BWindow::Hide();
|
||||
virtual void Hide() {
|
||||
BDirectWindow::Hide();
|
||||
_shown = false;
|
||||
|
||||
BMessage msg(BAPP_HIDE);
|
||||
_PostWindowEvent(msg);
|
||||
}
|
||||
|
||||
void Minimize(bool minimize) {
|
||||
BWindow::Minimize(minimize);
|
||||
virtual void Minimize(bool minimize) {
|
||||
BDirectWindow::Minimize(minimize);
|
||||
int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
|
||||
|
||||
BMessage msg(minState);
|
||||
_PostWindowEvent(msg);
|
||||
}
|
||||
|
||||
void ScreenChanged(BRect screenFrame, color_space depth)
|
||||
{
|
||||
if (_fullscreen) {
|
||||
MoveTo(screenFrame.left, screenFrame.top);
|
||||
ResizeTo(screenFrame.Width(), screenFrame.Height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* BView message interruption */
|
||||
void DispatchMessage(BMessage * msg, BHandler * target)
|
||||
virtual void DispatchMessage(BMessage * msg, BHandler * target)
|
||||
{
|
||||
BPoint where; /* Used by mouse moved */
|
||||
int32 buttons; /* Used for mouse button events */
|
||||
@@ -358,7 +356,7 @@ class SDL_BWin: public BWindow
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
|
||||
if (msg->FindInt32("key", &key) == B_OK) {
|
||||
_KeyEvent((SDL_Scancode)key, NULL, 0, SDL_PRESSED);
|
||||
@@ -378,15 +376,15 @@ class SDL_BWin: public BWindow
|
||||
- CTRL+Q to close window (and other shortcuts)
|
||||
- PrintScreen to make screenshot into /boot/home
|
||||
- etc.. */
|
||||
/* BWindow::DispatchMessage(msg, target); */
|
||||
/* BDirectWindow::DispatchMessage(msg, target); */
|
||||
break;
|
||||
}
|
||||
|
||||
BWindow::DispatchMessage(msg, target);
|
||||
BDirectWindow::DispatchMessage(msg, target);
|
||||
}
|
||||
|
||||
/* Handle command messages */
|
||||
void MessageReceived(BMessage* message) {
|
||||
virtual void MessageReceived(BMessage* message) {
|
||||
switch (message->what) {
|
||||
/* Handle commands from SDL */
|
||||
case BWIN_SET_TITLE:
|
||||
@@ -398,18 +396,12 @@ class SDL_BWin: public BWindow
|
||||
case BWIN_RESIZE_WINDOW:
|
||||
_ResizeTo(message);
|
||||
break;
|
||||
case BWIN_SET_BORDERED: {
|
||||
bool bEnabled;
|
||||
if (message->FindBool("window-border", &bEnabled) == B_OK)
|
||||
_SetBordered(bEnabled);
|
||||
case BWIN_SET_BORDERED:
|
||||
_SetBordered(message);
|
||||
break;
|
||||
}
|
||||
case BWIN_SET_RESIZABLE: {
|
||||
bool bEnabled;
|
||||
if (message->FindBool("window-resizable", &bEnabled) == B_OK)
|
||||
_SetResizable(bEnabled);
|
||||
case BWIN_SET_RESIZABLE:
|
||||
_SetResizable(message);
|
||||
break;
|
||||
}
|
||||
case BWIN_SHOW_WINDOW:
|
||||
Show();
|
||||
break;
|
||||
@@ -425,34 +417,12 @@ class SDL_BWin: public BWindow
|
||||
case BWIN_RESTORE_WINDOW:
|
||||
_Restore();
|
||||
break;
|
||||
case BWIN_FULLSCREEN: {
|
||||
bool fullscreen;
|
||||
if (message->FindBool("fullscreen", &fullscreen) == B_OK)
|
||||
_SetFullScreen(fullscreen);
|
||||
case BWIN_FULLSCREEN:
|
||||
_SetFullScreen(message);
|
||||
break;
|
||||
}
|
||||
case BWIN_MINIMUM_SIZE_WINDOW:
|
||||
_SetMinimumSize(message);
|
||||
break;
|
||||
case BWIN_UPDATE_FRAMEBUFFER: {
|
||||
BMessage* pendingMessage;
|
||||
while ((pendingMessage
|
||||
= MessageQueue()->FindMessage(BWIN_UPDATE_FRAMEBUFFER, 0))) {
|
||||
MessageQueue()->RemoveMessage(pendingMessage);
|
||||
delete pendingMessage;
|
||||
}
|
||||
if (_bitmap != NULL) {
|
||||
if (_SDL_View != NULL && _cur_view == _SDL_View)
|
||||
_SDL_View->Draw(Bounds());
|
||||
else if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) {
|
||||
_SDL_GLView->CopyPixelsIn(_bitmap, B_ORIGIN);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Perform normal message handling */
|
||||
BWindow::MessageReceived(message);
|
||||
BDirectWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -463,9 +433,19 @@ class SDL_BWin: public BWindow
|
||||
/* Accessor methods */
|
||||
bool IsShown() { return _shown; }
|
||||
int32 GetID() { return _id; }
|
||||
uint32 GetRowBytes() { return _row_bytes; }
|
||||
int32 GetFbX() { return _bounds.left; }
|
||||
int32 GetFbY() { return _bounds.top; }
|
||||
bool ConnectionEnabled() { return !_connection_disabled; }
|
||||
bool Connected() { return _connected; }
|
||||
clipping_rect *GetClips() { return _clips; }
|
||||
int32 GetNumClips() { return _num_clips; }
|
||||
uint8* GetBufferPx() { return _bits; }
|
||||
int32 GetBytesPerPx() { return _bytes_per_px; }
|
||||
bool CanTrashWindowBuffer() { return _trash_window_buffer; }
|
||||
bool BufferExists() { return _buffer_created; }
|
||||
bool BufferIsDirty() { return _buffer_dirty; }
|
||||
BBitmap *GetBitmap() { return _bitmap; }
|
||||
BView *GetCurView() { return _cur_view; }
|
||||
SDL_BView *GetView() { return _SDL_View; }
|
||||
#if SDL_VIDEO_OPENGL
|
||||
BGLView *GetGLView() { return _SDL_GLView; }
|
||||
Uint32 GetGLType() { return _gl_type; }
|
||||
@@ -473,9 +453,12 @@ class SDL_BWin: public BWindow
|
||||
|
||||
/* Setter methods */
|
||||
void SetID(int32 id) { _id = id; }
|
||||
void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
|
||||
void LockBuffer() { _buffer_locker->Lock(); }
|
||||
void UnlockBuffer() { _buffer_locker->Unlock(); }
|
||||
void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; if (_SDL_View != NULL) _SDL_View->SetBitmap(bitmap); }
|
||||
void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
|
||||
void SetTrashBuffer(bool trash) { _trash_window_buffer = trash; }
|
||||
void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; }
|
||||
|
||||
|
||||
private:
|
||||
@@ -581,10 +564,7 @@ private:
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (_fullscreen)
|
||||
_non_fullscreen_frame.OffsetTo(x, y);
|
||||
else
|
||||
MoveTo(x, y);
|
||||
MoveTo(x, y);
|
||||
}
|
||||
|
||||
void _ResizeTo(BMessage *msg) {
|
||||
@@ -595,48 +575,27 @@ private:
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (_fullscreen) {
|
||||
_non_fullscreen_frame.right = _non_fullscreen_frame.left + w;
|
||||
_non_fullscreen_frame.bottom = _non_fullscreen_frame.top + h;
|
||||
} else
|
||||
ResizeTo(w, h);
|
||||
ResizeTo(w, h);
|
||||
}
|
||||
|
||||
void _SetBordered(bool bEnabled) {
|
||||
if (_fullscreen)
|
||||
_bordered = bEnabled;
|
||||
else
|
||||
SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
|
||||
}
|
||||
|
||||
void _SetResizable(bool bEnabled) {
|
||||
if (_fullscreen)
|
||||
_resizable = bEnabled;
|
||||
else {
|
||||
if (bEnabled) {
|
||||
SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
|
||||
} else {
|
||||
SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
|
||||
}
|
||||
void _SetBordered(BMessage *msg) {
|
||||
bool bEnabled;
|
||||
if(msg->FindBool("window-border", &bEnabled) != B_OK) {
|
||||
return;
|
||||
}
|
||||
SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
|
||||
}
|
||||
|
||||
void _SetMinimumSize(BMessage *msg) {
|
||||
float maxHeight;
|
||||
float maxWidth;
|
||||
float _;
|
||||
int32 minHeight;
|
||||
int32 minWidth;
|
||||
|
||||
// This is a bit convoluted, we only want to set the minimum not the maximum
|
||||
// But there is no direct call to do that, so store the maximum size beforehand
|
||||
GetSizeLimits(&_, &maxWidth, &_, &maxHeight);
|
||||
if (msg->FindInt32("window-w", &minWidth) != B_OK)
|
||||
void _SetResizable(BMessage *msg) {
|
||||
bool bEnabled;
|
||||
if(msg->FindBool("window-resizable", &bEnabled) != B_OK) {
|
||||
return;
|
||||
if (msg->FindInt32("window-h", &minHeight) != B_OK)
|
||||
return;
|
||||
SetSizeLimits((float)minWidth, maxWidth, (float)minHeight, maxHeight);
|
||||
UpdateSizeLimits();
|
||||
}
|
||||
if (bEnabled) {
|
||||
SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
|
||||
} else {
|
||||
SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
|
||||
}
|
||||
}
|
||||
|
||||
void _Restore() {
|
||||
@@ -644,42 +603,23 @@ private:
|
||||
Minimize(false);
|
||||
} else if(IsHidden()) {
|
||||
Show();
|
||||
} else if (_fullscreen) {
|
||||
|
||||
} else if(_prev_frame != NULL) { /* Zoomed */
|
||||
MoveTo(_prev_frame->left, _prev_frame->top);
|
||||
ResizeTo(_prev_frame->Width(), _prev_frame->Height());
|
||||
}
|
||||
}
|
||||
|
||||
void _SetFullScreen(bool fullscreen) {
|
||||
if (fullscreen != _fullscreen) {
|
||||
if (fullscreen) {
|
||||
BScreen screen(this);
|
||||
BRect screenFrame = screen.Frame();
|
||||
printf("screen frame: "); screenFrame.PrintToStream(); printf("\n");
|
||||
_bordered = Look() != B_NO_BORDER_WINDOW_LOOK;
|
||||
_resizable = !(Flags() & B_NOT_RESIZABLE);
|
||||
_non_fullscreen_frame = Frame();
|
||||
_SetBordered(false);
|
||||
_SetResizable(false);
|
||||
MoveTo(screenFrame.left, screenFrame.top);
|
||||
ResizeTo(screenFrame.Width(), screenFrame.Height());
|
||||
_fullscreen = fullscreen;
|
||||
} else {
|
||||
_fullscreen = fullscreen;
|
||||
MoveTo(_non_fullscreen_frame.left, _non_fullscreen_frame.top);
|
||||
ResizeTo(_non_fullscreen_frame.Width(), _non_fullscreen_frame.Height());
|
||||
_SetBordered(_bordered);
|
||||
_SetResizable(_resizable);
|
||||
}
|
||||
void _SetFullScreen(BMessage *msg) {
|
||||
bool fullscreen;
|
||||
if(
|
||||
msg->FindBool("fullscreen", &fullscreen) != B_OK
|
||||
) {
|
||||
return;
|
||||
}
|
||||
SetFullScreen(fullscreen);
|
||||
}
|
||||
|
||||
/* Members */
|
||||
|
||||
BView* _cur_view;
|
||||
SDL_BView* _SDL_View;
|
||||
#if SDL_VIDEO_OPENGL
|
||||
BGLView * _SDL_GLView;
|
||||
Uint32 _gl_type;
|
||||
@@ -692,15 +632,23 @@ private:
|
||||
bool _inhibit_resize;
|
||||
|
||||
BRect *_prev_frame; /* Previous position and size of the window */
|
||||
bool _fullscreen;
|
||||
// valid only if fullscreen
|
||||
BRect _non_fullscreen_frame;
|
||||
bool _bordered;
|
||||
bool _resizable;
|
||||
|
||||
/* Framebuffer members */
|
||||
BLocker *_buffer_locker;
|
||||
BBitmap *_bitmap;
|
||||
bool _connected,
|
||||
_connection_disabled,
|
||||
_buffer_created,
|
||||
_buffer_dirty,
|
||||
_trash_window_buffer;
|
||||
uint8 *_bits;
|
||||
uint32 _row_bytes;
|
||||
clipping_rect _bounds;
|
||||
BLocker *_buffer_locker;
|
||||
clipping_rect *_clips;
|
||||
uint32 _num_clips;
|
||||
int32 _bytes_per_px;
|
||||
thread_id _draw_thread_id;
|
||||
|
||||
BBitmap *_bitmap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
150
externals/SDL/src/video/haiku/SDL_bframebuffer.cc
vendored
150
externals/SDL/src/video/haiku/SDL_bframebuffer.cc
vendored
@@ -35,6 +35,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DRAWTHREAD
|
||||
static int32 HAIKU_UpdateOnce(SDL_Window *window);
|
||||
#endif
|
||||
|
||||
static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
|
||||
return ((SDL_BWin*)(window->driverdata));
|
||||
}
|
||||
@@ -52,11 +56,11 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
|
||||
return -1;
|
||||
}
|
||||
|
||||
while(!bwin->Connected()) { snooze(100); }
|
||||
|
||||
/* Make sure we have exclusive access to frame buffer data */
|
||||
bwin->LockBuffer();
|
||||
|
||||
bwin->CreateView();
|
||||
|
||||
/* format */
|
||||
display_mode bmode;
|
||||
bscreen.GetMode(&bmode);
|
||||
@@ -72,7 +76,7 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
|
||||
bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
|
||||
false, /* Views not accepted */
|
||||
true); /* Contiguous memory required */
|
||||
|
||||
|
||||
if(bitmap->InitCheck() != B_OK) {
|
||||
delete bitmap;
|
||||
return SDL_SetError("Could not initialize back buffer!");
|
||||
@@ -80,13 +84,15 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window,
|
||||
|
||||
|
||||
bwin->SetBitmap(bitmap);
|
||||
|
||||
|
||||
/* Set the pixel pointer */
|
||||
*pixels = bitmap->Bits();
|
||||
|
||||
/* pitch = width of window, in bytes */
|
||||
*pitch = bitmap->BytesPerRow();
|
||||
|
||||
bwin->SetBufferExists(true);
|
||||
bwin->SetTrashBuffer(false);
|
||||
bwin->UnlockBuffer();
|
||||
return 0;
|
||||
}
|
||||
@@ -100,26 +106,150 @@ int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
|
||||
|
||||
SDL_BWin *bwin = _ToBeWin(window);
|
||||
|
||||
bwin->PostMessage(BWIN_UPDATE_FRAMEBUFFER);
|
||||
#ifdef DRAWTHREAD
|
||||
bwin->LockBuffer();
|
||||
bwin->SetBufferDirty(true);
|
||||
bwin->UnlockBuffer();
|
||||
#else
|
||||
bwin->SetBufferDirty(true);
|
||||
HAIKU_UpdateOnce(window);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32 HAIKU_DrawThread(void *data) {
|
||||
SDL_BWin *bwin = (SDL_BWin*)data;
|
||||
|
||||
BScreen bscreen;
|
||||
if(!bscreen.IsValid()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while(bwin->ConnectionEnabled()) {
|
||||
if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
|
||||
bwin->LockBuffer();
|
||||
BBitmap *bitmap = NULL;
|
||||
bitmap = bwin->GetBitmap();
|
||||
int32 windowPitch = bitmap->BytesPerRow();
|
||||
int32 bufferPitch = bwin->GetRowBytes();
|
||||
uint8 *windowpx;
|
||||
uint8 *bufferpx;
|
||||
|
||||
int32 BPP = bwin->GetBytesPerPx();
|
||||
int32 windowSub = bwin->GetFbX() * BPP +
|
||||
bwin->GetFbY() * windowPitch;
|
||||
clipping_rect *clips = bwin->GetClips();
|
||||
int32 numClips = bwin->GetNumClips();
|
||||
int i, y;
|
||||
|
||||
/* Blit each clipping rectangle */
|
||||
bscreen.WaitForRetrace();
|
||||
for(i = 0; i < numClips; ++i) {
|
||||
/* Get addresses of the start of each clipping rectangle */
|
||||
int32 width = clips[i].right - clips[i].left + 1;
|
||||
int32 height = clips[i].bottom - clips[i].top + 1;
|
||||
bufferpx = bwin->GetBufferPx() +
|
||||
clips[i].top * bufferPitch + clips[i].left * BPP;
|
||||
windowpx = (uint8*)bitmap->Bits() +
|
||||
clips[i].top * windowPitch + clips[i].left * BPP -
|
||||
windowSub;
|
||||
|
||||
/* Copy each row of pixels from the window buffer into the frame
|
||||
buffer */
|
||||
for(y = 0; y < height; ++y)
|
||||
{
|
||||
|
||||
if(bwin->CanTrashWindowBuffer()) {
|
||||
goto escape; /* Break out before the buffer is killed */
|
||||
}
|
||||
|
||||
memcpy(bufferpx, windowpx, width * BPP);
|
||||
bufferpx += bufferPitch;
|
||||
windowpx += windowPitch;
|
||||
}
|
||||
}
|
||||
|
||||
bwin->SetBufferDirty(false);
|
||||
escape:
|
||||
bwin->UnlockBuffer();
|
||||
} else {
|
||||
snooze(16000);
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
|
||||
SDL_BWin *bwin = _ToBeWin(window);
|
||||
|
||||
|
||||
bwin->LockBuffer();
|
||||
|
||||
|
||||
/* Free and clear the window buffer */
|
||||
BBitmap *bitmap = bwin->GetBitmap();
|
||||
delete bitmap;
|
||||
bwin->SetBitmap(NULL);
|
||||
|
||||
bwin->RemoveView();
|
||||
|
||||
bwin->SetBufferExists(false);
|
||||
bwin->UnlockBuffer();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* This was written to test if certain errors were caused by threading issues.
|
||||
* The specific issues have since become rare enough that they may have been
|
||||
* solved, but I doubt it- they were pretty sporadic before now.
|
||||
*/
|
||||
#ifndef DRAWTHREAD
|
||||
static int32 HAIKU_UpdateOnce(SDL_Window *window) {
|
||||
SDL_BWin *bwin = _ToBeWin(window);
|
||||
BScreen bscreen;
|
||||
if(!bscreen.IsValid()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(bwin->ConnectionEnabled() && bwin->Connected()) {
|
||||
bwin->LockBuffer();
|
||||
int32 windowPitch = window->surface->pitch;
|
||||
int32 bufferPitch = bwin->GetRowBytes();
|
||||
uint8 *windowpx;
|
||||
uint8 *bufferpx;
|
||||
|
||||
int32 BPP = bwin->GetBytesPerPx();
|
||||
uint8 *windowBaseAddress = (uint8*)window->surface->pixels;
|
||||
int32 windowSub = bwin->GetFbX() * BPP +
|
||||
bwin->GetFbY() * windowPitch;
|
||||
clipping_rect *clips = bwin->GetClips();
|
||||
int32 numClips = bwin->GetNumClips();
|
||||
int i, y;
|
||||
|
||||
/* Blit each clipping rectangle */
|
||||
bscreen.WaitForRetrace();
|
||||
for(i = 0; i < numClips; ++i) {
|
||||
/* Get addresses of the start of each clipping rectangle */
|
||||
int32 width = clips[i].right - clips[i].left + 1;
|
||||
int32 height = clips[i].bottom - clips[i].top + 1;
|
||||
bufferpx = bwin->GetBufferPx() +
|
||||
clips[i].top * bufferPitch + clips[i].left * BPP;
|
||||
windowpx = windowBaseAddress +
|
||||
clips[i].top * windowPitch + clips[i].left * BPP - windowSub;
|
||||
|
||||
/* Copy each row of pixels from the window buffer into the frame
|
||||
buffer */
|
||||
for(y = 0; y < height; ++y)
|
||||
{
|
||||
memcpy(bufferpx, windowpx, width * BPP);
|
||||
bufferpx += bufferPitch;
|
||||
windowpx += windowPitch;
|
||||
}
|
||||
}
|
||||
bwin->UnlockBuffer();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
36
externals/SDL/src/video/haiku/SDL_bopengl.cc
vendored
36
externals/SDL/src/video/haiku/SDL_bopengl.cc
vendored
@@ -84,21 +84,16 @@ void *HAIKU_GL_GetProcAddress(_THIS, const char *proc)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window) {
|
||||
_ToBeWin(window)->SwapBuffers();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
|
||||
BGLView* glView = (BGLView*)context;
|
||||
// printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL));
|
||||
if (glView != NULL) {
|
||||
if ((glView->Window() == NULL) || (window == NULL) || (_ToBeWin(window)->GetGLView() != glView)) {
|
||||
SDL_SetError("MakeCurrent failed");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
_GetBeApp()->SetCurrentContext(glView);
|
||||
SDL_BWin* win = (SDL_BWin*)context;
|
||||
_GetBeApp()->SetCurrentContext(win ? win->GetGLView() : NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,11 +102,6 @@ SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window) {
|
||||
/* FIXME: Not sure what flags should be included here; may want to have
|
||||
most of them */
|
||||
SDL_BWin *bwin = _ToBeWin(window);
|
||||
// printf("HAIKU_GL_CreateContext, win = %llx, thread = %d\n", (uint64)window, find_thread(NULL));
|
||||
if (bwin->GetGLView() != NULL) {
|
||||
SDL_SetError("Context already creaded");
|
||||
return NULL;
|
||||
}
|
||||
Uint32 gl_flags = BGL_RGB;
|
||||
if (_this->gl_config.alpha_size) {
|
||||
gl_flags |= BGL_ALPHA;
|
||||
@@ -133,25 +123,13 @@ SDL_GLContext HAIKU_GL_CreateContext(_THIS, SDL_Window * window) {
|
||||
_this->gl_config.accum_alpha_size) {
|
||||
gl_flags |= BGL_ACCUM;
|
||||
}
|
||||
#if __GNUC__ > 3
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
gl_flags |= BGL_SHARE_CONTEXT;
|
||||
}
|
||||
#endif
|
||||
bwin->CreateGLView(gl_flags);
|
||||
_GetBeApp()->SetCurrentContext(bwin->GetGLView());
|
||||
return (SDL_GLContext)(bwin->GetGLView());
|
||||
return (SDL_GLContext)(bwin);
|
||||
}
|
||||
|
||||
void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context) {
|
||||
// printf("HAIKU_GL_DeleteContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL));
|
||||
BGLView* glView = (BGLView*)context;
|
||||
SDL_BWin *bwin = (SDL_BWin*)glView->Window();
|
||||
if (bwin == NULL) {
|
||||
delete glView;
|
||||
} else {
|
||||
bwin->RemoveGLView();
|
||||
}
|
||||
/* Currently, automatically unlocks the view */
|
||||
((SDL_BWin*)context)->RemoveGLView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
29
externals/SDL/src/video/haiku/SDL_bvideo.cc
vendored
29
externals/SDL/src/video/haiku/SDL_bvideo.cc
vendored
@@ -94,7 +94,6 @@ HAIKU_CreateDevice(int devindex)
|
||||
device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp;
|
||||
device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp;
|
||||
device->SetWindowMouseGrab = HAIKU_SetWindowMouseGrab;
|
||||
device->SetWindowMinimumSize = HAIKU_SetWindowMinimumSize;
|
||||
device->DestroyWindow = HAIKU_DestroyWindow;
|
||||
device->GetWindowWMInfo = HAIKU_GetWindowWMInfo;
|
||||
device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer;
|
||||
@@ -191,31 +190,6 @@ HAIKU_FreeCursor(SDL_Cursor * cursor)
|
||||
SDL_free(cursor);
|
||||
}
|
||||
|
||||
static SDL_Cursor *
|
||||
HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
SDL_Surface *converted;
|
||||
|
||||
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
|
||||
if (!converted) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BBitmap *cursorBitmap = new BBitmap(BRect(0, 0, surface->w - 1, surface->h - 1), B_RGBA32);
|
||||
cursorBitmap->SetBits(converted->pixels, converted->h * converted->pitch, 0, B_RGBA32);
|
||||
SDL_FreeSurface(converted);
|
||||
|
||||
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
|
||||
if (cursor) {
|
||||
cursor->driverdata = (void *)new BCursor(cursorBitmap, BPoint(hot_x, hot_y));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
static int HAIKU_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
@@ -248,7 +222,7 @@ HAIKU_SetRelativeMouseMode(SDL_bool enabled)
|
||||
|
||||
bewin->Lock();
|
||||
if (enabled)
|
||||
_SDL_GLView->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
_SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY);
|
||||
else
|
||||
_SDL_GLView->SetEventMask(0, 0);
|
||||
bewin->Unlock();
|
||||
@@ -261,7 +235,6 @@ static void HAIKU_MouseInit(_THIS)
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
if (!mouse)
|
||||
return;
|
||||
mouse->CreateCursor = HAIKU_CreateCursor;
|
||||
mouse->CreateSystemCursor = HAIKU_CreateSystemCursor;
|
||||
mouse->ShowCursor = HAIKU_ShowCursor;
|
||||
mouse->FreeCursor = HAIKU_FreeCursor;
|
||||
|
||||
14
externals/SDL/src/video/haiku/SDL_bwindow.cc
vendored
14
externals/SDL/src/video/haiku/SDL_bwindow.cc
vendored
@@ -205,13 +205,6 @@ int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
|
||||
}
|
||||
|
||||
|
||||
void HAIKU_SetWindowMinimumSize(_THIS, SDL_Window * window){
|
||||
BMessage msg(BWIN_MINIMUM_SIZE_WINDOW);
|
||||
msg.AddInt32("window-w", window->w -1);
|
||||
msg.AddInt32("window-h", window->h -1);
|
||||
_ToBeWin(window)->PostMessage(&msg);
|
||||
}
|
||||
|
||||
void HAIKU_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) {
|
||||
/* TODO: Implement this! */
|
||||
}
|
||||
@@ -226,12 +219,13 @@ void HAIKU_DestroyWindow(_THIS, SDL_Window * window) {
|
||||
SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info) {
|
||||
/* FIXME: What is the point of this? What information should be included? */
|
||||
if (info->version.major == SDL_MAJOR_VERSION) {
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_HAIKU;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
1
externals/SDL/src/video/haiku/SDL_bwindow.h
vendored
1
externals/SDL/src/video/haiku/SDL_bwindow.h
vendored
@@ -32,7 +32,6 @@ extern void HAIKU_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
extern void HAIKU_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_SetWindowSize(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_SetWindowMinimumSize(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_ShowWindow(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_HideWindow(_THIS, SDL_Window * window);
|
||||
extern void HAIKU_RaiseWindow(_THIS, SDL_Window * window);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#ifndef SDL_KMSDRM_MODULE
|
||||
#define SDL_KMSDRM_MODULE(modname)
|
||||
@@ -125,6 +125,6 @@ SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct
|
||||
#undef SDL_KMSDRM_SYM
|
||||
#undef SDL_KMSDRM_SYM_CONST
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -476,9 +476,9 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS,
|
||||
}
|
||||
}
|
||||
|
||||
/* If we couldn't find an appropriate plane, error out. */
|
||||
/* If we couldn't find an appropiate plane, error out. */
|
||||
if (plane == UINT32_MAX) {
|
||||
SDL_SetError("Vulkan couldn't find an appropriate plane.");
|
||||
SDL_SetError("Vulkan couldn't find an appropiate plane.");
|
||||
goto clean;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ NACL_CreateWindow(_THIS, SDL_Window * window)
|
||||
SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
if (driverdata->window) {
|
||||
return SDL_SetError("NaCl only supports one window");
|
||||
SDL_SetError("NaCl only supports one window");
|
||||
return -1;
|
||||
}
|
||||
driverdata->window = window;
|
||||
|
||||
|
||||
@@ -34,13 +34,17 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * f
|
||||
SDL_Surface *surface;
|
||||
const Uint32 surface_format = SDL_PIXELFORMAT_RGB888;
|
||||
int w, h;
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
SDL_OFFSCREEN_DestroyWindowFramebuffer(_this, window);
|
||||
surface = (SDL_Surface *) SDL_GetWindowData(window, OFFSCREEN_SURFACE);
|
||||
SDL_FreeSurface(surface);
|
||||
|
||||
/* Create a new one */
|
||||
SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
8
externals/SDL/src/video/os2/SDL_os2dive.c
vendored
8
externals/SDL/src/video/os2/SDL_os2dive.c
vendored
@@ -67,12 +67,10 @@ OS2VIDEOOUTPUT voDive = {
|
||||
|
||||
static BOOL voQueryInfo(VIDEOOUTPUTINFO *pInfo)
|
||||
{
|
||||
DIVE_CAPS sDiveCaps;
|
||||
FOURCC fccFormats[100];
|
||||
DIVE_CAPS sDiveCaps = { 0 };
|
||||
FOURCC fccFormats[100] = { 0 };
|
||||
|
||||
/* Query information about display hardware from DIVE. */
|
||||
SDL_zeroa(fccFormats);
|
||||
SDL_zero(sDiveCaps);
|
||||
sDiveCaps.pFormatData = fccFormats;
|
||||
sDiveCaps.ulFormatLength = 100;
|
||||
sDiveCaps.ulStructLen = sizeof(DIVE_CAPS);
|
||||
@@ -174,7 +172,7 @@ static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd,
|
||||
/* Setup DIVE blitter. */
|
||||
SETUP_BLITTER sSetupBlitter;
|
||||
SWP swp;
|
||||
POINTL pointl = { 0,0 };
|
||||
POINTL pointl = { 0 };
|
||||
|
||||
WinQueryWindowPos(hwnd, &swp);
|
||||
WinMapWindowPoints(hwnd, HWND_DESKTOP, &pointl, 1);
|
||||
|
||||
10
externals/SDL/src/video/os2/SDL_os2messagebox.c
vendored
10
externals/SDL/src/video/os2/SDL_os2messagebox.c
vendored
@@ -35,8 +35,8 @@
|
||||
#define IDD_PB_FIRST 1003
|
||||
|
||||
typedef struct _MSGBOXDLGDATA {
|
||||
USHORT cb;
|
||||
HWND hwndUnder;
|
||||
USHORT cb;
|
||||
HWND hwndUnder;
|
||||
} MSGBOXDLGDATA;
|
||||
|
||||
static VOID _wmInitDlg(HWND hwnd, MSGBOXDLGDATA *pDlgData)
|
||||
@@ -205,9 +205,9 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
|
||||
pSDLBtnData = (SDL_MessageBoxButtonData *)messageboxdata->buttons;
|
||||
ULONG cSDLBtnData = messageboxdata->numbuttons;
|
||||
|
||||
PSZ pszTitle = OS2_UTF8ToSys(messageboxdata->title);
|
||||
PSZ pszTitle = OS2_UTF8ToSys((PSZ) messageboxdata->title);
|
||||
ULONG cbTitle = (pszTitle == NULL)? 1 : (SDL_strlen(pszTitle) + 1);
|
||||
PSZ pszText = OS2_UTF8ToSys(messageboxdata->message);
|
||||
PSZ pszText = OS2_UTF8ToSys((PSZ) messageboxdata->message);
|
||||
ULONG cbText = (pszText == NULL)? 1 : (SDL_strlen(pszText) + 1);
|
||||
|
||||
PDLGTEMPLATE pTemplate;
|
||||
@@ -406,7 +406,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata)
|
||||
pDlgItem->cchClassName = 0; /* 0 - offClassname is WC_ constant. */
|
||||
pDlgItem->offClassName = (USHORT)WC_BUTTON;
|
||||
|
||||
pszBtnText = OS2_UTF8ToSys(pSDLBtnData[ulIdx].text);
|
||||
pszBtnText = OS2_UTF8ToSys((PSZ)pSDLBtnData[ulIdx].text);
|
||||
cbBtnText = (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1);
|
||||
pDlgItem->cchText = cbBtnText;
|
||||
pDlgItem->offText = pcDlgData - (PCHAR)pTemplate; /* Offset to the text. */
|
||||
|
||||
9
externals/SDL/src/video/os2/SDL_os2util.c
vendored
9
externals/SDL/src/video/os2/SDL_os2util.c
vendored
@@ -27,8 +27,8 @@
|
||||
HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
||||
{
|
||||
HBITMAP hbm;
|
||||
BITMAPINFOHEADER2 bmih;
|
||||
BITMAPINFO bmi;
|
||||
BITMAPINFOHEADER2 bmih = { 0 };
|
||||
BITMAPINFO bmi = { 0 };
|
||||
HPS hps;
|
||||
PULONG pulBitmap;
|
||||
PULONG pulDst, pulSrc, pulDstMask;
|
||||
@@ -40,7 +40,7 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
||||
return NULLHANDLE;
|
||||
}
|
||||
|
||||
pulBitmap = (PULONG) SDL_malloc(surface->h * surface->w * 2 * sizeof(ULONG));
|
||||
pulBitmap = SDL_malloc(surface->h * surface->w * 4 * 2);
|
||||
if (pulBitmap == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULLHANDLE;
|
||||
@@ -72,9 +72,6 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY)
|
||||
}
|
||||
|
||||
/* Create system bitmap object. */
|
||||
SDL_zero(bmih);
|
||||
SDL_zero(bmi);
|
||||
|
||||
bmih.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||
bmih.cx = surface->w;
|
||||
bmih.cy = 2 * surface->h;
|
||||
|
||||
18
externals/SDL/src/video/os2/SDL_os2video.c
vendored
18
externals/SDL/src/video/os2/SDL_os2video.c
vendored
@@ -335,7 +335,7 @@ static VOID _wmChar(WINDATA *pWinData, MPARAM mp1, MPARAM mp2)
|
||||
static VOID _wmMove(WINDATA *pWinData)
|
||||
{
|
||||
SDL_DisplayMode *pSDLDisplayMode = _getDisplayModeForSDLWindow(pWinData->window);
|
||||
POINTL pointl = { 0,0 };
|
||||
POINTL pointl = { 0 };
|
||||
RECTL rectl;
|
||||
|
||||
WinQueryWindowRect(pWinData->hwnd, &rectl);
|
||||
@@ -1137,8 +1137,8 @@ static SDL_bool OS2_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_SetError("Application not compiled with SDL %u",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %u.%u",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -1219,7 +1219,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape,
|
||||
{
|
||||
SDL_ShapeTree *pShapeTree;
|
||||
WINDATA *pWinData;
|
||||
SHAPERECTS stShapeRects;
|
||||
SHAPERECTS stShapeRects = { 0 };
|
||||
HPS hps;
|
||||
|
||||
debug_os2("Enter");
|
||||
@@ -1235,7 +1235,6 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape,
|
||||
pShapeTree = SDL_CalculateShapeTree(*shape_mode, shape);
|
||||
shaper->driverdata = pShapeTree;
|
||||
|
||||
SDL_zero(stShapeRects);
|
||||
stShapeRects.ulWinHeight = shaper->window->h;
|
||||
SDL_TraverseShapeTree(pShapeTree, &_combineRectRegions, &stShapeRects);
|
||||
|
||||
@@ -1402,19 +1401,18 @@ static char *OS2_GetClipboardText(_THIS)
|
||||
static SDL_bool OS2_HasClipboardText(_THIS)
|
||||
{
|
||||
SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata;
|
||||
PSZ pszClipboard;
|
||||
SDL_bool result;
|
||||
SDL_bool fClipboard;
|
||||
|
||||
if (!WinOpenClipbrd(pVData->hab)) {
|
||||
debug_os2("WinOpenClipbrd() failed");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
pszClipboard = (PSZ)WinQueryClipbrdData(pVData->hab, CF_TEXT);
|
||||
result = (pszClipboard && *pszClipboard) ? SDL_TRUE : SDL_FALSE;
|
||||
fClipboard = ((PSZ)WinQueryClipbrdData(pVData->hab, CF_TEXT) != NULL)?
|
||||
SDL_TRUE : SDL_FALSE;
|
||||
WinCloseClipbrd(pVData->hab);
|
||||
|
||||
return result;
|
||||
return fClipboard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
11
externals/SDL/src/video/os2/SDL_os2vman.c
vendored
11
externals/SDL/src/video/os2/SDL_os2vman.c
vendored
@@ -91,10 +91,10 @@ static VOID APIENTRY ExitVMan(VOID)
|
||||
static BOOL _vmanInit(void)
|
||||
{
|
||||
ULONG ulRC;
|
||||
CHAR acBuf[256];
|
||||
CHAR acBuf[255];
|
||||
INITPROCOUT stInitProcOut;
|
||||
|
||||
if (hmodVMan != NULLHANDLE) /* already initialized */
|
||||
if (hmodVMan != NULLHANDLE) /* Already was initialized */
|
||||
return TRUE;
|
||||
|
||||
/* Load vman.dll */
|
||||
@@ -108,7 +108,8 @@ static BOOL _vmanInit(void)
|
||||
/* Get VMIEntry */
|
||||
ulRC = DosQueryProcAddr(hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry);
|
||||
if (ulRC != NO_ERROR) {
|
||||
debug_os2("Could not query address of VMIEntry from VMAN.DLL (Err: %lu)", ulRC);
|
||||
debug_os2("Could not query address of pfnVMIEntry func. of VMAN.DLL, "
|
||||
"rc = %u", ulRC);
|
||||
DosFreeModule(hmodVMan);
|
||||
hmodVMan = NULLHANDLE;
|
||||
return FALSE;
|
||||
@@ -326,8 +327,9 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
PPOINTL pptlSrcOrg;
|
||||
PBLTRECT pbrDst;
|
||||
HWREQIN sHWReqIn;
|
||||
BITBLTINFO sBitbltInfo;
|
||||
BITBLTINFO sBitbltInfo = { 0 };
|
||||
ULONG ulIdx;
|
||||
/* RECTL rectlScreenUpdate;*/
|
||||
|
||||
if (pVOData->pBuffer == NULL)
|
||||
return FALSE;
|
||||
@@ -452,7 +454,6 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects,
|
||||
rclSrcBounds.xRight = bmiSrc.ulWidth;
|
||||
rclSrcBounds.yTop = bmiSrc.ulHeight;
|
||||
|
||||
SDL_zero(sBitbltInfo);
|
||||
sBitbltInfo.ulLength = sizeof(BITBLTINFO);
|
||||
sBitbltInfo.ulBltFlags = BF_DEFAULT_STATE | BF_ROP_INCL_SRC | BF_PAT_HOLLOW;
|
||||
sBitbltInfo.cBlits = cSDLRects;
|
||||
|
||||
@@ -302,8 +302,8 @@ PND_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
4
externals/SDL/src/video/psp/SDL_pspvideo.c
vendored
4
externals/SDL/src/video/psp/SDL_pspvideo.c
vendored
@@ -287,8 +287,8 @@ PSP_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,8 +431,8 @@ RPI_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ RISCOS_PollKeyboard(_THIS)
|
||||
|
||||
/* Check for key presses */
|
||||
while (key < 0xff) {
|
||||
SDL_bool already_pressed = SDL_FALSE;
|
||||
key = _kernel_osbyte(121, key + 1, 0) & 0xff;
|
||||
switch (key) {
|
||||
case 255:
|
||||
@@ -82,16 +83,22 @@ RISCOS_PollKeyboard(_THIS)
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_RISCOS_translate_keycode(key));
|
||||
|
||||
/* Record the press so we can detect release later. */
|
||||
/* Do we already know of this key? */
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||
if (driverdata->key_pressed[i] == key) {
|
||||
already_pressed = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
if (driverdata->key_pressed[i] == 255) {
|
||||
driverdata->key_pressed[i] = key;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!already_pressed) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_RISCOS_translate_keycode(key));
|
||||
/* Record the press so we can detect release later. */
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) {
|
||||
if (driverdata->key_pressed[i] == 255) {
|
||||
driverdata->key_pressed[i] = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +150,6 @@ int
|
||||
RISCOS_InitEvents(_THIS)
|
||||
{
|
||||
SDL_VideoData *driverdata = (SDL_VideoData *) _this->driverdata;
|
||||
_kernel_swi_regs regs;
|
||||
int i, status;
|
||||
|
||||
for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++)
|
||||
@@ -154,9 +160,6 @@ RISCOS_InitEvents(_THIS)
|
||||
SDL_ToggleModState(KMOD_CAPS, (status & (1 << 4)) == 0);
|
||||
SDL_ToggleModState(KMOD_SCROLL, (status & (1 << 1)) != 0);
|
||||
|
||||
_kernel_swi(OS_Mouse, ®s, ®s);
|
||||
driverdata->last_mouse_buttons = regs.r[2];
|
||||
|
||||
/* Disable escape. */
|
||||
_kernel_osbyte(229, 1, 0);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#if SDL_VIDEO_DRIVER_RISCOS
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosmodes.h"
|
||||
@@ -305,8 +304,8 @@ RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
_kernel_oswrch(disable_cursor[i]);
|
||||
}
|
||||
|
||||
/* Update cursor visibility, since it may have been disabled by the mode change. */
|
||||
SDL_SetCursor(NULL);
|
||||
/* Turn the mouse pointer on */
|
||||
/* _kernel_osbyte(106, 1, 0); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscosevents_c.h"
|
||||
#include "SDL_riscosframebuffer_c.h"
|
||||
#include "SDL_riscosmouse.h"
|
||||
#include "SDL_riscosmodes.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
|
||||
@@ -106,10 +105,6 @@ RISCOS_VideoInit(_THIS)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (RISCOS_InitMouse(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (RISCOS_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "SDL_version.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
|
||||
#include "SDL_riscosvideo.h"
|
||||
#include "SDL_riscoswindow.h"
|
||||
@@ -44,8 +42,6 @@ RISCOS_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
|
||||
SDL_SetMouseFocus(window);
|
||||
|
||||
/* All done! */
|
||||
window->driverdata = driverdata;
|
||||
return 0;
|
||||
@@ -66,12 +62,13 @@ RISCOS_DestroyWindow(_THIS, SDL_Window * window)
|
||||
SDL_bool
|
||||
RISCOS_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
{
|
||||
if (info->version.major == SDL_MAJOR_VERSION) {
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_RISCOS;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
Sources:
|
||||
- https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes
|
||||
*/
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
static SDL_Scancode const riscos_scancode_table[] = {
|
||||
/* 0 */ SDL_SCANCODE_UNKNOWN, /* Shift */
|
||||
/* 1 */ SDL_SCANCODE_UNKNOWN, /* Ctrl */
|
||||
@@ -155,4 +155,4 @@ static SDL_Scancode const riscos_scancode_table[] = {
|
||||
/* 126 */ SDL_SCANCODE_RGUI,
|
||||
/* 127 */ SDL_SCANCODE_MENU
|
||||
};
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
104
externals/SDL/src/video/sdlgenblit.pl
vendored
104
externals/SDL/src/video/sdlgenblit.pl
vendored
@@ -114,7 +114,7 @@ sub open_file {
|
||||
|
||||
#if SDL_HAVE_BLIT_AUTO
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
__EOF__
|
||||
}
|
||||
@@ -122,7 +122,7 @@ __EOF__
|
||||
sub close_file {
|
||||
my $name = shift;
|
||||
print FILE <<__EOF__;
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* SDL_HAVE_BLIT_AUTO */
|
||||
|
||||
@@ -220,82 +220,16 @@ sub output_copycore
|
||||
my $A_is_const_FF = shift;
|
||||
my $s = "";
|
||||
my $d = "";
|
||||
my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
|
||||
my $src_has_alpha = ($src =~ /A/) ? 1 : 0;
|
||||
my $sa = "";
|
||||
my $da = "";
|
||||
|
||||
if (!$modulate && !$blend) {
|
||||
# Nice and easy...
|
||||
if ( $src eq $dst ) {
|
||||
print FILE <<__EOF__;
|
||||
# Nice and easy...
|
||||
if ( $src eq $dst && !$modulate && !$blend ) {
|
||||
print FILE <<__EOF__;
|
||||
*dst = *src;
|
||||
__EOF__
|
||||
return;
|
||||
}
|
||||
|
||||
# Matching color-order
|
||||
$sa = $src;
|
||||
$sa =~ s/[A8]//g;
|
||||
$da = $dst;
|
||||
$da =~ s/[A8]//g;
|
||||
if ($sa eq $da) {
|
||||
if ($dst_has_alpha && $src_has_alpha) {
|
||||
$da = substr $dst, 0, 1;
|
||||
if ($da eq "A") {
|
||||
# RGBA -> ARGB
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel = (pixel >> 8) | (pixel << 24);
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
} else {
|
||||
# ARGB -> RGBA -- unused
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel = (pixel << 8) | A;
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
}
|
||||
} elsif ($dst_has_alpha) {
|
||||
$da = substr $dst, 0, 1;
|
||||
if ($da eq "A") {
|
||||
# RGB -> ARGB
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel |= (A << 24);
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
} else {
|
||||
# RGB -> RGBA -- unused
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel = (pixel << 8) | A;
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
}
|
||||
} else {
|
||||
$sa = substr $src, 0, 1;
|
||||
if ($sa eq "A") {
|
||||
# ARGB -> RGB
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel &= 0xFFFFFF;
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
} else {
|
||||
# RGBA -> RGB
|
||||
print FILE <<__EOF__;
|
||||
pixel = *src;
|
||||
pixel >>= 8;
|
||||
*dst = pixel;
|
||||
__EOF__
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
|
||||
my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
|
||||
|
||||
if ( $blend ) {
|
||||
@@ -432,14 +366,6 @@ sub output_copyfunc
|
||||
my $is_modulateA_done = 0;
|
||||
my $A_is_const_FF = 0;
|
||||
|
||||
my $sa = $src;
|
||||
my $da = $dst;
|
||||
my $matching_colors = 0;
|
||||
|
||||
$sa =~ s/[A8]//g;
|
||||
$da =~ s/[A8]//g;
|
||||
$matching_colors = (!$modulate && !$blend && ($sa eq $da)) ? 1 : 0;
|
||||
|
||||
output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
|
||||
print FILE <<__EOF__;
|
||||
{
|
||||
@@ -498,8 +424,8 @@ __EOF__
|
||||
print FILE <<__EOF__;
|
||||
Uint32 pixel;
|
||||
__EOF__
|
||||
if ( !$ignore_dst_alpha && !$src_has_alpha ) {
|
||||
if ( $modulate ) {
|
||||
if (!$ignore_dst_alpha && !$src_has_alpha) {
|
||||
if ($modulate){
|
||||
$is_modulateA_done = 1;
|
||||
print FILE <<__EOF__;
|
||||
const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
|
||||
@@ -510,18 +436,14 @@ __EOF__
|
||||
const Uint32 A = 0xFF;
|
||||
__EOF__
|
||||
}
|
||||
if ( !$matching_colors ) {
|
||||
print FILE <<__EOF__;
|
||||
print FILE <<__EOF__;
|
||||
Uint32 R, G, B;
|
||||
__EOF__
|
||||
}
|
||||
} elsif ( !$ignore_dst_alpha ) {
|
||||
if ( !$matching_colors ) {
|
||||
print FILE <<__EOF__;
|
||||
} elsif (!$ignore_dst_alpha) {
|
||||
print FILE <<__EOF__;
|
||||
Uint32 R, G, B, A;
|
||||
__EOF__
|
||||
}
|
||||
} elsif ( !$matching_colors ) {
|
||||
} else {
|
||||
print FILE <<__EOF__;
|
||||
Uint32 R, G, B;
|
||||
__EOF__
|
||||
|
||||
@@ -87,7 +87,7 @@ static id keyboard_disconnect_observer = nil;
|
||||
static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
{
|
||||
keyboard_connected = SDL_TRUE;
|
||||
keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed)
|
||||
keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *keyboard, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed)
|
||||
{
|
||||
SDL_SendKeyboardKey(pressed ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)keyCode);
|
||||
};
|
||||
@@ -225,15 +225,15 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14
|
||||
};
|
||||
|
||||
int auxiliary_button = SDL_BUTTON_X1;
|
||||
for (GCControllerButtonInput *btn in mouse.mouseInput.auxiliaryButtons) {
|
||||
btn.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
for (GCControllerButtonInput *button in mouse.mouseInput.auxiliaryButtons) {
|
||||
button.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed)
|
||||
{
|
||||
OnGCMouseButtonChanged(mouseID, auxiliary_button, pressed);
|
||||
};
|
||||
++auxiliary_button;
|
||||
}
|
||||
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouseInput, float deltaX, float deltaY)
|
||||
mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouse, float deltaX, float deltaY)
|
||||
{
|
||||
if (SDL_GCMouseRelativeMode()) {
|
||||
SDL_SendMouseMotion(SDL_GetMouseFocus(), mouseID, 1, (int)deltaX, -(int)deltaY);
|
||||
|
||||
@@ -86,7 +86,7 @@ UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, in
|
||||
|
||||
action = [UIAlertAction actionWithTitle:@(sdlButton->text)
|
||||
style:style
|
||||
handler:^(UIAlertAction *alertAction) {
|
||||
handler:^(UIAlertAction *action) {
|
||||
clickedindex = (int)(sdlButton - messageboxdata->buttons);
|
||||
}];
|
||||
[alert addAction:action];
|
||||
@@ -186,8 +186,8 @@ UIKit_ShowMessageBoxAlertView(const SDL_MessageBoxData *messageboxdata, int *but
|
||||
#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED < 80000 */
|
||||
}
|
||||
|
||||
static void
|
||||
UIKit_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid, int *returnValue)
|
||||
int
|
||||
UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
BOOL success = NO;
|
||||
|
||||
@@ -199,26 +199,12 @@ UIKit_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
*returnValue = SDL_SetError("Could not show message box.");
|
||||
} else {
|
||||
*returnValue = 0;
|
||||
return SDL_SetError("Could not show message box.");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
__block int returnValue = 0;
|
||||
|
||||
if ([NSThread isMainThread]) {
|
||||
UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue);
|
||||
} else {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{ UIKit_ShowMessageBoxImpl(messageboxdata, buttonid, &returnValue); });
|
||||
}
|
||||
return returnValue;
|
||||
}}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_UIKIT */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -162,8 +162,8 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
if (_this->gl_config.share_with_current_context) {
|
||||
EAGLContext *currContext = (__bridge EAGLContext *) SDL_GL_GetCurrentContext();
|
||||
sharegroup = currContext.sharegroup;
|
||||
EAGLContext *context = (__bridge EAGLContext *) SDL_GL_GetCurrentContext();
|
||||
sharegroup = context.sharegroup;
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
|
||||
|
||||
/* Clamp the samples to the max supported count. */
|
||||
samples = SDL_min(samples, maxsamples);
|
||||
samples = MIN(samples, maxsamples);
|
||||
}
|
||||
|
||||
if (sRGB) {
|
||||
|
||||
11
externals/SDL/src/video/uikit/SDL_uikitvideo.m
vendored
11
externals/SDL/src/video/uikit/SDL_uikitvideo.m
vendored
@@ -278,16 +278,11 @@ UIKit_ForceUpdateHomeIndicator()
|
||||
*/
|
||||
|
||||
#if !defined(SDL_VIDEO_DRIVER_COCOA)
|
||||
void SDL_NSLog(const char *prefix, const char *text)
|
||||
void SDL_NSLog(const char *text)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSString *nsText = [NSString stringWithUTF8String:text];
|
||||
if (prefix) {
|
||||
NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
|
||||
NSLog(@"%@: %@", nsPrefix, nsText);
|
||||
} else {
|
||||
NSLog(@"%@", nsText);
|
||||
}
|
||||
NSString *str = [NSString stringWithUTF8String:text];
|
||||
NSLog(@"%@", str);
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_COCOA */
|
||||
|
||||
@@ -403,8 +403,8 @@ UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
|
||||
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
#define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8
|
||||
|
||||
void *vita_gpu_alloc(unsigned int type, unsigned int size, SceUID *uid)
|
||||
void *vita_gpu_alloc(SceKernelMemBlockType type, unsigned int size, SceUID *uid)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
|
||||
2
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
2
externals/SDL/src/video/vita/SDL_vitagl.c
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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/vita/SDL_vitagl_c.h
vendored
2
externals/SDL/src/video/vita/SDL_vitagl_c.h
vendored
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 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
externals/SDL/src/video/vita/SDL_vitagl_pvr.c
vendored
69
externals/SDL/src/video/vita/SDL_vitagl_pvr.c
vendored
@@ -20,12 +20,11 @@
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR && SDL_VIDEO_VITA_PVR_OGL
|
||||
#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <psp2/kernel/modulemgr.h>
|
||||
#include <gpu_es4/psp2_pvr_hint.h>
|
||||
#include <gl4esinit.h>
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_log.h"
|
||||
@@ -35,16 +34,6 @@
|
||||
|
||||
#define MAX_PATH 256 // vita limits are somehow wrong
|
||||
|
||||
/* Defaults */
|
||||
int FB_WIDTH = 960;
|
||||
int FB_HEIGHT = 544;
|
||||
|
||||
void getFBSize(int *width, int *height)
|
||||
{
|
||||
*width = FB_WIDTH;
|
||||
*height = FB_HEIGHT;
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
{
|
||||
@@ -64,9 +53,6 @@ VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL);
|
||||
sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL);
|
||||
|
||||
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx");
|
||||
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
|
||||
|
||||
SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx");
|
||||
sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL);
|
||||
|
||||
@@ -88,45 +74,30 @@ VITA_GL_LoadLibrary(_THIS, const char *path)
|
||||
SDL_GLContext
|
||||
VITA_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
char gl_version[3];
|
||||
SDL_GLContext context = NULL;
|
||||
int temp_major = _this->gl_config.major_version;
|
||||
int temp_minor = _this->gl_config.minor_version;
|
||||
int temp_profile = _this->gl_config.profile_mask;
|
||||
|
||||
/* Set version to 2.0 and PROFILE to ES */
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 0;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
|
||||
context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
|
||||
if (context != NULL)
|
||||
{
|
||||
FB_WIDTH = window->w;
|
||||
FB_HEIGHT = window->h;
|
||||
set_getprocaddress((void *(*)(const char *))eglGetProcAddress);
|
||||
set_getmainfbsize(getFBSize);
|
||||
SDL_snprintf(gl_version, 3, "%d%d", temp_major, temp_minor);
|
||||
gl4es_setenv("LIBGL_NOTEXRECT", "1", 1); /* Currently broken in driver */
|
||||
gl4es_setenv("LIBGL_GL", gl_version, 1);
|
||||
initialize_gl4es();
|
||||
}
|
||||
|
||||
/* Restore gl_config */
|
||||
_this->gl_config.major_version = temp_major;
|
||||
_this->gl_config.minor_version = temp_minor;
|
||||
_this->gl_config.profile_mask = temp_profile;
|
||||
|
||||
return context;
|
||||
return SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
}
|
||||
|
||||
void *
|
||||
VITA_GL_GetProcAddress(_THIS, const char *proc)
|
||||
int
|
||||
VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
return gl4es_GetProcAddress(proc);
|
||||
if (window && context) {
|
||||
return SDL_EGL_MakeCurrent(_this, ((SDL_WindowData *) window->driverdata)->egl_surface, context);
|
||||
} else {
|
||||
return SDL_EGL_MakeCurrent(_this, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VITA_GL_SwapWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
if (videodata->ime_active) {
|
||||
sceImeUpdate();
|
||||
}
|
||||
return SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface);
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -19,16 +19,17 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_vitagl_pvr_c_h_
|
||||
#define SDL_vitagl_pvr_c_h_
|
||||
#ifndef SDL_vitagl_c_h_
|
||||
#define SDL_vitagl_c_h_
|
||||
|
||||
#include "SDL_vitavideo.h"
|
||||
|
||||
extern int VITA_GL_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context);
|
||||
extern int VITA_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
extern int VITA_GL_LoadLibrary(_THIS, const char *path);
|
||||
extern void *VITA_GL_GetProcAddress(_THIS, const char *proc);
|
||||
|
||||
|
||||
#endif /* SDL_vitagl_pvr_c_h_ */
|
||||
#endif /* SDL_vitagl_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
29
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
29
externals/SDL/src/video/vita/SDL_vitatouch.c
vendored
@@ -108,30 +108,17 @@ VITA_PollTouch(void)
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range;
|
||||
int finger_down = 0;
|
||||
|
||||
if (touch_old[port].reportNum > 0) {
|
||||
for (int j = 0; j < touch_old[port].reportNum; j++) {
|
||||
if (touch[port].report[i].id == touch_old[port].report[j].id ) {
|
||||
finger_down = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
|
||||
finger_id = (SDL_FingerID) touch[port].report[i].id;
|
||||
|
||||
// Skip if finger was already previously down
|
||||
if(!finger_down) {
|
||||
// Send an initial touch
|
||||
SDL_SendTouch((SDL_TouchID)port,
|
||||
finger_id,
|
||||
Vita_Window,
|
||||
SDL_TRUE,
|
||||
x,
|
||||
y,
|
||||
force);
|
||||
}
|
||||
// Send an initial touch
|
||||
SDL_SendTouch((SDL_TouchID)port,
|
||||
finger_id,
|
||||
Vita_Window,
|
||||
SDL_TRUE,
|
||||
x,
|
||||
y,
|
||||
force);
|
||||
|
||||
// Always send the motion
|
||||
SDL_SendTouchMotion((SDL_TouchID)port,
|
||||
|
||||
68
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
68
externals/SDL/src/video/vita/SDL_vitavideo.c
vendored
@@ -41,17 +41,15 @@
|
||||
#include "SDL_vitaframebuffer.h"
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PIB)
|
||||
#include "SDL_vitagles_c.h"
|
||||
#include "SDL_vitagl_c.h"
|
||||
#elif defined(SDL_VIDEO_VITA_PVR)
|
||||
#include "SDL_vitagles_pvr_c.h"
|
||||
#if defined(SDL_VIDEO_VITA_PVR_OGL)
|
||||
#include "SDL_vitagl_pvr_c.h"
|
||||
#endif
|
||||
#define VITA_GLES_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define VITA_GLES_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define VITA_GLES_SetSwapInterval SDL_EGL_SetSwapInterval
|
||||
#define VITA_GLES_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
#define VITA_GLES_DeleteContext SDL_EGL_DeleteContext
|
||||
#include "../SDL_egl_c.h"
|
||||
#define VITA_GL_GetProcAddress SDL_EGL_GetProcAddress
|
||||
#define VITA_GL_UnloadLibrary SDL_EGL_UnloadLibrary
|
||||
#define VITA_GL_SetSwapInterval SDL_EGL_SetSwapInterval
|
||||
#define VITA_GL_GetSwapInterval SDL_EGL_GetSwapInterval
|
||||
#define VITA_GL_DeleteContext SDL_EGL_DeleteContext
|
||||
#endif
|
||||
|
||||
SDL_Window *Vita_Window;
|
||||
@@ -142,26 +140,15 @@ VITA_Create()
|
||||
*/
|
||||
|
||||
#if defined(SDL_VIDEO_VITA_PIB) || defined(SDL_VIDEO_VITA_PVR)
|
||||
#if defined(SDL_VIDEO_VITA_PVR_OGL)
|
||||
if(SDL_getenv("VITA_PVR_OGL") != NULL) {
|
||||
device->GL_LoadLibrary = VITA_GL_LoadLibrary;
|
||||
device->GL_CreateContext = VITA_GL_CreateContext;
|
||||
device->GL_GetProcAddress = VITA_GL_GetProcAddress;
|
||||
} else {
|
||||
#endif
|
||||
device->GL_LoadLibrary = VITA_GLES_LoadLibrary;
|
||||
device->GL_CreateContext = VITA_GLES_CreateContext;
|
||||
device->GL_GetProcAddress = VITA_GLES_GetProcAddress;
|
||||
#if defined(SDL_VIDEO_VITA_PVR_OGL)
|
||||
}
|
||||
#endif
|
||||
|
||||
device->GL_UnloadLibrary = VITA_GLES_UnloadLibrary;
|
||||
device->GL_MakeCurrent = VITA_GLES_MakeCurrent;
|
||||
device->GL_SetSwapInterval = VITA_GLES_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = VITA_GLES_GetSwapInterval;
|
||||
device->GL_SwapWindow = VITA_GLES_SwapWindow;
|
||||
device->GL_DeleteContext = VITA_GLES_DeleteContext;
|
||||
device->GL_UnloadLibrary = VITA_GL_UnloadLibrary;
|
||||
device->GL_CreateContext = VITA_GL_CreateContext;
|
||||
device->GL_MakeCurrent = VITA_GL_MakeCurrent;
|
||||
device->GL_SetSwapInterval = VITA_GL_SetSwapInterval;
|
||||
device->GL_GetSwapInterval = VITA_GL_GetSwapInterval;
|
||||
device->GL_SwapWindow = VITA_GL_SwapWindow;
|
||||
device->GL_DeleteContext = VITA_GL_DeleteContext;
|
||||
#endif
|
||||
|
||||
device->HasScreenKeyboardSupport = VITA_HasScreenKeyboardSupport;
|
||||
@@ -258,9 +245,6 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
SDL_WindowData *wdata;
|
||||
#if defined(SDL_VIDEO_VITA_PVR)
|
||||
Psp2NativeWindow win;
|
||||
int temp_major = 2;
|
||||
int temp_minor = 1;
|
||||
int temp_profile = 0;
|
||||
#endif
|
||||
|
||||
/* Allocate window internal data */
|
||||
@@ -275,7 +259,8 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
// Vita can only have one window
|
||||
if (Vita_Window != NULL)
|
||||
{
|
||||
return SDL_SetError("Only one window supported");
|
||||
SDL_SetError("Only one window supported");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Vita_Window = window;
|
||||
@@ -298,26 +283,11 @@ VITA_CreateWindow(_THIS, SDL_Window * window)
|
||||
win.windowSize = PSP2_WINDOW_960X544;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_OPENGL) != 0) {
|
||||
if(SDL_getenv("VITA_PVR_OGL") != NULL) {
|
||||
/* Set version to 2.1 and PROFILE to ES */
|
||||
temp_major = _this->gl_config.major_version;
|
||||
temp_minor = _this->gl_config.minor_version;
|
||||
temp_profile = _this->gl_config.profile_mask;
|
||||
|
||||
_this->gl_config.major_version = 2;
|
||||
_this->gl_config.minor_version = 1;
|
||||
_this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
|
||||
}
|
||||
wdata->egl_surface = SDL_EGL_CreateSurface(_this, &win);
|
||||
|
||||
if (wdata->egl_surface == EGL_NO_SURFACE) {
|
||||
return SDL_SetError("Could not create GLES window surface");
|
||||
}
|
||||
if(SDL_getenv("VITA_PVR_OGL") != NULL) {
|
||||
/* Revert */
|
||||
_this->gl_config.major_version = temp_major;
|
||||
_this->gl_config.minor_version = temp_minor;
|
||||
_this->gl_config.profile_mask = temp_profile;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -404,8 +374,8 @@ VITA_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
if (info->version.major <= SDL_MAJOR_VERSION) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("application not compiled with SDL %d\n",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("application not compiled with SDL %d.%d\n",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
21
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
21
externals/SDL/src/video/vita/SDL_vitavideo.h
vendored
@@ -90,23 +90,16 @@ SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo *info);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_VITA
|
||||
#if defined(SDL_VIDEO_VITA_PVR_OGL)
|
||||
/* OpenGL functions */
|
||||
int VITA_GL_LoadLibrary(_THIS, const char *path);
|
||||
SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
void *VITA_GL_GetProcAddress(_THIS, const char *proc);
|
||||
#endif
|
||||
|
||||
/* OpenGLES functions */
|
||||
int VITA_GLES_LoadLibrary(_THIS, const char *path);
|
||||
void *VITA_GLES_GetProcAddress(_THIS, const char *proc);
|
||||
void VITA_GLES_UnloadLibrary(_THIS);
|
||||
SDL_GLContext VITA_GLES_CreateContext(_THIS, SDL_Window * window);
|
||||
int VITA_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int VITA_GLES_SetSwapInterval(_THIS, int interval);
|
||||
int VITA_GLES_GetSwapInterval(_THIS);
|
||||
int VITA_GLES_SwapWindow(_THIS, SDL_Window * window);
|
||||
void VITA_GLES_DeleteContext(_THIS, SDL_GLContext context);
|
||||
void VITA_GL_UnloadLibrary(_THIS);
|
||||
SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window);
|
||||
int VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int VITA_GL_SetSwapInterval(_THIS, int interval);
|
||||
int VITA_GL_GetSwapInterval(_THIS);
|
||||
int VITA_GL_SwapWindow(_THIS, SDL_Window * window);
|
||||
void VITA_GL_DeleteContext(_THIS, SDL_GLContext context);
|
||||
#endif
|
||||
|
||||
/* VITA on screen keyboard */
|
||||
|
||||
@@ -382,14 +382,15 @@ VIVANTE_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(0);
|
||||
|
||||
if (info->version.major == SDL_MAJOR_VERSION) {
|
||||
if (info->version.major == SDL_MAJOR_VERSION &&
|
||||
info->version.minor == SDL_MINOR_VERSION) {
|
||||
info->subsystem = SDL_SYSWM_VIVANTE;
|
||||
info->info.vivante.display = displaydata->native_display;
|
||||
info->info.vivante.window = data->native_window;
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
SDL_SetError("Application not compiled with SDL %d",
|
||||
SDL_MAJOR_VERSION);
|
||||
SDL_SetError("Application not compiled with SDL %d.%d",
|
||||
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
12
externals/SDL/src/video/wayland/SDL_waylanddyn.h
vendored
12
externals/SDL/src/video/wayland/SDL_waylanddyn.h
vendored
@@ -52,14 +52,6 @@ enum libdecor_window_state;
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
#include "xkbcommon/xkbcommon-compose.h"
|
||||
|
||||
/* Must be included before our #defines, see Bugzilla #4957 */
|
||||
#include "wayland-client-core.h"
|
||||
|
||||
#define SDL_WAYLAND_CHECK_VERSION(x, y, z) \
|
||||
(WAYLAND_VERSION_MAJOR > x || \
|
||||
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \
|
||||
(WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && WAYLAND_VERSION_MICRO >= z))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
@@ -79,6 +71,9 @@ void SDL_WAYLAND_UnloadSymbols(void);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Must be included before our #defines, see Bugzilla #4957 */
|
||||
#include "wayland-client-core.h"
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
|
||||
|
||||
#if defined(_WAYLAND_CLIENT_H) || defined(WAYLAND_CLIENT_H)
|
||||
@@ -153,7 +148,6 @@ void SDL_WAYLAND_UnloadSymbols(void);
|
||||
#define libdecor_state_free (*WAYLAND_libdecor_state_free)
|
||||
#define libdecor_configuration_get_content_size (*WAYLAND_libdecor_configuration_get_content_size)
|
||||
#define libdecor_configuration_get_window_state (*WAYLAND_libdecor_configuration_get_window_state)
|
||||
#define libdecor_dispatch (*WAYLAND_libdecor_dispatch)
|
||||
#endif
|
||||
|
||||
#else /* SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC */
|
||||
|
||||
665
externals/SDL/src/video/wayland/SDL_waylandevents.c
vendored
665
externals/SDL/src/video/wayland/SDL_waylandevents.c
vendored
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#include "../../core/unix/SDL_poll.h"
|
||||
#include "../../events/SDL_sysevents.h"
|
||||
@@ -41,7 +40,6 @@
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
|
||||
#include "text-input-unstable-v3-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
#include <libdecor.h>
|
||||
@@ -85,7 +83,6 @@ static const struct {
|
||||
{ XKB_KEY_Super_R, SDLK_RGUI },
|
||||
{ XKB_KEY_Hyper_L, SDLK_LGUI },
|
||||
{ XKB_KEY_Hyper_R, SDLK_RGUI },
|
||||
{ XKB_KEY_BackSpace, SDLK_BACKSPACE },
|
||||
};
|
||||
|
||||
struct SDL_WaylandTouchPoint {
|
||||
@@ -295,12 +292,6 @@ Wayland_WaitEventTimeout(_THIS, int timeout)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (d->shell.libdecor) {
|
||||
libdecor_dispatch(d->shell.libdecor, timeout);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* wl_display_prepare_read() will return -1 if the default queue is not empty.
|
||||
* If the default queue is empty, it will prepare us for our SDL_IOReady() call. */
|
||||
if (WAYLAND_wl_display_prepare_read(d->display) == 0) {
|
||||
@@ -396,10 +387,8 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
|
||||
input->sx_w = sx_w;
|
||||
input->sy_w = sy_w;
|
||||
if (input->pointer_focus) {
|
||||
const float sx_f = (float)wl_fixed_to_double(sx_w);
|
||||
const float sy_f = (float)wl_fixed_to_double(sy_w);
|
||||
const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x);
|
||||
const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y);
|
||||
const int sx = wl_fixed_to_int(sx_w);
|
||||
const int sy = wl_fixed_to_int(sy_w);
|
||||
SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy);
|
||||
}
|
||||
}
|
||||
@@ -479,24 +468,20 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
static const uint32_t directions_libdecor[] = {
|
||||
LIBDECOR_RESIZE_EDGE_TOP_LEFT, LIBDECOR_RESIZE_EDGE_TOP,
|
||||
LIBDECOR_RESIZE_EDGE_TOP_RIGHT, LIBDECOR_RESIZE_EDGE_RIGHT,
|
||||
LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT, LIBDECOR_RESIZE_EDGE_BOTTOM,
|
||||
LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT, LIBDECOR_RESIZE_EDGE_LEFT
|
||||
};
|
||||
/* ditto for libdecor. */
|
||||
const uint32_t *directions_libdecor = directions;
|
||||
#endif
|
||||
|
||||
switch (rc) {
|
||||
case SDL_HITTEST_DRAGGABLE:
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
|
||||
if (input->display->shell.libdecor) {
|
||||
if (window_data->shell_surface.libdecor.frame) {
|
||||
libdecor_frame_move(window_data->shell_surface.libdecor.frame, input->seat, serial);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) {
|
||||
if (input->display->shell.xdg) {
|
||||
if (window_data->shell_surface.xdg.roleobj.toplevel) {
|
||||
xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel,
|
||||
input->seat,
|
||||
@@ -514,13 +499,13 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
|
||||
case SDL_HITTEST_RESIZE_BOTTOMLEFT:
|
||||
case SDL_HITTEST_RESIZE_LEFT:
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
|
||||
if (input->display->shell.libdecor) {
|
||||
if (window_data->shell_surface.libdecor.frame) {
|
||||
libdecor_frame_resize(window_data->shell_surface.libdecor.frame, input->seat, serial, directions_libdecor[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (window_data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) {
|
||||
if (input->display->shell.xdg) {
|
||||
if (window_data->shell_surface.xdg.roleobj.toplevel) {
|
||||
xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel,
|
||||
input->seat,
|
||||
@@ -730,8 +715,8 @@ touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial,
|
||||
int id, wl_fixed_t fx, wl_fixed_t fy)
|
||||
{
|
||||
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface);
|
||||
const double dblx = wl_fixed_to_double(fx) * window_data->pointer_scale_x;
|
||||
const double dbly = wl_fixed_to_double(fy) * window_data->pointer_scale_y;
|
||||
const double dblx = wl_fixed_to_double(fx);
|
||||
const double dbly = wl_fixed_to_double(fy);
|
||||
const float x = dblx / window_data->sdlwindow->w;
|
||||
const float y = dbly / window_data->sdlwindow->h;
|
||||
|
||||
@@ -763,8 +748,8 @@ touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp,
|
||||
int id, wl_fixed_t fx, wl_fixed_t fy)
|
||||
{
|
||||
SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(touch_surface(id));
|
||||
const double dblx = wl_fixed_to_double(fx) * window_data->pointer_scale_x;
|
||||
const double dbly = wl_fixed_to_double(fy) * window_data->pointer_scale_y;
|
||||
const double dblx = wl_fixed_to_double(fx);
|
||||
const double dbly = wl_fixed_to_double(fy);
|
||||
const float x = dblx / window_data->sdlwindow->w;
|
||||
const float y = dbly / window_data->sdlwindow->h;
|
||||
|
||||
@@ -830,16 +815,6 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
|
||||
return;
|
||||
}
|
||||
|
||||
#define GET_MOD_INDEX(mod) \
|
||||
WAYLAND_xkb_keymap_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_##mod)
|
||||
input->xkb.idx_shift = 1 << GET_MOD_INDEX(SHIFT);
|
||||
input->xkb.idx_ctrl = 1 << GET_MOD_INDEX(CTRL);
|
||||
input->xkb.idx_alt = 1 << GET_MOD_INDEX(ALT);
|
||||
input->xkb.idx_gui = 1 << GET_MOD_INDEX(LOGO);
|
||||
input->xkb.idx_num = 1 << GET_MOD_INDEX(NUM);
|
||||
input->xkb.idx_caps = 1 << GET_MOD_INDEX(CAPS);
|
||||
#undef GET_MOD_INDEX
|
||||
|
||||
input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap);
|
||||
if (!input->xkb.state) {
|
||||
fprintf(stderr, "failed to create XKB state\n");
|
||||
@@ -854,14 +829,10 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
|
||||
*/
|
||||
|
||||
/* Look up the preferred locale, falling back to "C" as default */
|
||||
if (!(locale = SDL_getenv("LC_ALL"))) {
|
||||
if (!(locale = SDL_getenv("LC_CTYPE"))) {
|
||||
if (!(locale = SDL_getenv("LANG"))) {
|
||||
if (!(locale = SDL_getenv("LC_ALL")))
|
||||
if (!(locale = SDL_getenv("LC_CTYPE")))
|
||||
if (!(locale = SDL_getenv("LANG")))
|
||||
locale = "C";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up XKB compose table */
|
||||
input->xkb.compose_table = WAYLAND_xkb_compose_table_new_from_locale(input->display->xkb_context,
|
||||
locale, XKB_COMPOSE_COMPILE_NO_FLAGS);
|
||||
@@ -932,7 +903,7 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, SDL_bool *handled_by_ime)
|
||||
keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, SDL_bool *handled_by_ime)
|
||||
{
|
||||
SDL_WindowData *window = input->keyboard_focus;
|
||||
const xkb_keysym_t *syms;
|
||||
@@ -949,16 +920,12 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint
|
||||
sym = syms[0];
|
||||
|
||||
#ifdef SDL_USE_IME
|
||||
if (SDL_IME_ProcessKeyEvent(sym, key + 8, state)) {
|
||||
if (SDL_IME_ProcessKeyEvent(sym, key + 8)) {
|
||||
*handled_by_ime = SDL_TRUE;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (state == SDL_RELEASED) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (input->xkb.compose_state && WAYLAND_xkb_compose_state_feed(input->xkb.compose_state, sym) == XKB_COMPOSE_FEED_ACCEPTED) {
|
||||
switch(WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) {
|
||||
case XKB_COMPOSE_COMPOSING:
|
||||
@@ -992,7 +959,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
SDL_bool handled_by_ime = SDL_FALSE;
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
has_text = keyboard_input_get_text(text, input, key, SDL_PRESSED, &handled_by_ime);
|
||||
has_text = keyboard_input_get_text(text, input, key, &handled_by_ime);
|
||||
} else {
|
||||
if (keyboard_repeat_is_set(&input->keyboard_repeat)) {
|
||||
// Send any due key repeat events before stopping the repeat and generating the key up event
|
||||
@@ -1002,7 +969,6 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
keyboard_repeat_handle(&input->keyboard_repeat, time - input->keyboard_repeat.wl_press_time);
|
||||
keyboard_repeat_clear(&input->keyboard_repeat);
|
||||
}
|
||||
keyboard_input_get_text(text, input, key, SDL_RELEASED, &handled_by_ime);
|
||||
}
|
||||
|
||||
if (!handled_by_ime && key < SDL_arraysize(xfree86_scancode_table2)) {
|
||||
@@ -1021,9 +987,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
SDL_SendKeyboardText(text);
|
||||
}
|
||||
}
|
||||
if (input->xkb.keymap && WAYLAND_xkb_keymap_key_repeats(input->xkb.keymap, key + 8)) {
|
||||
keyboard_repeat_set(&input->keyboard_repeat, time, scancode, has_text, text);
|
||||
}
|
||||
keyboard_repeat_set(&input->keyboard_repeat, time, scancode, has_text, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,24 +1052,10 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
|
||||
{
|
||||
struct SDL_WaylandInput *input = data;
|
||||
Wayland_Keymap keymap;
|
||||
uint32_t modstate = (mods_depressed | mods_latched | mods_locked);
|
||||
|
||||
WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
|
||||
mods_locked, 0, 0, group);
|
||||
|
||||
SDL_ToggleModState(KMOD_SHIFT, modstate & input->xkb.idx_shift);
|
||||
SDL_ToggleModState(KMOD_CTRL, modstate & input->xkb.idx_ctrl);
|
||||
SDL_ToggleModState(KMOD_ALT, modstate & input->xkb.idx_alt);
|
||||
SDL_ToggleModState(KMOD_GUI, modstate & input->xkb.idx_gui);
|
||||
SDL_ToggleModState(KMOD_NUM, modstate & input->xkb.idx_num);
|
||||
SDL_ToggleModState(KMOD_CAPS, modstate & input->xkb.idx_caps);
|
||||
|
||||
if (group == input->xkb.current_group) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* The layout changed, remap and fire an event */
|
||||
input->xkb.current_group = group;
|
||||
keymap.layout = group;
|
||||
SDL_GetDefaultKeymap(keymap.keymap);
|
||||
WAYLAND_xkb_keymap_key_for_each(input->xkb.keymap,
|
||||
@@ -1362,145 +1312,36 @@ data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
|
||||
{
|
||||
}
|
||||
|
||||
/* Decodes URI escape sequences in string buf of len bytes
|
||||
(excluding the terminating NULL byte) in-place. Since
|
||||
URI-encoded characters take three times the space of
|
||||
normal characters, this should not be an issue.
|
||||
|
||||
Returns the number of decoded bytes that wound up in
|
||||
the buffer, excluding the terminating NULL byte.
|
||||
|
||||
The buffer is guaranteed to be NULL-terminated but
|
||||
may contain embedded NULL bytes.
|
||||
|
||||
On error, -1 is returned.
|
||||
|
||||
FIXME: This was shamelessly copied from SDL_x11events.c
|
||||
*/
|
||||
static int Wayland_URIDecode(char *buf, int len) {
|
||||
int ri, wi, di;
|
||||
char decode = '\0';
|
||||
if (buf == NULL || len < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (len == 0) {
|
||||
len = SDL_strlen(buf);
|
||||
}
|
||||
for (ri = 0, wi = 0, di = 0; ri < len && wi < len; ri += 1) {
|
||||
if (di == 0) {
|
||||
/* start decoding */
|
||||
if (buf[ri] == '%') {
|
||||
decode = '\0';
|
||||
di += 1;
|
||||
continue;
|
||||
}
|
||||
/* normal write */
|
||||
buf[wi] = buf[ri];
|
||||
wi += 1;
|
||||
continue;
|
||||
} else if (di == 1 || di == 2) {
|
||||
char off = '\0';
|
||||
char isa = buf[ri] >= 'a' && buf[ri] <= 'f';
|
||||
char isA = buf[ri] >= 'A' && buf[ri] <= 'F';
|
||||
char isn = buf[ri] >= '0' && buf[ri] <= '9';
|
||||
if (!(isa || isA || isn)) {
|
||||
/* not a hexadecimal */
|
||||
int sri;
|
||||
for (sri = ri - di; sri <= ri; sri += 1) {
|
||||
buf[wi] = buf[sri];
|
||||
wi += 1;
|
||||
}
|
||||
di = 0;
|
||||
continue;
|
||||
}
|
||||
/* itsy bitsy magicsy */
|
||||
if (isn) {
|
||||
off = 0 - '0';
|
||||
} else if (isa) {
|
||||
off = 10 - 'a';
|
||||
} else if (isA) {
|
||||
off = 10 - 'A';
|
||||
}
|
||||
decode |= (buf[ri] + off) << (2 - di) * 4;
|
||||
if (di == 2) {
|
||||
buf[wi] = decode;
|
||||
wi += 1;
|
||||
di = 0;
|
||||
} else {
|
||||
di += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
buf[wi] = '\0';
|
||||
return wi;
|
||||
}
|
||||
|
||||
/* Convert URI to local filename
|
||||
return filename if possible, else NULL
|
||||
|
||||
FIXME: This was shamelessly copied from SDL_x11events.c
|
||||
*/
|
||||
static char* Wayland_URIToLocal(char* uri) {
|
||||
char *file = NULL;
|
||||
SDL_bool local;
|
||||
|
||||
if (SDL_memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */
|
||||
else if (SDL_strstr(uri,":/") != NULL) return file; /* wrong scheme */
|
||||
|
||||
local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/');
|
||||
|
||||
/* got a hostname? */
|
||||
if (!local && uri[0] == '/' && uri[2] != '/') {
|
||||
char* hostname_end = SDL_strchr(uri+1, '/');
|
||||
if (hostname_end != NULL) {
|
||||
char hostname[ 257 ];
|
||||
if (gethostname(hostname, 255) == 0) {
|
||||
hostname[ 256 ] = '\0';
|
||||
if (SDL_memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) {
|
||||
uri = hostname_end + 1;
|
||||
local = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (local) {
|
||||
file = uri;
|
||||
/* Convert URI escape sequences to real characters */
|
||||
Wayland_URIDecode(file, 0);
|
||||
if (uri[1] == '/') {
|
||||
file++;
|
||||
} else {
|
||||
file--;
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
static void
|
||||
data_device_handle_drop(void *data, struct wl_data_device *wl_data_device)
|
||||
{
|
||||
SDL_WaylandDataDevice *data_device = data;
|
||||
void *buffer = NULL;
|
||||
size_t length = 0;
|
||||
|
||||
const char *current_uri = NULL;
|
||||
const char *last_char = NULL;
|
||||
char *current_char = NULL;
|
||||
|
||||
if (data_device->drag_offer != NULL) {
|
||||
/* TODO: SDL Support more mime types */
|
||||
size_t length;
|
||||
void *buffer = Wayland_data_offer_receive(data_device->drag_offer,
|
||||
&length, FILE_MIME, SDL_FALSE);
|
||||
if (buffer) {
|
||||
char *saveptr = NULL;
|
||||
char *token = SDL_strtokr((char *) buffer, "\r\n", &saveptr);
|
||||
while (token != NULL) {
|
||||
char *fn = Wayland_URIToLocal(token);
|
||||
if (fn) {
|
||||
SDL_SendDropFile(NULL, fn); /* FIXME: Window? */
|
||||
buffer = Wayland_data_offer_receive(data_device->drag_offer,
|
||||
&length, FILE_MIME, SDL_FALSE);
|
||||
|
||||
/* uri-list */
|
||||
current_uri = (const char *)buffer;
|
||||
last_char = (const char *)buffer + length;
|
||||
for (current_char = buffer; current_char < last_char; ++current_char) {
|
||||
if (*current_char == '\n' || *current_char == 0) {
|
||||
if (*current_uri != 0 && *current_uri != '#') {
|
||||
*current_char = 0;
|
||||
SDL_SendDropFile(NULL, current_uri);
|
||||
}
|
||||
token = SDL_strtokr(NULL, "\r\n", &saveptr);
|
||||
current_uri = (const char *)current_char + 1;
|
||||
}
|
||||
SDL_SendDropComplete(NULL); /* FIXME: Window? */
|
||||
SDL_free(buffer);
|
||||
}
|
||||
|
||||
SDL_free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1555,37 +1396,20 @@ text_input_preedit_string(void *data,
|
||||
int32_t cursor_begin,
|
||||
int32_t cursor_end)
|
||||
{
|
||||
SDL_WaylandTextInput *text_input = data;
|
||||
char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
text_input->has_preedit = SDL_TRUE;
|
||||
if (text) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, SDL_FALSE)) {
|
||||
size_t cursor_begin_utf8 = cursor_begin >= 0 ? SDL_utf8strnlen(text, cursor_begin) : -1;
|
||||
size_t cursor_end_utf8 = cursor_end >= 0 ? SDL_utf8strnlen(text, cursor_end) : -1;
|
||||
size_t cursor_size_utf8;
|
||||
if (cursor_end_utf8 >= 0) {
|
||||
if (cursor_begin_utf8 >= 0) {
|
||||
cursor_size_utf8 = cursor_end_utf8 - cursor_begin_utf8;
|
||||
} else {
|
||||
cursor_size_utf8 = cursor_end_utf8;
|
||||
}
|
||||
} else {
|
||||
cursor_size_utf8 = -1;
|
||||
}
|
||||
SDL_SendEditingText(text, cursor_begin_utf8, cursor_size_utf8);
|
||||
} else {
|
||||
size_t text_bytes = SDL_strlen(text), i = 0;
|
||||
size_t cursor = 0;
|
||||
do {
|
||||
const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
|
||||
const size_t chars = SDL_utf8strlen(buf);
|
||||
|
||||
SDL_SendEditingText(buf, cursor, chars);
|
||||
|
||||
i += sz;
|
||||
cursor += chars;
|
||||
} while (i < text_bytes);
|
||||
}
|
||||
size_t text_bytes = SDL_strlen(text), i = 0;
|
||||
size_t cursor = 0;
|
||||
|
||||
do {
|
||||
const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf));
|
||||
const size_t chars = SDL_utf8strlen(buf);
|
||||
|
||||
SDL_SendEditingText(buf, cursor, chars);
|
||||
|
||||
i += sz;
|
||||
cursor += chars;
|
||||
} while (i < text_bytes);
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
SDL_SendEditingText(buf, 0, 0);
|
||||
@@ -1624,11 +1448,7 @@ text_input_done(void *data,
|
||||
struct zwp_text_input_v3 *zwp_text_input_v3,
|
||||
uint32_t serial)
|
||||
{
|
||||
SDL_WaylandTextInput *text_input = data;
|
||||
if (!text_input->has_preedit) {
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
text_input->has_preedit = SDL_FALSE;
|
||||
/* No-op */
|
||||
}
|
||||
|
||||
static const struct zwp_text_input_v3_listener text_input_listener = {
|
||||
@@ -1709,363 +1529,6 @@ Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t version)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_type(void* data, struct zwp_tablet_tool_v2* tool, uint32_t type)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_hardware_serial(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial_hi, uint32_t serial_lo)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_hardware_id_wacom(void* data, struct zwp_tablet_tool_v2* tool, uint32_t id_hi, uint32_t id_lo)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_capability(void* data, struct zwp_tablet_tool_v2* tool, uint32_t capability)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_done(void* data, struct zwp_tablet_tool_v2* tool)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_removed(void* data, struct zwp_tablet_tool_v2* tool)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_proximity_in(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial, struct zwp_tablet_v2* tablet, struct wl_surface* surface)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
SDL_WindowData* window;
|
||||
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SDL_WAYLAND_own_surface(surface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
window = (SDL_WindowData*)wl_surface_get_user_data(surface);
|
||||
|
||||
if (window) {
|
||||
input->tool_focus = window;
|
||||
input->tool_prox_serial = serial;
|
||||
|
||||
input->is_down = SDL_FALSE;
|
||||
|
||||
input->btn_stylus = SDL_FALSE;
|
||||
input->btn_stylus2 = SDL_FALSE;
|
||||
input->btn_stylus3 = SDL_FALSE;
|
||||
|
||||
SDL_SetMouseFocus(window->sdlwindow);
|
||||
SDL_SetCursor(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_proximity_out(void* data, struct zwp_tablet_tool_v2* tool)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
|
||||
if (input->tool_focus) {
|
||||
SDL_SetMouseFocus(NULL);
|
||||
input->tool_focus = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
tablet_tool_btn_to_sdl_button(struct SDL_WaylandTabletInput* input)
|
||||
{
|
||||
unsigned int tool_btn = input->btn_stylus3 << 2 | input->btn_stylus2 << 1 | input->btn_stylus << 0;
|
||||
switch (tool_btn) {
|
||||
case 0b000:
|
||||
return SDL_BUTTON_LEFT;
|
||||
case 0b001:
|
||||
return SDL_BUTTON_RIGHT;
|
||||
case 0b010:
|
||||
return SDL_BUTTON_MIDDLE;
|
||||
case 0b100:
|
||||
return SDL_BUTTON_X1;
|
||||
default:
|
||||
return SDL_BUTTON_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_down(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
SDL_WindowData* window = input->tool_focus;
|
||||
input->is_down = SDL_TRUE;
|
||||
if (!window) {
|
||||
/* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd.
|
||||
* that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still
|
||||
* received. To prevent SIGSEGV this returns when this is the case.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SendMouseButton(window->sdlwindow, 0, SDL_PRESSED, tablet_tool_btn_to_sdl_button(input));
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_up(void* data, struct zwp_tablet_tool_v2* tool)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
SDL_WindowData* window = input->tool_focus;
|
||||
|
||||
input->is_down = SDL_FALSE;
|
||||
|
||||
if (!window) {
|
||||
/* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd.
|
||||
* that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still
|
||||
* received. To prevent SIGSEGV this returns when this is the case.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_SendMouseButton(window->sdlwindow, 0, SDL_RELEASED, tablet_tool_btn_to_sdl_button(input));
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_motion(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t sx_w, wl_fixed_t sy_w)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
SDL_WindowData* window = input->tool_focus;
|
||||
|
||||
input->sx_w = sx_w;
|
||||
input->sy_w = sy_w;
|
||||
if (input->tool_focus) {
|
||||
const float sx_f = (float)wl_fixed_to_double(sx_w);
|
||||
const float sy_f = (float)wl_fixed_to_double(sy_w);
|
||||
const int sx = (int)SDL_floorf(sx_f * window->pointer_scale_x);
|
||||
const int sy = (int)SDL_floorf(sy_f * window->pointer_scale_y);
|
||||
SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_pressure(void* data, struct zwp_tablet_tool_v2* tool, uint32_t pressure)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_distance(void* data, struct zwp_tablet_tool_v2* tool, uint32_t distance)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_tilt(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t xtilt, wl_fixed_t ytilt)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_button(void* data, struct zwp_tablet_tool_v2* tool, uint32_t serial, uint32_t button, uint32_t state)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
|
||||
if (input->is_down) {
|
||||
tablet_tool_handle_up(data, tool);
|
||||
input->is_down = SDL_TRUE;
|
||||
}
|
||||
|
||||
switch (button) {
|
||||
/* see %{_includedir}/linux/input-event-codes.h */
|
||||
case 0x14b: /* BTN_STYLUS */
|
||||
input->btn_stylus = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
|
||||
break;
|
||||
case 0x14c: /* BTN_STYLUS2 */
|
||||
input->btn_stylus2 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
|
||||
break;
|
||||
case 0x149: /* BTN_STYLUS3 */
|
||||
input->btn_stylus3 = state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED ? SDL_TRUE : SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (input->is_down) {
|
||||
tablet_tool_handle_down(data, tool, serial);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_rotation(void* data, struct zwp_tablet_tool_v2* tool, wl_fixed_t degrees)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_slider(void* data, struct zwp_tablet_tool_v2* tool, int32_t position)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_wheel(void* data, struct zwp_tablet_tool_v2* tool, int32_t degrees, int32_t clicks)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_tool_handle_frame(void* data, struct zwp_tablet_tool_v2* tool, uint32_t time)
|
||||
{
|
||||
/* unimplemented */
|
||||
}
|
||||
|
||||
|
||||
static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = {
|
||||
tablet_tool_handle_type,
|
||||
tablet_tool_handle_hardware_serial,
|
||||
tablet_tool_handle_hardware_id_wacom,
|
||||
tablet_tool_handle_capability,
|
||||
tablet_tool_handle_done,
|
||||
tablet_tool_handle_removed,
|
||||
tablet_tool_handle_proximity_in,
|
||||
tablet_tool_handle_proximity_out,
|
||||
tablet_tool_handle_down,
|
||||
tablet_tool_handle_up,
|
||||
tablet_tool_handle_motion,
|
||||
tablet_tool_handle_pressure,
|
||||
tablet_tool_handle_distance,
|
||||
tablet_tool_handle_tilt,
|
||||
tablet_tool_handle_rotation,
|
||||
tablet_tool_handle_slider,
|
||||
tablet_tool_handle_wheel,
|
||||
tablet_tool_handle_button,
|
||||
tablet_tool_handle_frame
|
||||
};
|
||||
|
||||
struct SDL_WaylandTabletObjectListNode*
|
||||
tablet_object_list_new_node(void* object)
|
||||
{
|
||||
struct SDL_WaylandTabletObjectListNode* node;
|
||||
|
||||
node = SDL_calloc(1, sizeof *node);
|
||||
if (node == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
node->next = NULL;
|
||||
node->object = object;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode* head, void* object)
|
||||
{
|
||||
if (head->object == NULL) {
|
||||
head->object = object;
|
||||
return;
|
||||
}
|
||||
|
||||
while (head->next) {
|
||||
head = head->next;
|
||||
}
|
||||
|
||||
head->next = tablet_object_list_new_node(object);
|
||||
}
|
||||
|
||||
void tablet_object_list_destroy(struct SDL_WaylandTabletObjectListNode* head, void (*deleter)(void* object))
|
||||
{
|
||||
while (head) {
|
||||
struct SDL_WaylandTabletObjectListNode* next = head->next;
|
||||
if (head->object) {
|
||||
(*deleter)(head->object);
|
||||
}
|
||||
SDL_free(head);
|
||||
head = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tablet_seat_handle_tablet_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_v2* tablet)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
|
||||
tablet_object_list_append(input->tablets, tablet);
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_seat_handle_tool_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_tool_v2* tool)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
|
||||
zwp_tablet_tool_v2_add_listener(tool, &tablet_tool_listener, data);
|
||||
zwp_tablet_tool_v2_set_user_data(tool, data);
|
||||
|
||||
tablet_object_list_append(input->tools, tool);
|
||||
}
|
||||
|
||||
static void
|
||||
tablet_seat_handle_pad_added(void* data, struct zwp_tablet_seat_v2* seat, struct zwp_tablet_pad_v2* pad)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* input = data;
|
||||
|
||||
tablet_object_list_append(input->pads, pad);
|
||||
}
|
||||
|
||||
static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
|
||||
tablet_seat_handle_tablet_added,
|
||||
tablet_seat_handle_tool_added,
|
||||
tablet_seat_handle_pad_added
|
||||
};
|
||||
|
||||
void
|
||||
Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager* tablet_manager)
|
||||
{
|
||||
struct SDL_WaylandTabletInput* tablet_input;
|
||||
|
||||
if (!tablet_manager || !input || !input->seat) {
|
||||
return;
|
||||
}
|
||||
|
||||
tablet_input = SDL_calloc(1, sizeof *tablet_input);
|
||||
if (tablet_input == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
input->tablet = tablet_input;
|
||||
|
||||
tablet_input->seat = (struct SDL_WaylandTabletSeat*)zwp_tablet_manager_v2_get_tablet_seat((struct zwp_tablet_manager_v2*)tablet_manager, input->seat);
|
||||
|
||||
tablet_input->tablets = tablet_object_list_new_node(NULL);
|
||||
tablet_input->tools = tablet_object_list_new_node(NULL);
|
||||
tablet_input->pads = tablet_object_list_new_node(NULL);
|
||||
|
||||
zwp_tablet_seat_v2_add_listener((struct zwp_tablet_seat_v2*)tablet_input->seat, &tablet_seat_listener, tablet_input);
|
||||
}
|
||||
|
||||
#define TABLET_OBJECT_LIST_DELETER(fun) (void (*)(void*))fun
|
||||
void
|
||||
Wayland_input_destroy_tablet(struct SDL_WaylandInput* input)
|
||||
{
|
||||
tablet_object_list_destroy(input->tablet->pads, TABLET_OBJECT_LIST_DELETER(zwp_tablet_pad_v2_destroy));
|
||||
tablet_object_list_destroy(input->tablet->tools, TABLET_OBJECT_LIST_DELETER(zwp_tablet_tool_v2_destroy));
|
||||
tablet_object_list_destroy(input->tablet->tablets, TABLET_OBJECT_LIST_DELETER(zwp_tablet_v2_destroy));
|
||||
|
||||
zwp_tablet_seat_v2_destroy((struct zwp_tablet_seat_v2*)input->tablet->seat);
|
||||
|
||||
SDL_free(input->tablet);
|
||||
input->tablet = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
|
||||
{
|
||||
@@ -2079,7 +1542,6 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
|
||||
input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(5, version));
|
||||
input->sx_w = wl_fixed_from_int(0);
|
||||
input->sy_w = wl_fixed_from_int(0);
|
||||
input->xkb.current_group = ~0;
|
||||
d->input = input;
|
||||
|
||||
if (d->data_device_manager != NULL) {
|
||||
@@ -2092,10 +1554,6 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version)
|
||||
wl_seat_add_listener(input->seat, &seat_listener, input);
|
||||
wl_seat_set_user_data(input->seat, input);
|
||||
|
||||
if (d->tablet_manager) {
|
||||
Wayland_input_add_tablet(input, d->tablet_manager);
|
||||
}
|
||||
|
||||
WAYLAND_wl_display_flush(d->display);
|
||||
}
|
||||
|
||||
@@ -2136,10 +1594,6 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
|
||||
wl_touch_destroy(input->touch);
|
||||
}
|
||||
|
||||
if (input->tablet) {
|
||||
Wayland_input_destroy_tablet(input);
|
||||
}
|
||||
|
||||
if (input->seat)
|
||||
wl_seat_destroy(input->seat);
|
||||
|
||||
@@ -2380,19 +1834,12 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi
|
||||
if (SDL_RectEmpty(&window->mouse_rect)) {
|
||||
confine_rect = NULL;
|
||||
} else {
|
||||
SDL_Rect scaled_mouse_rect;
|
||||
|
||||
scaled_mouse_rect.x = (int)SDL_floorf((float)window->mouse_rect.x / w->pointer_scale_x);
|
||||
scaled_mouse_rect.y = (int)SDL_floorf((float)window->mouse_rect.y / w->pointer_scale_y);
|
||||
scaled_mouse_rect.w = (int)SDL_ceilf((float)window->mouse_rect.w / w->pointer_scale_x);
|
||||
scaled_mouse_rect.h = (int)SDL_ceilf((float)window->mouse_rect.h / w->pointer_scale_y);
|
||||
|
||||
confine_rect = wl_compositor_create_region(d->compositor);
|
||||
wl_region_add(confine_rect,
|
||||
scaled_mouse_rect.x,
|
||||
scaled_mouse_rect.y,
|
||||
scaled_mouse_rect.w,
|
||||
scaled_mouse_rect.h);
|
||||
window->mouse_rect.x,
|
||||
window->mouse_rect.y,
|
||||
window->mouse_rect.w,
|
||||
window->mouse_rect.h);
|
||||
}
|
||||
|
||||
confined_pointer =
|
||||
|
||||
@@ -29,34 +29,6 @@
|
||||
#include "SDL_waylanddatamanager.h"
|
||||
#include "SDL_waylandkeyboard.h"
|
||||
|
||||
struct SDL_WaylandTabletSeat;
|
||||
|
||||
struct SDL_WaylandTabletObjectListNode {
|
||||
void* object;
|
||||
struct SDL_WaylandTabletObjectListNode* next;
|
||||
};
|
||||
|
||||
struct SDL_WaylandTabletInput {
|
||||
struct SDL_WaylandTabletSeat* seat;
|
||||
|
||||
struct SDL_WaylandTabletObjectListNode* tablets;
|
||||
struct SDL_WaylandTabletObjectListNode* tools;
|
||||
struct SDL_WaylandTabletObjectListNode* pads;
|
||||
|
||||
SDL_WindowData *tool_focus;
|
||||
uint32_t tool_prox_serial;
|
||||
|
||||
/* Last motion location */
|
||||
wl_fixed_t sx_w;
|
||||
wl_fixed_t sy_w;
|
||||
|
||||
SDL_bool is_down;
|
||||
|
||||
SDL_bool btn_stylus;
|
||||
SDL_bool btn_stylus2;
|
||||
SDL_bool btn_stylus3;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
// repeat_rate in range of [1, 1000]
|
||||
int32_t repeat_rate;
|
||||
@@ -96,17 +68,6 @@ struct SDL_WaylandInput {
|
||||
struct xkb_state *state;
|
||||
struct xkb_compose_table *compose_table;
|
||||
struct xkb_compose_state *compose_state;
|
||||
|
||||
/* Keyboard layout "group" */
|
||||
uint32_t current_group;
|
||||
|
||||
/* Modifier bitshift values */
|
||||
uint32_t idx_shift;
|
||||
uint32_t idx_ctrl;
|
||||
uint32_t idx_alt;
|
||||
uint32_t idx_gui;
|
||||
uint32_t idx_num;
|
||||
uint32_t idx_caps;
|
||||
} xkb;
|
||||
|
||||
/* information about axis events on current frame */
|
||||
@@ -119,8 +80,6 @@ struct SDL_WaylandInput {
|
||||
} pointer_curr_axis_info;
|
||||
|
||||
SDL_WaylandKeyboardRepeat keyboard_repeat;
|
||||
|
||||
struct SDL_WaylandTabletInput* tablet;
|
||||
};
|
||||
|
||||
extern void Wayland_PumpEvents(_THIS);
|
||||
@@ -148,9 +107,6 @@ extern void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d);
|
||||
extern int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input);
|
||||
extern int Wayland_input_ungrab_keyboard(SDL_Window *window);
|
||||
|
||||
extern void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_WaylandTabletManager* tablet_manager);
|
||||
extern void Wayland_input_destroy_tablet(struct SDL_WaylandInput *input);
|
||||
|
||||
#endif /* SDL_waylandevents_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -27,7 +27,6 @@ typedef struct SDL_WaylandTextInput
|
||||
{
|
||||
struct zwp_text_input_v3 *text_input;
|
||||
SDL_Rect cursor_rect;
|
||||
SDL_bool has_preedit;
|
||||
} SDL_WaylandTextInput;
|
||||
|
||||
extern int Wayland_InitKeyboard(_THIS);
|
||||
|
||||
@@ -140,9 +140,9 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
||||
/* wl_display_prepare_read_queue() will return -1 if the event queue is not empty.
|
||||
* If the event queue is empty, it will prepare us for our SDL_IOReady() call. */
|
||||
if (WAYLAND_wl_display_prepare_read_queue(display, data->gles_swap_frame_event_queue) != 0) {
|
||||
if (WAYLAND_wl_display_prepare_read_queue(display, data->frame_event_queue) != 0) {
|
||||
/* We have some pending events. Check if the frame callback happened. */
|
||||
WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue);
|
||||
WAYLAND_wl_display_dispatch_queue_pending(display, data->frame_event_queue);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
|
||||
|
||||
/* We have events. Read and dispatch them. */
|
||||
WAYLAND_wl_display_read_events(display);
|
||||
WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue);
|
||||
WAYLAND_wl_display_dispatch_queue_pending(display, data->frame_event_queue);
|
||||
}
|
||||
SDL_AtomicSet(&data->swap_interval_ready, 0);
|
||||
}
|
||||
@@ -205,11 +205,11 @@ Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (w) {
|
||||
*w = data->drawable_width;
|
||||
*w = window->w * data->scale_factor;
|
||||
}
|
||||
|
||||
if (h) {
|
||||
*h = data->drawable_height;
|
||||
*h = window->h * data->scale_factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
externals/SDL/src/video/wayland/SDL_waylandsym.h
vendored
22
externals/SDL/src/video/wayland/SDL_waylandsym.h
vendored
@@ -19,7 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
#ifndef SDL_WAYLAND_MODULE
|
||||
#define SDL_WAYLAND_MODULE(modname)
|
||||
@@ -72,19 +72,21 @@ SDL_WAYLAND_SYM(void, wl_list_remove, (struct wl_list *))
|
||||
SDL_WAYLAND_SYM(int, wl_list_length, (const struct wl_list *))
|
||||
SDL_WAYLAND_SYM(int, wl_list_empty, (const struct wl_list *))
|
||||
SDL_WAYLAND_SYM(void, wl_list_insert_list, (struct wl_list *, struct wl_list *))
|
||||
|
||||
/* These functions are available in Wayland >= 1.4 */
|
||||
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_4)
|
||||
SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_marshal_constructor, (struct wl_proxy *, uint32_t opcode, const struct wl_interface *interface, ...))
|
||||
|
||||
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_10)
|
||||
SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_marshal_constructor_versioned, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, ...))
|
||||
|
||||
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_18)
|
||||
SDL_WAYLAND_SYM(void, wl_proxy_set_tag, (struct wl_proxy *, const char * const *))
|
||||
SDL_WAYLAND_SYM(const char * const *, wl_proxy_get_tag, (struct wl_proxy *))
|
||||
|
||||
#if SDL_WAYLAND_CHECK_VERSION(1, 20, 0)
|
||||
/* wayland-scanner 1.20 generates code that will call these, so these are
|
||||
* non-optional when we are compiling against Wayland 1.20. We don't
|
||||
* explicitly call them ourselves, though, so if we are only compiling
|
||||
* against Wayland 1.18, they're unnecessary. */
|
||||
SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_20)
|
||||
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interfac, uint32_t version, uint32_t flags, ...))
|
||||
SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_array_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, union wl_argument *args))
|
||||
#endif
|
||||
|
||||
SDL_WAYLAND_INTERFACE(wl_seat_interface)
|
||||
SDL_WAYLAND_INTERFACE(wl_surface_interface)
|
||||
@@ -120,7 +122,6 @@ SDL_WAYLAND_SYM(int, xkb_state_key_get_syms, (struct xkb_state *, xkb_keycode_t,
|
||||
SDL_WAYLAND_SYM(int, xkb_keysym_to_utf8, (xkb_keysym_t, char *, size_t) )
|
||||
SDL_WAYLAND_SYM(struct xkb_keymap *, xkb_keymap_new_from_string, (struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags))
|
||||
SDL_WAYLAND_SYM(struct xkb_state *, xkb_state_new, (struct xkb_keymap *) )
|
||||
SDL_WAYLAND_SYM(int, xkb_keymap_key_repeats, (struct xkb_keymap *keymap, xkb_keycode_t key) );
|
||||
SDL_WAYLAND_SYM(void, xkb_keymap_unref, (struct xkb_keymap *) )
|
||||
SDL_WAYLAND_SYM(void, xkb_state_unref, (struct xkb_state *) )
|
||||
SDL_WAYLAND_SYM(void, xkb_context_unref, (struct xkb_context *) )
|
||||
@@ -147,8 +148,6 @@ SDL_WAYLAND_SYM(int, xkb_keymap_key_get_syms_by_level, (struct xkb_keymap *,
|
||||
xkb_layout_index_t,
|
||||
const xkb_keysym_t **) )
|
||||
SDL_WAYLAND_SYM(uint32_t, xkb_keysym_to_utf32, (xkb_keysym_t) )
|
||||
SDL_WAYLAND_SYM(uint32_t, xkb_keymap_mod_get_index, (struct xkb_keymap *,
|
||||
const char *) )
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
SDL_WAYLAND_MODULE(WAYLAND_LIBDECOR)
|
||||
@@ -204,13 +203,12 @@ SDL_WAYLAND_SYM(bool, libdecor_configuration_get_content_size, (struct libdecor_
|
||||
int *))
|
||||
SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_configuration *,\
|
||||
enum libdecor_window_state *))
|
||||
SDL_WAYLAND_SYM(bool, libdecor_dispatch, (struct libdecor *, int))
|
||||
#endif
|
||||
|
||||
#undef SDL_WAYLAND_MODULE
|
||||
#undef SDL_WAYLAND_SYM
|
||||
#undef SDL_WAYLAND_INTERFACE
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
447
externals/SDL/src/video/wayland/SDL_waylandvideo.c
vendored
447
externals/SDL/src/video/wayland/SDL_waylandvideo.c
vendored
@@ -52,9 +52,6 @@
|
||||
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
||||
#include "xdg-activation-v1-client-protocol.h"
|
||||
#include "text-input-unstable-v3-client-protocol.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
#include "xdg-output-unstable-v1-client-protocol.h"
|
||||
#include "viewporter-client-protocol.h"
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
#include <libdecor.h>
|
||||
@@ -62,9 +59,6 @@
|
||||
|
||||
#define WAYLANDVID_DRIVER_NAME "wayland"
|
||||
|
||||
static void
|
||||
display_handle_done(void *data, struct wl_output *output);
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int
|
||||
Wayland_VideoInit(_THIS);
|
||||
@@ -139,22 +133,32 @@ static const char *SDL_WAYLAND_output_tag = "sdl-output";
|
||||
|
||||
void SDL_WAYLAND_register_surface(struct wl_surface *surface)
|
||||
{
|
||||
wl_proxy_set_tag((struct wl_proxy *)surface, &SDL_WAYLAND_surface_tag);
|
||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||
wl_proxy_set_tag((struct wl_proxy *)surface, &SDL_WAYLAND_surface_tag);
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_WAYLAND_register_output(struct wl_output *output)
|
||||
{
|
||||
wl_proxy_set_tag((struct wl_proxy *)output, &SDL_WAYLAND_output_tag);
|
||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||
wl_proxy_set_tag((struct wl_proxy *)output, &SDL_WAYLAND_output_tag);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface)
|
||||
{
|
||||
return wl_proxy_get_tag((struct wl_proxy *) surface) == &SDL_WAYLAND_surface_tag;
|
||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||
return wl_proxy_get_tag((struct wl_proxy *) surface) == &SDL_WAYLAND_surface_tag;
|
||||
}
|
||||
return SDL_TRUE; /* For older clients we have to assume this is us... */
|
||||
}
|
||||
|
||||
SDL_bool SDL_WAYLAND_own_output(struct wl_output *output)
|
||||
{
|
||||
return wl_proxy_get_tag((struct wl_proxy *) output) == &SDL_WAYLAND_output_tag;
|
||||
if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT_1_18) {
|
||||
return wl_proxy_get_tag((struct wl_proxy *) output) == &SDL_WAYLAND_output_tag;
|
||||
}
|
||||
return SDL_TRUE; /* For older clients we have to assume this is us... */
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -226,7 +230,6 @@ Wayland_CreateDevice(int devindex)
|
||||
device->WaitEventTimeout = Wayland_WaitEventTimeout;
|
||||
device->SendWakeupEvent = Wayland_SendWakeupEvent;
|
||||
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
device->GL_SwapWindow = Wayland_GLES_SwapWindow;
|
||||
device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval;
|
||||
device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval;
|
||||
@@ -237,7 +240,6 @@ Wayland_CreateDevice(int devindex)
|
||||
device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary;
|
||||
device->GL_GetProcAddress = Wayland_GLES_GetProcAddress;
|
||||
device->GL_DeleteContext = Wayland_GLES_DeleteContext;
|
||||
#endif
|
||||
|
||||
device->CreateSDLWindow = Wayland_CreateWindow;
|
||||
device->ShowWindow = Wayland_ShowWindow;
|
||||
@@ -279,8 +281,6 @@ Wayland_CreateDevice(int devindex)
|
||||
|
||||
device->free = Wayland_DeleteDevice;
|
||||
|
||||
device->disable_display_mode_switching = SDL_TRUE;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -289,167 +289,6 @@ VideoBootStrap Wayland_bootstrap = {
|
||||
Wayland_CreateDevice
|
||||
};
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
int32_t x, int32_t y)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
|
||||
driverdata->x = x;
|
||||
driverdata->y = y;
|
||||
driverdata->has_logical_position = SDL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
int32_t width, int32_t height)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
|
||||
if (driverdata->width != 0 && driverdata->height != 0) {
|
||||
/* FIXME: GNOME has a bug where the logical size does not account for
|
||||
* scale, resulting in bogus viewport sizes.
|
||||
*
|
||||
* Until this is fixed, validate that _some_ kind of scaling is being
|
||||
* done (we can't match exactly because fractional scaling can't be
|
||||
* detected otherwise), then override if necessary.
|
||||
* -flibit
|
||||
*/
|
||||
const float scale = (float) driverdata->width / (float) width;
|
||||
if ((scale == 1.0f) && (driverdata->scale_factor != 1.0f)) {
|
||||
SDL_LogWarn(
|
||||
SDL_LOG_CATEGORY_VIDEO,
|
||||
"xdg_output scale did not match, overriding with wl_output scale"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
driverdata->width = width;
|
||||
driverdata->height = height;
|
||||
driverdata->has_logical_size = SDL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
|
||||
/*
|
||||
* xdg-output.done events are deprecated and only apply below version 3 of the protocol.
|
||||
* A wl-output.done event will be emitted in version 3 or higher.
|
||||
*/
|
||||
if (zxdg_output_v1_get_version(driverdata->xdg_output) < 3) {
|
||||
display_handle_done(data, driverdata->output);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,
|
||||
const char *description)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
|
||||
if (driverdata->index == -1) {
|
||||
/* xdg-output descriptions, if available, supersede wl-output model names. */
|
||||
if (driverdata->placeholder.name != NULL) {
|
||||
SDL_free(driverdata->placeholder.name);
|
||||
}
|
||||
|
||||
driverdata->placeholder.name = SDL_strdup(description);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
||||
xdg_output_handle_logical_position,
|
||||
xdg_output_handle_logical_size,
|
||||
xdg_output_handle_done,
|
||||
xdg_output_handle_name,
|
||||
xdg_output_handle_description,
|
||||
};
|
||||
|
||||
static void
|
||||
AddEmulatedModes(SDL_VideoDisplay *dpy, SDL_bool rot_90)
|
||||
{
|
||||
struct EmulatedMode
|
||||
{
|
||||
int w;
|
||||
int h;
|
||||
};
|
||||
|
||||
/* Resolution lists courtesy of XWayland */
|
||||
const struct EmulatedMode mode_list[] = {
|
||||
/* 16:9 (1.77) */
|
||||
{ 7680, 4320 },
|
||||
{ 6144, 3160 },
|
||||
{ 5120, 2880 },
|
||||
{ 4096, 2304 },
|
||||
{ 3840, 2160 },
|
||||
{ 3200, 1800 },
|
||||
{ 2880, 1620 },
|
||||
{ 2560, 1440 },
|
||||
{ 2048, 1152 },
|
||||
{ 1920, 1080 },
|
||||
{ 1600, 900 },
|
||||
{ 1368, 768 },
|
||||
{ 1280, 720 },
|
||||
{ 864, 486 },
|
||||
|
||||
/* 16:10 (1.6) */
|
||||
{ 2560, 1600 },
|
||||
{ 1920, 1200 },
|
||||
{ 1680, 1050 },
|
||||
{ 1440, 900 },
|
||||
{ 1280, 800 },
|
||||
|
||||
/* 3:2 (1.5) */
|
||||
{ 720, 480 },
|
||||
|
||||
/* 4:3 (1.33) */
|
||||
{ 2048, 1536 },
|
||||
{ 1920, 1440 },
|
||||
{ 1600, 1200 },
|
||||
{ 1440, 1080 },
|
||||
{ 1400, 1050 },
|
||||
{ 1280, 1024 },
|
||||
{ 1280, 960 },
|
||||
{ 1152, 864 },
|
||||
{ 1024, 768 },
|
||||
{ 800, 600 },
|
||||
{ 640, 480 }
|
||||
};
|
||||
|
||||
int i;
|
||||
SDL_DisplayMode mode;
|
||||
const int native_width = dpy->display_modes->w;
|
||||
const int native_height = dpy->display_modes->h;
|
||||
|
||||
for (i = 0; i < SDL_arraysize(mode_list); ++i) {
|
||||
mode = *dpy->display_modes;
|
||||
|
||||
if (rot_90) {
|
||||
mode.w = mode_list[i].h;
|
||||
mode.h = mode_list[i].w;
|
||||
} else {
|
||||
mode.w = mode_list[i].w;
|
||||
mode.h = mode_list[i].h;
|
||||
}
|
||||
|
||||
/* Only add modes that are smaller than the native mode. */
|
||||
if ((mode.w < native_width && mode.h < native_height) ||
|
||||
(mode.w < native_width && mode.h == native_height) ||
|
||||
(mode.w == native_width && mode.h < native_height)) {
|
||||
SDL_AddDisplayMode(dpy, &mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
display_handle_geometry(void *data,
|
||||
struct wl_output *output,
|
||||
@@ -466,7 +305,7 @@ display_handle_geometry(void *data,
|
||||
SDL_VideoDisplay *display;
|
||||
int i;
|
||||
|
||||
if (driverdata->wl_output_done_count) {
|
||||
if (driverdata->done) {
|
||||
/* Clear the wl_output ref so Reset doesn't free it */
|
||||
display = SDL_GetDisplay(driverdata->index);
|
||||
for (i = 0; i < display->num_display_modes; i += 1) {
|
||||
@@ -477,19 +316,14 @@ display_handle_geometry(void *data,
|
||||
SDL_ResetDisplayModes(driverdata->index);
|
||||
|
||||
/* The display has officially started over. */
|
||||
driverdata->wl_output_done_count = 0;
|
||||
driverdata->done = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Apply the change from wl-output only if xdg-output is not supported */
|
||||
if (!driverdata->has_logical_position) {
|
||||
driverdata->x = x;
|
||||
driverdata->y = y;
|
||||
}
|
||||
driverdata->x = x;
|
||||
driverdata->y = y;
|
||||
driverdata->physical_width = physical_width;
|
||||
driverdata->physical_height = physical_height;
|
||||
|
||||
/* The output name is only set if xdg-output hasn't provided a description. */
|
||||
if (driverdata->index == -1 && driverdata->placeholder.name == NULL) {
|
||||
if (driverdata->index == -1) {
|
||||
driverdata->placeholder.name = SDL_strdup(model);
|
||||
}
|
||||
|
||||
@@ -533,22 +367,37 @@ display_handle_mode(void *data,
|
||||
int refresh)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT) {
|
||||
driverdata->native_width = width;
|
||||
driverdata->native_height = height;
|
||||
|
||||
/*
|
||||
* Don't rotate this yet, wl-output coordinates are transformed in
|
||||
* handle_done and xdg-output coordinates are pre-transformed.
|
||||
*/
|
||||
if (!driverdata->has_logical_size) {
|
||||
driverdata->width = width;
|
||||
driverdata->height = height;
|
||||
}
|
||||
|
||||
/* Don't rotate this yet, handle_done will do it later */
|
||||
driverdata->width = width;
|
||||
driverdata->height = height;
|
||||
driverdata->refresh = refresh;
|
||||
}
|
||||
|
||||
/* Note that the width/height are NOT multiplied by scale_factor!
|
||||
* This is intentional and is designed to get the unscaled modes, which is
|
||||
* important for high-DPI games intending to use the display mode as the
|
||||
* target drawable size. The scaled desktop mode will be added at the end
|
||||
* when display_handle_done is called (see below).
|
||||
*/
|
||||
SDL_zero(mode);
|
||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
mode.w = height;
|
||||
mode.h = width;
|
||||
} else {
|
||||
mode.w = width;
|
||||
mode.h = height;
|
||||
}
|
||||
mode.refresh_rate = refresh / 1000; /* mHz to Hz */
|
||||
mode.driverdata = driverdata->output;
|
||||
if (driverdata->index > -1) {
|
||||
SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &mode);
|
||||
} else {
|
||||
SDL_AddDisplayMode(&driverdata->placeholder, &mode);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -556,75 +405,20 @@ display_handle_done(void *data,
|
||||
struct wl_output *output)
|
||||
{
|
||||
SDL_WaylandOutputData* driverdata = data;
|
||||
SDL_VideoData* video = driverdata->videodata;
|
||||
SDL_DisplayMode native_mode, desktop_mode;
|
||||
SDL_DisplayMode mode;
|
||||
SDL_VideoDisplay *dpy;
|
||||
const SDL_bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, SDL_TRUE);
|
||||
|
||||
/*
|
||||
* When using xdg-output, two wl-output.done events will be emitted:
|
||||
* one at the completion of wl-display and one at the completion of xdg-output.
|
||||
*
|
||||
* All required events must be received before proceeding.
|
||||
*/
|
||||
const int event_await_count = 1 + (driverdata->xdg_output != NULL);
|
||||
|
||||
driverdata->wl_output_done_count = SDL_min(driverdata->wl_output_done_count + 1, event_await_count + 1);
|
||||
|
||||
if (driverdata->wl_output_done_count != event_await_count) {
|
||||
if (driverdata->done)
|
||||
return;
|
||||
}
|
||||
|
||||
/* The native display resolution */
|
||||
SDL_zero(native_mode);
|
||||
native_mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
driverdata->done = SDL_TRUE;
|
||||
|
||||
SDL_zero(mode);
|
||||
mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
native_mode.w = driverdata->native_height;
|
||||
native_mode.h = driverdata->native_width;
|
||||
} else {
|
||||
native_mode.w = driverdata->native_width;
|
||||
native_mode.h = driverdata->native_height;
|
||||
}
|
||||
native_mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */
|
||||
native_mode.driverdata = driverdata->output;
|
||||
mode.w = driverdata->height / driverdata->scale_factor;
|
||||
mode.h = driverdata->width / driverdata->scale_factor;
|
||||
|
||||
/* The scaled desktop mode */
|
||||
SDL_zero(desktop_mode);
|
||||
desktop_mode.format = SDL_PIXELFORMAT_RGB888;
|
||||
|
||||
if (driverdata->has_logical_size) { /* If xdg-output is present, calculate the true scale of the desktop */
|
||||
driverdata->scale_factor = (float)native_mode.w / (float)driverdata->width;
|
||||
} else { /* Scale the desktop coordinates, if xdg-output isn't present */
|
||||
driverdata->width /= driverdata->scale_factor;
|
||||
driverdata->height /= driverdata->scale_factor;
|
||||
}
|
||||
|
||||
/* xdg-output dimensions are already transformed, so no need to rotate. */
|
||||
if (driverdata->has_logical_size || !(driverdata->transform & WL_OUTPUT_TRANSFORM_90)) {
|
||||
desktop_mode.w = driverdata->width;
|
||||
desktop_mode.h = driverdata->height;
|
||||
} else {
|
||||
desktop_mode.w = driverdata->height;
|
||||
desktop_mode.h = driverdata->width;
|
||||
}
|
||||
desktop_mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */
|
||||
desktop_mode.driverdata = driverdata->output;
|
||||
|
||||
/*
|
||||
* The native display mode is only exposed separately from the desktop size if the
|
||||
* desktop is scaled and the wp_viewporter protocol is supported.
|
||||
*/
|
||||
if (driverdata->scale_factor > 1.0f && video->viewporter != NULL) {
|
||||
if (driverdata->index > -1) {
|
||||
SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &native_mode);
|
||||
} else {
|
||||
SDL_AddDisplayMode(&driverdata->placeholder, &native_mode);
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the display DPI */
|
||||
if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
|
||||
driverdata->hdpi = driverdata->physical_height ?
|
||||
(((float) driverdata->height) * 25.4f / driverdata->physical_height) :
|
||||
0.0f;
|
||||
@@ -636,6 +430,9 @@ display_handle_done(void *data,
|
||||
((float) driverdata->physical_height) / 25.4f,
|
||||
((float) driverdata->physical_width) / 25.4f);
|
||||
} else {
|
||||
mode.w = driverdata->width / driverdata->scale_factor;
|
||||
mode.h = driverdata->height / driverdata->scale_factor;
|
||||
|
||||
driverdata->hdpi = driverdata->physical_width ?
|
||||
(((float) driverdata->width) * 25.4f / driverdata->physical_width) :
|
||||
0.0f;
|
||||
@@ -647,6 +444,8 @@ display_handle_done(void *data,
|
||||
((float) driverdata->physical_width) / 25.4f,
|
||||
((float) driverdata->physical_height) / 25.4f);
|
||||
}
|
||||
mode.refresh_rate = driverdata->refresh / 1000; /* mHz to Hz */
|
||||
mode.driverdata = driverdata->output;
|
||||
|
||||
if (driverdata->index > -1) {
|
||||
dpy = SDL_GetDisplay(driverdata->index);
|
||||
@@ -654,16 +453,9 @@ display_handle_done(void *data,
|
||||
dpy = &driverdata->placeholder;
|
||||
}
|
||||
|
||||
SDL_AddDisplayMode(dpy, &desktop_mode);
|
||||
SDL_SetCurrentDisplayMode(dpy, &desktop_mode);
|
||||
SDL_SetDesktopDisplayMode(dpy, &desktop_mode);
|
||||
|
||||
/* Add emulated modes if wp_viewporter is supported and mode emulation is enabled. */
|
||||
if (video->viewporter && mode_emulation_enabled) {
|
||||
const SDL_bool rot_90 = ((driverdata->transform & WL_OUTPUT_TRANSFORM_90) != 0) ||
|
||||
(driverdata->width < driverdata->height);
|
||||
AddEmulatedModes(dpy, rot_90);
|
||||
}
|
||||
SDL_AddDisplayMode(dpy, &mode);
|
||||
SDL_SetCurrentDisplayMode(dpy, &mode);
|
||||
SDL_SetDesktopDisplayMode(dpy, &mode);
|
||||
|
||||
if (driverdata->index == -1) {
|
||||
/* First time getting display info, create the VideoDisplay */
|
||||
@@ -710,29 +502,11 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id)
|
||||
data->videodata = d;
|
||||
data->output = output;
|
||||
data->registry_id = id;
|
||||
data->scale_factor = 1.0f;
|
||||
data->scale_factor = 1.0;
|
||||
data->index = -1;
|
||||
|
||||
wl_output_add_listener(output, &output_listener, data);
|
||||
SDL_WAYLAND_register_output(output);
|
||||
|
||||
/* Keep a list of outputs for deferred xdg-output initialization. */
|
||||
if (d->output_list != NULL) {
|
||||
SDL_WaylandOutputData *node = (SDL_WaylandOutputData*)d->output_list;
|
||||
|
||||
while (node->next != NULL) {
|
||||
node = (SDL_WaylandOutputData*)node->next;
|
||||
}
|
||||
|
||||
node->next = (struct SDL_WaylandOutputData*)data;
|
||||
} else {
|
||||
d->output_list = (struct SDL_WaylandOutputData*)data;
|
||||
}
|
||||
|
||||
if (data->videodata->xdg_output_manager) {
|
||||
data->xdg_output = zxdg_output_manager_v1_get_xdg_output(data->videodata->xdg_output_manager, output);
|
||||
zxdg_output_v1_add_listener(data->xdg_output, &xdg_output_listener, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -748,9 +522,6 @@ Wayland_free_display(uint32_t id)
|
||||
data = (SDL_WaylandOutputData *) display->driverdata;
|
||||
if (data->registry_id == id) {
|
||||
SDL_DelVideoDisplay(i);
|
||||
if (data->xdg_output) {
|
||||
zxdg_output_v1_destroy(data->xdg_output);
|
||||
}
|
||||
wl_output_destroy(data->output);
|
||||
SDL_free(data);
|
||||
|
||||
@@ -767,16 +538,6 @@ Wayland_free_display(uint32_t id)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Wayland_init_xdg_output(SDL_VideoData *d)
|
||||
{
|
||||
SDL_WaylandOutputData *node;
|
||||
for (node = d->output_list; node != NULL; node = node->next) {
|
||||
node->xdg_output = zxdg_output_manager_v1_get_xdg_output(node->videodata->xdg_output_manager, node->output);
|
||||
zxdg_output_v1_add_listener(node->xdg_output, &xdg_output_listener, node);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
static void
|
||||
windowmanager_hints(void *data, struct qt_windowmanager *qt_windowmanager,
|
||||
@@ -837,7 +598,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
||||
} else if (SDL_strcmp(interface, "wl_seat") == 0) {
|
||||
Wayland_display_add_input(d, id, version);
|
||||
} else if (SDL_strcmp(interface, "xdg_wm_base") == 0) {
|
||||
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 3));
|
||||
d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, 1);
|
||||
xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL);
|
||||
} else if (SDL_strcmp(interface, "wl_shm") == 0) {
|
||||
d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||
@@ -857,17 +618,6 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
|
||||
Wayland_add_data_device_manager(d, id, version);
|
||||
} else if (SDL_strcmp(interface, "zxdg_decoration_manager_v1") == 0) {
|
||||
d->decoration_manager = wl_registry_bind(d->registry, id, &zxdg_decoration_manager_v1_interface, 1);
|
||||
} else if (SDL_strcmp(interface, "zwp_tablet_manager_v2") == 0) {
|
||||
d->tablet_manager = wl_registry_bind(d->registry, id, &zwp_tablet_manager_v2_interface, 1);
|
||||
if (d->input) {
|
||||
Wayland_input_add_tablet(d->input, d->tablet_manager);
|
||||
}
|
||||
} else if (SDL_strcmp(interface, "zxdg_output_manager_v1") == 0) {
|
||||
version = SDL_min(version, 3); /* Versions 1 through 3 are supported. */
|
||||
d->xdg_output_manager = wl_registry_bind(d->registry, id, &zxdg_output_manager_v1_interface, version);
|
||||
Wayland_init_xdg_output(d);
|
||||
} else if (SDL_strcmp(interface, "wp_viewporter") == 0) {
|
||||
d->viewporter = wl_registry_bind(d->registry, id, &wp_viewporter_interface, 1);
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
} else if (SDL_strcmp(interface, "qt_touch_extension") == 0) {
|
||||
@@ -894,48 +644,6 @@ static const struct wl_registry_listener registry_listener = {
|
||||
display_handle_global,
|
||||
display_remove_global
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
static SDL_bool should_use_libdecor(SDL_VideoData *data, SDL_bool ignore_xdg)
|
||||
{
|
||||
if (!SDL_WAYLAND_HAVE_WAYLAND_LIBDECOR) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, SDL_TRUE)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR, SDL_FALSE)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (ignore_xdg) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (data->decoration_manager) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_bool
|
||||
Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg)
|
||||
{
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
if (data->shell.libdecor != NULL) {
|
||||
return SDL_TRUE; /* Already loaded! */
|
||||
}
|
||||
if (should_use_libdecor(data, ignore_xdg)) {
|
||||
data->shell.libdecor = libdecor_new(data->display, &libdecor_interface);
|
||||
return data->shell.libdecor != NULL;
|
||||
}
|
||||
#endif
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
Wayland_VideoInit(_THIS)
|
||||
@@ -957,8 +665,18 @@ Wayland_VideoInit(_THIS)
|
||||
// First roundtrip to receive all registry objects.
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
|
||||
/* Now that we have all the protocols, load libdecor if applicable */
|
||||
Wayland_LoadLibdecor(data, SDL_FALSE);
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
/* Don't have server-side decorations? Try client-side instead. */
|
||||
if (!data->decoration_manager && SDL_WAYLAND_HAVE_WAYLAND_LIBDECOR && SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, SDL_TRUE)) {
|
||||
data->shell.libdecor = libdecor_new(data->display, &libdecor_interface);
|
||||
|
||||
/* If libdecor works, we don't need xdg-shell anymore. */
|
||||
if (data->shell.libdecor && data->shell.xdg) {
|
||||
xdg_wm_base_destroy(data->shell.xdg);
|
||||
data->shell.xdg = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Second roundtrip to receive all output events.
|
||||
WAYLAND_wl_display_roundtrip(data->display);
|
||||
@@ -1017,10 +735,6 @@ Wayland_VideoQuit(_THIS)
|
||||
for (i = 0; i < _this->num_displays; ++i) {
|
||||
SDL_VideoDisplay *display = &_this->displays[i];
|
||||
|
||||
if (((SDL_WaylandOutputData*)display->driverdata)->xdg_output) {
|
||||
zxdg_output_v1_destroy(((SDL_WaylandOutputData*)display->driverdata)->xdg_output);
|
||||
}
|
||||
|
||||
wl_output_destroy(((SDL_WaylandOutputData*)display->driverdata)->output);
|
||||
SDL_free(display->driverdata);
|
||||
display->driverdata = NULL;
|
||||
@@ -1063,9 +777,6 @@ Wayland_VideoQuit(_THIS)
|
||||
Wayland_touch_destroy(data);
|
||||
#endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
|
||||
|
||||
if (data->tablet_manager)
|
||||
zwp_tablet_manager_v2_destroy((struct zwp_tablet_manager_v2*)data->tablet_manager);
|
||||
|
||||
if (data->data_device_manager)
|
||||
wl_data_device_manager_destroy(data->data_device_manager);
|
||||
|
||||
@@ -1085,14 +796,6 @@ Wayland_VideoQuit(_THIS)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data->xdg_output_manager) {
|
||||
zxdg_output_manager_v1_destroy(data->xdg_output_manager);
|
||||
}
|
||||
|
||||
if (data->viewporter) {
|
||||
wp_viewporter_destroy(data->viewporter);
|
||||
}
|
||||
|
||||
if (data->compositor)
|
||||
wl_compositor_destroy(data->compositor);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
struct xkb_context;
|
||||
struct SDL_WaylandInput;
|
||||
struct SDL_WaylandTabletManager;
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
struct SDL_WaylandTouch;
|
||||
@@ -47,8 +46,6 @@ typedef struct {
|
||||
int size;
|
||||
} SDL_WaylandCursorTheme;
|
||||
|
||||
typedef struct SDL_WaylandOutputData SDL_WaylandOutputData;
|
||||
|
||||
typedef struct {
|
||||
SDL_bool initializing;
|
||||
struct wl_display *display;
|
||||
@@ -73,8 +70,6 @@ typedef struct {
|
||||
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
|
||||
struct xdg_activation_v1 *activation_manager;
|
||||
struct zwp_text_input_manager_v3 *text_input_manager;
|
||||
struct zxdg_output_manager_v1 *xdg_output_manager;
|
||||
struct wp_viewporter *viewporter;
|
||||
|
||||
EGLDisplay edpy;
|
||||
EGLContext context;
|
||||
@@ -82,8 +77,6 @@ typedef struct {
|
||||
|
||||
struct xkb_context *xkb_context;
|
||||
struct SDL_WaylandInput *input;
|
||||
struct SDL_WaylandTabletManager *tablet_manager;
|
||||
SDL_WaylandOutputData *output_list;
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH
|
||||
struct SDL_WaylandTouch *touch;
|
||||
@@ -96,23 +89,19 @@ typedef struct {
|
||||
int relative_mouse_mode;
|
||||
} SDL_VideoData;
|
||||
|
||||
struct SDL_WaylandOutputData {
|
||||
typedef struct {
|
||||
SDL_VideoData *videodata;
|
||||
struct wl_output *output;
|
||||
struct zxdg_output_v1 *xdg_output;
|
||||
uint32_t registry_id;
|
||||
float scale_factor;
|
||||
int native_width, native_height;
|
||||
int x, y, width, height, refresh, transform;
|
||||
SDL_DisplayOrientation orientation;
|
||||
int physical_width, physical_height;
|
||||
float ddpi, hdpi, vdpi;
|
||||
SDL_bool has_logical_position, has_logical_size;
|
||||
int index;
|
||||
SDL_VideoDisplay placeholder;
|
||||
int wl_output_done_count;
|
||||
SDL_WaylandOutputData *next;
|
||||
};
|
||||
SDL_bool done;
|
||||
} SDL_WaylandOutputData;
|
||||
|
||||
/* Needed here to get wl_surface declaration, fixes GitHub#4594 */
|
||||
#include "SDL_waylanddyn.h"
|
||||
@@ -122,8 +111,6 @@ extern void SDL_WAYLAND_register_output(struct wl_output *output);
|
||||
extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface);
|
||||
extern SDL_bool SDL_WAYLAND_own_output(struct wl_output *output);
|
||||
|
||||
extern SDL_bool Wayland_LoadLibdecor(SDL_VideoData *data, SDL_bool ignore_xdg);
|
||||
|
||||
#endif /* SDL_waylandvideo_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -139,11 +139,11 @@ void Wayland_Vulkan_GetDrawableSize(_THIS, SDL_Window *window, int *w, int *h)
|
||||
data = (SDL_WindowData *) window->driverdata;
|
||||
|
||||
if (w) {
|
||||
*w = data->drawable_width;
|
||||
*w = window->w * data->scale_factor;
|
||||
}
|
||||
|
||||
if (h) {
|
||||
*h = data->drawable_height;
|
||||
*h = window->h * data->scale_factor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
913
externals/SDL/src/video/wayland/SDL_waylandwindow.c
vendored
913
externals/SDL/src/video/wayland/SDL_waylandwindow.c
vendored
File diff suppressed because it is too large
Load Diff
@@ -32,61 +32,44 @@
|
||||
|
||||
struct SDL_WaylandInput;
|
||||
|
||||
/* TODO: Remove these helpers, they're from before we had shell_surface_type */
|
||||
#define WINDOW_IS_XDG_POPUP(window) \
|
||||
(((SDL_WindowData*) window->driverdata)->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP)
|
||||
#define WINDOW_IS_LIBDECOR(ignoreme, window) \
|
||||
(((SDL_WindowData*) window->driverdata)->shell_surface_type == WAYLAND_SURFACE_LIBDECOR)
|
||||
typedef struct {
|
||||
struct xdg_surface *surface;
|
||||
union {
|
||||
struct xdg_toplevel *toplevel;
|
||||
struct xdg_popup *popup;
|
||||
} roleobj;
|
||||
SDL_bool initial_configure_seen;
|
||||
} SDL_xdg_shell_surface;
|
||||
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
typedef struct {
|
||||
struct libdecor_frame *frame;
|
||||
SDL_bool initial_configure_seen;
|
||||
} SDL_libdecor_surface;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
SDL_Window *sdlwindow;
|
||||
SDL_VideoData *waylandData;
|
||||
struct wl_surface *surface;
|
||||
struct wl_callback *gles_swap_frame_callback;
|
||||
struct wl_event_queue *gles_swap_frame_event_queue;
|
||||
struct wl_surface *gles_swap_frame_surface_wrapper;
|
||||
struct wl_callback *surface_damage_frame_callback;
|
||||
|
||||
struct wl_callback *frame_callback;
|
||||
struct wl_event_queue *frame_event_queue;
|
||||
struct wl_surface *frame_surface_wrapper;
|
||||
union {
|
||||
#ifdef HAVE_LIBDECOR_H
|
||||
struct {
|
||||
struct libdecor_frame *frame;
|
||||
SDL_bool initial_configure_seen;
|
||||
} libdecor;
|
||||
SDL_libdecor_surface libdecor;
|
||||
#endif
|
||||
struct {
|
||||
struct xdg_surface *surface;
|
||||
union {
|
||||
struct xdg_toplevel *toplevel;
|
||||
struct {
|
||||
struct xdg_popup *popup;
|
||||
struct xdg_positioner *positioner;
|
||||
Uint32 parentID;
|
||||
SDL_Window *child;
|
||||
} popup;
|
||||
} roleobj;
|
||||
SDL_bool initial_configure_seen;
|
||||
} xdg;
|
||||
SDL_xdg_shell_surface xdg;
|
||||
} shell_surface;
|
||||
enum {
|
||||
WAYLAND_SURFACE_UNKNOWN = 0,
|
||||
WAYLAND_SURFACE_XDG_TOPLEVEL,
|
||||
WAYLAND_SURFACE_XDG_POPUP,
|
||||
WAYLAND_SURFACE_LIBDECOR
|
||||
} shell_surface_type;
|
||||
|
||||
struct wl_egl_window *egl_window;
|
||||
struct SDL_WaylandInput *keyboard_device;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
#endif
|
||||
struct zwp_locked_pointer_v1 *locked_pointer;
|
||||
struct zwp_confined_pointer_v1 *confined_pointer;
|
||||
struct zxdg_toplevel_decoration_v1 *server_decoration;
|
||||
struct zwp_keyboard_shortcuts_inhibitor_v1 *key_inhibitor;
|
||||
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
|
||||
struct xdg_activation_token_v1 *activation_token;
|
||||
struct wp_viewport *draw_viewport;
|
||||
|
||||
/* floating dimensions for restoring from maximized and fullscreen */
|
||||
int floating_width, floating_height;
|
||||
@@ -101,12 +84,6 @@ typedef struct {
|
||||
int num_outputs;
|
||||
|
||||
float scale_factor;
|
||||
float pointer_scale_x;
|
||||
float pointer_scale_y;
|
||||
int drawable_width, drawable_height;
|
||||
SDL_Rect viewport_rect;
|
||||
SDL_bool needs_resize_event;
|
||||
SDL_bool floating_resize_pending;
|
||||
} SDL_WindowData;
|
||||
|
||||
extern void Wayland_ShowWindow(_THIS, SDL_Window *window);
|
||||
|
||||
305
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
305
externals/SDL/src/video/windows/SDL_windowsevents.c
vendored
@@ -29,12 +29,10 @@
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_vkeys.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_main.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../../events/SDL_touch_c.h"
|
||||
#include "../../events/scancodes_windows.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_log.h"
|
||||
|
||||
/* Dropfile support */
|
||||
#include <shellapi.h>
|
||||
@@ -42,19 +40,12 @@
|
||||
/* For GET_X_LPARAM, GET_Y_LPARAM. */
|
||||
#include <windowsx.h>
|
||||
|
||||
/* For WM_TABLET_QUERYSYSTEMGESTURESTATUS et. al. */
|
||||
#if HAVE_TPCSHRD_H
|
||||
#include <tpcshrd.h>
|
||||
#endif /* HAVE_TPCSHRD_H */
|
||||
|
||||
/* #define WMMSG_DEBUG */
|
||||
#ifdef WMMSG_DEBUG
|
||||
#include <stdio.h>
|
||||
#include "wmmsg.h"
|
||||
#endif
|
||||
|
||||
/* #define HIGHDPI_DEBUG */
|
||||
|
||||
/* Masks for processing the windows KEYDOWN and KEYUP messages */
|
||||
#define REPEATED_KEYMASK (1<<30)
|
||||
#define EXTENDED_KEYMASK (1<<24)
|
||||
@@ -89,12 +80,6 @@
|
||||
#ifndef WM_UNICHAR
|
||||
#define WM_UNICHAR 0x0109
|
||||
#endif
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif
|
||||
#ifndef WM_GETDPISCALEDSIZE
|
||||
#define WM_GETDPISCALEDSIZE 0x02E4
|
||||
#endif
|
||||
|
||||
#ifndef IS_HIGH_SURROGATE
|
||||
#define IS_HIGH_SURROGATE(x) (((x) >= 0xd800) && ((x) <= 0xdbff))
|
||||
@@ -384,18 +369,18 @@ WIN_CheckAsyncMouseRelease(SDL_WindowData *data)
|
||||
if (!(keyState & 0x8000)) {
|
||||
WIN_CheckWParamMouseButton(SDL_FALSE, mouseFlags, swapButtons, data, SDL_BUTTON_X2, 0);
|
||||
}
|
||||
data->mouse_button_flags = (WPARAM)-1;
|
||||
data->mouse_button_flags = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus)
|
||||
WIN_UpdateFocus(SDL_Window *window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
HWND hwnd = data->hwnd;
|
||||
SDL_bool had_focus = (SDL_GetKeyboardFocus() == window) ? SDL_TRUE : SDL_FALSE;
|
||||
SDL_bool has_focus = (GetForegroundWindow() == hwnd) ? SDL_TRUE : SDL_FALSE;
|
||||
|
||||
if (had_focus == has_focus || has_focus != expect_focus) {
|
||||
if (had_focus == has_focus) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -696,7 +681,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
/* Update the focus here, since it's possible to get WM_ACTIVATE and WM_SETFOCUS without
|
||||
actually being the foreground window, but this appears to get called in all cases where
|
||||
the global foreground window changes to and from this window. */
|
||||
WIN_UpdateFocus(data->window, !!wParam);
|
||||
WIN_UpdateFocus(data->window);
|
||||
WIN_CheckICMProfileChanged(data->window);
|
||||
}
|
||||
break;
|
||||
@@ -704,22 +689,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
/* Update the focus in case we changed focus to a child window and then away from the application */
|
||||
WIN_UpdateFocus(data->window, !!LOWORD(wParam));
|
||||
WIN_UpdateFocus(data->window);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
{
|
||||
/* Update the focus in case it's changing between top-level windows in the same application */
|
||||
WIN_UpdateFocus(data->window, SDL_TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
case WM_ENTERIDLE:
|
||||
{
|
||||
/* Update the focus in case it's changing between top-level windows in the same application */
|
||||
WIN_UpdateFocus(data->window, SDL_FALSE);
|
||||
WIN_UpdateFocus(data->window);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -749,17 +728,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
/* Only generate mouse events for real mouse */
|
||||
if (GetMouseMessageSource() != SDL_MOUSE_EVENT_SOURCE_TOUCH &&
|
||||
lParam != data->last_pointer_update) {
|
||||
int x = GET_X_LPARAM(lParam);
|
||||
int y = GET_Y_LPARAM(lParam);
|
||||
|
||||
WIN_ClientPointToSDL(data->window, &x, &y);
|
||||
|
||||
SDL_SendMouseMotion(data->window, 0, 0, x, y);
|
||||
SDL_SendMouseMotion(data->window, 0, 0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* don't break here, fall through to check the wParam like the button presses */
|
||||
SDL_FALLTHROUGH;
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONUP:
|
||||
@@ -1073,12 +1047,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
|
||||
SDL_GetWindowMaximumSize(data->window, &max_w, &max_h);
|
||||
|
||||
/* Convert w, h, min_w, min_h, max_w, max_h from dpi-scaled points to pixels,
|
||||
treating them as coordinates within the client area. */
|
||||
WIN_ClientPointFromSDL(data->window, &w, &h);
|
||||
WIN_ClientPointFromSDL(data->window, &min_w, &min_h);
|
||||
WIN_ClientPointFromSDL(data->window, &max_w, &max_h);
|
||||
|
||||
/* Store in min_w and min_h difference between current size and minimal
|
||||
size so we don't need to call AdjustWindowRectEx twice */
|
||||
min_w -= w;
|
||||
@@ -1099,25 +1067,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
inside their function, so I have to do it here.
|
||||
*/
|
||||
BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
|
||||
UINT dpi;
|
||||
|
||||
dpi = 96;
|
||||
size.top = 0;
|
||||
size.left = 0;
|
||||
size.bottom = h;
|
||||
size.right = w;
|
||||
|
||||
if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) {
|
||||
dpi = data->videodata->GetDpiForWindow(hwnd);
|
||||
data->videodata->AdjustWindowRectExForDpi(&size, style, menu, 0, dpi);
|
||||
} else {
|
||||
AdjustWindowRectEx(&size, style, menu, 0);
|
||||
}
|
||||
AdjustWindowRectEx(&size, style, menu, 0);
|
||||
w = size.right - size.left;
|
||||
h = size.bottom - size.top;
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_GETMINMAXINFO: max window size: %dx%d using dpi: %u", w, h, dpi);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Fix our size to the current size */
|
||||
@@ -1179,23 +1136,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
x = rect.left;
|
||||
y = rect.top;
|
||||
WIN_ScreenPointToSDL(&x, &y);
|
||||
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
|
||||
/* Convert client area width/height from pixels to dpi-scaled points */
|
||||
w = rect.right - rect.left;
|
||||
h = rect.bottom - rect.top;
|
||||
WIN_ClientPointToSDL(data->window, &w, &h);
|
||||
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_WINDOWPOSCHANGED: Windows client rect (pixels): (%d, %d) (%d x %d)\tSDL client rect (points): (%d, %d) (%d x %d) cached dpi %d, windows reported dpi %d",
|
||||
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
||||
x, y, w, h, data->scaling_dpi, data->videodata->GetDpiForWindow ? data->videodata->GetDpiForWindow(data->hwnd) : 0);
|
||||
#endif
|
||||
|
||||
/* Forces a WM_PAINT event */
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
|
||||
@@ -1216,12 +1162,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_SendWindowEvent(data->window,
|
||||
SDL_WINDOWEVENT_MINIMIZED, 0, 0);
|
||||
break;
|
||||
case SIZE_RESTORED:
|
||||
default:
|
||||
SDL_SendWindowEvent(data->window,
|
||||
SDL_WINDOWEVENT_RESTORED, 0, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1341,25 +1285,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
|
||||
#if HAVE_TPCSHRD_H
|
||||
|
||||
case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
|
||||
/* See https://msdn.microsoft.com/en-us/library/windows/desktop/bb969148(v=vs.85).aspx .
|
||||
* If we're handling our own touches, we don't want any gestures.
|
||||
* Not all of these settings are documented.
|
||||
* The use of the undocumented ones was suggested by https://github.com/bjarkeck/GCGJ/blob/master/Monogame/Windows/WinFormsGameForm.cs . */
|
||||
return TABLET_DISABLE_PRESSANDHOLD | /* disables press and hold (right-click) gesture */
|
||||
TABLET_DISABLE_PENTAPFEEDBACK | /* disables UI feedback on pen up (waves) */
|
||||
TABLET_DISABLE_PENBARRELFEEDBACK | /* disables UI feedback on pen button down (circle) */
|
||||
TABLET_DISABLE_TOUCHUIFORCEON |
|
||||
TABLET_DISABLE_TOUCHUIFORCEOFF |
|
||||
TABLET_DISABLE_TOUCHSWITCH |
|
||||
TABLET_DISABLE_FLICKS | /* disables pen flicks (back, forward, drag down, drag up) */
|
||||
TABLET_DISABLE_SMOOTHSCROLLING |
|
||||
TABLET_DISABLE_FLICKFALLBACKKEYS;
|
||||
|
||||
#endif /* HAVE_TPCSHRD_H */
|
||||
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
UINT i;
|
||||
@@ -1401,7 +1326,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam;
|
||||
w = data->window->windowed.w;
|
||||
h = data->window->windowed.h;
|
||||
WIN_ClientPointFromSDL(data->window, &w, &h);
|
||||
params->rgrc[0].right = params->rgrc[0].left + w;
|
||||
params->rgrc[0].bottom = params->rgrc[0].top + h;
|
||||
}
|
||||
@@ -1414,16 +1338,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SDL_Window *window = data->window;
|
||||
if (window->hit_test) {
|
||||
POINT winpoint;
|
||||
winpoint.x = GET_X_LPARAM(lParam);
|
||||
winpoint.y = GET_Y_LPARAM(lParam);
|
||||
POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||
if (ScreenToClient(hwnd, &winpoint)) {
|
||||
SDL_Point point;
|
||||
SDL_HitTestResult rc;
|
||||
point.x = winpoint.x;
|
||||
point.y = winpoint.y;
|
||||
WIN_ClientPointToSDL(data->window, &point.x, &point.y);
|
||||
rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
|
||||
const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
|
||||
switch (rc) {
|
||||
#define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; }
|
||||
case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION);
|
||||
@@ -1443,169 +1361,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_GETDPISCALEDSIZE:
|
||||
/* Windows 10 Creators Update+ */
|
||||
/* Documented as only being sent to windows that are per-monitor V2 DPI aware.
|
||||
|
||||
Experimentation shows it's only sent during interactive dragging, not in response to
|
||||
SetWindowPos. */
|
||||
if (data->videodata->GetDpiForWindow && data->videodata->AdjustWindowRectExForDpi) {
|
||||
/* Windows expects applications to scale their window rects linearly
|
||||
when dragging between monitors with different DPI's.
|
||||
e.g. a 100x100 window dragged to a 200% scaled monitor
|
||||
becomes 200x200.
|
||||
|
||||
For SDL, we instead want the client size to scale linearly.
|
||||
This is not the same as the window rect scaling linearly,
|
||||
because Windows doesn't scale the non-client area (titlebar etc.)
|
||||
linearly. So, we need to handle this message to request custom
|
||||
scaling. */
|
||||
|
||||
const int nextDPI = (int)wParam;
|
||||
const int prevDPI = (int)data->videodata->GetDpiForWindow(hwnd);
|
||||
SIZE *sizeInOut = (SIZE *)lParam;
|
||||
|
||||
int frame_w, frame_h;
|
||||
int query_client_w_win, query_client_h_win;
|
||||
|
||||
const DWORD style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
const BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_GETDPISCALEDSIZE: current DPI: %d potential DPI: %d input size: (%dx%d)",
|
||||
prevDPI, nextDPI, sizeInOut->cx, sizeInOut->cy);
|
||||
#endif
|
||||
|
||||
/* Subtract the window frame size that would have been used at prevDPI */
|
||||
{
|
||||
RECT rect = {0};
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
data->videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, prevDPI);
|
||||
}
|
||||
|
||||
frame_w = -rect.left + rect.right;
|
||||
frame_h = -rect.top + rect.bottom;
|
||||
|
||||
query_client_w_win = sizeInOut->cx - frame_w;
|
||||
query_client_h_win = sizeInOut->cy - frame_h;
|
||||
}
|
||||
|
||||
/* Convert to new dpi if we are using scaling.
|
||||
* Otherwise leave as pixels.
|
||||
*/
|
||||
if (data->videodata->dpi_scaling_enabled) {
|
||||
query_client_w_win = MulDiv(query_client_w_win, nextDPI, prevDPI);
|
||||
query_client_h_win = MulDiv(query_client_h_win, nextDPI, prevDPI);
|
||||
}
|
||||
|
||||
/* Add the window frame size that would be used at nextDPI */
|
||||
{
|
||||
RECT rect = {0};
|
||||
rect.right = query_client_w_win;
|
||||
rect.bottom = query_client_h_win;
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
data->videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, nextDPI);
|
||||
}
|
||||
|
||||
/* This is supposed to control the suggested rect param of WM_DPICHANGED */
|
||||
sizeInOut->cx = rect.right - rect.left;
|
||||
sizeInOut->cy = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_GETDPISCALEDSIZE: output size: (%dx%d)", sizeInOut->cx, sizeInOut->cy);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DPICHANGED:
|
||||
/* Windows 8.1+ */
|
||||
{
|
||||
const int newDPI = HIWORD(wParam);
|
||||
RECT* const suggestedRect = (RECT*)lParam;
|
||||
int w, h;
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_DPICHANGED: to %d\tsuggested rect: (%d, %d), (%dx%d)\n", newDPI,
|
||||
suggestedRect->left, suggestedRect->top, suggestedRect->right - suggestedRect->left, suggestedRect->bottom - suggestedRect->top);
|
||||
#endif
|
||||
|
||||
if (data->videodata->dpi_scaling_enabled) {
|
||||
/* Update the cached DPI value for this window */
|
||||
data->scaling_dpi = newDPI;
|
||||
|
||||
/* Send a SDL_WINDOWEVENT_SIZE_CHANGED saying that the client size (in dpi-scaled points) is unchanged.
|
||||
Renderers need to get this to know that the framebuffer size changed. */
|
||||
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SIZE_CHANGED, data->window->w, data->window->h);
|
||||
}
|
||||
|
||||
if (data->expected_resize) {
|
||||
/* This DPI change is coming from an explicit SetWindowPos call within SDL.
|
||||
Assume all call sites are calculating the DPI-aware frame correctly, so
|
||||
we don't need to do any further adjustment. */
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_DPICHANGED: Doing nothing, assuming window is already sized correctly");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Interactive user-initiated resizing/movement */
|
||||
|
||||
if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) {
|
||||
/* WM_GETDPISCALEDSIZE should have been called prior, so we can trust the given
|
||||
suggestedRect. */
|
||||
w = suggestedRect->right - suggestedRect->left;
|
||||
h = suggestedRect->bottom - suggestedRect->top;
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_DPICHANGED: using suggestedRect");
|
||||
#endif
|
||||
} else {
|
||||
/* permonitor and earlier DPI awareness: calculate the new frame w/h such that
|
||||
the client area size is maintained. */
|
||||
const DWORD style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
const BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
|
||||
|
||||
RECT rect = {0};
|
||||
rect.right = data->window->w;
|
||||
rect.bottom = data->window->h;
|
||||
|
||||
if (data->videodata->dpi_scaling_enabled) {
|
||||
/* scale client size to from points to the new DPI */
|
||||
rect.right = MulDiv(rect.right, newDPI, 96);
|
||||
rect.bottom = MulDiv(rect.bottom, newDPI, 96);
|
||||
}
|
||||
|
||||
if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) {
|
||||
AdjustWindowRectEx(&rect, style, menu, 0);
|
||||
}
|
||||
|
||||
w = rect.right - rect.left;
|
||||
h = rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
#ifdef HIGHDPI_DEBUG
|
||||
SDL_Log("WM_DPICHANGED: current SDL window size: (%dx%d)\tcalling SetWindowPos: (%d, %d), (%dx%d)\n",
|
||||
data->window->w, data->window->h,
|
||||
suggestedRect->left, suggestedRect->top, w, h);
|
||||
#endif
|
||||
|
||||
data->expected_resize = SDL_TRUE;
|
||||
SetWindowPos(hwnd,
|
||||
NULL,
|
||||
suggestedRect->left,
|
||||
suggestedRect->top,
|
||||
w,
|
||||
h,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
data->expected_resize = SDL_FALSE;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there's a window proc, assume it's going to handle messages */
|
||||
@@ -1800,14 +1555,6 @@ LPTSTR SDL_Appname = NULL;
|
||||
Uint32 SDL_Appstyle = 0;
|
||||
HINSTANCE SDL_Instance = NULL;
|
||||
|
||||
static void WIN_CleanRegisterApp(WNDCLASSEX wcex)
|
||||
{
|
||||
if (wcex.hIcon) DestroyIcon(wcex.hIcon);
|
||||
if (wcex.hIconSm) DestroyIcon(wcex.hIconSm);
|
||||
SDL_free(SDL_Appname);
|
||||
SDL_Appname = NULL;
|
||||
}
|
||||
|
||||
/* Register the class for this application */
|
||||
int
|
||||
SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
@@ -1821,16 +1568,19 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
++app_registered;
|
||||
return (0);
|
||||
}
|
||||
SDL_assert(SDL_Appname == NULL);
|
||||
if (!name) {
|
||||
if (!name && !SDL_Appname) {
|
||||
name = "SDL_app";
|
||||
#if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC)
|
||||
style = (CS_BYTEALIGNCLIENT | CS_OWNDC);
|
||||
SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC);
|
||||
#endif
|
||||
SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
|
||||
}
|
||||
|
||||
if (name) {
|
||||
SDL_Appname = WIN_UTF8ToString(name);
|
||||
SDL_Appstyle = style;
|
||||
SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
|
||||
}
|
||||
SDL_Appname = WIN_UTF8ToString(name);
|
||||
SDL_Appstyle = style;
|
||||
SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
|
||||
|
||||
/* Register the application class */
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
@@ -1861,7 +1611,6 @@ SDL_RegisterApp(const char *name, Uint32 style, void *hInst)
|
||||
}
|
||||
|
||||
if (!RegisterClassEx(&wcex)) {
|
||||
WIN_CleanRegisterApp(wcex);
|
||||
return SDL_SetError("Couldn't register application class");
|
||||
}
|
||||
|
||||
@@ -1881,14 +1630,14 @@ SDL_UnregisterApp()
|
||||
}
|
||||
--app_registered;
|
||||
if (app_registered == 0) {
|
||||
/* Ensure the icons are initialized. */
|
||||
wcex.hIcon = NULL;
|
||||
wcex.hIconSm = NULL;
|
||||
/* Check for any registered window classes. */
|
||||
if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) {
|
||||
UnregisterClass(SDL_Appname, SDL_Instance);
|
||||
if (wcex.hIcon) DestroyIcon(wcex.hIcon);
|
||||
if (wcex.hIconSm) DestroyIcon(wcex.hIconSm);
|
||||
}
|
||||
WIN_CleanRegisterApp(wcex);
|
||||
SDL_free(SDL_Appname);
|
||||
SDL_Appname = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@ static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
|
||||
static void IME_Quit(SDL_VideoData *videodata);
|
||||
static void IME_ClearComposition(SDL_VideoData *videodata);
|
||||
static SDL_bool IME_IsTextInputShown(SDL_VideoData* videodata);
|
||||
#endif /* !SDL_DISABLE_WINDOWS_IME */
|
||||
|
||||
#ifndef MAPVK_VK_TO_VSC
|
||||
@@ -64,14 +62,12 @@ WIN_InitKeyboard(_THIS)
|
||||
data->ime_hwnd_main = 0;
|
||||
data->ime_hwnd_current = 0;
|
||||
data->ime_himc = 0;
|
||||
data->ime_composition_length = 32 * sizeof(WCHAR);
|
||||
data->ime_composition = (WCHAR*)SDL_malloc(data->ime_composition_length + sizeof(WCHAR));
|
||||
data->ime_composition[0] = 0;
|
||||
data->ime_readingstring[0] = 0;
|
||||
data->ime_cursor = 0;
|
||||
|
||||
data->ime_candlist = SDL_FALSE;
|
||||
data->ime_candidates = NULL;
|
||||
SDL_memset(data->ime_candidates, 0, sizeof(data->ime_candidates));
|
||||
data->ime_candcount = 0;
|
||||
data->ime_candref = 0;
|
||||
data->ime_candsel = 0;
|
||||
@@ -276,17 +272,14 @@ WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
WIN_ShouldShowNativeUI()
|
||||
{
|
||||
return SDL_GetHintBoolean(SDL_HINT_IME_SHOW_UI, SDL_FALSE);
|
||||
}
|
||||
|
||||
#ifdef SDL_DISABLE_WINDOWS_IME
|
||||
|
||||
void WIN_ClearComposition(_THIS)
|
||||
{
|
||||
}
|
||||
|
||||
SDL_bool WIN_IsTextInputShown(_THIS)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
|
||||
@@ -356,7 +349,6 @@ DEFINE_GUID(IID_ITfThreadMgrEx, 0x3E90ADE3,0x7594
|
||||
#define SUBLANG() SUBLANGID(LANG())
|
||||
|
||||
static void IME_UpdateInputLocale(SDL_VideoData *videodata);
|
||||
static int IME_ShowCandidateList(SDL_VideoData *videodata);
|
||||
static void IME_ClearComposition(SDL_VideoData *videodata);
|
||||
static void IME_SetWindow(SDL_VideoData* videodata, HWND hwnd);
|
||||
static void IME_SetupAPI(SDL_VideoData *videodata);
|
||||
@@ -369,12 +361,6 @@ static void UILess_ReleaseSinks(SDL_VideoData *videodata);
|
||||
static void UILess_EnableUIUpdates(SDL_VideoData *videodata);
|
||||
static void UILess_DisableUIUpdates(SDL_VideoData *videodata);
|
||||
|
||||
static SDL_bool
|
||||
WIN_ShouldShowNativeUI()
|
||||
{
|
||||
return SDL_GetHintBoolean(SDL_HINT_IME_SHOW_UI, SDL_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_Init(SDL_VideoData *videodata, HWND hwnd)
|
||||
{
|
||||
@@ -601,16 +587,16 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
|
||||
char szTemp[256];
|
||||
HKL hkl = 0;
|
||||
DWORD dwLang = 0;
|
||||
SDL_assert(uIndex < sizeof(dwRet) / sizeof(dwRet[0]));
|
||||
if (uIndex >= sizeof(dwRet) / sizeof(dwRet[0]))
|
||||
return 0;
|
||||
|
||||
hkl = videodata->ime_hkl;
|
||||
if (hklprev == hkl)
|
||||
return dwRet[uIndex];
|
||||
hklprev = hkl;
|
||||
|
||||
SDL_assert(uIndex == 0);
|
||||
hklprev = hkl;
|
||||
dwLang = ((DWORD_PTR)hkl & 0xffff);
|
||||
if (videodata->ime_uiless && dwLang == LANG_CHT) {
|
||||
if (videodata->ime_uiless && LANG() == LANG_CHT) {
|
||||
dwRet[0] = IMEID_CHT_VER_VISTA;
|
||||
dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
@@ -621,11 +607,11 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
|
||||
&& hkl != CHT_HKL_HK_CANTONESE
|
||||
&& hkl != CHS_HKL) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
if (!ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1)) {
|
||||
if (ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1) <= 0) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
if (!videodata->GetReadingString) {
|
||||
#define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
|
||||
@@ -635,7 +621,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2
|
||||
&& CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) {
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
#undef LCID_INVARIANT
|
||||
dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle);
|
||||
@@ -674,7 +660,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex)
|
||||
}
|
||||
}
|
||||
dwRet[0] = dwRet[1] = 0;
|
||||
return dwRet[0];
|
||||
return dwRet[uIndex];
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -689,7 +675,7 @@ IME_SetupAPI(SDL_VideoData *videodata)
|
||||
return;
|
||||
|
||||
hkl = videodata->ime_hkl;
|
||||
if (!ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1))
|
||||
if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0)
|
||||
return;
|
||||
|
||||
hime = SDL_LoadObject(ime_file);
|
||||
@@ -726,13 +712,26 @@ IME_SetWindow(SDL_VideoData* videodata, HWND hwnd)
|
||||
static void
|
||||
IME_UpdateInputLocale(SDL_VideoData *videodata)
|
||||
{
|
||||
HKL hklnext = GetKeyboardLayout(0);
|
||||
|
||||
if (hklnext == videodata->ime_hkl)
|
||||
static HKL hklprev = 0;
|
||||
videodata->ime_hkl = GetKeyboardLayout(0);
|
||||
if (hklprev == videodata->ime_hkl)
|
||||
return;
|
||||
|
||||
videodata->ime_hkl = hklnext;
|
||||
videodata->ime_candvertical = (PRIMLANG() == LANG_KOREAN || LANG() == LANG_CHS) ? SDL_FALSE : SDL_TRUE;
|
||||
hklprev = videodata->ime_hkl;
|
||||
switch (PRIMLANG()) {
|
||||
case LANG_CHINESE:
|
||||
videodata->ime_candvertical = SDL_TRUE;
|
||||
if (SUBLANG() == SUBLANG_CHINESE_SIMPLIFIED)
|
||||
videodata->ime_candvertical = SDL_FALSE;
|
||||
|
||||
break;
|
||||
case LANG_JAPANESE:
|
||||
videodata->ime_candvertical = SDL_TRUE;
|
||||
break;
|
||||
case LANG_KOREAN:
|
||||
videodata->ime_candvertical = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -755,48 +754,18 @@ IME_ClearComposition(SDL_VideoData *videodata)
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
IME_IsTextInputShown(SDL_VideoData* videodata)
|
||||
{
|
||||
if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled)
|
||||
return SDL_FALSE;
|
||||
|
||||
return videodata->ime_uicontext != 0 ? SDL_TRUE : SDL_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
|
||||
{
|
||||
LONG length;
|
||||
DWORD dwLang = ((DWORD_PTR)videodata->ime_hkl & 0xffff);
|
||||
|
||||
length = ImmGetCompositionStringW(himc, string, NULL, 0);
|
||||
if (length > 0 && videodata->ime_composition_length < length) {
|
||||
if (videodata->ime_composition != NULL)
|
||||
SDL_free(videodata->ime_composition);
|
||||
|
||||
videodata->ime_composition = (WCHAR*)SDL_malloc(length + sizeof(WCHAR));
|
||||
videodata->ime_composition_length = length;
|
||||
}
|
||||
|
||||
length = ImmGetCompositionStringW(
|
||||
himc,
|
||||
string,
|
||||
videodata->ime_composition,
|
||||
videodata->ime_composition_length
|
||||
);
|
||||
|
||||
LONG length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, sizeof(videodata->ime_composition) - sizeof(videodata->ime_composition[0]));
|
||||
if (length < 0)
|
||||
length = 0;
|
||||
|
||||
length /= sizeof(WCHAR);
|
||||
length /= sizeof(videodata->ime_composition[0]);
|
||||
videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0));
|
||||
if ((dwLang == LANG_CHT || dwLang == LANG_CHS) &&
|
||||
videodata->ime_cursor > 0 &&
|
||||
videodata->ime_cursor < (int)(videodata->ime_composition_length / sizeof(WCHAR)) &&
|
||||
(videodata->ime_composition[0] == 0x3000 || videodata->ime_composition[0] == 0x0020)) {
|
||||
// Traditional Chinese IMEs add a placeholder U+3000
|
||||
// Simplified Chinese IMEs seem to add a placeholder U+0020 sometimes
|
||||
if (videodata->ime_cursor > 0 &&
|
||||
videodata->ime_cursor < SDL_arraysize(videodata->ime_composition) &&
|
||||
videodata->ime_composition[videodata->ime_cursor] == 0x3000) {
|
||||
int i;
|
||||
for (i = videodata->ime_cursor + 1; i < length; ++i)
|
||||
videodata->ime_composition[i - 1] = videodata->ime_composition[i];
|
||||
@@ -805,39 +774,6 @@ IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string)
|
||||
}
|
||||
|
||||
videodata->ime_composition[length] = 0;
|
||||
|
||||
// Get the correct caret position if we've selected a candidate from the candidate window
|
||||
if (videodata->ime_cursor == 0 && length > 0) {
|
||||
Sint32 start = 0;
|
||||
Sint32 end = 0;
|
||||
|
||||
length = ImmGetCompositionStringW(himc, GCS_COMPATTR, NULL, 0);
|
||||
if (length > 0) {
|
||||
Uint8* attributes = (Uint8*)SDL_malloc(length + sizeof(WCHAR));
|
||||
ImmGetCompositionString(himc, GCS_COMPATTR, attributes, length);
|
||||
|
||||
for (start = 0; start < length; ++start) {
|
||||
if (attributes[start] == ATTR_TARGET_CONVERTED ||
|
||||
attributes[start] == ATTR_TARGET_NOTCONVERTED)
|
||||
break;
|
||||
}
|
||||
|
||||
for (end = start; end < length; ++end) {
|
||||
if (attributes[end] != ATTR_TARGET_CONVERTED &&
|
||||
attributes[end] != ATTR_TARGET_NOTCONVERTED)
|
||||
break;
|
||||
}
|
||||
|
||||
if (start == length) {
|
||||
start = 0;
|
||||
end = length;
|
||||
}
|
||||
|
||||
SDL_free(attributes);
|
||||
}
|
||||
|
||||
videodata->ime_cursor = end;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -856,66 +792,48 @@ IME_SendInputEvent(SDL_VideoData *videodata)
|
||||
static void
|
||||
IME_SendEditingEvent(SDL_VideoData *videodata)
|
||||
{
|
||||
char *s = NULL;
|
||||
WCHAR *buffer = NULL;
|
||||
size_t size = videodata->ime_composition_length;
|
||||
char *s = 0;
|
||||
WCHAR buffer[SDL_TEXTEDITINGEVENT_TEXT_SIZE];
|
||||
const size_t size = SDL_arraysize(buffer);
|
||||
buffer[0] = 0;
|
||||
if (videodata->ime_readingstring[0]) {
|
||||
size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor);
|
||||
|
||||
size += sizeof(videodata->ime_readingstring);
|
||||
buffer = (WCHAR*)SDL_malloc(size + sizeof(WCHAR));
|
||||
buffer[0] = 0;
|
||||
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, len + 1);
|
||||
SDL_wcslcat(buffer, videodata->ime_readingstring, size);
|
||||
SDL_wcslcat(buffer, &videodata->ime_composition[len], size);
|
||||
}
|
||||
else {
|
||||
buffer = (WCHAR*)SDL_malloc(size + sizeof(WCHAR));
|
||||
buffer[0] = 0;
|
||||
SDL_wcslcpy(buffer, videodata->ime_composition, size);
|
||||
}
|
||||
|
||||
s = WIN_StringToUTF8W(buffer);
|
||||
SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0);
|
||||
SDL_free(s);
|
||||
SDL_free(buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate)
|
||||
{
|
||||
LPWSTR dst = &videodata->ime_candidates[i * MAX_CANDLENGTH];
|
||||
LPWSTR end = &dst[MAX_CANDLENGTH - 1];
|
||||
SDL_COMPILE_TIME_ASSERT(IME_CANDIDATE_INDEXING_REQUIRES, MAX_CANDLIST == 10);
|
||||
LPWSTR dst = videodata->ime_candidates[i];
|
||||
*dst++ = (WCHAR)(TEXT('0') + ((i + videodata->ime_candlistindexbase) % 10));
|
||||
if (videodata->ime_candvertical)
|
||||
*dst++ = TEXT(' ');
|
||||
|
||||
while (*candidate && dst < end)
|
||||
while (*candidate && (SDL_arraysize(videodata->ime_candidates[i]) > (dst - videodata->ime_candidates[i])))
|
||||
*dst++ = *candidate++;
|
||||
|
||||
*dst = (WCHAR)'\0';
|
||||
}
|
||||
|
||||
static void
|
||||
IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata)
|
||||
IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata)
|
||||
{
|
||||
HIMC himc;
|
||||
DWORD size;
|
||||
LPCANDIDATELIST cand_list;
|
||||
|
||||
if (IME_ShowCandidateList(videodata) < 0)
|
||||
return;
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (!himc)
|
||||
return;
|
||||
size = ImmGetCandidateListW(himc, 0, 0, 0);
|
||||
if (size != 0) {
|
||||
LPCANDIDATELIST cand_list = 0;
|
||||
DWORD size = ImmGetCandidateListW(himc, 0, 0, 0);
|
||||
if (size) {
|
||||
cand_list = (LPCANDIDATELIST)SDL_malloc(size);
|
||||
if (cand_list != NULL) {
|
||||
if (cand_list) {
|
||||
size = ImmGetCandidateListW(himc, 0, cand_list, size);
|
||||
if (size != 0) {
|
||||
if (size) {
|
||||
UINT i, j;
|
||||
UINT page_start = 0;
|
||||
videodata->ime_candsel = cand_list->dwSelection;
|
||||
@@ -940,44 +858,34 @@ IME_GetCandidateList(HWND hwnd, SDL_VideoData *videodata)
|
||||
}
|
||||
videodata->ime_candpgsize = i - page_start;
|
||||
} else {
|
||||
videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize == 0 ? MAX_CANDLIST : cand_list->dwPageSize, MAX_CANDLIST);
|
||||
page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
|
||||
videodata->ime_candpgsize = SDL_min(cand_list->dwPageSize, MAX_CANDLIST);
|
||||
if (videodata->ime_candpgsize > 0) {
|
||||
page_start = (cand_list->dwSelection / videodata->ime_candpgsize) * videodata->ime_candpgsize;
|
||||
} else {
|
||||
page_start = 0;
|
||||
}
|
||||
}
|
||||
for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < videodata->ime_candpgsize; i++, j++) {
|
||||
SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
|
||||
for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
|
||||
LPCWSTR candidate = (LPCWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i]);
|
||||
IME_AddCandidate(videodata, j, candidate);
|
||||
}
|
||||
// TODO: why was this necessary? check ime_candvertical instead? PRIMLANG() never equals LANG_CHT !
|
||||
//if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0)))
|
||||
// videodata->ime_candsel = -1;
|
||||
if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0)))
|
||||
videodata->ime_candsel = -1;
|
||||
|
||||
}
|
||||
SDL_free(cand_list);
|
||||
}
|
||||
}
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
}
|
||||
|
||||
static int
|
||||
static void
|
||||
IME_ShowCandidateList(SDL_VideoData *videodata)
|
||||
{
|
||||
void *candidates;
|
||||
|
||||
videodata->ime_candcount = 0;
|
||||
candidates = SDL_realloc(videodata->ime_candidates, MAX_CANDSIZE);
|
||||
if (candidates != NULL)
|
||||
videodata->ime_candidates = (WCHAR *)candidates;
|
||||
|
||||
if (videodata->ime_candidates == NULL)
|
||||
return -1;
|
||||
|
||||
SDL_memset(videodata->ime_candidates, 0, MAX_CANDSIZE);
|
||||
|
||||
videodata->ime_dirty = SDL_TRUE;
|
||||
videodata->ime_candlist = SDL_TRUE;
|
||||
IME_DestroyTextures(videodata);
|
||||
IME_SendEditingEvent(videodata);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -998,15 +906,6 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
||||
return SDL_FALSE;
|
||||
|
||||
switch (msg) {
|
||||
case WM_KEYDOWN:
|
||||
if (wParam == VK_PROCESSKEY)
|
||||
{
|
||||
videodata->ime_uicontext = 1;
|
||||
trap = SDL_TRUE;
|
||||
}
|
||||
else
|
||||
videodata->ime_uicontext = 0;
|
||||
break;
|
||||
case WM_INPUTLANGCHANGE:
|
||||
IME_InputLangChanged(videodata);
|
||||
break;
|
||||
@@ -1015,17 +914,14 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
||||
*lParam = 0;
|
||||
}
|
||||
break;
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
videodata->ime_suppress_endcomposition_event = SDL_FALSE;
|
||||
case WM_IME_STARTCOMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
break;
|
||||
case WM_IME_COMPOSITION:
|
||||
trap = SDL_TRUE;
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (*lParam & GCS_RESULTSTR) {
|
||||
videodata->ime_suppress_endcomposition_event = SDL_TRUE;
|
||||
IME_GetCompositionString(videodata, himc, GCS_RESULTSTR);
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
IME_SendInputEvent(videodata);
|
||||
}
|
||||
if (*lParam & GCS_COMPSTR) {
|
||||
@@ -1038,13 +934,10 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
break;
|
||||
case WM_IME_ENDCOMPOSITION:
|
||||
videodata->ime_uicontext = 0;
|
||||
videodata->ime_composition[0] = 0;
|
||||
videodata->ime_readingstring[0] = 0;
|
||||
videodata->ime_cursor = 0;
|
||||
if (videodata->ime_suppress_endcomposition_event == SDL_FALSE)
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
videodata->ime_suppress_endcomposition_event = SDL_FALSE;
|
||||
SDL_SendEditingText("", 0, 0);
|
||||
break;
|
||||
case WM_IME_NOTIFY:
|
||||
switch (wParam) {
|
||||
@@ -1058,12 +951,16 @@ IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoD
|
||||
break;
|
||||
|
||||
trap = SDL_TRUE;
|
||||
videodata->ime_uicontext = 1;
|
||||
IME_GetCandidateList(hwnd, videodata);
|
||||
IME_ShowCandidateList(videodata);
|
||||
himc = ImmGetContext(hwnd);
|
||||
if (!himc)
|
||||
break;
|
||||
|
||||
IME_GetCandidateList(himc, videodata);
|
||||
ImmReleaseContext(hwnd, himc);
|
||||
break;
|
||||
case IMN_CLOSECANDIDATE:
|
||||
trap = SDL_TRUE;
|
||||
videodata->ime_uicontext = 0;
|
||||
IME_HideCandidateList(videodata);
|
||||
break;
|
||||
case IMN_PRIVATE:
|
||||
@@ -1110,8 +1007,7 @@ IME_CloseCandidateList(SDL_VideoData *videodata)
|
||||
{
|
||||
IME_HideCandidateList(videodata);
|
||||
videodata->ime_candcount = 0;
|
||||
SDL_free(videodata->ime_candidates);
|
||||
videodata->ime_candidates = NULL;
|
||||
SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1124,16 +1020,13 @@ UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pca
|
||||
DWORD pgstart = 0;
|
||||
DWORD pgsize = 0;
|
||||
UINT i, j;
|
||||
|
||||
if (IME_ShowCandidateList(videodata) < 0)
|
||||
return;
|
||||
|
||||
pcandlist->lpVtbl->GetSelection(pcandlist, &selection);
|
||||
pcandlist->lpVtbl->GetCount(pcandlist, &count);
|
||||
pcandlist->lpVtbl->GetCurrentPage(pcandlist, &page);
|
||||
|
||||
videodata->ime_candsel = selection;
|
||||
videodata->ime_candcount = count;
|
||||
IME_ShowCandidateList(videodata);
|
||||
|
||||
pcandlist->lpVtbl->GetPageIndex(pcandlist, 0, 0, &pgcount);
|
||||
if (pgcount > 0) {
|
||||
@@ -1151,6 +1044,8 @@ UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pca
|
||||
}
|
||||
videodata->ime_candpgsize = SDL_min(pgsize, MAX_CANDLIST);
|
||||
videodata->ime_candsel = videodata->ime_candsel - pgstart;
|
||||
|
||||
SDL_memset(videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
|
||||
for (i = pgstart, j = 0; (DWORD)i < count && j < videodata->ime_candpgsize; i++, j++) {
|
||||
BSTR bstr;
|
||||
if (SUCCEEDED(pcandlist->lpVtbl->GetString(pcandlist, i, &bstr))) {
|
||||
@@ -1160,9 +1055,8 @@ UILess_GetCandidateList(SDL_VideoData *videodata, ITfCandidateListUIElement *pca
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: why was this necessary? check ime_candvertical instead?
|
||||
//if (PRIMLANG() == LANG_KOREAN)
|
||||
// videodata->ime_candsel = -1;
|
||||
if (PRIMLANG() == LANG_KOREAN)
|
||||
videodata->ime_candsel = -1;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) TSFSink_AddRef(TSFSink *sink)
|
||||
@@ -1579,7 +1473,7 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||
SelectObject(hdc, font);
|
||||
|
||||
for (i = 0; i < candcount; ++i) {
|
||||
const WCHAR *s = &videodata->ime_candidates[i * MAX_CANDLENGTH];
|
||||
const WCHAR *s = videodata->ime_candidates[i];
|
||||
if (!*s)
|
||||
break;
|
||||
|
||||
@@ -1641,7 +1535,7 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
|
||||
for (i = 0; i < candcount; ++i) {
|
||||
const WCHAR *s = &videodata->ime_candidates[i * MAX_CANDLENGTH];
|
||||
const WCHAR *s = videodata->ime_candidates[i];
|
||||
int left, top, right, bottom;
|
||||
if (!*s)
|
||||
break;
|
||||
@@ -1711,18 +1605,6 @@ void IME_Present(SDL_VideoData *videodata)
|
||||
/* FIXME: Need to show the IME bitmap */
|
||||
}
|
||||
|
||||
SDL_bool WIN_IsTextInputShown(_THIS)
|
||||
{
|
||||
SDL_VideoData* videodata = (SDL_VideoData*)_this->driverdata;
|
||||
return IME_IsTextInputShown(videodata);
|
||||
}
|
||||
|
||||
void WIN_ClearComposition(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
|
||||
IME_ClearComposition(videodata);
|
||||
}
|
||||
|
||||
#endif /* SDL_DISABLE_WINDOWS_IME */
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WINDOWS */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user