2015-06-21 17:33:46 +02:00
|
|
|
/*
|
|
|
|
|
Simple DirectMedia Layer
|
2024-01-01 13:15:26 -08:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
2022-11-29 18:34:15 -08:00
|
|
|
#include "SDL_internal.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2024-09-30 22:15:38 -07:00
|
|
|
#include "SDL_surface_c.h"
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef SDL_SSE_INTRINSICS
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
/* *INDENT-OFF* */ // clang-format off
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2021-03-04 18:27:56 +03:00
|
|
|
#if defined(_MSC_VER) && !defined(__clang__)
|
2015-06-21 17:33:46 +02:00
|
|
|
#define SSE_BEGIN \
|
|
|
|
|
__m128 c128; \
|
|
|
|
|
c128.m128_u32[0] = color; \
|
|
|
|
|
c128.m128_u32[1] = color; \
|
|
|
|
|
c128.m128_u32[2] = color; \
|
|
|
|
|
c128.m128_u32[3] = color;
|
|
|
|
|
#else
|
|
|
|
|
#define SSE_BEGIN \
|
|
|
|
|
__m128 c128; \
|
|
|
|
|
DECLARE_ALIGNED(Uint32, cccc[4], 16); \
|
|
|
|
|
cccc[0] = color; \
|
|
|
|
|
cccc[1] = color; \
|
|
|
|
|
cccc[2] = color; \
|
|
|
|
|
cccc[3] = color; \
|
|
|
|
|
c128 = *(__m128 *)cccc;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define SSE_WORK \
|
|
|
|
|
for (i = n / 64; i--;) { \
|
|
|
|
|
_mm_stream_ps((float *)(p+0), c128); \
|
|
|
|
|
_mm_stream_ps((float *)(p+16), c128); \
|
|
|
|
|
_mm_stream_ps((float *)(p+32), c128); \
|
|
|
|
|
_mm_stream_ps((float *)(p+48), c128); \
|
|
|
|
|
p += 64; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SSE_END
|
|
|
|
|
|
|
|
|
|
#define DEFINE_SSE_FILLRECT(bpp, type) \
|
2023-03-17 20:57:40 +03:00
|
|
|
static void SDL_TARGETING("sse") SDL_FillSurfaceRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
|
2015-06-21 17:33:46 +02:00
|
|
|
{ \
|
|
|
|
|
int i, n; \
|
|
|
|
|
Uint8 *p = NULL; \
|
2024-11-23 14:48:52 -08:00
|
|
|
\
|
|
|
|
|
/* If the number of bytes per row is equal to the pitch, treat */ \
|
|
|
|
|
/* all rows as one long continuous row (for better performance) */ \
|
|
|
|
|
if ((w) * (bpp) == pitch) { \
|
|
|
|
|
w = w * h; \
|
|
|
|
|
h = 1; \
|
|
|
|
|
} \
|
2015-06-21 17:33:46 +02:00
|
|
|
\
|
|
|
|
|
SSE_BEGIN; \
|
|
|
|
|
\
|
|
|
|
|
while (h--) { \
|
2022-12-05 15:20:48 +01:00
|
|
|
n = (w) * (bpp); \
|
2015-06-21 17:33:46 +02:00
|
|
|
p = pixels; \
|
|
|
|
|
\
|
|
|
|
|
if (n > 63) { \
|
|
|
|
|
int adjust = 16 - ((uintptr_t)p & 15); \
|
|
|
|
|
if (adjust < 16) { \
|
|
|
|
|
n -= adjust; \
|
2022-12-05 15:20:48 +01:00
|
|
|
adjust /= (bpp); \
|
2015-06-21 17:33:46 +02:00
|
|
|
while (adjust--) { \
|
|
|
|
|
*((type *)p) = (type)color; \
|
2022-12-05 15:20:48 +01:00
|
|
|
p += (bpp); \
|
2015-06-21 17:33:46 +02:00
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
SSE_WORK; \
|
|
|
|
|
} \
|
|
|
|
|
if (n & 63) { \
|
|
|
|
|
int remainder = (n & 63); \
|
2022-12-05 15:20:48 +01:00
|
|
|
remainder /= (bpp); \
|
2015-06-21 17:33:46 +02:00
|
|
|
while (remainder--) { \
|
|
|
|
|
*((type *)p) = (type)color; \
|
2022-12-05 15:20:48 +01:00
|
|
|
p += (bpp); \
|
2015-06-21 17:33:46 +02:00
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
pixels += pitch; \
|
|
|
|
|
} \
|
|
|
|
|
\
|
|
|
|
|
SSE_END; \
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-17 20:57:40 +03:00
|
|
|
static void SDL_TARGETING("sse") SDL_FillSurfaceRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
|
|
SSE_BEGIN;
|
|
|
|
|
while (h--) {
|
|
|
|
|
Uint8 *p = pixels;
|
|
|
|
|
n = w;
|
|
|
|
|
|
|
|
|
|
if (n > 63) {
|
|
|
|
|
int adjust = 16 - ((uintptr_t)p & 15);
|
|
|
|
|
if (adjust) {
|
|
|
|
|
n -= adjust;
|
|
|
|
|
SDL_memset(p, color, adjust);
|
|
|
|
|
p += adjust;
|
|
|
|
|
}
|
|
|
|
|
SSE_WORK;
|
|
|
|
|
}
|
|
|
|
|
if (n & 63) {
|
|
|
|
|
int remainder = (n & 63);
|
|
|
|
|
SDL_memset(p, color, remainder);
|
|
|
|
|
}
|
|
|
|
|
pixels += pitch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SSE_END;
|
|
|
|
|
}
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// DEFINE_SSE_FILLRECT(1, Uint8)
|
2015-06-21 17:33:46 +02:00
|
|
|
DEFINE_SSE_FILLRECT(2, Uint16)
|
|
|
|
|
DEFINE_SSE_FILLRECT(4, Uint32)
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
/* *INDENT-ON* */ // clang-format on
|
|
|
|
|
#endif // __SSE__
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2022-12-27 06:36:39 -08:00
|
|
|
static void SDL_FillSurfaceRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
Uint8 *p = NULL;
|
2022-11-30 12:51:59 -08:00
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
while (h--) {
|
|
|
|
|
n = w;
|
|
|
|
|
p = pixels;
|
|
|
|
|
|
|
|
|
|
if (n > 3) {
|
2022-11-30 12:51:59 -08:00
|
|
|
switch ((uintptr_t)p & 3) {
|
2015-06-21 17:33:46 +02:00
|
|
|
case 1:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
|
|
|
|
--n;
|
|
|
|
|
SDL_FALLTHROUGH;
|
2015-06-21 17:33:46 +02:00
|
|
|
case 2:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
|
|
|
|
--n;
|
|
|
|
|
SDL_FALLTHROUGH;
|
2015-06-21 17:33:46 +02:00
|
|
|
case 3:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.
So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).
Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.
Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).
All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-09-27 14:38:12 -07:00
|
|
|
--n;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
SDL_memset4(p, color, (n >> 2));
|
|
|
|
|
}
|
|
|
|
|
if (n & 3) {
|
|
|
|
|
p += (n & ~3);
|
|
|
|
|
switch (n & 3) {
|
|
|
|
|
case 3:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
|
|
|
|
SDL_FALLTHROUGH;
|
2015-06-21 17:33:46 +02:00
|
|
|
case 2:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
|
|
|
|
SDL_FALLTHROUGH;
|
2015-06-21 17:33:46 +02:00
|
|
|
case 1:
|
2022-11-30 12:51:59 -08:00
|
|
|
*p++ = (Uint8)color;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pixels += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 06:36:39 -08:00
|
|
|
static void SDL_FillSurfaceRect2(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
Uint16 *p = NULL;
|
2022-11-30 12:51:59 -08:00
|
|
|
|
2015-06-21 17:33:46 +02:00
|
|
|
while (h--) {
|
|
|
|
|
n = w;
|
2022-11-30 12:51:59 -08:00
|
|
|
p = (Uint16 *)pixels;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
|
|
|
|
if (n > 1) {
|
2022-11-30 12:51:59 -08:00
|
|
|
if ((uintptr_t)p & 2) {
|
|
|
|
|
*p++ = (Uint16)color;
|
2015-06-21 17:33:46 +02:00
|
|
|
--n;
|
|
|
|
|
}
|
|
|
|
|
SDL_memset4(p, color, (n >> 1));
|
|
|
|
|
}
|
|
|
|
|
if (n & 1) {
|
2022-11-30 12:51:59 -08:00
|
|
|
p[n - 1] = (Uint16)color;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
pixels += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 06:36:39 -08:00
|
|
|
static void SDL_FillSurfaceRect3(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
2022-11-30 12:51:59 -08:00
|
|
|
Uint8 b1 = (Uint8)(color & 0xFF);
|
|
|
|
|
Uint8 b2 = (Uint8)((color >> 8) & 0xFF);
|
|
|
|
|
Uint8 b3 = (Uint8)((color >> 16) & 0xFF);
|
2015-06-21 17:33:46 +02:00
|
|
|
#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
|
2022-11-30 12:51:59 -08:00
|
|
|
Uint8 b1 = (Uint8)((color >> 16) & 0xFF);
|
|
|
|
|
Uint8 b2 = (Uint8)((color >> 8) & 0xFF);
|
|
|
|
|
Uint8 b3 = (Uint8)(color & 0xFF);
|
2015-06-21 17:33:46 +02:00
|
|
|
#endif
|
|
|
|
|
int n;
|
|
|
|
|
Uint8 *p = NULL;
|
|
|
|
|
|
|
|
|
|
while (h--) {
|
|
|
|
|
n = w;
|
|
|
|
|
p = pixels;
|
|
|
|
|
|
|
|
|
|
while (n--) {
|
|
|
|
|
*p++ = b1;
|
|
|
|
|
*p++ = b2;
|
|
|
|
|
*p++ = b3;
|
|
|
|
|
}
|
|
|
|
|
pixels += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 06:36:39 -08:00
|
|
|
static void SDL_FillSurfaceRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
|
|
|
|
while (h--) {
|
|
|
|
|
SDL_memset4(pixels, color, w);
|
|
|
|
|
pixels += pitch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
/*
|
2015-06-21 17:33:46 +02:00
|
|
|
* This function performs a fast fill of the given rectangle with 'color'
|
|
|
|
|
*/
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
|
2015-06-21 17:33:46 +02:00
|
|
|
{
|
2024-07-08 14:59:18 -07:00
|
|
|
if (!SDL_SurfaceValid(dst)) {
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_InvalidParamError("SDL_FillSurfaceRect(): dst");
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// If 'rect' == NULL, then fill the whole surface
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!rect) {
|
2024-09-30 22:15:38 -07:00
|
|
|
rect = &dst->clip_rect;
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Don't attempt to fill if the surface's clip_rect is empty
|
2022-12-28 19:34:01 -08:00
|
|
|
if (SDL_RectEmpty(rect)) {
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_FillSurfaceRects(dst, rect, 1, color);
|
2019-10-15 14:03:01 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-18 07:52:28 -07:00
|
|
|
bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color)
|
2019-10-15 14:03:01 -04:00
|
|
|
{
|
|
|
|
|
SDL_Rect clipped;
|
|
|
|
|
Uint8 *pixels;
|
2022-11-30 12:51:59 -08:00
|
|
|
const SDL_Rect *rect;
|
2019-10-15 14:55:09 -04:00
|
|
|
void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL;
|
2019-10-15 14:03:01 -04:00
|
|
|
int i;
|
|
|
|
|
|
2024-07-08 14:59:18 -07:00
|
|
|
if (!SDL_SurfaceValid(dst)) {
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_InvalidParamError("SDL_FillSurfaceRects(): dst");
|
2019-10-15 14:03:01 -04:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Nothing to do
|
2020-11-27 09:42:14 +01:00
|
|
|
if (dst->w == 0 || dst->h == 0) {
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2020-11-27 09:42:14 +01:00
|
|
|
}
|
|
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Perform software fill
|
2015-06-21 17:33:46 +02:00
|
|
|
if (!dst->pixels) {
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_SetError("SDL_FillSurfaceRects(): You must lock the surface");
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2023-11-09 22:29:15 +01:00
|
|
|
if (!rects) {
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_InvalidParamError("SDL_FillSurfaceRects(): rects");
|
2019-10-15 14:03:01 -04:00
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2022-02-10 13:44:59 +01:00
|
|
|
/* This function doesn't usually work on surfaces < 8 bpp
|
|
|
|
|
* Except: support for 4bits, when filling full size.
|
|
|
|
|
*/
|
2024-07-08 14:59:18 -07:00
|
|
|
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
2022-02-10 13:44:59 +01:00
|
|
|
if (count == 1) {
|
|
|
|
|
const SDL_Rect *r = &rects[0];
|
2022-09-27 10:21:15 +02:00
|
|
|
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) {
|
2024-07-08 14:59:18 -07:00
|
|
|
if (SDL_BITSPERPIXEL(dst->format) == 4) {
|
2022-11-30 12:51:59 -08:00
|
|
|
Uint8 b = (((Uint8)color << 4) | (Uint8)color);
|
2022-12-01 16:07:03 -05:00
|
|
|
SDL_memset(dst->pixels, b, (size_t)dst->h * dst->pitch);
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2022-02-10 13:44:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-27 06:36:39 -08:00
|
|
|
return SDL_SetError("SDL_FillSurfaceRects(): Unsupported surface format");
|
2022-02-10 13:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-13 10:10:14 -05:00
|
|
|
if (fill_function == NULL) {
|
2024-07-08 14:59:18 -07:00
|
|
|
switch (SDL_BYTESPERPIXEL(dst->format)) {
|
2019-10-29 16:13:41 +01:00
|
|
|
case 1:
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
|
|
|
|
color |= (color << 8);
|
|
|
|
|
color |= (color << 16);
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef SDL_SSE_INTRINSICS
|
2022-11-30 12:51:59 -08:00
|
|
|
if (SDL_HasSSE()) {
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect1SSE;
|
2015-06-21 17:33:46 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2022-11-30 12:51:59 -08:00
|
|
|
#endif
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect1;
|
2022-11-30 12:51:59 -08:00
|
|
|
break;
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2019-10-29 16:13:41 +01:00
|
|
|
case 2:
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
|
|
|
|
color |= (color << 16);
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef SDL_SSE_INTRINSICS
|
2022-11-30 12:51:59 -08:00
|
|
|
if (SDL_HasSSE()) {
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect2SSE;
|
2015-06-21 17:33:46 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2022-11-30 12:51:59 -08:00
|
|
|
#endif
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect2;
|
2022-11-30 12:51:59 -08:00
|
|
|
break;
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2019-10-29 16:13:41 +01:00
|
|
|
case 3:
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// 24-bit RGB is a slow path, at least for now.
|
2019-10-29 16:13:41 +01:00
|
|
|
{
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect3;
|
2019-10-29 16:13:41 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2019-10-29 16:13:41 +01:00
|
|
|
case 4:
|
2022-11-30 12:51:59 -08:00
|
|
|
{
|
2023-03-30 20:26:31 +02:00
|
|
|
#ifdef SDL_SSE_INTRINSICS
|
2022-11-30 12:51:59 -08:00
|
|
|
if (SDL_HasSSE()) {
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect4SSE;
|
2015-06-21 17:33:46 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2022-11-30 12:51:59 -08:00
|
|
|
#endif
|
2022-12-27 06:36:39 -08:00
|
|
|
fill_function = SDL_FillSurfaceRect4;
|
2022-11-30 12:51:59 -08:00
|
|
|
break;
|
|
|
|
|
}
|
2019-10-15 14:55:09 -04:00
|
|
|
|
2019-10-29 16:13:41 +01:00
|
|
|
default:
|
|
|
|
|
return SDL_SetError("Unsupported pixel format");
|
|
|
|
|
}
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-15 14:03:01 -04:00
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
|
rect = &rects[i];
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// Perform clipping
|
2024-09-30 22:15:38 -07:00
|
|
|
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
|
2019-10-15 14:03:01 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
rect = &clipped;
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2022-11-30 12:51:59 -08:00
|
|
|
pixels = (Uint8 *)dst->pixels + rect->y * dst->pitch +
|
2024-07-08 14:59:18 -07:00
|
|
|
rect->x * SDL_BYTESPERPIXEL(dst->format);
|
2015-06-21 17:33:46 +02:00
|
|
|
|
2019-10-15 14:03:01 -04:00
|
|
|
fill_function(pixels, dst->pitch, color, rect->w, rect->h);
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|
2019-10-15 14:03:01 -04:00
|
|
|
|
Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
2024-08-22 10:30:45 -07:00
|
|
|
// We're done!
|
2024-08-22 17:33:49 -07:00
|
|
|
return true;
|
2015-06-21 17:33:46 +02:00
|
|
|
}
|