early-access version 2835

This commit is contained in:
pineappleEA
2022-07-15 04:00:50 +02:00
parent 5c0ee5eba6
commit 0e7aef7e36
1173 changed files with 55320 additions and 18881 deletions

View File

@@ -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
@@ -92,10 +92,6 @@
#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))
@@ -1161,13 +1157,13 @@ RLEAlphaSurface(SDL_Surface * surface)
ADD_OPAQUE_COUNTS(max_opaque_run, 0);
skip -= max_opaque_run;
}
len = MIN(run, max_opaque_run);
len = SDL_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 = MIN(run, max_opaque_run);
len = SDL_min(run, max_opaque_run);
ADD_OPAQUE_COUNTS(0, len);
dst += copy_opaque(dst, src + runstart, len, sf, df);
runstart += len;
@@ -1195,13 +1191,13 @@ RLEAlphaSurface(SDL_Surface * surface)
ADD_TRANSL_COUNTS(max_transl_run, 0);
skip -= max_transl_run;
}
len = MIN(run, max_transl_run);
len = SDL_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 = MIN(run, max_transl_run);
len = SDL_min(run, max_transl_run);
ADD_TRANSL_COUNTS(0, len);
dst += copy_transl(dst, src + runstart, len, sf, df);
runstart += len;
@@ -1222,9 +1218,13 @@ RLEAlphaSurface(SDL_Surface * surface)
/* Now that we have it encoded, release the original pixels */
if (!(surface->flags & SDL_PREALLOC)) {
SDL_SIMDFree(surface->pixels);
if (surface->flags & SDL_SIMD_ALIGNED) {
SDL_SIMDFree(surface->pixels);
surface->flags &= ~SDL_SIMD_ALIGNED;
} else {
SDL_free(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 = MIN(run, maxn);
len = SDL_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 = MIN(run, maxn);
len = SDL_min(run, maxn);
ADD_COUNTS(0, len);
SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
dst += len * bpp;
@@ -1386,9 +1386,13 @@ RLEColorkeySurface(SDL_Surface * surface)
/* Now that we have it encoded, release the original pixels */
if (!(surface->flags & SDL_PREALLOC)) {
SDL_SIMDFree(surface->pixels);
if (surface->flags & SDL_SIMD_ALIGNED) {
SDL_SIMDFree(surface->pixels);
surface->flags &= ~SDL_SIMD_ALIGNED;
} else {
SDL_free(surface->pixels);
}
surface->pixels = NULL;
surface->flags &= ~SDL_SIMD_ALIGNED;
}
/* reallocate the buffer to release unused memory */

View File

@@ -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

View File

@@ -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
@@ -231,9 +231,7 @@ 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) {
/* Greater than 8 bits per channel not supported yet */
SDL_InvalidateMap(map);
return SDL_SetError("Blit combination not supported");
blit = SDL_Blit_Slow;
}
#if SDL_HAVE_BLIT_0
else if (surface->format->BitsPerPixel < 8 &&

View File

@@ -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
@@ -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; \
} \

View File

@@ -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
@@ -452,11 +452,94 @@ 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;

View File

@@ -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
@@ -50,7 +50,7 @@ Blit1to1(SDL_BlitInfo * info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst = map[*src];
@@ -58,7 +58,7 @@ Blit1to1(SDL_BlitInfo * info)
dst++;
src++;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*(Uint16 *)dst = map[*src++];
dst += 2;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -210,7 +210,7 @@ Blit1to3(SDL_BlitInfo * info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
o = *src * 4;
@@ -221,7 +221,7 @@ Blit1to3(SDL_BlitInfo * info)
src++;
dst += 3;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
*dst++ = map[*src++];
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -309,13 +309,13 @@ Blit1to1Key(SDL_BlitInfo * info)
src++;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -325,7 +325,7 @@ Blit1to1Key(SDL_BlitInfo * info)
src++;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -348,7 +348,7 @@ Blit1to2Key(SDL_BlitInfo * info)
dstskip /= 2;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -358,7 +358,7 @@ Blit1to2Key(SDL_BlitInfo * info)
dstp++;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dstp += dstskip;
}
@@ -378,7 +378,7 @@ Blit1to3Key(SDL_BlitInfo * info)
int o;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -391,7 +391,7 @@ Blit1to3Key(SDL_BlitInfo * info)
dst += 3;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -413,7 +413,7 @@ Blit1to4Key(SDL_BlitInfo * info)
dstskip /= 4;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -423,7 +423,7 @@ Blit1to4Key(SDL_BlitInfo * info)
dstp++;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dstp += dstskip;
}
@@ -450,7 +450,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
dstbpp = dstfmt->BytesPerPixel;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
{
sR = srcpal[*src].r;
@@ -463,7 +463,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
dst += dstbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -491,7 +491,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
dstbpp = dstfmt->BytesPerPixel;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( *src != ckey ) {
@@ -506,7 +506,7 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
dst += dstbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}

View File

@@ -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
@@ -47,7 +47,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
const unsigned A = info->a;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -93,7 +93,7 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info)
unsigned dR, dG, dB;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -141,7 +141,7 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
const unsigned A = info->a;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -348,7 +348,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
multmask2 = 0x00FF00FF00FF00FFULL;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 alpha = *srcp & amask;
if (alpha == 0) {
@@ -382,7 +382,7 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info)
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -467,14 +467,14 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
int dstskip = info->dst_skip >> 2;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
+ (s & d & 0x00010101)) | 0xff000000;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -500,7 +500,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
Uint32 d1;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
s = *srcp;
d = *dstp;
@@ -515,7 +515,7 @@ BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -534,7 +534,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
int dstskip = info->dst_skip >> 2;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 dalpha;
Uint32 d;
@@ -569,7 +569,7 @@ BlitRGBtoRGBPixelAlpha(SDL_BlitInfo * info)
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -587,7 +587,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
int dstskip = info->dst_skip >> 2;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 dalpha;
Uint32 d;
@@ -624,7 +624,7 @@ BlitRGBtoBGRPixelAlpha(SDL_BlitInfo * info)
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -654,7 +654,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
multmask2 = 0x00FF00FF00FF00FFULL;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
Uint32 alpha;
@@ -694,7 +694,7 @@ BlitRGBtoRGBPixelAlphaMMX3DNOW(SDL_BlitInfo * info)
++srcp;
++dstp;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP_124(
{
s = *srcp++;
@@ -944,7 +944,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
srcp += 4;
dstp += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP_124(
{
s = *srcp++;
@@ -1082,7 +1082,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
srcp += 4;
dstp += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -1109,7 +1109,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
alpha >>= 3; /* downscale alpha to 5 bits */
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -1148,7 +1148,7 @@ Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
alpha >>= 3; /* downscale alpha to 5 bits */
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -1182,7 +1182,7 @@ BlitARGBto565PixelAlpha(SDL_BlitInfo * info)
int dstskip = info->dst_skip >> 1;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -1228,7 +1228,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
int dstskip = info->dst_skip >> 1;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
unsigned alpha;
Uint32 s = *srcp;
@@ -1257,7 +1257,7 @@ BlitARGBto555PixelAlpha(SDL_BlitInfo * info)
srcp++;
dstp++;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
srcp += srcskip;
dstp += dstskip;
}
@@ -1284,7 +1284,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
if (sA) {
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -1323,7 +1323,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
const unsigned sA = info->a;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
{
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
@@ -1337,7 +1337,7 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
dst += dstbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -1366,7 +1366,7 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info)
dstbpp = dstfmt->BytesPerPixel;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}

View File

@@ -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
@@ -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 */
const static const struct SDL_PixelFormat default_pixel_format = {
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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB888_RGB332(*dst++, *src);
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB888_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB101010_RGB332(*dst++, *src);
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB101010_RGB332(Pixel, *src);
*dst++ = map[Pixel];
++src;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB888_RGB555(dst, src);
++src;
++dst;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -1361,13 +1361,13 @@ Blit_RGB888_RGB565(SDL_BlitInfo * info)
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
RGB888_RGB565(dst, src);
++src;
++dst;
, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst++ = RGB565_32(dst, src, map);
src += 2;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst = *src | mask;
@@ -2096,7 +2096,7 @@ Blit_RGB555_ARGB1555(SDL_BlitInfo * info)
++src;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst = *src | mask;
@@ -2222,7 +2222,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
++src;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst = *src & mask;
@@ -2239,7 +2239,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
++src;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
*dst = *src;
@@ -2267,7 +2267,7 @@ Blit4to4CopyAlpha(SDL_BlitInfo * info)
++src;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
dst[0] = src[p0];
@@ -2391,7 +2391,7 @@ BlitNtoN(SDL_BlitInfo * info)
src += 4;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
dst[0] = src[p0];
@@ -2417,7 +2417,7 @@ BlitNtoN(SDL_BlitInfo * info)
src += 4;
dst += 3;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
dst[0] = src[p0];
@@ -2445,7 +2445,7 @@ BlitNtoN(SDL_BlitInfo * info)
src += 3;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2454,7 +2454,7 @@ BlitNtoN(SDL_BlitInfo * info)
#endif
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint32 Pixel;
@@ -2467,7 +2467,7 @@ BlitNtoN(SDL_BlitInfo * info)
src += srcbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
dst[0] = src[p0];
@@ -2509,7 +2509,7 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info)
src += 4;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2554,7 +2554,7 @@ BlitNto1Key(SDL_BlitInfo * info)
if (palmap == NULL) {
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
@@ -2569,13 +2569,13 @@ BlitNto1Key(SDL_BlitInfo * info)
src += srcbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
} else {
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel,
@@ -2590,7 +2590,7 @@ BlitNto1Key(SDL_BlitInfo * info)
src += srcbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2615,7 +2615,7 @@ Blit2to2Key(SDL_BlitInfo * info)
ckey &= rgbmask;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ( (*srcp & rgbmask) != ckey ) {
@@ -2625,7 +2625,7 @@ Blit2to2Key(SDL_BlitInfo * info)
srcp++;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ((*src32 & rgbmask) != ckey) {
@@ -2671,7 +2671,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
++dst32;
++src32;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ((*src32 & rgbmask) != ckey) {
@@ -2689,7 +2689,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
++dst32;
++src32;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint32 *src32 = (Uint32*)src;
@@ -2723,7 +2723,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
src += 4;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2746,7 +2746,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
#endif
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint8 s0 = src[0];
@@ -2762,7 +2762,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
dst += 3;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2784,7 +2784,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
#endif
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint8 s0 = src[0];
@@ -2800,7 +2800,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
dst += 3;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint32 *src32 = (Uint32*)src;
@@ -2828,7 +2828,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
src += 4;
dst += 3;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint8 s0 = src[0];
@@ -2872,7 +2872,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
src += 3;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2881,7 +2881,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
#endif
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint32 Pixel;
@@ -2897,7 +2897,7 @@ BlitNtoNKey(SDL_BlitInfo * info)
src += srcbpp;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
if ((*src32 & rgbmask) != ckey) {
@@ -2948,7 +2948,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
++dst32;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Uint32 *src32 = (Uint32*)src;
@@ -2980,7 +2980,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
src += 4;
dst += 4;
}, width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -2989,7 +2989,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
#endif
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -3022,7 +3022,7 @@ Blit2101010toN(SDL_BlitInfo * info)
unsigned sR, sG, sB, sA;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
{
Pixel = *(Uint32 *)src;
@@ -3032,7 +3032,7 @@ Blit2101010toN(SDL_BlitInfo * info)
src += 4;
},
width);
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}
@@ -3054,7 +3054,7 @@ BlitNto2101010(SDL_BlitInfo * info)
unsigned sR, sG, sB, sA;
while (height--) {
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format on */
src += srcskip;
dst += dstskip;
}

View File

@@ -1,7 +1,7 @@
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
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
@@ -23,7 +23,7 @@
#if SDL_HAVE_BLIT_AUTO
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format off */
#include "SDL_video.h"
#include "SDL_blit.h"
@@ -756,7 +756,6 @@ 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;
@@ -776,8 +775,7 @@ 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;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
pixel = (A << 24) | (R << 16) | (G << 8) | B;
pixel |= (A << 24);
*dst = pixel;
posx += incx;
++dst;
@@ -2232,7 +2230,6 @@ 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;
@@ -2252,8 +2249,7 @@ 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;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
pixel = (R << 16) | (G << 8) | B;
pixel &= 0xFFFFFF;
*dst = pixel;
posx += incx;
++dst;
@@ -3395,7 +3391,6 @@ 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;
@@ -3415,8 +3410,7 @@ 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;
R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8);
pixel = (R << 16) | (G << 8) | B;
pixel >>= 8;
*dst = pixel;
posx += incx;
++dst;
@@ -4163,7 +4157,6 @@ 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;
@@ -4183,8 +4176,7 @@ 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;
R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
pixel = (A << 24) | (R << 16) | (G << 8) | B;
pixel = (pixel >> 8) | (pixel << 24);
*dst = pixel;
posx += incx;
++dst;
@@ -4947,7 +4939,6 @@ 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;
@@ -4967,8 +4958,7 @@ 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;
B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
pixel = (B << 16) | (G << 8) | R;
pixel &= 0xFFFFFF;
*dst = pixel;
posx += incx;
++dst;
@@ -6115,7 +6105,6 @@ 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;
@@ -6135,8 +6124,7 @@ 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;
B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8);
pixel = (B << 16) | (G << 8) | R;
pixel >>= 8;
*dst = pixel;
posx += incx;
++dst;
@@ -7026,7 +7014,7 @@ SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
{ 0, 0, 0, 0, NULL }
};
/* *INDENT-ON* */
/* *INDENT-ON* */ /* clang-format on */
#endif /* SDL_HAVE_BLIT_AUTO */

View File

@@ -1,7 +1,7 @@
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -24,6 +24,21 @@
#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.
*/
@@ -46,9 +61,14 @@ 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 */
@@ -62,14 +82,18 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
while (n--) {
srcx = posx >> 16;
src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
if (src_fmt->Amask) {
DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
srcB, srcA);
} else {
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
srcB);
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;
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
srcpixel = *((Uint32 *)(src));
RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA);
}
if (flags & SDL_COPY_COLORKEY) {
/* srcpixel isn't set for 24 bpp */
if (srcbpp == 3) {
@@ -82,13 +106,15 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
continue;
}
}
if (dst_fmt->Amask) {
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
dstB, dstA);
} else {
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
dstB);
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;
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
dstpixel = *((Uint32 *)(dst));
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
}
if (flags & SDL_COPY_MODULATE_COLOR) {
@@ -151,10 +177,15 @@ SDL_Blit_Slow(SDL_BlitInfo * info)
dstA = 255;
break;
}
if (dst_fmt->Amask) {
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
} else {
} 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;
}
posx += incx;
dst += dstbpp;

View File

@@ -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

View File

@@ -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
@@ -53,7 +53,7 @@
#define LCS_WINDOWS_COLOR_SPACE 0x57696E20
#endif
static int readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
static SDL_bool 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 int 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 1;
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
/*
| 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 1;
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
if (isRle8) { /* 256-color bitmap, compressed */
do {
COPY_PIXEL(pixel);
@@ -98,18 +98,18 @@ static int 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 1;
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
switch (ch) {
case 0: /* end of line */
ofs = 0;
bits -= pitch; /* go to previous */
break;
case 1: /* end of bitmap */
return 0; /* success! */
return SDL_FALSE; /* success! */
case 2: /* delta */
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
ofs += ch;
if (!SDL_RWread(src, &ch, 1, 1)) return 1;
if (!SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
bits -= (ch * pitch);
break;
default: /* no compression */
@@ -117,14 +117,14 @@ static int readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
needsPad = (ch & 1);
do {
Uint8 pixel;
if (!SDL_RWread(src, &pixel, 1, 1)) return 1;
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
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 1;
if (!SDL_RWread(src, &pixel, 1, 1)) return SDL_TRUE;
COPY_PIXEL(pixel >> 4);
if (!--ch) break;
COPY_PIXEL(pixel & 0x0F);
@@ -132,7 +132,7 @@ static int readRlePixels(SDL_Surface * surface, SDL_RWops * src, int isRle8)
}
}
/* pad at even boundary */
if (needsPad && !SDL_RWread(src, &ch, 1, 1)) return 1;
if (needsPad && !SDL_RWread(src, &ch, 1, 1)) return SDL_TRUE;
break;
}
}
@@ -213,12 +213,17 @@ 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);
@@ -407,6 +412,12 @@ 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;
}
@@ -451,8 +462,8 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
goto done;
}
if ((biCompression == BI_RLE4) || (biCompression == BI_RLE8)) {
was_error = (SDL_bool)readRlePixels(surface, src, biCompression == BI_RLE8);
if (was_error) SDL_SetError("Error reading from BMP");
was_error = readRlePixels(surface, src, biCompression == BI_RLE8);
if (was_error) SDL_Error(SDL_EFREAD);
goto done;
}
top = (Uint8 *)surface->pixels;
@@ -484,7 +495,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_SetError("Error reading from BMP");
SDL_Error(SDL_EFREAD);
was_error = SDL_TRUE;
goto done;
}

View File

@@ -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

View File

@@ -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
@@ -27,7 +27,6 @@
#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
@@ -99,7 +98,7 @@
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
#endif /* SDL_VIDEO_DRIVER_RPI */
#if SDL_VIDEO_OPENGL
#if SDL_VIDEO_OPENGL && !SDL_VIDEO_VITA_PVR_OGL
#include "SDL_opengl.h"
#endif
@@ -115,7 +114,7 @@
_this->egl_data->NAME = (void *)NAME;
#else
#define LOAD_FUNC(NAME) \
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
_this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \
if (!_this->egl_data->NAME) \
{ \
return SDL_SetError("Could not retrieve EGL function " #NAME); \
@@ -251,12 +250,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->egl_dll_handle, proc);
retval = SDL_LoadFunction(_this->egl_data->opengl_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->egl_dll_handle, procname);
retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, procname);
}
}
#endif
@@ -281,14 +280,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;
@@ -298,7 +297,7 @@ SDL_EGL_UnloadLibrary(_THIS)
int
SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
{
void *dll_handle = NULL, *egl_dll_handle = NULL; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */
void *egl_dll_handle = NULL, *opengl_dll_handle = NULL;
const char *path = NULL;
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
const char *d3dcompiler;
@@ -350,32 +349,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) {
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
}
if (egl_dll_handle == NULL) {
if (opengl_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;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_OGL_ES2
if (egl_dll_handle == NULL && !vc4) {
if (opengl_dll_handle == NULL && !vc4) {
path = ALT_OGL_ES2;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
}
#endif
} else {
path = DEFAULT_OGL_ES;
egl_dll_handle = SDL_LoadObject(path);
if (egl_dll_handle == NULL) {
opengl_dll_handle = SDL_LoadObject(path);
if (opengl_dll_handle == NULL) {
path = DEFAULT_OGL_ES_PVR;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
}
#ifdef ALT_OGL_ES2
if (egl_dll_handle == NULL && !vc4) {
if (opengl_dll_handle == NULL && !vc4) {
path = ALT_OGL_ES2;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
}
#endif
}
@@ -383,47 +382,47 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
#ifdef DEFAULT_OGL
else {
path = DEFAULT_OGL;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_OGL
if (egl_dll_handle == NULL) {
if (opengl_dll_handle == NULL) {
path = ALT_OGL;
egl_dll_handle = SDL_LoadObject(path);
opengl_dll_handle = SDL_LoadObject(path);
}
#endif
}
#endif
}
_this->egl_data->egl_dll_handle = egl_dll_handle;
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
if (egl_dll_handle == NULL) {
if (opengl_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) {
dll_handle = SDL_LoadObject(egl_path);
egl_dll_handle = SDL_LoadObject(egl_path);
}
/* Try loading a EGL symbol, if it does not work try the default library paths */
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
if (dll_handle != NULL) {
SDL_UnloadObject(dll_handle);
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle != NULL) {
SDL_UnloadObject(egl_dll_handle);
}
path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
if (path == NULL) {
path = DEFAULT_EGL;
}
dll_handle = SDL_LoadObject(path);
egl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_EGL
if (dll_handle == NULL && !vc4) {
if (egl_dll_handle == NULL && !vc4) {
path = ALT_EGL;
dll_handle = SDL_LoadObject(path);
egl_dll_handle = SDL_LoadObject(path);
}
#endif
if (dll_handle == NULL || SDL_LoadFunction(dll_handle, "eglChooseConfig") == NULL) {
if (dll_handle != NULL) {
SDL_UnloadObject(dll_handle);
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle != NULL) {
SDL_UnloadObject(egl_dll_handle);
}
return SDL_SetError("Could not load EGL library");
}
@@ -431,9 +430,9 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path)
}
#endif
_this->egl_data->dll_handle = dll_handle;
#if SDL_VIDEO_DRIVER_VITA
_this->egl_data->egl_dll_handle = egl_dll_handle;
#if SDL_VIDEO_DRIVER_VITA
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
#endif
/* Load new function pointers */
@@ -530,7 +529,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) {
if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) {
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
}
if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
@@ -909,8 +908,7 @@ SDL_EGL_ChooseConfig(_THIS)
int ret;
if (!_this->egl_data) {
/* The EGL library wasn't loaded, SDL_GetError() should have info */
return -1;
return SDL_SetError("EGL not initialized");
}
/* Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG */
@@ -943,7 +941,7 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
SDL_bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES);
if (!_this->egl_data) {
/* The EGL library wasn't loaded, SDL_GetError() should have info */
SDL_SetError("EGL not initialized");
return NULL;
}
@@ -1044,16 +1042,8 @@ SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
_this->egl_data->egl_swapinterval = 0;
if (SDL_EGL_MakeCurrent(_this, egl_surface, egl_context) < 0) {
/* 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() */
/* Delete the context */
SDL_EGL_DeleteContext(_this, egl_context);
/* Restore the SDL error */
SDL_SetError("%s", errorText);
return NULL;
}
@@ -1071,7 +1061,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
#if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA)
} else {
/* Desktop OpenGL supports it by default from version 3.0 on. */
void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params);
@@ -1096,7 +1086,7 @@ SDL_EGL_MakeCurrent(_THIS, EGLSurface egl_surface, SDL_GLContext context)
EGLContext egl_context = (EGLContext) context;
if (!_this->egl_data) {
return SDL_SetError("OpenGL not initialized");
return SDL_SetError("EGL not initialized");
}
if (!_this->egl_data->eglMakeCurrent) {
@@ -1104,7 +1094,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("OpenGL not initialized"); /* something clearly went wrong somewhere. */
return SDL_SetError("EGL not initialized"); /* something clearly went wrong somewhere. */
}
}
@@ -1260,10 +1250,12 @@ EGLSurface
SDL_EGL_CreateOffscreenSurface(_THIS, int width, int height)
{
EGLint attributes[] = {
EGL_WIDTH, width,
EGL_HEIGHT, height,
EGL_WIDTH, 0,
EGL_HEIGHT, 0,
EGL_NONE
};
attributes[1] = width;
attributes[3] = height;
if (SDL_EGL_ChooseConfig(_this) != 0) {
return EGL_NO_SURFACE;

View File

@@ -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
@@ -33,7 +33,7 @@
typedef struct SDL_EGL_VideoData
{
void *egl_dll_handle, *dll_handle;
void *opengl_dll_handle, *egl_dll_handle;
EGLDisplay egl_display;
EGLConfig egl_config;
int egl_swapinterval;

View File

@@ -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
@@ -26,7 +26,7 @@
#ifdef __SSE__
/* *INDENT-OFF* */
/* *INDENT-OFF* */ /* clang-format 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* */
/* *INDENT-ON* */ /* clang-format 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_SetError("Passed NULL destination surface");
return SDL_InvalidParamError("SDL_FillRect(): dst");
}
/* If 'rect' == NULL, then fill the whole surface */
@@ -306,12 +306,7 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
int i;
if (!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");
return SDL_InvalidParamError("SDL_FillRects(): dst");
}
/* Nothing to do */
@@ -321,11 +316,28 @@ SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
/* Perform software fill */
if (!dst->pixels) {
return SDL_SetError("SDL_FillRect(): You must lock the surface");
return SDL_SetError("SDL_FillRects(): You must lock the surface");
}
if (!rects) {
return SDL_SetError("SDL_FillRects() passed NULL 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");
}
#if SDL_ARM_NEON_BLITTERS

View File

@@ -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
@@ -28,6 +28,7 @@
#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 */
@@ -677,7 +678,7 @@ int
SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette)
{
if (!format) {
return SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format");
return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format");
}
if (palette && palette->ncolors > (1 << format->BitsPerPixel)) {
@@ -1024,12 +1025,6 @@ SDL_AllocBlitMap(void)
}
typedef struct SDL_ListNode
{
void *entry;
struct SDL_ListNode *next;
} SDL_ListNode;
void
SDL_InvalidateAllBlitMap(SDL_Surface *surface)
{
@@ -1045,40 +1040,6 @@ 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)
{

View File

@@ -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

View File

@@ -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
@@ -23,447 +23,8 @@
#include "SDL_rect.h"
#include "SDL_rect_c.h"
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;
}
/* 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_GetSpanEnclosingRect(int width, int height,
int numrects, const SDL_Rect * rects, SDL_Rect *span)
@@ -475,24 +36,16 @@ SDL_GetSpanEnclosingRect(int width, int height,
if (width < 1) {
SDL_InvalidParamError("width");
return SDL_FALSE;
}
if (height < 1) {
} else if (height < 1) {
SDL_InvalidParamError("height");
return SDL_FALSE;
}
if (!rects) {
} else if (!rects) {
SDL_InvalidParamError("rects");
return SDL_FALSE;
}
if (!span) {
} else if (!span) {
SDL_InvalidParamError("span");
return SDL_FALSE;
}
if (numrects < 1) {
} else if (numrects < 1) {
SDL_InvalidParamError("numrects");
return SDL_FALSE;
}
@@ -527,4 +80,36 @@ 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: */

View File

@@ -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

444
externals/SDL/src/video/SDL_rect_impl.h vendored Executable file
View File

@@ -0,0 +1,444 @@
/*
Simple DirectMedia Layer
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
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* This file is #included twice to support int and float versions with the same code. */
SDL_bool
SDL_HASINTERSECTION(const RECTTYPE * A, const RECTTYPE * B)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) {
return SDL_FALSE; /* Special cases for empty rects */
}
/* 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 RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (!result) {
SDL_InvalidParamError("result");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */
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 RECTTYPE * A, const RECTTYPE * B, RECTTYPE * result)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (!A) {
SDL_InvalidParamError("A");
return;
} else if (!B) {
SDL_InvalidParamError("B");
return;
} else if (!result) {
SDL_InvalidParamError("result");
return;
} else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */
if (SDL_RECTEMPTY(B)) { /* A and B empty */
SDL_zerop(result);
} 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 POINTTYPE * points, int count, const RECTTYPE * clip,
RECTTYPE * result)
{
SCALARTYPE minx = 0;
SCALARTYPE miny = 0;
SCALARTYPE maxx = 0;
SCALARTYPE maxy = 0;
SCALARTYPE x, y;
int i;
if (!points) {
SDL_InvalidParamError("points");
return SDL_FALSE;
} else if (count < 1) {
SDL_InvalidParamError("count");
return SDL_FALSE;
}
if (clip) {
SDL_bool added = SDL_FALSE;
const SCALARTYPE clip_minx = clip->x;
const SCALARTYPE clip_miny = clip->y;
const SCALARTYPE clip_maxx = clip->x+clip->w-1;
const SCALARTYPE 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 */
static int
COMPUTEOUTCODE(const RECTTYPE * rect, SCALARTYPE x, SCALARTYPE 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 RECTTYPE * rect, SCALARTYPE *X1, SCALARTYPE *Y1, SCALARTYPE *X2,
SCALARTYPE *Y2)
{
SCALARTYPE x = 0;
SCALARTYPE y = 0;
SCALARTYPE x1, y1;
SCALARTYPE x2, y2;
SCALARTYPE rectx1;
SCALARTYPE recty1;
SCALARTYPE rectx2;
SCALARTYPE recty2;
int outcode1, outcode2;
if (!rect) {
SDL_InvalidParamError("rect");
return SDL_FALSE;
} else if (!X1) {
SDL_InvalidParamError("X1");
return SDL_FALSE;
} else if (!Y1) {
SDL_InvalidParamError("Y1");
return SDL_FALSE;
} else if (!X2) {
SDL_InvalidParamError("X2");
return SDL_FALSE;
} else if (!Y2) {
SDL_InvalidParamError("Y2");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(rect)) {
return SDL_FALSE; /* Special case for empty rect */
}
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;
}
#undef RECTTYPE
#undef POINTTYPE
#undef SCALARTYPE
#undef COMPUTEOUTCODE
#undef SDL_HASINTERSECTION
#undef SDL_INTERSECTRECT
#undef SDL_RECTEMPTY
#undef SDL_UNIONRECT
#undef SDL_ENCLOSEPOINTS
#undef SDL_INTERSECTRECTANDLINE
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -33,25 +33,43 @@
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
* Calculate the pad-aligned scanline width of a surface.
* Return SDL_SIZE_MAX on overflow.
*/
static Sint64
SDL_CalculatePitch(Uint32 format, int width)
static size_t
SDL_CalculatePitch(Uint32 format, size_t width, SDL_bool minimal)
{
Sint64 pitch;
size_t pitch;
if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_BITSPERPIXEL(format) >= 8) {
pitch = ((Sint64)width * SDL_BYTESPERPIXEL(format));
if (SDL_size_mul_overflow(width, SDL_BYTESPERPIXEL(format), &pitch)) {
return SDL_SIZE_MAX;
}
} else {
pitch = (((Sint64)width * SDL_BITSPERPIXEL(format)) + 7) / 8;
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 = (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
@@ -60,14 +78,24 @@ SDL_Surface *
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
Uint32 format)
{
Sint64 pitch;
size_t pitch;
SDL_Surface *surface;
/* The flags are no longer used, make the compiler happy */
(void)flags;
pitch = SDL_CalculatePitch(format, width);
if (pitch < 0 || pitch > SDL_MAX_SINT32) {
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) {
/* Overflow... */
SDL_OutOfMemory();
return NULL;
@@ -113,15 +141,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 */
Sint64 size = ((Sint64)surface->h * surface->pitch);
if (size < 0 || size > SDL_MAX_SINT32) {
size_t size;
if (SDL_size_mul_overflow(surface->h, surface->pitch, &size)) {
/* Overflow... */
SDL_FreeSurface(surface);
SDL_OutOfMemory();
return NULL;
}
surface->pixels = SDL_SIMDAlloc((size_t)size);
surface->pixels = SDL_SIMDAlloc(size);
if (!surface->pixels) {
SDL_FreeSurface(surface);
SDL_OutOfMemory();
@@ -129,7 +157,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, surface->h * surface->pitch);
SDL_memset(surface->pixels, 0, size);
}
/* Allocate an empty mapping */
@@ -149,6 +177,7 @@ 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
*/
@@ -179,8 +208,34 @@ SDL_CreateRGBSurfaceFrom(void *pixels,
Uint32 Amask)
{
SDL_Surface *surface;
Uint32 format;
size_t minimalPitch;
surface = SDL_CreateRGBSurface(0, 0, 0, depth, Rmask, Gmask, Bmask, Amask);
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);
if (surface != NULL) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
@@ -192,6 +247,7 @@ 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
@@ -202,6 +258,24 @@ 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) {
@@ -219,7 +293,7 @@ int
SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
{
if (!surface) {
return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface");
}
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
return -1;
@@ -646,7 +720,7 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect,
/* Make sure the surfaces aren't locked */
if (!src || !dst) {
return SDL_SetError("SDL_UpperBlit: passed a NULL surface");
return SDL_InvalidParamError("SDL_UpperBlit(): src/dst");
}
if (src->locked || dst->locked) {
return SDL_SetError("Surfaces must not be locked during blit");
@@ -757,7 +831,7 @@ SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect,
/* Make sure the surfaces aren't locked */
if (!src || !dst) {
return SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface");
return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst");
}
if (src->locked || dst->locked) {
return SDL_SetError("Surfaces must not be locked during blit");
@@ -1404,8 +1478,7 @@ int SDL_ConvertPixels(int width, int height,
}
#else
if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
SDL_SetError("SDL not built with YUV support");
return -1;
return SDL_SetError("SDL not built with YUV support");
}
#endif

View File

@@ -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
@@ -237,6 +237,7 @@ 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);
@@ -307,6 +308,8 @@ 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);
@@ -330,6 +333,8 @@ 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;
@@ -342,6 +347,7 @@ 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 */
@@ -452,9 +458,12 @@ 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);
@@ -468,6 +477,7 @@ 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);

View File

@@ -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
@@ -118,6 +118,9 @@ 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,
@@ -128,8 +131,6 @@ static VideoBootStrap *bootstrap[] = {
NULL
};
static SDL_VideoDevice *_this = NULL;
#define CHECK_WINDOW_MAGIC(window, retval) \
if (!_this) { \
SDL_UninitializedVideo(); \
@@ -172,129 +173,58 @@ 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 *unused, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch)
{
SDL_WindowTextureData *data;
SDL_RendererInfo info;
SDL_WindowTextureData *data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
int i;
data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA);
if (!data) {
SDL_Renderer *renderer = NULL;
int i;
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
/* Check to see if there's a specific driver requested */
if (hint && *hint != '0' && *hint != '1' &&
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) {
SDL_strcasecmp(hint, "software") != 0
);
/* Check to see if there's a specific driver requested */
if (specific_accelerated_renderer) {
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) {
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 {
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) {
break;
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) {
return SDL_SetError("No hardware accelerated renderers available");
}
}
if (!renderer) {
return SDL_SetError("No hardware accelerated renderers available");
}
SDL_assert(renderer != NULL); /* should have explicitly checked this above. */
/* Create the data after we successfully create the renderer (bug #1116) */
data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data));
@@ -305,6 +235,10 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f
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 */
@@ -315,23 +249,14 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f
SDL_free(data->pixels);
data->pixels = NULL;
{
SDL_RendererInfo info;
Uint32 i;
/* Find the first format without an alpha channel */
*format = info.texture_formats[0];
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;
}
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;
}
}
@@ -339,6 +264,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f
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;
}
@@ -364,6 +290,9 @@ SDL_CreateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, Uint32 * f
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)
{
@@ -413,8 +342,7 @@ SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window * window)
SDL_free(data);
}
static int
static int SDLCALL
cmpmodes(const void *A, const void *B)
{
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
@@ -465,6 +393,10 @@ SDL_VideoInit(const char *driver_name)
SDL_VideoDevice *video;
int index;
int i;
SDL_bool init_events = SDL_FALSE;
SDL_bool init_keyboard = SDL_FALSE;
SDL_bool init_mouse = SDL_FALSE;
SDL_bool init_touch = SDL_FALSE;
/* Check to make sure we don't overwrite '_this' */
if (_this != NULL) {
@@ -476,18 +408,28 @@ SDL_VideoInit(const char *driver_name)
#endif
/* Start the event loop */
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0 ||
SDL_KeyboardInit() < 0 ||
SDL_MouseInit() < 0 ||
SDL_TouchInit() < 0) {
return -1;
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) {
goto pre_driver_error;
}
init_events = SDL_TRUE;
if (SDL_KeyboardInit() < 0) {
goto pre_driver_error;
}
init_keyboard = SDL_TRUE;
if (SDL_MouseInit() < 0) {
goto pre_driver_error;
}
init_mouse = SDL_TRUE;
if (SDL_TouchInit() < 0) {
goto pre_driver_error;
}
init_touch = SDL_TRUE;
/* Select the proper video driver */
i = index = 0;
video = NULL;
if (driver_name == NULL) {
driver_name = SDL_getenv("SDL_VIDEODRIVER");
driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER);
}
if (driver_name != NULL && *driver_name != 0) {
const char *driver_attempt = driver_name;
@@ -516,13 +458,19 @@ SDL_VideoInit(const char *driver_name)
}
if (video == NULL) {
if (driver_name) {
return SDL_SetError("%s not available", driver_name);
SDL_SetError("%s not available", driver_name);
goto pre_driver_error;
}
return SDL_SetError("No available video device");
SDL_SetError("No available video device");
goto pre_driver_error;
}
/* From this point on, use SDL_VideoQuit to cleanup on error, rather than
pre_driver_error. */
_this = video;
_this->name = bootstrap[i]->name;
_this->next_object_id = 1;
_this->thread = SDL_ThreadID();
/* Set some very sane GL defaults */
@@ -545,13 +493,6 @@ 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
@@ -575,6 +516,22 @@ SDL_VideoInit(const char *driver_name)
/* We're ready to go! */
return 0;
pre_driver_error:
SDL_assert(_this == NULL);
if (init_touch) {
SDL_TouchQuit();
}
if (init_mouse) {
SDL_MouseQuit();
}
if (init_keyboard) {
SDL_KeyboardQuit();
}
if (init_events) {
SDL_QuitSubSystem(SDL_INIT_EVENTS);
}
return -1;
}
const char *
@@ -593,6 +550,12 @@ 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)
{
@@ -935,7 +898,7 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display,
SDL_DisplayMode *current, *match;
if (!mode || !closest) {
SDL_SetError("Missing desired mode or closest mode parameter");
SDL_InvalidParamError("mode/closest");
return NULL;
}
@@ -1108,61 +1071,64 @@ 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;
if (SDL_WINDOWPOS_ISUNDEFINED(window->x) ||
SDL_WINDOWPOS_ISCENTERED(window->x)) {
displayIndex = (window->x & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
return displayIndex;
}
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(&center, 1, &rect, NULL)) {
return i;
if (SDL_WINDOWPOS_ISUNDEFINED(window->y) ||
SDL_WINDOWPOS_ISCENTERED(window->y)) {
displayIndex = (window->y & 0xFFFF);
if (displayIndex >= _this->num_displays) {
displayIndex = 0;
}
return displayIndex;
}
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;
/* 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(&center, 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;
}
if (closest < 0) {
SDL_SetError("Couldn't find any displays");
}
return closest;
}
SDL_VideoDisplay *
@@ -1233,6 +1199,7 @@ 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");
}
@@ -1386,14 +1353,17 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
resized = 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;
/* 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;
}
}
}
@@ -1404,12 +1374,17 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen)
/* Generate a mode change event here */
if (resized) {
#ifndef ANDROID
#if !defined(ANDROID) && !defined(WIN32)
/* 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
@@ -1541,12 +1516,16 @@ 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 (!_this->is_dummy && !graphics_flags && !SDL_IsVideoContextExternal()) {
if (!graphics_flags && !SDL_IsVideoContextExternal()) {
#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__
flags |= SDL_WINDOW_OPENGL;
if (_this->GL_CreateContext != NULL) {
flags |= SDL_WINDOW_OPENGL;
}
#endif
#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__)
flags |= SDL_WINDOW_METAL;
if (_this->Metal_CreateView != NULL) {
flags |= SDL_WINDOW_METAL;
}
#endif
}
@@ -1721,6 +1700,7 @@ SDL_Window *
SDL_CreateWindowFrom(const void *data)
{
SDL_Window *window;
Uint32 flags = SDL_WINDOW_FOREIGN;
if (!_this) {
SDL_UninitializedVideo();
@@ -1730,6 +1710,37 @@ 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();
@@ -1737,7 +1748,7 @@ SDL_CreateWindowFrom(const void *data)
}
window->magic = &_this->window_magic;
window->id = _this->next_object_id++;
window->flags = SDL_WINDOW_FOREIGN;
window->flags = flags;
window->last_fullscreen_flags = window->flags;
window->is_destroying = SDL_FALSE;
window->opacity = 1.0f;
@@ -1783,7 +1794,9 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
}
/* Restore video mode, etc. */
SDL_HideWindow(window);
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
SDL_HideWindow(window);
}
/* Tear down the old native window */
if (window->surface) {
@@ -1792,9 +1805,13 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
window->surface = NULL;
window->surface_valid = SDL_FALSE;
}
if (_this->DestroyWindowFramebuffer) {
_this->DestroyWindowFramebuffer(_this, window);
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->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
_this->DestroyWindow(_this, window);
}
@@ -1810,17 +1827,6 @@ 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;
@@ -1833,18 +1839,15 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
}
if ((flags & SDL_WINDOW_VULKAN) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Vulkan and OpenGL not supported on same window");
return -1;
return SDL_SetError("Vulkan and OpenGL not supported on same window");
}
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_OPENGL)) {
SDL_SetError("Metal and OpenGL not supported on same window");
return -1;
return SDL_SetError("Metal and OpenGL not supported on same window");
}
if ((flags & SDL_WINDOW_METAL) && (flags & SDL_WINDOW_VULKAN)) {
SDL_SetError("Metal and Vulkan not supported on same window");
return -1;
return SDL_SetError("Metal and Vulkan not supported on same window");
}
if (need_gl_unload) {
@@ -2238,12 +2241,14 @@ 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 == w && window->h == h) {
if (window->w != old_w || window->h != old_h) {
/* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */
SDL_OnWindowResized(window);
}
@@ -2504,18 +2509,71 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
static SDL_Surface *
SDL_CreateWindowFramebuffer(SDL_Window * window)
{
Uint32 format;
void *pixels;
int pitch;
Uint32 format = 0;
void *pixels = NULL;
int pitch = 0;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_bool created_framebuffer = SDL_FALSE;
if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
return NULL;
/* 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, window, &format, &pixels, &pitch) < 0) {
return NULL;
if (!created_framebuffer) {
if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
return NULL;
}
if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) {
return NULL;
}
}
if (window->surface) {
@@ -2573,6 +2631,8 @@ 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);
}
@@ -2991,7 +3051,7 @@ SDL_OnWindowFocusGained(SDL_Window * window)
if (mouse && mouse->relative_mode) {
SDL_SetMouseFocus(window);
if (mouse->relative_mode_warp) {
SDL_WarpMouseInWindow(window, window->w/2, window->h/2);
SDL_PerformWarpMouseInWindow(window, window->w/2, window->h/2, SDL_TRUE);
}
}
@@ -3027,7 +3087,8 @@ 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) {
if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP ||
_this->disable_display_mode_switching == SDL_TRUE) {
return SDL_FALSE;
} else {
return SDL_TRUE;
@@ -3078,7 +3139,9 @@ SDL_DestroyWindow(SDL_Window * window)
window->is_destroying = SDL_TRUE;
/* Restore video mode, etc. */
SDL_HideWindow(window);
if (!(window->flags & SDL_WINDOW_FOREIGN)) {
SDL_HideWindow(window);
}
/* Make sure this window no longer has focus */
if (SDL_GetKeyboardFocus() == window) {
@@ -3101,8 +3164,10 @@ SDL_DestroyWindow(SDL_Window * window)
window->surface = NULL;
window->surface_valid = SDL_FALSE;
}
if (_this->DestroyWindowFramebuffer) {
_this->DestroyWindowFramebuffer(_this, window);
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->DestroyWindow) {
_this->DestroyWindow(_this, window);
@@ -3807,10 +3872,23 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
}
if (attachmentattrib && isAtLeastGL3((const char *) glGetStringFunc(GL_VERSION))) {
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
/* glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. */
GLint current_fbo = 0;
void (APIENTRY *glGetIntegervFunc) (GLenum pname, GLint * params) = SDL_GL_GetProcAddress("glGetIntegerv");
void (APIENTRY *glBindFramebufferFunc) (GLenum target, GLuint fbo) = SDL_GL_GetProcAddress("glBindFramebuffer");
if (glGetIntegervFunc && glBindFramebufferFunc) {
glGetIntegervFunc(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
}
glGetFramebufferAttachmentParameterivFunc = SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv");
if (glGetFramebufferAttachmentParameterivFunc) {
if (glBindFramebufferFunc && (current_fbo != 0)) {
glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, 0);
}
glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *) value);
if (glBindFramebufferFunc && (current_fbo != 0)) {
glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, current_fbo);
}
} else {
return -1;
}
@@ -3874,6 +3952,10 @@ 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. */
@@ -4131,6 +4213,24 @@ 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)
{
@@ -4184,6 +4284,12 @@ 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
@@ -4244,7 +4350,6 @@ 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;
@@ -4254,10 +4359,11 @@ 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_CaptureMouse(SDL_FALSE);
SDL_UpdateMouseCapture(SDL_FALSE);
SDL_SetRelativeMouseMode(SDL_FALSE);
show_cursor_prev = SDL_ShowCursor(1);
SDL_ResetKeyboard();
@@ -4361,15 +4467,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;
}

View File

@@ -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
@@ -25,12 +25,10 @@
#include "SDL_stdinc.h"
#if defined(SDL_LOADSO_DISABLED)
#undef SDL_VIDEO_VULKAN
#define SDL_VIDEO_VULKAN 0
#endif
#if SDL_VIDEO_VULKAN
#if SDL_LOADSO_DISABLED || SDL_LOADSO_DUMMY
#error You should not be here.
#endif
#if SDL_VIDEO_DRIVER_ANDROID
#define VK_USE_PLATFORM_ANDROID_KHR

View File

@@ -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

View File

@@ -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
@@ -290,6 +290,48 @@ 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,
@@ -417,6 +459,10 @@ 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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -67,6 +67,7 @@ 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)
{
@@ -96,7 +97,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
@@ -113,12 +114,14 @@ 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();
@@ -138,11 +141,13 @@ 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()) {
@@ -188,11 +193,13 @@ 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();
@@ -219,12 +226,14 @@ 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()) {

View File

@@ -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

View File

@@ -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
@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#if SDL_VIDEO_DRIVER_ANDROID && SDL_VIDEO_OPENGL_EGL
/* Android SDL video driver implementation */

View File

@@ -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

View File

@@ -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
@@ -41,12 +41,12 @@ void Android_InitKeyboard(void)
static SDL_Scancode Android_Keycodes[] = {
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */
SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */
SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */
SDL_SCANCODE_CALL, /* AKEYCODE_CALL */
SDL_SCANCODE_ENDCALL, /* AKEYCODE_ENDCALL */
SDL_SCANCODE_0, /* AKEYCODE_0 */
SDL_SCANCODE_1, /* AKEYCODE_1 */
SDL_SCANCODE_2, /* AKEYCODE_2 */

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -113,6 +113,10 @@ Android_CreateSystemCursor(SDL_SystemCursor id)
static void
Android_FreeCursor(SDL_Cursor * cursor)
{
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*) cursor->driverdata;
if (data->custom_cursor != 0) {
Android_JNI_DestroyCustomCursor(data->custom_cursor);
}
SDL_free(cursor->driverdata);
SDL_free(cursor);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -122,12 +122,14 @@ 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;
@@ -137,6 +139,7 @@ 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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -81,6 +81,7 @@ 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);
@@ -91,6 +92,7 @@ Android_CreateWindow(_THIS, SDL_Window * window)
goto endfunction;
}
}
#endif
window->driverdata = data;
Android_Window = window;
@@ -114,6 +116,8 @@ 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) {
@@ -130,8 +134,7 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
goto endfunction;
}
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
data = (SDL_WindowData *)window->driverdata;
if (!data || !data->native_window) {
if (data && !data->native_window) {
SDL_SetError("Missing native window");
@@ -139,11 +142,11 @@ Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display
goto endfunction;
}
int old_w = window->w;
int old_h = window->h;
old_w = window->w;
old_h = window->h;
int new_w = ANativeWindow_getWidth(data->native_window);
int new_h = ANativeWindow_getHeight(data->native_window);
new_w = ANativeWindow_getWidth(data->native_window);
new_h = ANativeWindow_getHeight(data->native_window);
if (new_w < 0 || new_h < 0) {
SDL_SetError("ANativeWindow_getWidth/Height() fails");
@@ -165,6 +168,12 @@ 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)
{
@@ -175,9 +184,13 @@ 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);
}
@@ -194,15 +207,18 @@ Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (info->version.major == SDL_MAJOR_VERSION &&
info->version.minor == SDL_MINOR_VERSION) {
if (info->version.major == SDL_MAJOR_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.%d",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
SDL_SetError("Application not compiled with SDL %d",
SDL_MAJOR_VERSION);
return SDL_FALSE;
}
}

View File

@@ -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
@@ -30,6 +30,7 @@ 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);
@@ -37,8 +38,10 @@ 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;

View File

@@ -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
@@ -24,12 +24,12 @@
#define SDL_cocoaclipboard_h_
/* Forward declaration */
struct SDL_VideoData;
@class 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(struct SDL_VideoData * data);
extern void Cocoa_CheckClipboardUpdate(SDL_VideoData * data);
#endif /* SDL_cocoaclipboard_h_ */

View File

@@ -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
@@ -29,7 +29,7 @@ int
Cocoa_SetClipboardText(_THIS, const char *text)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge 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(struct SDL_VideoData * data)
Cocoa_CheckClipboardUpdate(SDL_VideoData * data)
{ @autoreleasepool
{
NSPasteboard *pasteboard;
@@ -94,11 +94,11 @@ Cocoa_CheckClipboardUpdate(struct 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;
}
}}

View File

@@ -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

View File

@@ -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
@@ -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 = ((SDL_WindowData *) sdlwindow->driverdata)->nswindow;
NSWindow *nswindow = ((__bridge SDL_WindowData *) sdlwindow->driverdata).nswindow;
if (win == nswindow)
return sdlwindow;
}
@@ -121,7 +121,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
[NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState",
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[appDefaults release];
}
@end // SDLApplication
@@ -182,8 +181,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
removeEventHandlerForEventClass:kInternetEventClass
andEventID:kAEGetURL];
}
[super dealloc];
}
- (void)windowWillClose:(NSNotification *)notification;
@@ -374,9 +371,6 @@ 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:@""];
@@ -396,7 +390,6 @@ CreateApplicationMenus(void)
[menuItem setSubmenu:serviceMenu];
[NSApp setServicesMenu:serviceMenu];
[serviceMenu release];
[appleMenu addItem:[NSMenuItem separatorItem]];
@@ -417,12 +410,9 @@ 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"];
@@ -434,26 +424,21 @@ CreateApplicationMenus(void)
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
/* 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];
}
/* 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];
/* 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
@@ -518,19 +503,6 @@ 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 ) {
@@ -576,7 +548,7 @@ Cocoa_PumpEvents(_THIS)
void Cocoa_SendWakeupEvent(_THIS, SDL_Window *window)
{ @autoreleasepool
{
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
NSWindow *nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
NSEvent* event = [NSEvent otherEventWithType: NSEventTypeApplicationDefined
location: NSMakePoint(0,0)
@@ -595,15 +567,11 @@ void
Cocoa_SuspendScreenSaver(_THIS)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
SDL_VideoData *data = (__bridge SDL_VideoData *)_this->driverdata;
if (!data->screensaver_use_iopm) {
return;
}
if (data->screensaver_assertion) {
IOPMAssertionRelease(data->screensaver_assertion);
data->screensaver_assertion = 0;
if (data.screensaver_assertion) {
IOPMAssertionRelease(data.screensaver_assertion);
data.screensaver_assertion = kIOPMNullAssertionID;
}
if (_this->suspend_screensaver) {
@@ -612,11 +580,13 @@ 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,
(CFStringRef) name,
(__bridge CFStringRef) name,
NULL, NULL, NULL, 0, NULL,
&data->screensaver_assertion);
&assertion);
data.screensaver_assertion = assertion;
}
}}

View File

@@ -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

View File

@@ -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
@@ -104,8 +104,7 @@
}
if (_markedText != aString) {
[_markedText release];
_markedText = [aString retain];
_markedText = aString;
}
_selectedRange = selectedRange;
@@ -120,7 +119,6 @@
- (void)unmarkText
{
[_markedText release];
_markedText = nil;
SDL_SendEditingText("", 0, 0);
@@ -142,14 +140,7 @@
aRange.location, aRange.length, windowHeight,
NSStringFromRect(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];
}
rect = [window convertRectToScreen:rect];
return rect;
}
@@ -381,14 +372,14 @@ DoSidedModifiers(unsigned short scancode,
static void
HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge 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
@@ -402,10 +393,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);
@@ -461,7 +452,7 @@ cleanup:
void
Cocoa_InitKeyboard(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
UpdateKeymap(data, SDL_FALSE);
@@ -473,19 +464,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 = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
SDL_Window *window = SDL_GetKeyboardFocus();
NSWindow *nswindow = nil;
if (window) {
nswindow = ((SDL_WindowData*)window->driverdata)->nswindow;
nswindow = ((__bridge SDL_WindowData*)window->driverdata).nswindow;
}
NSView *parentView = [nswindow contentView];
@@ -495,16 +486,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];
}
}}
@@ -512,32 +503,31 @@ void
Cocoa_StopTextInput(_THIS)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
if (data && data->fieldEdit) {
[data->fieldEdit removeFromSuperview];
[data->fieldEdit release];
data->fieldEdit = nil;
if (data && data.fieldEdit) {
[data.fieldEdit removeFromSuperview];
data.fieldEdit = nil;
}
}}
void
Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge 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 ? ((SDL_VideoData *) _this->driverdata) : NULL;
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *) _this->driverdata) : nil;
if (!data) {
return; /* can happen when returning from fullscreen Space on shutdown */
}
@@ -575,7 +565,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) {

View File

@@ -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

View File

@@ -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
@@ -45,9 +45,9 @@
/* Retain the NSWindow because we'll show the alert later on the main thread */
if (window) {
nswindow = [((SDL_WindowData *) window->driverdata)->nswindow retain];
nswindow = ((__bridge SDL_WindowData *) window->driverdata).nswindow;
} else {
nswindow = NULL;
nswindow = nil;
}
}
@@ -60,7 +60,7 @@
#ifdef MAC_OS_X_VERSION_10_9
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
[alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) {
clicked = returnCode;
self->clicked = returnCode;
}];
} else
#endif
@@ -75,7 +75,7 @@
SDL_Delay(100);
}
[nswindow release];
nswindow = nil;
} else {
clicked = [alert runModal];
}
@@ -94,7 +94,7 @@ Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonid
{
Cocoa_RegisterApp();
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
NSAlert* alert = [[NSAlert alloc] init];
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] autorelease];
SDLMessageBoxPresenter* presenter = [[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window];
[presenter showAlert:alert];

View File

@@ -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
@@ -39,7 +39,6 @@
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#define METALVIEW_TAG 255
@interface SDL_cocoametalview : NSView

View File

@@ -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
@@ -31,6 +31,8 @@
#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
#include "SDL_events.h"
#include "SDL_syswm.h"
static int SDLCALL
SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
@@ -87,7 +89,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
/* Allow resize. */
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
SDL_AddEventWatch(SDL_MetalViewEventWatch, self);
SDL_AddEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
[self updateDrawableSize];
}
@@ -97,13 +99,12 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
- (void)dealloc
{
SDL_DelEventWatch(SDL_MetalViewEventWatch, self);
[super dealloc];
SDL_DelEventWatch(SDL_MetalViewEventWatch, (__bridge void *)(self));
}
- (NSInteger)tag
{
return METALVIEW_TAG;
return SDL_METALVIEW_TAG;
}
- (void)updateDrawableSize
@@ -133,7 +134,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;
@@ -149,7 +150,6 @@ Cocoa_Metal_CreateView(_THIS, SDL_Window * window)
[view addSubview:newview];
metalview = (SDL_MetalView)CFBridgingRetain(newview);
[newview release];
return metalview;
}}
@@ -172,8 +172,8 @@ void
Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
{ @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
NSView *contentView = data->sdlContentView;
SDL_cocoametalview* metalview = [contentView viewWithTag:METALVIEW_TAG];
NSView *contentView = data.sdlContentView;
SDL_cocoametalview* metalview = [contentView viewWithTag:SDL_METALVIEW_TAG];
if (metalview) {
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
SDL_assert(layer != NULL);
@@ -187,11 +187,8 @@ 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, only
* supported on 10.7+. */
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
viewport = [contentView convertRectToBacking:viewport];
}
/* This gives us the correct viewport for a Retina-enabled view. */
viewport = [contentView convertRectToBacking:viewport];
}
if (w) {
*w = viewport.size.width;

View File

@@ -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

View File

@@ -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
@@ -31,33 +31,16 @@
#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
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();
}
#if (IOGRAPHICSTYPES_REV < 40)
#define kDisplayModeNativeFlag 0x02000000
#endif
}
static int
CG_SetError(const char *prefix, CGDisplayErr result)
@@ -303,7 +286,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 = [(NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
NSDictionary *localizedNames = [(__bridge NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]];
const char* displayName = NULL;
if ([localizedNames count] > 0) {
@@ -454,28 +437,68 @@ Cocoa_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdp
/* we need the backingScaleFactor for Retina displays, which is only exposed through NSScreen, not CGDisplay, afaik, so find our screen... */
CGFloat scaleFactor = 1.0f;
NSArray *screens = [NSScreen screens];
NSSize displayNativeSize;
displayNativeSize.width = (int) CGDisplayPixelsWide(data->display);
displayNativeSize.height = (int) CGDisplayPixelsHigh(data->display);
for (NSScreen *screen in screens) {
const CGDirectDisplayID dpyid = (const CGDirectDisplayID ) [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
if (dpyid == data->display) {
if ([screen respondsToSelector:@selector(backingScaleFactor)]) { // Mac OS X 10.7 and later
#ifdef MAC_OS_X_VERSION_10_8
/* Neither CGDisplayScreenSize(description's NSScreenNumber) nor [NSScreen backingScaleFactor] can calculate the correct dpi in macOS. E.g. backingScaleFactor is always 2 in all display modes for rMBP 16" */
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
CFStringRef dmKeys[1] = { kCGDisplayShowDuplicateLowResolutionModes };
CFBooleanRef dmValues[1] = { kCFBooleanTrue };
CFDictionaryRef dmOptions = CFDictionaryCreate(kCFAllocatorDefault, (const void**) dmKeys, (const void**) dmValues, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );
CFArrayRef allDisplayModes = CGDisplayCopyAllDisplayModes(dpyid, dmOptions);
CFIndex n = CFArrayGetCount(allDisplayModes);
for(CFIndex i = 0; i < n; ++i) {
CGDisplayModeRef m = (CGDisplayModeRef)CFArrayGetValueAtIndex(allDisplayModes, i);
CGFloat width = CGDisplayModeGetPixelWidth(m);
CGFloat height = CGDisplayModeGetPixelHeight(m);
CGFloat HiDPIWidth = CGDisplayModeGetWidth(m);
//Only check 1x mode
if(width == HiDPIWidth) {
if (CGDisplayModeGetIOFlags(m) & kDisplayModeNativeFlag) {
displayNativeSize.width = width;
displayNativeSize.height = height;
break;
}
//Get the largest size even if kDisplayModeNativeFlag is not present e.g. iMac 27-Inch with 5K Retina
if(width > displayNativeSize.width) {
displayNativeSize.width = width;
displayNativeSize.height = height;
}
}
}
CFRelease(allDisplayModes);
CFRelease(dmOptions);
} else
#endif
{
// fallback for 10.7
scaleFactor = [screen backingScaleFactor];
displayNativeSize.width = displayNativeSize.width * scaleFactor;
displayNativeSize.height = displayNativeSize.height * scaleFactor;
break;
}
}
}
const CGSize displaySize = CGDisplayScreenSize(data->display);
const int pixelWidth = (int) CGDisplayPixelsWide(data->display);
const int pixelHeight = (int) CGDisplayPixelsHigh(data->display);
const int pixelWidth = displayNativeSize.width;
const int pixelHeight = displayNativeSize.height;
if (ddpi) {
*ddpi = (SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH)) * scaleFactor;
*ddpi = (SDL_ComputeDiagonalDPI(pixelWidth, pixelHeight, displaySize.width / MM_IN_INCH, displaySize.height / MM_IN_INCH));
}
if (hdpi) {
*hdpi = (pixelWidth * MM_IN_INCH / displaySize.width) * scaleFactor;
*hdpi = (pixelWidth * MM_IN_INCH / displaySize.width);
}
if (vdpi) {
*vdpi = (pixelHeight * MM_IN_INCH / displaySize.height) * scaleFactor;
*vdpi = (pixelHeight * MM_IN_INCH / displaySize.height);
}
return 0;
@@ -603,10 +626,6 @@ 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)) {
@@ -626,11 +645,6 @@ 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) */
@@ -677,7 +691,6 @@ Cocoa_QuitModes(_THIS)
CFRelease(mode->modes);
}
}
Cocoa_ToggleMenuBar(YES);
}
#endif /* SDL_VIDEO_DRIVER_COCOA */

View File

@@ -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

View File

@@ -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
@@ -53,7 +53,7 @@
NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0]
length:sizeof(cursorBytes)
freeWhenDone:NO];
NSImage *cursorImage = [[[NSImage alloc] initWithData:cursorData] autorelease];
NSImage *cursorImage = [[NSImage alloc] initWithData:cursorData];
invisibleCursor = [[NSCursor alloc] initWithImage:cursorImage
hotSpot:NSZeroPoint];
}
@@ -75,8 +75,7 @@ Cocoa_CreateDefaultCursor()
if (nscursor) {
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
cursor->driverdata = nscursor;
[nscursor retain];
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
}
}
@@ -99,15 +98,52 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
if (nscursor) {
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
cursor->driverdata = nscursor;
} else {
[nscursor release];
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
}
}
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
@@ -122,27 +158,29 @@ 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_WAITARROW:
nscursor = [NSCursor arrowCursor];
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));
break;
case SDL_SYSTEM_CURSOR_SIZENWSE:
nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor));
break;
case SDL_SYSTEM_CURSOR_SIZENESW:
nscursor = [NSCursor closedHandCursor];
nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor));
break;
case SDL_SYSTEM_CURSOR_SIZEWE:
nscursor = [NSCursor resizeLeftRightCursor];
nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor));
break;
case SDL_SYSTEM_CURSOR_SIZENS:
nscursor = [NSCursor resizeUpDownCursor];
nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor));
break;
case SDL_SYSTEM_CURSOR_SIZEALL:
nscursor = [NSCursor closedHandCursor];
nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor));
break;
case SDL_SYSTEM_CURSOR_NO:
nscursor = [NSCursor operationNotAllowedCursor];
@@ -159,8 +197,7 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id)
cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) {
/* We'll free it later, so retain it here */
[nscursor retain];
cursor->driverdata = nscursor;
cursor->driverdata = (void *)CFBridgingRetain(nscursor);
}
}
@@ -171,9 +208,7 @@ static void
Cocoa_FreeCursor(SDL_Cursor * cursor)
{ @autoreleasepool
{
NSCursor *nscursor = (NSCursor *)cursor->driverdata;
[nscursor release];
CFBridgingRelease(cursor->driverdata);
SDL_free(cursor);
}}
@@ -184,11 +219,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 = (SDL_WindowData *)window->driverdata;
SDL_WindowData *driverdata = (__bridge 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;
@@ -214,10 +249,10 @@ Cocoa_WarpMouseGlobal(int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->focus) {
SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata;
if ([data->listener isMovingOrFocusClickPending]) {
SDL_WindowData *data = (__bridge 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;
}
}
@@ -253,28 +288,12 @@ Cocoa_WarpMouseGlobal(int x, int y)
static void
Cocoa_WarpMouse(SDL_Window * window, int x, int y)
{
Cocoa_WarpMouseGlobal(x + window->x, y + window->y);
Cocoa_WarpMouseGlobal(window->x + x, window->y + 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.");
@@ -287,6 +306,22 @@ 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
*/
@@ -360,18 +395,18 @@ Cocoa_HandleTitleButtonEvent(_THIS, NSEvent *event)
NSWindow *nswindow = [event window];
for (window = _this->windows; window; window = window->next) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
if (data && data->nswindow == nswindow) {
SDL_WindowData *data = (__bridge 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;
@@ -467,15 +502,13 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event)
CGFloat y = [event deltaY];
SDL_MouseWheelDirection direction = SDL_MOUSEWHEEL_NORMAL;
if ([event respondsToSelector:@selector(isDirectionInvertedFromDevice)]) {
if ([event isDirectionInvertedFromDevice] == YES) {
direction = SDL_MOUSEWHEEL_FLIPPED;
}
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 respondsToSelector:@selector(hasPreciseScrollingDeltas)] || ![event hasPreciseScrollingDeltas]) {
if (![event hasPreciseScrollingDeltas]) {
if (x > 0) {
x = SDL_ceil(x);
} else if (x < 0) {

View File

@@ -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

View File

@@ -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
@@ -82,10 +82,10 @@
- (void)setWindow:(SDL_Window *)newWindow
{
if (self->window) {
SDL_WindowData *oldwindowdata = (SDL_WindowData *)self->window->driverdata;
SDL_WindowData *oldwindowdata = (__bridge 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 = (SDL_WindowData *)newWindow->driverdata;
NSView *contentview = windowdata->sdlContentView;
SDL_WindowData *windowdata = (__bridge 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,22 +213,15 @@ 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;
/* 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;
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++] = NSOpenGLPFAColorSize;
attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8;
@@ -288,20 +281,20 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
}
if (_this->gl_config.share_with_current_context) {
share_context = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
share_context = (__bridge 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;
}
if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) {
Cocoa_GL_DeleteContext(_this, context);
sdlcontext = (SDL_GLContext)CFBridgingRetain(context);
if ( Cocoa_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context) < 0 ) {
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
SDL_SetError("Failed making OpenGL context current");
return NULL;
}
@@ -315,27 +308,27 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString");
if (!glGetStringFunc) {
Cocoa_GL_DeleteContext(_this, context);
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
SDL_SetError ("Failed getting OpenGL glGetString entry point");
return NULL;
}
glversion = (const char *)glGetStringFunc(GL_VERSION);
if (glversion == NULL) {
Cocoa_GL_DeleteContext(_this, context);
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)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, context);
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)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, context);
Cocoa_GL_DeleteContext(_this, (__bridge SDL_GLContext)context);
SDL_SetError ("Failed creating OpenGL context at version requested");
return NULL;
}
@@ -346,7 +339,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
/*_this->gl_config.major_version = glversion_major;*/
/*_this->gl_config.minor_version = glversion_minor;*/
}
return context;
return sdlcontext;
}}
int
@@ -354,7 +347,7 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
{ @autoreleasepool
{
if (context) {
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
if ([nscontext window] != window) {
[nscontext setWindow:window];
[nscontext updateIfNeeded];
@@ -369,17 +362,15 @@ 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 = (SDL_WindowData *) window->driverdata;
NSView *contentView = windata->sdlContentView;
SDL_WindowData *windata = (__bridge 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, only
* supported on 10.7+. */
if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) {
viewport = [contentView convertRectToBacking:viewport];
}
/* This gives us the correct viewport for a Retina-enabled view. */
viewport = [contentView convertRectToBacking:viewport];
}
if (w) {
@@ -389,7 +380,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)
@@ -403,7 +394,7 @@ Cocoa_GL_SetSwapInterval(_THIS, int interval)
return SDL_SetError("Late swap tearing currently unsupported");
}
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
if (nscontext != nil) {
value = interval;
[nscontext setValues:&value forParameter:NSOpenGLCPSwapInterval];
@@ -423,7 +414,7 @@ Cocoa_GL_GetSwapInterval(_THIS)
GLint value;
int status = 0;
nscontext = (NSOpenGLContext*)SDL_GL_GetCurrentContext();
nscontext = (__bridge NSOpenGLContext*)SDL_GL_GetCurrentContext();
if (nscontext != nil) {
[nscontext getValues:&value forParameter:NSOpenGLCPSwapInterval];
status = (int)value;
@@ -436,15 +427,15 @@ int
Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
{ @autoreleasepool
{
SDLOpenGLContext* nscontext = (SDLOpenGLContext*)SDL_GL_GetCurrentContext();
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
SDLOpenGLContext* nscontext = (__bridge SDLOpenGLContext*)SDL_GL_GetCurrentContext();
SDL_VideoData *videodata = (__bridge 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;
}}
@@ -452,10 +443,8 @@ void
Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
{ @autoreleasepool
{
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)context;
SDLOpenGLContext *nscontext = (SDLOpenGLContext *)CFBridgingRelease(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. */

View File

@@ -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

View File

@@ -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
@@ -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,9 +59,10 @@ Cocoa_GLES_LoadLibrary(_THIS, const char *path) {
SDL_GLContext
Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
{ @autoreleasepool
{
SDL_GLContext context;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
#if SDL_VIDEO_OPENGL_CGL
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
@@ -85,25 +86,37 @@ 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);
}
}}
SDL_EGL_SwapWindow_impl(Cocoa)
SDL_EGL_MakeCurrent_impl(Cocoa)
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);
}}
int
Cocoa_GLES_SetupWindow(_THIS, SDL_Window * window)
{
/* The current context is lost in here; save it and reset it. */
SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
SDL_WindowData *windowdata = (__bridge SDL_WindowData *) window->driverdata;
SDL_Window *current_win = SDL_GL_GetCurrentWindow();
SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
@@ -121,10 +134,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, (NativeWindowType)[v layer]);
NSView* v = windowdata.nswindow.contentView;
windowdata.egl_surface = SDL_EGL_CreateSurface(_this, (__bridge 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");
}

View File

@@ -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

View File

@@ -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
@@ -29,11 +29,12 @@
SDL_WindowShaper*
Cocoa_CreateShaper(SDL_Window* window)
{ @autoreleasepool
{
SDL_WindowData* windata = (SDL_WindowData*)window->driverdata;
[windata->nswindow setOpaque:NO];
SDL_WindowData* windata = (__bridge 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;
@@ -44,14 +45,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;
@@ -74,7 +75,7 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowSha
{ @autoreleasepool
{
SDL_ShapeData* data = (SDL_ShapeData*)shaper->driverdata;
SDL_WindowData* windata = (SDL_WindowData*)shaper->window->driverdata;
SDL_WindowData* windata = (__bridge SDL_WindowData*)shaper->window->driverdata;
SDL_CocoaClosure closure;
if(data->saved == SDL_TRUE) {
[data->context restoreGraphicsState];
@@ -86,10 +87,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);

View File

@@ -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
@@ -97,18 +97,15 @@ DECLARE_ALERT_STYLE(Critical);
@class SDLTranslatorResponder;
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;
@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
/* Utility functions */
extern NSImage * Cocoa_CreateImage(SDL_Surface * surface);

View File

@@ -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
@@ -22,6 +22,10 @@
#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"
@@ -29,6 +33,10 @@
#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);
@@ -37,16 +45,18 @@ static void Cocoa_VideoQuit(_THIS);
static void
Cocoa_DeleteDevice(SDL_VideoDevice * device)
{ @autoreleasepool
{
if (device->wakeup_lock) {
SDL_DestroyMutex(device->wakeup_lock);
}
SDL_free(device->driverdata);
CFBridgingRelease(device->driverdata);
SDL_free(device);
}
}}
static SDL_VideoDevice *
Cocoa_CreateDevice(int devindex)
{ @autoreleasepool
{
SDL_VideoDevice *device;
SDL_VideoData *data;
@@ -56,16 +66,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 = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
data = [[SDL_VideoData alloc] init];
} else {
data = NULL;
data = nil;
}
if (!data) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata = data;
device->driverdata = (void *)CFBridgingRetain(data);
device->wakeup_lock = SDL_CreateMutex();
/* Set the function pointers */
@@ -103,6 +113,7 @@ 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;
@@ -165,7 +176,7 @@ Cocoa_CreateDevice(int devindex)
device->free = Cocoa_DeleteDevice;
return device;
}
}}
VideoBootStrap COCOA_bootstrap = {
"cocoa", "SDL Cocoa video driver",
@@ -175,8 +186,9 @@ VideoBootStrap COCOA_bootstrap = {
int
Cocoa_VideoInit(_THIS)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge SDL_VideoData *) _this->driverdata;
Cocoa_InitModes(_this);
Cocoa_InitKeyboard(_this);
@@ -184,29 +196,27 @@ Cocoa_VideoInit(_THIS)
return -1;
}
data->allow_spaces = ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) && SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE));
data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_TRUE);
/* 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) {
data.swaplock = SDL_CreateMutex();
if (!data.swaplock) {
return -1;
}
return 0;
}
}}
void
Cocoa_VideoQuit(_THIS)
{ @autoreleasepool
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_VideoData *data = (__bridge 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 *
@@ -223,7 +233,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
@@ -232,7 +242,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bytesPerRow: converted->pitch
bitsPerPixel: converted->format->BitsPerPixel] autorelease];
bitsPerPixel: converted->format->BitsPerPixel];
if (imgrep == nil) {
SDL_FreeSurface(converted);
return nil;
@@ -252,7 +262,7 @@ Cocoa_CreateImage(SDL_Surface * surface)
pixels += 4;
}
img = [[[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)] autorelease];
img = [[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)];
if (img != nil) {
[img addRepresentation: imgrep];
}
@@ -269,11 +279,16 @@ Cocoa_CreateImage(SDL_Surface * surface)
* versions remain identical!
*/
void SDL_NSLog(const char *text)
void SDL_NSLog(const char *prefix, const char *text)
{
@autoreleasepool {
NSString *str = [NSString stringWithUTF8String:text];
NSLog(@"%@", str);
NSString *nsText = [NSString stringWithUTF8String:text];
if (prefix) {
NSString *nsPrefix = [NSString stringWithUTF8String:prefix];
NSLog(@"%@: %@", nsPrefix, nsText);
} else {
NSLog(@"%@", nsText);
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -29,7 +29,7 @@
#include "../SDL_egl_c.h"
#endif
typedef struct SDL_WindowData SDL_WindowData;
@class SDL_WindowData;
typedef enum
{
@@ -40,7 +40,10 @@ typedef enum
} PendingWindowOperation;
@interface Cocoa_WindowListener : NSResponder <NSWindowDelegate> {
SDL_WindowData *_data;
/* 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;
BOOL observingVisible;
BOOL wasCtrlLeft;
BOOL wasVisible;
@@ -114,22 +117,22 @@ typedef enum
/* *INDENT-ON* */
@class SDLOpenGLContext;
@class SDL_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;
@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;
#if SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
@property (nonatomic) EGLSurface egl_surface;
#endif
};
@end
extern int Cocoa_CreateWindow(_THIS, SDL_Window * window);
extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window,
@@ -153,6 +156,7 @@ 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);

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -633,7 +633,7 @@ DirectFB_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const
static int
DirectFB_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
const float *xy, int xy_stride, const int *color, int color_stride, const float *uv, int uv_stride,
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y)
{

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

Some files were not shown because too many files have changed in this diff Show More