mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-22 11:18:14 +00:00
Simplified internal SDL_Surface structure
This commit is contained in:
@@ -86,9 +86,7 @@ typedef enum SDL_FlipMode
|
|||||||
SDL_FLIP_VERTICAL /**< flip vertically */
|
SDL_FLIP_VERTICAL /**< flip vertically */
|
||||||
} SDL_FlipMode;
|
} SDL_FlipMode;
|
||||||
|
|
||||||
/* Internal surface data */
|
#ifndef SDL_INTERNAL
|
||||||
typedef struct SDL_SurfaceData SDL_SurfaceData;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of pixels used in software blitting.
|
* A collection of pixels used in software blitting.
|
||||||
*
|
*
|
||||||
@@ -105,8 +103,11 @@ typedef struct SDL_SurfaceData SDL_SurfaceData;
|
|||||||
* alignment, and have undefined contents.
|
* alignment, and have undefined contents.
|
||||||
*
|
*
|
||||||
* \since This struct is available since SDL 3.0.0.
|
* \since This struct is available since SDL 3.0.0.
|
||||||
|
*
|
||||||
|
* \sa SDL_CreateSurface
|
||||||
|
* \sa SDL_DestroySurface
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Surface
|
struct SDL_Surface
|
||||||
{
|
{
|
||||||
SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */
|
SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */
|
||||||
SDL_PixelFormat format; /**< The format of the surface, read-only */
|
SDL_PixelFormat format; /**< The format of the surface, read-only */
|
||||||
@@ -117,10 +118,11 @@ typedef struct SDL_Surface
|
|||||||
|
|
||||||
int refcount; /**< Application reference count, used when freeing surface */
|
int refcount; /**< Application reference count, used when freeing surface */
|
||||||
|
|
||||||
SDL_SurfaceData *internal; /**< Private */
|
void *reserved; /**< Reserved for internal use */
|
||||||
|
};
|
||||||
} SDL_Surface;
|
#endif /* !SDL_INTERNAL */
|
||||||
|
|
||||||
|
typedef struct SDL_Surface SDL_Surface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new surface with a specific pixel format.
|
* Allocate a new surface with a specific pixel format.
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
#include "stdlib/SDL_getenv_c.h"
|
#include "stdlib/SDL_getenv_c.h"
|
||||||
#include "thread/SDL_thread_c.h"
|
#include "thread/SDL_thread_c.h"
|
||||||
#include "video/SDL_pixels_c.h"
|
#include "video/SDL_pixels_c.h"
|
||||||
|
#include "video/SDL_surface_c.h"
|
||||||
#include "video/SDL_video_c.h"
|
#include "video/SDL_video_c.h"
|
||||||
#include "filesystem/SDL_filesystem_c.h"
|
#include "filesystem/SDL_filesystem_c.h"
|
||||||
|
|
||||||
|
@@ -237,6 +237,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SDL_utils_c.h"
|
#include "SDL_utils_c.h"
|
||||||
|
#include "SDL_hashtable.h"
|
||||||
|
|
||||||
// Do any initialization that needs to happen before threads are started
|
// Do any initialization that needs to happen before threads are started
|
||||||
extern void SDL_InitMainThread(void);
|
extern void SDL_InitMainThread(void);
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
#include "SDL_hashtable.h"
|
|
||||||
#include "SDL_hints_c.h"
|
#include "SDL_hints_c.h"
|
||||||
#include "SDL_properties_c.h"
|
#include "SDL_properties_c.h"
|
||||||
|
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_hashtable.h"
|
|
||||||
|
|
||||||
#if defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE)
|
#if defined(SDL_PLATFORM_UNIX) || defined(SDL_PLATFORM_APPLE)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@@ -18,7 +18,8 @@
|
|||||||
misrepresented as being the original software.
|
misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
// This is included in SDL_internal.h
|
||||||
|
//#include "SDL_internal.h"
|
||||||
|
|
||||||
#ifndef SDL_utils_h_
|
#ifndef SDL_utils_h_
|
||||||
#define SDL_utils_h_
|
#define SDL_utils_h_
|
||||||
|
@@ -24,8 +24,6 @@
|
|||||||
#ifndef SDL_sysaudio_h_
|
#ifndef SDL_sysaudio_h_
|
||||||
#define SDL_sysaudio_h_
|
#define SDL_sysaudio_h_
|
||||||
|
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
|
|
||||||
#define DEBUG_AUDIOSTREAM 0
|
#define DEBUG_AUDIOSTREAM 0
|
||||||
#define DEBUG_AUDIO_CONVERT 0
|
#define DEBUG_AUDIO_CONVERT 0
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "SDL_syscamera.h"
|
#include "SDL_syscamera.h"
|
||||||
#include "SDL_camera_c.h"
|
#include "SDL_camera_c.h"
|
||||||
#include "../video/SDL_pixels_c.h"
|
#include "../video/SDL_pixels_c.h"
|
||||||
|
#include "../video/SDL_surface_c.h"
|
||||||
#include "../thread/SDL_systhread.h"
|
#include "../thread/SDL_systhread.h"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#ifndef SDL_syscamera_h_
|
#ifndef SDL_syscamera_h_
|
||||||
#define SDL_syscamera_h_
|
#define SDL_syscamera_h_
|
||||||
|
|
||||||
#include "../SDL_hashtable.h"
|
#include "../video/SDL_surface_c.h"
|
||||||
|
|
||||||
#define DEBUG_CAMERA 0
|
#define DEBUG_CAMERA 0
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "../SDL_syscamera.h"
|
#include "../SDL_syscamera.h"
|
||||||
#include "../SDL_camera_c.h"
|
#include "../SDL_camera_c.h"
|
||||||
#include "../../video/SDL_pixels_c.h"
|
#include "../../video/SDL_pixels_c.h"
|
||||||
|
#include "../../video/SDL_surface_c.h"
|
||||||
#include "../../thread/SDL_systhread.h"
|
#include "../../thread/SDL_systhread.h"
|
||||||
|
|
||||||
#ifdef SDL_CAMERA_DRIVER_ANDROID
|
#ifdef SDL_CAMERA_DRIVER_ANDROID
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "../SDL_syscamera.h"
|
#include "../SDL_syscamera.h"
|
||||||
#include "../SDL_camera_c.h"
|
#include "../SDL_camera_c.h"
|
||||||
#include "../../video/SDL_pixels_c.h"
|
#include "../../video/SDL_pixels_c.h"
|
||||||
|
#include "../../video/SDL_surface_c.h"
|
||||||
|
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ SDL_COMPILE_TIME_ASSERT(v4l2devicecaps, offsetof(struct v4l2_capability,device_c
|
|||||||
#include "../SDL_syscamera.h"
|
#include "../SDL_syscamera.h"
|
||||||
#include "../SDL_camera_c.h"
|
#include "../SDL_camera_c.h"
|
||||||
#include "../../video/SDL_pixels_c.h"
|
#include "../../video/SDL_pixels_c.h"
|
||||||
|
#include "../../video/SDL_surface_c.h"
|
||||||
#include "../../thread/SDL_systhread.h"
|
#include "../../thread/SDL_systhread.h"
|
||||||
#include "../../core/linux/SDL_evdev_capabilities.h"
|
#include "../../core/linux/SDL_evdev_capabilities.h"
|
||||||
#include "../../core/linux/SDL_udev.h"
|
#include "../../core/linux/SDL_udev.h"
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include "SDL_keymap_c.h"
|
#include "SDL_keymap_c.h"
|
||||||
#include "SDL_keyboard_c.h"
|
#include "SDL_keyboard_c.h"
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
|
|
||||||
struct SDL_Keymap
|
struct SDL_Keymap
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include "../../core/windows/SDL_windows.h"
|
#include "../../core/windows/SDL_windows.h"
|
||||||
#include "../../video/directx/SDL_d3d12.h"
|
#include "../../video/directx/SDL_d3d12.h"
|
||||||
#include "../SDL_sysgpu.h"
|
#include "../SDL_sysgpu.h"
|
||||||
#include "SDL_hashtable.h"
|
|
||||||
|
|
||||||
#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
|
#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
|
||||||
#define HAVE_IDXGIINFOQUEUE
|
#define HAVE_IDXGIINFOQUEUE
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
#include "../../video/khronos/vulkan/vulkan.h"
|
#include "../../video/khronos/vulkan/vulkan.h"
|
||||||
|
|
||||||
#include "SDL_hashtable.h"
|
|
||||||
#include <SDL3/SDL_vulkan.h>
|
#include <SDL3/SDL_vulkan.h>
|
||||||
|
|
||||||
#include "../SDL_sysgpu.h"
|
#include "../SDL_sysgpu.h"
|
||||||
|
@@ -31,7 +31,6 @@
|
|||||||
#include "usb_ids.h"
|
#include "usb_ids.h"
|
||||||
#include "hidapi/SDL_hidapi_nintendo.h"
|
#include "hidapi/SDL_hidapi_nintendo.h"
|
||||||
#include "../events/SDL_events_c.h"
|
#include "../events/SDL_events_c.h"
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SDL_PLATFORM_ANDROID
|
#ifdef SDL_PLATFORM_ANDROID
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
#ifndef SDL_sysrender_h_
|
#ifndef SDL_sysrender_h_
|
||||||
#define SDL_sysrender_h_
|
#define SDL_sysrender_h_
|
||||||
|
|
||||||
|
#include "../video/SDL_surface_c.h"
|
||||||
|
|
||||||
#include "SDL_yuv_sw_c.h"
|
#include "SDL_yuv_sw_c.h"
|
||||||
|
|
||||||
// Set up for C function definitions, even when using C++
|
// Set up for C function definitions, even when using C++
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#if SDL_HAVE_YUV
|
#if SDL_HAVE_YUV
|
||||||
|
|
||||||
#include "SDL_yuv_sw_c.h"
|
#include "SDL_yuv_sw_c.h"
|
||||||
#include "../video/SDL_blit.h"
|
#include "../video/SDL_surface_c.h"
|
||||||
#include "../video/SDL_yuv_c.h"
|
#include "../video/SDL_yuv_c.h"
|
||||||
|
|
||||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h)
|
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h)
|
||||||
|
@@ -26,8 +26,6 @@
|
|||||||
|
|
||||||
#include "SDL_shaders_gpu.h"
|
#include "SDL_shaders_gpu.h"
|
||||||
|
|
||||||
#include "SDL_hashtable.h"
|
|
||||||
|
|
||||||
typedef struct GPU_PipelineParameters
|
typedef struct GPU_PipelineParameters
|
||||||
{
|
{
|
||||||
SDL_BlendMode blend_mode;
|
SDL_BlendMode blend_mode;
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow
|
#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow
|
||||||
#include <SDL3/SDL_opengles2.h>
|
#include <SDL3/SDL_opengles2.h>
|
||||||
#include "../SDL_sysrender.h"
|
#include "../SDL_sysrender.h"
|
||||||
#include "../../video/SDL_blit.h"
|
|
||||||
#include "../../video/SDL_pixels_c.h"
|
#include "../../video/SDL_pixels_c.h"
|
||||||
#include "SDL_shaders_gles2.h"
|
#include "SDL_shaders_gles2.h"
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ static bool SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
|||||||
static bool SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
static bool SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned inva = 0xff - a;
|
unsigned inva = 0xff - a;
|
||||||
|
|
||||||
switch (fmt->bytes_per_pixel) {
|
switch (fmt->bytes_per_pixel) {
|
||||||
@@ -202,7 +202,7 @@ static bool SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
|||||||
static bool SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
static bool SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned inva = 0xff - a;
|
unsigned inva = 0xff - a;
|
||||||
|
|
||||||
switch (fmt->bytes_per_pixel) {
|
switch (fmt->bytes_per_pixel) {
|
||||||
@@ -250,12 +250,12 @@ bool SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode ble
|
|||||||
// If 'rect' == NULL, then fill the whole surface
|
// If 'rect' == NULL, then fill the whole surface
|
||||||
if (rect) {
|
if (rect) {
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
rect = &clipped;
|
rect = &clipped;
|
||||||
} else {
|
} else {
|
||||||
rect = &dst->internal->clip_rect;
|
rect = &dst->clip_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||||
@@ -264,23 +264,23 @@ bool SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode ble
|
|||||||
b = DRAW_MUL(b, a);
|
b = DRAW_MUL(b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dst->internal->format->bits_per_pixel) {
|
switch (dst->fmt->bits_per_pixel) {
|
||||||
case 15:
|
case 15:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x7C00:
|
case 0x7C00:
|
||||||
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0xF800:
|
case 0xF800:
|
||||||
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x00FF0000:
|
case 0x00FF0000:
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
return SDL_BlendFillRect_XRGB8888(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_XRGB8888(dst, rect, blendMode, r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||||
@@ -292,7 +292,7 @@ bool SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode ble
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
|
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
|
||||||
@@ -311,7 +311,7 @@ bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function doesn't work on surfaces < 8 bpp
|
// This function doesn't work on surfaces < 8 bpp
|
||||||
if (dst->internal->format->bits_per_pixel < 8) {
|
if (dst->fmt->bits_per_pixel < 8) {
|
||||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,23 +322,23 @@ bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Does this function pointer slow things down significantly?
|
// FIXME: Does this function pointer slow things down significantly?
|
||||||
switch (dst->internal->format->bits_per_pixel) {
|
switch (dst->fmt->bits_per_pixel) {
|
||||||
case 15:
|
case 15:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x7C00:
|
case 0x7C00:
|
||||||
func = SDL_BlendFillRect_RGB555;
|
func = SDL_BlendFillRect_RGB555;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0xF800:
|
case 0xF800:
|
||||||
func = SDL_BlendFillRect_RGB565;
|
func = SDL_BlendFillRect_RGB565;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x00FF0000:
|
case 0x00FF0000:
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
func = SDL_BlendFillRect_XRGB8888;
|
func = SDL_BlendFillRect_XRGB8888;
|
||||||
} else {
|
} else {
|
||||||
func = SDL_BlendFillRect_ARGB8888;
|
func = SDL_BlendFillRect_ARGB8888;
|
||||||
@@ -351,7 +351,7 @@ bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!func) {
|
if (!func) {
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
func = SDL_BlendFillRect_RGB;
|
func = SDL_BlendFillRect_RGB;
|
||||||
} else {
|
} else {
|
||||||
func = SDL_BlendFillRect_RGBA;
|
func = SDL_BlendFillRect_RGBA;
|
||||||
@@ -360,7 +360,7 @@ bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_
|
|||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
|
if (!SDL_GetRectIntersection(&rects[i], &dst->clip_rect, &rect)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result = func(dst, &rect, blendMode, r, g, b, a);
|
result = func(dst, &rect, blendMode, r, g, b, a);
|
||||||
|
@@ -30,7 +30,7 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
|||||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||||
bool draw_end)
|
bool draw_end)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned r, g, b, a, inva;
|
unsigned r, g, b, a, inva;
|
||||||
|
|
||||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||||
@@ -397,7 +397,7 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
|||||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||||
bool draw_end)
|
bool draw_end)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned r, g, b, a, inva;
|
unsigned r, g, b, a, inva;
|
||||||
|
|
||||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||||
@@ -520,7 +520,7 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
|
|||||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||||
bool draw_end)
|
bool draw_end)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned r, g, b, a, inva;
|
unsigned r, g, b, a, inva;
|
||||||
|
|
||||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||||
@@ -927,14 +927,14 @@ bool SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMo
|
|||||||
return SDL_InvalidParamError("SDL_BlendLine(): dst");
|
return SDL_InvalidParamError("SDL_BlendLine(): dst");
|
||||||
}
|
}
|
||||||
|
|
||||||
func = SDL_CalculateBlendLineFunc(dst->internal->format);
|
func = SDL_CalculateBlendLineFunc(dst->fmt);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
// FIXME: We don't actually want to clip, as it may change line slope
|
// FIXME: We don't actually want to clip, as it may change line slope
|
||||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,7 +954,7 @@ bool SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_Bl
|
|||||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||||
}
|
}
|
||||||
|
|
||||||
func = SDL_CalculateBlendLineFunc(dst->internal->format);
|
func = SDL_CalculateBlendLineFunc(dst->fmt);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
@@ -967,7 +967,7 @@ bool SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_Bl
|
|||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
// FIXME: We don't actually want to clip, as it may change line slope
|
// FIXME: We don't actually want to clip, as it may change line slope
|
||||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ static bool SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMod
|
|||||||
static bool SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
static bool SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||||
Uint8 g, Uint8 b, Uint8 a)
|
Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned inva = 0xff - a;
|
unsigned inva = 0xff - a;
|
||||||
|
|
||||||
switch (fmt->bytes_per_pixel) {
|
switch (fmt->bytes_per_pixel) {
|
||||||
@@ -202,7 +202,7 @@ static bool SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode ble
|
|||||||
static bool SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
static bool SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||||
Uint8 g, Uint8 b, Uint8 a)
|
Uint8 g, Uint8 b, Uint8 a)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
unsigned inva = 0xff - a;
|
unsigned inva = 0xff - a;
|
||||||
|
|
||||||
switch (fmt->bytes_per_pixel) {
|
switch (fmt->bytes_per_pixel) {
|
||||||
@@ -246,9 +246,9 @@ bool SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,23 +258,23 @@ bool SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uin
|
|||||||
b = DRAW_MUL(b, a);
|
b = DRAW_MUL(b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dst->internal->format->bits_per_pixel) {
|
switch (dst->fmt->bits_per_pixel) {
|
||||||
case 15:
|
case 15:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x7C00:
|
case 0x7C00:
|
||||||
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0xF800:
|
case 0xF800:
|
||||||
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x00FF0000:
|
case 0x00FF0000:
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
return SDL_BlendPoint_XRGB8888(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_XRGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||||
@@ -286,7 +286,7 @@ bool SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uin
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
|
return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
|
||||||
@@ -307,7 +307,7 @@ bool SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_B
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function doesn't work on surfaces < 8 bpp
|
// This function doesn't work on surfaces < 8 bpp
|
||||||
if (dst->internal->format->bits_per_pixel < 8) {
|
if (dst->fmt->bits_per_pixel < 8) {
|
||||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,25 +318,25 @@ bool SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_B
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Does this function pointer slow things down significantly?
|
// FIXME: Does this function pointer slow things down significantly?
|
||||||
switch (dst->internal->format->bits_per_pixel) {
|
switch (dst->fmt->bits_per_pixel) {
|
||||||
case 15:
|
case 15:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x7C00:
|
case 0x7C00:
|
||||||
func = SDL_BlendPoint_RGB555;
|
func = SDL_BlendPoint_RGB555;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0xF800:
|
case 0xF800:
|
||||||
func = SDL_BlendPoint_RGB565;
|
func = SDL_BlendPoint_RGB565;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
switch (dst->internal->format->Rmask) {
|
switch (dst->fmt->Rmask) {
|
||||||
case 0x00FF0000:
|
case 0x00FF0000:
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
func = SDL_BlendPoint_XRGB8888;
|
func = SDL_BlendPoint_XRGB8888;
|
||||||
} else {
|
} else {
|
||||||
func = SDL_BlendPoint_ARGB8888;
|
func = SDL_BlendPoint_ARGB8888;
|
||||||
@@ -349,17 +349,17 @@ bool SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_B
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!func) {
|
if (!func) {
|
||||||
if (!dst->internal->format->Amask) {
|
if (!dst->fmt->Amask) {
|
||||||
func = SDL_BlendPoint_RGB;
|
func = SDL_BlendPoint_RGB;
|
||||||
} else {
|
} else {
|
||||||
func = SDL_BlendPoint_RGBA;
|
func = SDL_BlendPoint_RGBA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minx = dst->internal->clip_rect.x;
|
minx = dst->clip_rect.x;
|
||||||
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
|
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||||
miny = dst->internal->clip_rect.y;
|
miny = dst->clip_rect.y;
|
||||||
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
|
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
x = points[i].x;
|
x = points[i].x;
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "../../video/SDL_blit.h"
|
#include "../../video/SDL_surface_c.h"
|
||||||
|
|
||||||
/* This code assumes that r, g, b, a are the source color,
|
/* This code assumes that r, g, b, a are the source color,
|
||||||
* and in the blend and add case, the RGB values are premultiplied by a.
|
* and in the blend and add case, the RGB values are premultiplied by a.
|
||||||
@@ -428,7 +428,7 @@
|
|||||||
#define HLINE(type, op, draw_end) \
|
#define HLINE(type, op, draw_end) \
|
||||||
{ \
|
{ \
|
||||||
int length; \
|
int length; \
|
||||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
|
||||||
type *pixel; \
|
type *pixel; \
|
||||||
if (x1 <= x2) { \
|
if (x1 <= x2) { \
|
||||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||||
@@ -450,7 +450,7 @@
|
|||||||
#define VLINE(type, op, draw_end) \
|
#define VLINE(type, op, draw_end) \
|
||||||
{ \
|
{ \
|
||||||
int length; \
|
int length; \
|
||||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
|
||||||
type *pixel; \
|
type *pixel; \
|
||||||
if (y1 <= y2) { \
|
if (y1 <= y2) { \
|
||||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||||
@@ -472,7 +472,7 @@
|
|||||||
#define DLINE(type, op, draw_end) \
|
#define DLINE(type, op, draw_end) \
|
||||||
{ \
|
{ \
|
||||||
int length; \
|
int length; \
|
||||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
|
||||||
type *pixel; \
|
type *pixel; \
|
||||||
if (y1 <= y2) { \
|
if (y1 <= y2) { \
|
||||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||||
@@ -692,7 +692,7 @@
|
|||||||
do { \
|
do { \
|
||||||
int width = rect->w; \
|
int width = rect->w; \
|
||||||
int height = rect->h; \
|
int height = rect->h; \
|
||||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
|
||||||
int skip = pitch - width; \
|
int skip = pitch - width; \
|
||||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||||
while (height--) { \
|
while (height--) { \
|
||||||
|
@@ -31,7 +31,7 @@ static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||||||
{
|
{
|
||||||
if (y1 == y2) {
|
if (y1 == y2) {
|
||||||
int length;
|
int length;
|
||||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel);
|
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel);
|
||||||
Uint8 *pixel;
|
Uint8 *pixel;
|
||||||
if (x1 <= x2) {
|
if (x1 <= x2) {
|
||||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||||
@@ -64,8 +64,8 @@ static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||||
} else {
|
} else {
|
||||||
Uint8 _r, _g, _b, _a;
|
Uint8 _r, _g, _b, _a;
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
|
SDL_GetRGBA(color, fmt, dst->palette, &_r, &_g, &_b, &_a);
|
||||||
if (fmt->Rmask == 0x7C00) {
|
if (fmt->Rmask == 0x7C00) {
|
||||||
AALINE(x1, y1, x2, y2,
|
AALINE(x1, y1, x2, y2,
|
||||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
|
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||||
@@ -93,8 +93,8 @@ static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||||
} else {
|
} else {
|
||||||
Uint8 _r, _g, _b, _a;
|
Uint8 _r, _g, _b, _a;
|
||||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = dst->fmt;
|
||||||
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
|
SDL_GetRGBA(color, fmt, dst->palette, &_r, &_g, &_b, &_a);
|
||||||
if (fmt->Rmask == 0x00FF0000) {
|
if (fmt->Rmask == 0x00FF0000) {
|
||||||
if (!fmt->Amask) {
|
if (!fmt->Amask) {
|
||||||
AALINE(x1, y1, x2, y2,
|
AALINE(x1, y1, x2, y2,
|
||||||
@@ -141,14 +141,14 @@ bool SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color
|
|||||||
return SDL_InvalidParamError("SDL_DrawLine(): dst");
|
return SDL_InvalidParamError("SDL_DrawLine(): dst");
|
||||||
}
|
}
|
||||||
|
|
||||||
func = SDL_CalculateDrawLineFunc(dst->internal->format);
|
func = SDL_CalculateDrawLineFunc(dst->fmt);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
// FIXME: We don't actually want to clip, as it may change line slope
|
// FIXME: We don't actually want to clip, as it may change line slope
|
||||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ bool SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
|
|||||||
return SDL_InvalidParamError("SDL_DrawLines(): dst");
|
return SDL_InvalidParamError("SDL_DrawLines(): dst");
|
||||||
}
|
}
|
||||||
|
|
||||||
func = SDL_CalculateDrawLineFunc(dst->internal->format);
|
func = SDL_CalculateDrawLineFunc(dst->fmt);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ bool SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
|
|||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
// FIXME: We don't actually want to clip, as it may change line slope
|
// FIXME: We don't actually want to clip, as it may change line slope
|
||||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,18 +32,18 @@ bool SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function doesn't work on surfaces < 8 bpp
|
// This function doesn't work on surfaces < 8 bpp
|
||||||
if (dst->internal->format->bits_per_pixel < 8) {
|
if (dst->fmt->bits_per_pixel < 8) {
|
||||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dst->internal->format->bytes_per_pixel) {
|
switch (dst->fmt->bytes_per_pixel) {
|
||||||
case 1:
|
case 1:
|
||||||
DRAW_FASTSETPIXELXY1(x, y);
|
DRAW_FASTSETPIXELXY1(x, y);
|
||||||
break;
|
break;
|
||||||
@@ -71,14 +71,14 @@ bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function doesn't work on surfaces < 8 bpp
|
// This function doesn't work on surfaces < 8 bpp
|
||||||
if (dst->internal->format->bits_per_pixel < 8) {
|
if (dst->fmt->bits_per_pixel < 8) {
|
||||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||||
}
|
}
|
||||||
|
|
||||||
minx = dst->internal->clip_rect.x;
|
minx = dst->clip_rect.x;
|
||||||
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
|
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||||
miny = dst->internal->clip_rect.y;
|
miny = dst->clip_rect.y;
|
||||||
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
|
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
x = points[i].x;
|
x = points[i].x;
|
||||||
@@ -88,7 +88,7 @@ bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (dst->internal->format->bytes_per_pixel) {
|
switch (dst->fmt->bytes_per_pixel) {
|
||||||
case 1:
|
case 1:
|
||||||
DRAW_FASTSETPIXELXY1(x, y);
|
DRAW_FASTSETPIXELXY1(x, y);
|
||||||
break;
|
break;
|
||||||
|
@@ -142,8 +142,8 @@ static bool SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
src = (Uint8 *)pixels;
|
src = (Uint8 *)pixels;
|
||||||
dst = (Uint8 *)surface->pixels +
|
dst = (Uint8 *)surface->pixels +
|
||||||
rect->y * surface->pitch +
|
rect->y * surface->pitch +
|
||||||
rect->x * surface->internal->format->bytes_per_pixel;
|
rect->x * surface->fmt->bytes_per_pixel;
|
||||||
length = (size_t)rect->w * surface->internal->format->bytes_per_pixel;
|
length = (size_t)rect->w * surface->fmt->bytes_per_pixel;
|
||||||
for (row = 0; row < rect->h; ++row) {
|
for (row = 0; row < rect->h; ++row) {
|
||||||
SDL_memcpy(dst, src, length);
|
SDL_memcpy(dst, src, length);
|
||||||
src += pitch;
|
src += pitch;
|
||||||
@@ -162,7 +162,7 @@ static bool SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||||||
|
|
||||||
*pixels =
|
*pixels =
|
||||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||||
rect->x * surface->internal->format->bytes_per_pixel);
|
rect->x * surface->fmt->bytes_per_pixel);
|
||||||
*pitch = surface->pitch;
|
*pitch = surface->pitch;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -364,7 +364,7 @@ static bool SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Te
|
|||||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||||
|
|
||||||
// SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted.
|
// SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted.
|
||||||
if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
|
if (src->fmt->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
|
||||||
blitRequired = true;
|
blitRequired = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -984,7 +984,7 @@ static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
|||||||
|
|
||||||
pixels = (void *)((Uint8 *)surface->pixels +
|
pixels = (void *)((Uint8 *)surface->pixels +
|
||||||
rect->y * surface->pitch +
|
rect->y * surface->pitch +
|
||||||
rect->x * surface->internal->format->bytes_per_pixel);
|
rect->x * surface->fmt->bytes_per_pixel);
|
||||||
|
|
||||||
return SDL_DuplicatePixels(rect->w, rect->h, surface->format, SDL_COLORSPACE_SRGB, pixels, surface->pitch);
|
return SDL_DuplicatePixels(rect->w, rect->h, surface->format, SDL_COLORSPACE_SRGB, pixels, surface->pitch);
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
|||||||
|
|
||||||
#include "SDL_rotate.h"
|
#include "SDL_rotate.h"
|
||||||
|
|
||||||
#include "../../video/SDL_blit.h"
|
#include "../../video/SDL_surface_c.h"
|
||||||
|
|
||||||
// ---- Internally used structures
|
// ---- Internally used structures
|
||||||
|
|
||||||
@@ -506,8 +506,8 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// This function requires a 32-bit surface or 8-bit surface with a colorkey
|
// This function requires a 32-bit surface or 8-bit surface with a colorkey
|
||||||
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
|
is8bit = src->fmt->bits_per_pixel == 8 && colorKeyAvailable;
|
||||||
if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
|
if (!(is8bit || (src->fmt->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,7 +521,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||||||
// Target surface is 8 bit
|
// Target surface is 8 bit
|
||||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||||
if (rz_dst) {
|
if (rz_dst) {
|
||||||
SDL_SetSurfacePalette(rz_dst, src->internal->palette);
|
SDL_SetSurfacePalette(rz_dst, src->palette);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Target surface is 32 bit with source RGBA ordering
|
// Target surface is 32 bit with source RGBA ordering
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "SDL_triangle.h"
|
#include "SDL_triangle.h"
|
||||||
|
|
||||||
#include "../../video/SDL_blit.h"
|
#include "../../video/SDL_surface_c.h"
|
||||||
|
|
||||||
/* fixed points bits precision
|
/* fixed points bits precision
|
||||||
* Set to 1, so that it can start rendering with middle of a pixel precision.
|
* Set to 1, so that it can start rendering with middle of a pixel precision.
|
||||||
@@ -309,13 +309,13 @@ bool SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poi
|
|||||||
|
|
||||||
SDL_SetSurfaceBlendMode(tmp, blend);
|
SDL_SetSurfaceBlendMode(tmp, blend);
|
||||||
|
|
||||||
dstbpp = tmp->internal->format->bytes_per_pixel;
|
dstbpp = tmp->fmt->bytes_per_pixel;
|
||||||
dst_ptr = (Uint8 *)tmp->pixels;
|
dst_ptr = (Uint8 *)tmp->pixels;
|
||||||
dst_pitch = tmp->pitch;
|
dst_pitch = tmp->pitch;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Write directly to destination surface
|
// Write directly to destination surface
|
||||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
dstbpp = dst->fmt->bytes_per_pixel;
|
||||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||||
dst_pitch = dst->pitch;
|
dst_pitch = dst->pitch;
|
||||||
}
|
}
|
||||||
@@ -406,11 +406,11 @@ bool SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poi
|
|||||||
const SDL_PixelFormatDetails *format;
|
const SDL_PixelFormatDetails *format;
|
||||||
SDL_Palette *palette;
|
SDL_Palette *palette;
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
format = tmp->internal->format;
|
format = tmp->fmt;
|
||||||
palette = tmp->internal->palette;
|
palette = tmp->palette;
|
||||||
} else {
|
} else {
|
||||||
format = dst->internal->format;
|
format = dst->fmt;
|
||||||
palette = dst->internal->palette;
|
palette = dst->palette;
|
||||||
}
|
}
|
||||||
if (dstbpp == 4) {
|
if (dstbpp == 4) {
|
||||||
TRIANGLE_BEGIN_LOOP
|
TRIANGLE_BEGIN_LOOP
|
||||||
@@ -584,7 +584,7 @@ bool SDL_SW_BlitTriangle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set destination pointer
|
// Set destination pointer
|
||||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
dstbpp = dst->fmt->bytes_per_pixel;
|
||||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||||
dst_pitch = dst->pitch;
|
dst_pitch = dst->pitch;
|
||||||
|
|
||||||
@@ -662,13 +662,13 @@ bool SDL_SW_BlitTriangle(
|
|||||||
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
|
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
|
||||||
// Use SDL_BlitTriangle_Slow
|
// Use SDL_BlitTriangle_Slow
|
||||||
|
|
||||||
SDL_BlitInfo *info = &src->internal->map.info;
|
SDL_BlitInfo *info = &src->map.info;
|
||||||
SDL_BlitInfo tmp_info;
|
SDL_BlitInfo tmp_info;
|
||||||
|
|
||||||
SDL_zero(tmp_info);
|
SDL_zero(tmp_info);
|
||||||
|
|
||||||
tmp_info.src_fmt = src->internal->format;
|
tmp_info.src_fmt = src->fmt;
|
||||||
tmp_info.dst_fmt = dst->internal->format;
|
tmp_info.dst_fmt = dst->fmt;
|
||||||
tmp_info.flags = info->flags;
|
tmp_info.flags = info->flags;
|
||||||
/*
|
/*
|
||||||
tmp_info.r = info->r;
|
tmp_info.r = info->r;
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
#include "SDL_getenv_c.h"
|
#include "SDL_getenv_c.h"
|
||||||
|
|
||||||
#if defined(SDL_PLATFORM_WINDOWS)
|
#if defined(SDL_PLATFORM_WINDOWS)
|
||||||
|
@@ -88,7 +88,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_RLEaccel_c.h"
|
#include "SDL_RLEaccel_c.h"
|
||||||
|
|
||||||
#define PIXEL_COPY(to, from, len, bpp) \
|
#define PIXEL_COPY(to, from, len, bpp) \
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||||
Uint8 *dstbuf, const SDL_Rect *srcrect, unsigned alpha)
|
Uint8 *dstbuf, const SDL_Rect *srcrect, unsigned alpha)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *fmt = surf_dst->internal->format;
|
const SDL_PixelFormatDetails *fmt = surf_dst->fmt;
|
||||||
|
|
||||||
CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt);
|
CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt);
|
||||||
}
|
}
|
||||||
@@ -461,8 +461,8 @@ static bool SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||||||
// Set up the source and destination pointers
|
// Set up the source and destination pointers
|
||||||
x = dstrect->x;
|
x = dstrect->x;
|
||||||
y = dstrect->y;
|
y = dstrect->y;
|
||||||
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->internal->format->bytes_per_pixel;
|
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->fmt->bytes_per_pixel;
|
||||||
srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat);
|
srcbuf = (Uint8 *)surf_src->map.data + sizeof(SDL_PixelFormat);
|
||||||
|
|
||||||
{
|
{
|
||||||
// skip lines at the top if necessary
|
// skip lines at the top if necessary
|
||||||
@@ -488,7 +488,7 @@ static bool SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (surf_src->internal->format->bytes_per_pixel) {
|
switch (surf_src->fmt->bytes_per_pixel) {
|
||||||
case 1:
|
case 1:
|
||||||
RLESKIP(1, Uint8);
|
RLESKIP(1, Uint8);
|
||||||
break;
|
break;
|
||||||
@@ -507,12 +507,12 @@ static bool SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alpha = surf_src->internal->map.info.a;
|
alpha = surf_src->map.info.a;
|
||||||
// if left or right edge clipping needed, call clip blit
|
// if left or right edge clipping needed, call clip blit
|
||||||
if (srcrect->x || srcrect->w != surf_src->w) {
|
if (srcrect->x || srcrect->w != surf_src->w) {
|
||||||
RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
|
RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
|
||||||
} else {
|
} else {
|
||||||
const SDL_PixelFormatDetails *fmt = surf_src->internal->format;
|
const SDL_PixelFormatDetails *fmt = surf_src->fmt;
|
||||||
|
|
||||||
#define RLEBLIT(bpp, Type, do_blit) \
|
#define RLEBLIT(bpp, Type, do_blit) \
|
||||||
do { \
|
do { \
|
||||||
@@ -608,7 +608,7 @@ done:
|
|||||||
static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||||
Uint8 *dstbuf, const SDL_Rect *srcrect)
|
Uint8 *dstbuf, const SDL_Rect *srcrect)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *df = surf_dst->internal->format;
|
const SDL_PixelFormatDetails *df = surf_dst->fmt;
|
||||||
/*
|
/*
|
||||||
* clipped blitter: Ptype is the destination pixel type,
|
* clipped blitter: Ptype is the destination pixel type,
|
||||||
* Ctype the translucent count type, and do_blend the macro
|
* Ctype the translucent count type, and do_blend the macro
|
||||||
@@ -703,7 +703,7 @@ static bool SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcr
|
|||||||
int x, y;
|
int x, y;
|
||||||
int w = surf_src->w;
|
int w = surf_src->w;
|
||||||
Uint8 *srcbuf, *dstbuf;
|
Uint8 *srcbuf, *dstbuf;
|
||||||
const SDL_PixelFormatDetails *df = surf_dst->internal->format;
|
const SDL_PixelFormatDetails *df = surf_dst->fmt;
|
||||||
|
|
||||||
// Lock the destination if necessary
|
// Lock the destination if necessary
|
||||||
if (SDL_MUSTLOCK(surf_dst)) {
|
if (SDL_MUSTLOCK(surf_dst)) {
|
||||||
@@ -715,7 +715,7 @@ static bool SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcr
|
|||||||
x = dstrect->x;
|
x = dstrect->x;
|
||||||
y = dstrect->y;
|
y = dstrect->y;
|
||||||
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * df->bytes_per_pixel;
|
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * df->bytes_per_pixel;
|
||||||
srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat);
|
srcbuf = (Uint8 *)surf_src->map.data + sizeof(SDL_PixelFormat);
|
||||||
|
|
||||||
{
|
{
|
||||||
// skip lines at the top if necessary
|
// skip lines at the top if necessary
|
||||||
@@ -1002,12 +1002,12 @@ static bool RLEAlphaSurface(SDL_Surface *surface)
|
|||||||
int (*copy_transl)(void *, const Uint32 *, int,
|
int (*copy_transl)(void *, const Uint32 *, int,
|
||||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||||
|
|
||||||
dest = surface->internal->map.info.dst_surface;
|
dest = surface->map.info.dst_surface;
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
df = dest->internal->format;
|
df = dest->fmt;
|
||||||
if (surface->internal->format->bits_per_pixel != 32) {
|
if (surface->fmt->bits_per_pixel != 32) {
|
||||||
return false; // only 32bpp source supported
|
return false; // only 32bpp source supported
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1071,7 +1071,7 @@ static bool RLEAlphaSurface(SDL_Surface *surface)
|
|||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
int h = surface->h, w = surface->w;
|
int h = surface->h, w = surface->w;
|
||||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
const SDL_PixelFormatDetails *sf = surface->fmt;
|
||||||
Uint32 *src = (Uint32 *)surface->pixels;
|
Uint32 *src = (Uint32 *)surface->pixels;
|
||||||
Uint8 *lastline = dst; // end of last non-blank line
|
Uint8 *lastline = dst; // end of last non-blank line
|
||||||
|
|
||||||
@@ -1194,7 +1194,7 @@ static bool RLEAlphaSurface(SDL_Surface *surface)
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
p = rlebuf;
|
p = rlebuf;
|
||||||
}
|
}
|
||||||
surface->internal->map.data = p;
|
surface->map.data = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1237,7 +1237,7 @@ static bool RLEColorkeySurface(SDL_Surface *surface)
|
|||||||
int y;
|
int y;
|
||||||
Uint8 *srcbuf, *lastline;
|
Uint8 *srcbuf, *lastline;
|
||||||
int maxsize = 0;
|
int maxsize = 0;
|
||||||
const int bpp = surface->internal->format->bytes_per_pixel;
|
const int bpp = surface->fmt->bytes_per_pixel;
|
||||||
getpix_func getpix;
|
getpix_func getpix;
|
||||||
Uint32 ckey, rgbmask;
|
Uint32 ckey, rgbmask;
|
||||||
int w, h;
|
int w, h;
|
||||||
@@ -1272,8 +1272,8 @@ static bool RLEColorkeySurface(SDL_Surface *surface)
|
|||||||
srcbuf = (Uint8 *)surface->pixels;
|
srcbuf = (Uint8 *)surface->pixels;
|
||||||
maxn = bpp == 4 ? 65535 : 255;
|
maxn = bpp == 4 ? 65535 : 255;
|
||||||
dst = rlebuf;
|
dst = rlebuf;
|
||||||
rgbmask = ~surface->internal->format->Amask;
|
rgbmask = ~surface->fmt->Amask;
|
||||||
ckey = surface->internal->map.info.colorkey & rgbmask;
|
ckey = surface->map.info.colorkey & rgbmask;
|
||||||
lastline = dst;
|
lastline = dst;
|
||||||
getpix = getpixes[bpp - 1];
|
getpix = getpixes[bpp - 1];
|
||||||
w = surface->w;
|
w = surface->w;
|
||||||
@@ -1362,7 +1362,7 @@ static bool RLEColorkeySurface(SDL_Surface *surface)
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
p = rlebuf;
|
p = rlebuf;
|
||||||
}
|
}
|
||||||
surface->internal->map.data = p;
|
surface->map.data = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1373,7 +1373,7 @@ bool SDL_RLESurface(SDL_Surface *surface)
|
|||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// Clear any previous RLE conversion
|
// Clear any previous RLE conversion
|
||||||
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||||
SDL_UnRLESurface(surface, true);
|
SDL_UnRLESurface(surface, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1387,7 +1387,7 @@ bool SDL_RLESurface(SDL_Surface *surface)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = surface->internal->map.info.flags;
|
flags = surface->map.info.flags;
|
||||||
if (flags & SDL_COPY_COLORKEY) {
|
if (flags & SDL_COPY_COLORKEY) {
|
||||||
// ok
|
// ok
|
||||||
} else if ((flags & SDL_COPY_BLEND) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) {
|
} else if ((flags & SDL_COPY_BLEND) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) {
|
||||||
@@ -1407,24 +1407,24 @@ bool SDL_RLESurface(SDL_Surface *surface)
|
|||||||
|
|
||||||
// Encode and set up the blit
|
// Encode and set up the blit
|
||||||
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) || !(flags & SDL_COPY_BLEND)) {
|
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) || !(flags & SDL_COPY_BLEND)) {
|
||||||
if (!surface->internal->map.identity) {
|
if (!surface->map.identity) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!RLEColorkeySurface(surface)) {
|
if (!RLEColorkeySurface(surface)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
surface->internal->map.blit = SDL_RLEBlit;
|
surface->map.blit = SDL_RLEBlit;
|
||||||
surface->internal->map.info.flags |= SDL_COPY_RLE_COLORKEY;
|
surface->map.info.flags |= SDL_COPY_RLE_COLORKEY;
|
||||||
} else {
|
} else {
|
||||||
if (!RLEAlphaSurface(surface)) {
|
if (!RLEAlphaSurface(surface)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
surface->internal->map.blit = SDL_RLEAlphaBlit;
|
surface->map.blit = SDL_RLEAlphaBlit;
|
||||||
surface->internal->map.info.flags |= SDL_COPY_RLE_ALPHAKEY;
|
surface->map.info.flags |= SDL_COPY_RLE_ALPHAKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The surface is now accelerated
|
// The surface is now accelerated
|
||||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1439,8 +1439,8 @@ static bool UnRLEAlpha(SDL_Surface *surface)
|
|||||||
{
|
{
|
||||||
Uint8 *srcbuf;
|
Uint8 *srcbuf;
|
||||||
Uint32 *dst;
|
Uint32 *dst;
|
||||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
const SDL_PixelFormatDetails *sf = surface->fmt;
|
||||||
const SDL_PixelFormatDetails *df = SDL_GetPixelFormatDetails(*(SDL_PixelFormat *)surface->internal->map.data);
|
const SDL_PixelFormatDetails *df = SDL_GetPixelFormatDetails(*(SDL_PixelFormat *)surface->map.data);
|
||||||
int (*uncopy_opaque)(Uint32 *, const void *, int,
|
int (*uncopy_opaque)(Uint32 *, const void *, int,
|
||||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||||
int (*uncopy_transl)(Uint32 *, const void *, int,
|
int (*uncopy_transl)(Uint32 *, const void *, int,
|
||||||
@@ -1469,7 +1469,7 @@ static bool UnRLEAlpha(SDL_Surface *surface)
|
|||||||
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||||
|
|
||||||
dst = (Uint32 *)surface->pixels;
|
dst = (Uint32 *)surface->pixels;
|
||||||
srcbuf = (Uint8 *)surface->internal->map.data + sizeof(SDL_PixelFormat);
|
srcbuf = (Uint8 *)surface->map.data + sizeof(SDL_PixelFormat);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// copy opaque pixels
|
// copy opaque pixels
|
||||||
int ofs = 0;
|
int ofs = 0;
|
||||||
@@ -1518,30 +1518,30 @@ end_function:
|
|||||||
|
|
||||||
void SDL_UnRLESurface(SDL_Surface *surface, bool recode)
|
void SDL_UnRLESurface(SDL_Surface *surface, bool recode)
|
||||||
{
|
{
|
||||||
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||||
surface->internal->flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL;
|
surface->internal_flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||||
|
|
||||||
if (recode && !(surface->flags & SDL_SURFACE_PREALLOCATED)) {
|
if (recode && !(surface->flags & SDL_SURFACE_PREALLOCATED)) {
|
||||||
if (surface->internal->map.info.flags & SDL_COPY_RLE_COLORKEY) {
|
if (surface->map.info.flags & SDL_COPY_RLE_COLORKEY) {
|
||||||
SDL_Rect full;
|
SDL_Rect full;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
// re-create the original surface
|
// re-create the original surface
|
||||||
if (!SDL_size_mul_check_overflow(surface->h, surface->pitch, &size)) {
|
if (!SDL_size_mul_check_overflow(surface->h, surface->pitch, &size)) {
|
||||||
// Memory corruption?
|
// Memory corruption?
|
||||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
|
surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
|
||||||
if (!surface->pixels) {
|
if (!surface->pixels) {
|
||||||
// Oh crap...
|
// Oh crap...
|
||||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
||||||
|
|
||||||
// fill it with the background color
|
// fill it with the background color
|
||||||
SDL_FillSurfaceRect(surface, NULL, surface->internal->map.info.colorkey);
|
SDL_FillSurfaceRect(surface, NULL, surface->map.info.colorkey);
|
||||||
|
|
||||||
// now render the encoded surface
|
// now render the encoded surface
|
||||||
full.x = full.y = 0;
|
full.x = full.y = 0;
|
||||||
@@ -1551,16 +1551,16 @@ void SDL_UnRLESurface(SDL_Surface *surface, bool recode)
|
|||||||
} else {
|
} else {
|
||||||
if (!UnRLEAlpha(surface)) {
|
if (!UnRLEAlpha(surface)) {
|
||||||
// Oh crap...
|
// Oh crap...
|
||||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
surface->internal->map.info.flags &=
|
surface->map.info.flags &=
|
||||||
~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
|
~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
|
||||||
|
|
||||||
SDL_free(surface->internal->map.data);
|
SDL_free(surface->map.data);
|
||||||
surface->internal->map.data = NULL;
|
surface->map.data = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_blit_auto.h"
|
#include "SDL_blit_auto.h"
|
||||||
#include "SDL_blit_copy.h"
|
#include "SDL_blit_copy.h"
|
||||||
#include "SDL_blit_slow.h"
|
#include "SDL_blit_slow.h"
|
||||||
@@ -61,7 +61,7 @@ static bool SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||||||
// Set up source and destination buffer pointers, and BLIT!
|
// Set up source and destination buffer pointers, and BLIT!
|
||||||
if (okay) {
|
if (okay) {
|
||||||
SDL_BlitFunc RunBlit;
|
SDL_BlitFunc RunBlit;
|
||||||
SDL_BlitInfo *info = &src->internal->map.info;
|
SDL_BlitInfo *info = &src->map.info;
|
||||||
|
|
||||||
// Set up the blit information
|
// Set up the blit information
|
||||||
info->src = (Uint8 *)src->pixels +
|
info->src = (Uint8 *)src->pixels +
|
||||||
@@ -80,7 +80,7 @@ static bool SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||||||
info->dst_pitch = dst->pitch;
|
info->dst_pitch = dst->pitch;
|
||||||
info->dst_skip =
|
info->dst_skip =
|
||||||
info->dst_pitch - info->dst_w * info->dst_fmt->bytes_per_pixel;
|
info->dst_pitch - info->dst_w * info->dst_fmt->bytes_per_pixel;
|
||||||
RunBlit = (SDL_BlitFunc)src->internal->map.data;
|
RunBlit = (SDL_BlitFunc)src->map.data;
|
||||||
|
|
||||||
// Run the actual software blit
|
// Run the actual software blit
|
||||||
RunBlit(info);
|
RunBlit(info);
|
||||||
@@ -179,9 +179,9 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelForm
|
|||||||
bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst)
|
bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst)
|
||||||
{
|
{
|
||||||
SDL_BlitFunc blit = NULL;
|
SDL_BlitFunc blit = NULL;
|
||||||
SDL_BlitMap *map = &surface->internal->map;
|
SDL_BlitMap *map = &surface->map;
|
||||||
SDL_Colorspace src_colorspace = surface->internal->colorspace;
|
SDL_Colorspace src_colorspace = surface->colorspace;
|
||||||
SDL_Colorspace dst_colorspace = dst->internal->colorspace;
|
SDL_Colorspace dst_colorspace = dst->colorspace;
|
||||||
|
|
||||||
// We don't currently support blitting to < 8 bpp surfaces
|
// We don't currently support blitting to < 8 bpp surfaces
|
||||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||||
@@ -198,11 +198,11 @@ bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst)
|
|||||||
|
|
||||||
map->blit = SDL_SoftBlit;
|
map->blit = SDL_SoftBlit;
|
||||||
map->info.src_surface = surface;
|
map->info.src_surface = surface;
|
||||||
map->info.src_fmt = surface->internal->format;
|
map->info.src_fmt = surface->fmt;
|
||||||
map->info.src_pal = surface->internal->palette;
|
map->info.src_pal = surface->palette;
|
||||||
map->info.dst_surface = dst;
|
map->info.dst_surface = dst;
|
||||||
map->info.dst_fmt = dst->internal->format;
|
map->info.dst_fmt = dst->fmt;
|
||||||
map->info.dst_pal = dst->internal->palette;
|
map->info.dst_pal = dst->palette;
|
||||||
|
|
||||||
#if SDL_HAVE_RLE
|
#if SDL_HAVE_RLE
|
||||||
// See if we can do RLE acceleration
|
// See if we can do RLE acceleration
|
||||||
@@ -270,10 +270,10 @@ bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst)
|
|||||||
SDL_PixelFormat dst_format = dst->format;
|
SDL_PixelFormat dst_format = dst->format;
|
||||||
|
|
||||||
if ((!SDL_ISPIXELFORMAT_INDEXED(src_format) ||
|
if ((!SDL_ISPIXELFORMAT_INDEXED(src_format) ||
|
||||||
(src_format == SDL_PIXELFORMAT_INDEX8 && surface->internal->palette)) &&
|
(src_format == SDL_PIXELFORMAT_INDEX8 && surface->palette)) &&
|
||||||
!SDL_ISPIXELFORMAT_FOURCC(src_format) &&
|
!SDL_ISPIXELFORMAT_FOURCC(src_format) &&
|
||||||
(!SDL_ISPIXELFORMAT_INDEXED(dst_format) ||
|
(!SDL_ISPIXELFORMAT_INDEXED(dst_format) ||
|
||||||
(dst_format == SDL_PIXELFORMAT_INDEX8 && dst->internal->palette)) &&
|
(dst_format == SDL_PIXELFORMAT_INDEX8 && dst->palette)) &&
|
||||||
!SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
|
!SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
|
||||||
blit = SDL_Blit_Slow;
|
blit = SDL_Blit_Slow;
|
||||||
}
|
}
|
||||||
|
@@ -23,8 +23,6 @@
|
|||||||
#ifndef SDL_blit_h_
|
#ifndef SDL_blit_h_
|
||||||
#define SDL_blit_h_
|
#define SDL_blit_h_
|
||||||
|
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
|
|
||||||
// Table to do pixel byte expansion
|
// Table to do pixel byte expansion
|
||||||
extern const Uint8 *SDL_expand_byte[9];
|
extern const Uint8 *SDL_expand_byte[9];
|
||||||
extern const Uint16 SDL_expand_byte_10[];
|
extern const Uint16 SDL_expand_byte_10[];
|
||||||
@@ -724,6 +722,4 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||||||
#pragma warning(disable : 4244) // '=': conversion from 'X' to 'Y', possible loss of data
|
#pragma warning(disable : 4244) // '=': conversion from 'X' to 'Y', possible loss of data
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SDL_surface_c.h"
|
|
||||||
|
|
||||||
#endif // SDL_blit_h_
|
#endif // SDL_blit_h_
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if SDL_HAVE_BLIT_0
|
#if SDL_HAVE_BLIT_0
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
// Functions to blit from bitmaps to other surfaces
|
// Functions to blit from bitmaps to other surfaces
|
||||||
|
|
||||||
@@ -919,14 +919,14 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||||||
{
|
{
|
||||||
int which;
|
int which;
|
||||||
|
|
||||||
if (SDL_BITSPERPIXEL(surface->internal->map.info.dst_fmt->format) < 8) {
|
if (SDL_BITSPERPIXEL(surface->map.info.dst_fmt->format) < 8) {
|
||||||
which = 0;
|
which = 0;
|
||||||
} else {
|
} else {
|
||||||
which = SDL_BYTESPERPIXEL(surface->internal->map.info.dst_fmt->format);
|
which = SDL_BYTESPERPIXEL(surface->map.info.dst_fmt->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
if (which < SDL_arraysize(bitmap_blit_1b)) {
|
if (which < SDL_arraysize(bitmap_blit_1b)) {
|
||||||
return bitmap_blit_1b[which];
|
return bitmap_blit_1b[which];
|
||||||
@@ -949,7 +949,7 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
if (which < SDL_arraysize(bitmap_blit_2b)) {
|
if (which < SDL_arraysize(bitmap_blit_2b)) {
|
||||||
return bitmap_blit_2b[which];
|
return bitmap_blit_2b[which];
|
||||||
@@ -972,7 +972,7 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) {
|
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) {
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
if (which < SDL_arraysize(bitmap_blit_4b)) {
|
if (which < SDL_arraysize(bitmap_blit_4b)) {
|
||||||
return bitmap_blit_4b[which];
|
return bitmap_blit_4b[which];
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if SDL_HAVE_BLIT_1
|
#if SDL_HAVE_BLIT_1
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
|
|
||||||
// Functions to blit from 8-bit surfaces to other surfaces
|
// Functions to blit from 8-bit surfaces to other surfaces
|
||||||
@@ -518,13 +518,13 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
|
|||||||
{
|
{
|
||||||
int which;
|
int which;
|
||||||
|
|
||||||
if (SDL_BITSPERPIXEL(surface->internal->map.info.dst_fmt->format) < 8) {
|
if (SDL_BITSPERPIXEL(surface->map.info.dst_fmt->format) < 8) {
|
||||||
which = 0;
|
which = 0;
|
||||||
} else {
|
} else {
|
||||||
which = SDL_BYTESPERPIXEL(surface->internal->map.info.dst_fmt->format);
|
which = SDL_BYTESPERPIXEL(surface->map.info.dst_fmt->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
if (which < SDL_arraysize(one_blit)) {
|
if (which < SDL_arraysize(one_blit)) {
|
||||||
return one_blit[which];
|
return one_blit[which];
|
||||||
@@ -538,7 +538,7 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: // this is not super-robust but handles a specific case we found sdl12-compat.
|
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: // this is not super-robust but handles a specific case we found sdl12-compat.
|
||||||
if (surface->internal->map.info.a == 255) {
|
if (surface->map.info.a == 255) {
|
||||||
if (which < SDL_arraysize(one_blitkey)) {
|
if (which < SDL_arraysize(one_blitkey)) {
|
||||||
return one_blitkey[which];
|
return one_blitkey[which];
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if SDL_HAVE_BLIT_A
|
#if SDL_HAVE_BLIT_A
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
// Functions to perform alpha blended blitting
|
// Functions to perform alpha blended blitting
|
||||||
|
|
||||||
@@ -1322,15 +1322,15 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
|
|||||||
|
|
||||||
SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||||
{
|
{
|
||||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
const SDL_PixelFormatDetails *sf = surface->fmt;
|
||||||
const SDL_PixelFormatDetails *df = surface->internal->map.info.dst_fmt;
|
const SDL_PixelFormatDetails *df = surface->map.info.dst_fmt;
|
||||||
|
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case SDL_COPY_BLEND:
|
case SDL_COPY_BLEND:
|
||||||
// Per-pixel alpha blits
|
// Per-pixel alpha blits
|
||||||
switch (df->bytes_per_pixel) {
|
switch (df->bytes_per_pixel) {
|
||||||
case 1:
|
case 1:
|
||||||
if (surface->internal->map.info.dst_pal) {
|
if (surface->map.info.dst_pal) {
|
||||||
return BlitNto1PixelAlpha;
|
return BlitNto1PixelAlpha;
|
||||||
} else {
|
} else {
|
||||||
// RGB332 has no palette !
|
// RGB332 has no palette !
|
||||||
@@ -1386,7 +1386,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||||||
// Per-surface alpha blits
|
// Per-surface alpha blits
|
||||||
switch (df->bytes_per_pixel) {
|
switch (df->bytes_per_pixel) {
|
||||||
case 1:
|
case 1:
|
||||||
if (surface->internal->map.info.dst_pal) {
|
if (surface->map.info.dst_pal) {
|
||||||
return BlitNto1SurfaceAlpha;
|
return BlitNto1SurfaceAlpha;
|
||||||
} else {
|
} else {
|
||||||
// RGB332 has no palette !
|
// RGB332 has no palette !
|
||||||
@@ -1394,7 +1394,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (surface->internal->map.identity) {
|
if (surface->map.identity) {
|
||||||
if (df->Gmask == 0x7e0) {
|
if (df->Gmask == 0x7e0) {
|
||||||
#ifdef SDL_MMX_INTRINSICS
|
#ifdef SDL_MMX_INTRINSICS
|
||||||
if (SDL_HasMMX()) {
|
if (SDL_HasMMX()) {
|
||||||
@@ -1441,7 +1441,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||||||
if (sf->Amask == 0) {
|
if (sf->Amask == 0) {
|
||||||
if (df->bytes_per_pixel == 1) {
|
if (df->bytes_per_pixel == 1) {
|
||||||
|
|
||||||
if (surface->internal->map.info.dst_pal) {
|
if (surface->map.info.dst_pal) {
|
||||||
return BlitNto1SurfaceAlphaKey;
|
return BlitNto1SurfaceAlphaKey;
|
||||||
} else {
|
} else {
|
||||||
// RGB332 has no palette !
|
// RGB332 has no palette !
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#if SDL_HAVE_BLIT_N
|
#if SDL_HAVE_BLIT_N
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_blit_copy.h"
|
#include "SDL_blit_copy.h"
|
||||||
|
|
||||||
// General optimized routines that write char by char
|
// General optimized routines that write char by char
|
||||||
@@ -2948,15 +2948,15 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
|||||||
SDL_BlitFunc blitfun;
|
SDL_BlitFunc blitfun;
|
||||||
|
|
||||||
// Set up data for choosing the blit
|
// Set up data for choosing the blit
|
||||||
srcfmt = surface->internal->format;
|
srcfmt = surface->fmt;
|
||||||
dstfmt = surface->internal->map.info.dst_fmt;
|
dstfmt = surface->map.info.dst_fmt;
|
||||||
|
|
||||||
// We don't support destinations less than 8-bits
|
// We don't support destinations less than 8-bits
|
||||||
if (dstfmt->bits_per_pixel < 8) {
|
if (dstfmt->bits_per_pixel < 8) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||||
case 0:
|
case 0:
|
||||||
blitfun = NULL;
|
blitfun = NULL;
|
||||||
if (dstfmt->bits_per_pixel > 8) {
|
if (dstfmt->bits_per_pixel > 8) {
|
||||||
@@ -3017,7 +3017,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
|||||||
because RLE is the preferred fast way to deal with this.
|
because RLE is the preferred fast way to deal with this.
|
||||||
If a particular case turns out to be useful we'll add it. */
|
If a particular case turns out to be useful we'll add it. */
|
||||||
|
|
||||||
if (srcfmt->bytes_per_pixel == 2 && surface->internal->map.identity != 0) {
|
if (srcfmt->bytes_per_pixel == 2 && surface->map.identity != 0) {
|
||||||
return Blit2to2Key;
|
return Blit2to2Key;
|
||||||
} else {
|
} else {
|
||||||
#ifdef SDL_ALTIVEC_BLITTERS
|
#ifdef SDL_ALTIVEC_BLITTERS
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
#include "SDL_blit.h"
|
|
||||||
|
|
||||||
#if SDL_HAVE_BLIT_AUTO
|
#if SDL_HAVE_BLIT_AUTO
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_blit_copy.h"
|
#include "SDL_blit_copy.h"
|
||||||
|
|
||||||
#ifdef SDL_SSE_INTRINSICS
|
#ifdef SDL_SSE_INTRINSICS
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_blit_slow.h"
|
#include "SDL_blit_slow.h"
|
||||||
#include "SDL_pixels_c.h"
|
#include "SDL_pixels_c.h"
|
||||||
|
|
||||||
@@ -839,8 +839,8 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
|
|||||||
Uint32 last_pixel = 0;
|
Uint32 last_pixel = 0;
|
||||||
Uint8 last_index = 0;
|
Uint8 last_index = 0;
|
||||||
|
|
||||||
src_colorspace = info->src_surface->internal->colorspace;
|
src_colorspace = info->src_surface->colorspace;
|
||||||
dst_colorspace = info->dst_surface->internal->colorspace;
|
dst_colorspace = info->dst_surface->colorspace;
|
||||||
src_primaries = SDL_COLORSPACEPRIMARIES(src_colorspace);
|
src_primaries = SDL_COLORSPACEPRIMARIES(src_colorspace);
|
||||||
dst_primaries = SDL_COLORSPACEPRIMARIES(dst_colorspace);
|
dst_primaries = SDL_COLORSPACEPRIMARIES(dst_colorspace);
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SDL_pixels_c.h"
|
#include "SDL_pixels_c.h"
|
||||||
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
#define SAVE_32BIT_BMP
|
#define SAVE_32BIT_BMP
|
||||||
|
|
||||||
@@ -518,7 +519,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio)
|
|||||||
if (SDL_ReadIO(src, bits, surface->pitch) != (size_t)surface->pitch) {
|
if (SDL_ReadIO(src, bits, surface->pitch) != (size_t)surface->pitch) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (biBitCount == 8 && surface->internal->palette && biClrUsed < (1u << biBitCount)) {
|
if (biBitCount == 8 && surface->palette && biClrUsed < (1u << biBitCount)) {
|
||||||
for (i = 0; i < surface->w; ++i) {
|
for (i = 0; i < surface->w; ++i) {
|
||||||
if (bits[i] >= biClrUsed) {
|
if (bits[i] >= biClrUsed) {
|
||||||
SDL_SetError("A BMP image contains a pixel with a color out of the palette");
|
SDL_SetError("A BMP image contains a pixel with a color out of the palette");
|
||||||
@@ -644,12 +645,12 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
|||||||
// We can save alpha information in a 32-bit BMP
|
// We can save alpha information in a 32-bit BMP
|
||||||
if (SDL_BITSPERPIXEL(surface->format) >= 8 &&
|
if (SDL_BITSPERPIXEL(surface->format) >= 8 &&
|
||||||
(SDL_ISPIXELFORMAT_ALPHA(surface->format) ||
|
(SDL_ISPIXELFORMAT_ALPHA(surface->format) ||
|
||||||
surface->internal->map.info.flags & SDL_COPY_COLORKEY)) {
|
surface->map.info.flags & SDL_COPY_COLORKEY)) {
|
||||||
save32bit = true;
|
save32bit = true;
|
||||||
}
|
}
|
||||||
#endif // SAVE_32BIT_BMP
|
#endif // SAVE_32BIT_BMP
|
||||||
|
|
||||||
if (surface->internal->palette && !save32bit) {
|
if (surface->palette && !save32bit) {
|
||||||
if (SDL_BITSPERPIXEL(surface->format) == 8) {
|
if (SDL_BITSPERPIXEL(surface->format) == 8) {
|
||||||
intermediate_surface = surface;
|
intermediate_surface = surface;
|
||||||
} else {
|
} else {
|
||||||
@@ -659,13 +660,13 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
|||||||
}
|
}
|
||||||
} else if ((SDL_BITSPERPIXEL(surface->format) == 24) && !save32bit &&
|
} else if ((SDL_BITSPERPIXEL(surface->format) == 24) && !save32bit &&
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
(surface->internal->format->Rmask == 0x00FF0000) &&
|
(surface->fmt->Rmask == 0x00FF0000) &&
|
||||||
(surface->internal->format->Gmask == 0x0000FF00) &&
|
(surface->fmt->Gmask == 0x0000FF00) &&
|
||||||
(surface->internal->format->Bmask == 0x000000FF)
|
(surface->fmt->Bmask == 0x000000FF)
|
||||||
#else
|
#else
|
||||||
(surface->internal->format->Rmask == 0x000000FF) &&
|
(surface->fmt->Rmask == 0x000000FF) &&
|
||||||
(surface->internal->format->Gmask == 0x0000FF00) &&
|
(surface->fmt->Gmask == 0x0000FF00) &&
|
||||||
(surface->internal->format->Bmask == 0x00FF0000)
|
(surface->fmt->Bmask == 0x00FF0000)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
intermediate_surface = surface;
|
intermediate_surface = surface;
|
||||||
@@ -697,7 +698,7 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_LockSurface(intermediate_surface)) {
|
if (SDL_LockSurface(intermediate_surface)) {
|
||||||
const size_t bw = intermediate_surface->w * intermediate_surface->internal->format->bytes_per_pixel;
|
const size_t bw = intermediate_surface->w * intermediate_surface->fmt->bytes_per_pixel;
|
||||||
|
|
||||||
// Set the BMP file header values
|
// Set the BMP file header values
|
||||||
bfSize = 0; // We'll write this when we're done
|
bfSize = 0; // We'll write this when we're done
|
||||||
@@ -723,13 +724,13 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
|||||||
biWidth = intermediate_surface->w;
|
biWidth = intermediate_surface->w;
|
||||||
biHeight = intermediate_surface->h;
|
biHeight = intermediate_surface->h;
|
||||||
biPlanes = 1;
|
biPlanes = 1;
|
||||||
biBitCount = intermediate_surface->internal->format->bits_per_pixel;
|
biBitCount = intermediate_surface->fmt->bits_per_pixel;
|
||||||
biCompression = BI_RGB;
|
biCompression = BI_RGB;
|
||||||
biSizeImage = intermediate_surface->h * intermediate_surface->pitch;
|
biSizeImage = intermediate_surface->h * intermediate_surface->pitch;
|
||||||
biXPelsPerMeter = 0;
|
biXPelsPerMeter = 0;
|
||||||
biYPelsPerMeter = 0;
|
biYPelsPerMeter = 0;
|
||||||
if (intermediate_surface->internal->palette) {
|
if (intermediate_surface->palette) {
|
||||||
biClrUsed = intermediate_surface->internal->palette->ncolors;
|
biClrUsed = intermediate_surface->palette->ncolors;
|
||||||
} else {
|
} else {
|
||||||
biClrUsed = 0;
|
biClrUsed = 0;
|
||||||
}
|
}
|
||||||
@@ -787,12 +788,12 @@ bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the palette (in BGR color order)
|
// Write the palette (in BGR color order)
|
||||||
if (intermediate_surface->internal->palette) {
|
if (intermediate_surface->palette) {
|
||||||
SDL_Color *colors;
|
SDL_Color *colors;
|
||||||
int ncolors;
|
int ncolors;
|
||||||
|
|
||||||
colors = intermediate_surface->internal->palette->colors;
|
colors = intermediate_surface->palette->colors;
|
||||||
ncolors = intermediate_surface->internal->palette->ncolors;
|
ncolors = intermediate_surface->palette->ncolors;
|
||||||
for (i = 0; i < ncolors; ++i) {
|
for (i = 0; i < ncolors; ++i) {
|
||||||
if (!SDL_WriteU8(dst, colors[i].b) ||
|
if (!SDL_WriteU8(dst, colors[i].b) ||
|
||||||
!SDL_WriteU8(dst, colors[i].g) ||
|
!SDL_WriteU8(dst, colors[i].g) ||
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
#ifdef SDL_SSE_INTRINSICS
|
#ifdef SDL_SSE_INTRINSICS
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
@@ -237,7 +237,7 @@ bool SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
|
|||||||
|
|
||||||
// If 'rect' == NULL, then fill the whole surface
|
// If 'rect' == NULL, then fill the whole surface
|
||||||
if (!rect) {
|
if (!rect) {
|
||||||
rect = &dst->internal->clip_rect;
|
rect = &dst->clip_rect;
|
||||||
// Don't attempt to fill if the surface's clip_rect is empty
|
// Don't attempt to fill if the surface's clip_rect is empty
|
||||||
if (SDL_RectEmpty(rect)) {
|
if (SDL_RectEmpty(rect)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -346,7 +346,7 @@ bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Ui
|
|||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
rect = &rects[i];
|
rect = &rects[i];
|
||||||
// Perform clipping
|
// Perform clipping
|
||||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rect = &clipped;
|
rect = &clipped;
|
||||||
|
@@ -23,11 +23,8 @@
|
|||||||
// General (mostly internal) pixel/color manipulation routines for SDL
|
// General (mostly internal) pixel/color manipulation routines for SDL
|
||||||
|
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "SDL_blit.h"
|
|
||||||
#include "SDL_pixels_c.h"
|
#include "SDL_pixels_c.h"
|
||||||
#include "SDL_RLEaccel_c.h"
|
#include "SDL_RLEaccel_c.h"
|
||||||
#include "../SDL_hashtable.h"
|
|
||||||
#include "../SDL_list.h"
|
|
||||||
|
|
||||||
// Lookup tables to expand partial bytes to the full 0..255 range
|
// Lookup tables to expand partial bytes to the full 0..255 range
|
||||||
|
|
||||||
@@ -1419,22 +1416,22 @@ static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod
|
|||||||
|
|
||||||
bool SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst)
|
bool SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst)
|
||||||
{
|
{
|
||||||
SDL_BlitMap *map = &src->internal->map;
|
SDL_BlitMap *map = &src->map;
|
||||||
|
|
||||||
if (map->info.dst_fmt != dst->internal->format ||
|
if (map->info.dst_fmt != dst->fmt ||
|
||||||
map->info.dst_pal != dst->internal->palette ||
|
map->info.dst_pal != dst->palette ||
|
||||||
(dst->internal->palette &&
|
(dst->palette &&
|
||||||
map->dst_palette_version != dst->internal->palette->version) ||
|
map->dst_palette_version != dst->palette->version) ||
|
||||||
(src->internal->palette &&
|
(src->palette &&
|
||||||
map->src_palette_version != src->internal->palette->version)) {
|
map->src_palette_version != src->palette->version)) {
|
||||||
if (!SDL_MapSurface(src, dst)) {
|
if (!SDL_MapSurface(src, dst)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// just here for debugging
|
// just here for debugging
|
||||||
// printf
|
// printf
|
||||||
// ("src = 0x%08X src->flags = %08X map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->internal->map.info.flags = %08X\nmap->blit = 0x%08x\n",
|
// ("src = 0x%08X src->flags = %08X map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map.info.flags = %08X\nmap->blit = 0x%08x\n",
|
||||||
// src, dst->flags, map->info.flags, dst, dst->flags,
|
// src, dst->flags, map->info.flags, dst, dst->flags,
|
||||||
// dst->internal->map.info.flags, map->blit);
|
// dst->map.info.flags, map->blit);
|
||||||
} else {
|
} else {
|
||||||
map->info.dst_surface = dst;
|
map->info.dst_surface = dst;
|
||||||
}
|
}
|
||||||
@@ -1466,9 +1463,9 @@ bool SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||||||
SDL_BlitMap *map;
|
SDL_BlitMap *map;
|
||||||
|
|
||||||
// Clear out any previous mapping
|
// Clear out any previous mapping
|
||||||
map = &src->internal->map;
|
map = &src->map;
|
||||||
#if SDL_HAVE_RLE
|
#if SDL_HAVE_RLE
|
||||||
if (src->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
if (src->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||||
SDL_UnRLESurface(src, true);
|
SDL_UnRLESurface(src, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1476,10 +1473,10 @@ bool SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||||||
|
|
||||||
// Figure out what kind of mapping we're doing
|
// Figure out what kind of mapping we're doing
|
||||||
map->identity = 0;
|
map->identity = 0;
|
||||||
srcfmt = src->internal->format;
|
srcfmt = src->fmt;
|
||||||
srcpal = src->internal->palette;
|
srcpal = src->palette;
|
||||||
dstfmt = dst->internal->format;
|
dstfmt = dst->fmt;
|
||||||
dstpal = dst->internal->palette;
|
dstpal = dst->palette;
|
||||||
if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) {
|
if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) {
|
||||||
if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) {
|
if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) {
|
||||||
// Palette --> Palette
|
// Palette --> Palette
|
||||||
@@ -1499,8 +1496,8 @@ bool SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||||||
} else {
|
} else {
|
||||||
// Palette --> BitField
|
// Palette --> BitField
|
||||||
map->info.table =
|
map->info.table =
|
||||||
Map1toN(srcpal, src->internal->map.info.r, src->internal->map.info.g,
|
Map1toN(srcpal, src->map.info.r, src->map.info.g,
|
||||||
src->internal->map.info.b, src->internal->map.info.a, dstfmt);
|
src->map.info.b, src->map.info.a, dstfmt);
|
||||||
if (!map->info.table) {
|
if (!map->info.table) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
static bool SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
static bool SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
static bool SDL_LowerSoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
static bool SDL_LowerSoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||||
@@ -42,7 +42,7 @@ bool SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst
|
|||||||
|
|
||||||
if (src->format != dst->format) {
|
if (src->format != dst->format) {
|
||||||
// Slow!
|
// Slow!
|
||||||
SDL_Surface *src_tmp = SDL_ConvertSurfaceAndColorspace(src, dst->format, dst->internal->palette, dst->internal->colorspace, dst->internal->props);
|
SDL_Surface *src_tmp = SDL_ConvertSurfaceAndColorspace(src, dst->format, dst->palette, dst->colorspace, dst->props);
|
||||||
if (!src_tmp) {
|
if (!src_tmp) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ bool SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst
|
|||||||
result = SDL_ConvertPixelsAndColorspace(dstrect->w, dstrect->h,
|
result = SDL_ConvertPixelsAndColorspace(dstrect->w, dstrect->h,
|
||||||
dst_tmp->format, SDL_COLORSPACE_SRGB, 0,
|
dst_tmp->format, SDL_COLORSPACE_SRGB, 0,
|
||||||
dst_tmp->pixels, dst_tmp->pitch,
|
dst_tmp->pixels, dst_tmp->pitch,
|
||||||
dst->format, dst->internal->colorspace, SDL_GetSurfaceProperties(dst),
|
dst->format, dst->colorspace, SDL_GetSurfaceProperties(dst),
|
||||||
(Uint8 *)dst->pixels + dstrect->y * dst->pitch + dstrect->x * SDL_BYTESPERPIXEL(dst->format), dst->pitch);
|
(Uint8 *)dst->pixels + dstrect->y * dst->pitch + dstrect->x * SDL_BYTESPERPIXEL(dst->format), dst->pitch);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
// Useful functions and variables from SDL_surface.c
|
// Useful functions and variables from SDL_surface.c
|
||||||
|
|
||||||
#include "../SDL_list.h"
|
#include "SDL_blit.h"
|
||||||
|
|
||||||
// Surface internal flags
|
// Surface internal flags
|
||||||
typedef Uint32 SDL_SurfaceDataFlags;
|
typedef Uint32 SDL_SurfaceDataFlags;
|
||||||
@@ -35,16 +35,30 @@ typedef Uint32 SDL_SurfaceDataFlags;
|
|||||||
#define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */
|
#define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */
|
||||||
|
|
||||||
// Surface internal data definition
|
// Surface internal data definition
|
||||||
struct SDL_SurfaceData
|
struct SDL_Surface
|
||||||
{
|
{
|
||||||
|
// Public API definition
|
||||||
|
SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */
|
||||||
|
SDL_PixelFormat format; /**< The format of the surface, read-only */
|
||||||
|
int w; /**< The width of the surface, read-only. */
|
||||||
|
int h; /**< The height of the surface, read-only. */
|
||||||
|
int pitch; /**< The distance in bytes between rows of pixels, read-only */
|
||||||
|
void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */
|
||||||
|
|
||||||
|
int refcount; /**< Application reference count, used when freeing surface */
|
||||||
|
|
||||||
|
void *reserved; /**< Reserved for internal use */
|
||||||
|
|
||||||
|
// Private API definition
|
||||||
|
|
||||||
/** flags for this surface */
|
/** flags for this surface */
|
||||||
SDL_SurfaceDataFlags flags;
|
SDL_SurfaceDataFlags internal_flags;
|
||||||
|
|
||||||
/** properties for this surface */
|
/** properties for this surface */
|
||||||
SDL_PropertiesID props;
|
SDL_PropertiesID props;
|
||||||
|
|
||||||
/** detailed format for this surface */
|
/** detailed format for this surface */
|
||||||
const SDL_PixelFormatDetails *format;
|
const SDL_PixelFormatDetails *fmt;
|
||||||
|
|
||||||
/** Pixel colorspace */
|
/** Pixel colorspace */
|
||||||
SDL_Colorspace colorspace;
|
SDL_Colorspace colorspace;
|
||||||
@@ -66,13 +80,6 @@ struct SDL_SurfaceData
|
|||||||
SDL_BlitMap map;
|
SDL_BlitMap map;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SDL_InternalSurface
|
|
||||||
{
|
|
||||||
SDL_Surface surface;
|
|
||||||
SDL_SurfaceData internal;
|
|
||||||
|
|
||||||
} SDL_InternalSurface;
|
|
||||||
|
|
||||||
// Surface functions
|
// Surface functions
|
||||||
extern bool SDL_SurfaceValid(SDL_Surface *surface);
|
extern bool SDL_SurfaceValid(SDL_Surface *surface);
|
||||||
extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface);
|
extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface);
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL_vulkan.h>
|
#include <SDL3/SDL_vulkan.h>
|
||||||
|
|
||||||
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
// The SDL video driver
|
// The SDL video driver
|
||||||
|
|
||||||
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
|
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "SDL_egl_c.h"
|
#include "SDL_egl_c.h"
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
#include "SDL_pixels_c.h"
|
#include "SDL_pixels_c.h"
|
||||||
#include "SDL_rect_c.h"
|
#include "SDL_rect_c.h"
|
||||||
#include "SDL_video_c.h"
|
#include "SDL_video_c.h"
|
||||||
@@ -3414,7 +3414,7 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
|||||||
|
|
||||||
if (!window->surface_valid) {
|
if (!window->surface_valid) {
|
||||||
if (window->surface) {
|
if (window->surface) {
|
||||||
window->surface->internal->flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
window->surface->internal_flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
||||||
SDL_DestroySurface(window->surface);
|
SDL_DestroySurface(window->surface);
|
||||||
window->surface = NULL;
|
window->surface = NULL;
|
||||||
}
|
}
|
||||||
@@ -3422,7 +3422,7 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
|||||||
window->surface = SDL_CreateWindowFramebuffer(window);
|
window->surface = SDL_CreateWindowFramebuffer(window);
|
||||||
if (window->surface) {
|
if (window->surface) {
|
||||||
window->surface_valid = true;
|
window->surface_valid = true;
|
||||||
window->surface->internal->flags |= SDL_INTERNAL_SURFACE_DONTFREE;
|
window->surface->internal_flags |= SDL_INTERNAL_SURFACE_DONTFREE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return window->surface;
|
return window->surface;
|
||||||
@@ -3480,7 +3480,7 @@ bool SDL_DestroyWindowSurface(SDL_Window *window)
|
|||||||
CHECK_WINDOW_MAGIC(window, false);
|
CHECK_WINDOW_MAGIC(window, false);
|
||||||
|
|
||||||
if (window->surface) {
|
if (window->surface) {
|
||||||
window->surface->internal->flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
window->surface->internal_flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
||||||
SDL_DestroySurface(window->surface);
|
SDL_DestroySurface(window->surface);
|
||||||
window->surface = NULL;
|
window->surface = NULL;
|
||||||
window->surface_valid = false;
|
window->surface_valid = false;
|
||||||
|
@@ -112,7 +112,7 @@ sub open_file {
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
#include "SDL_blit.h"
|
#include "SDL_surface_c.h"
|
||||||
|
|
||||||
#if SDL_HAVE_BLIT_AUTO
|
#if SDL_HAVE_BLIT_AUTO
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@
|
|||||||
#include "SDL_windowsrawinput.h"
|
#include "SDL_windowsrawinput.h"
|
||||||
|
|
||||||
#include "../SDL_video_c.h"
|
#include "../SDL_video_c.h"
|
||||||
#include "../SDL_blit.h"
|
|
||||||
#include "../../events/SDL_mouse_c.h"
|
#include "../../events/SDL_mouse_c.h"
|
||||||
#include "../../joystick/usb_ids.h"
|
#include "../../joystick/usb_ids.h"
|
||||||
|
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include "SDL_windowsvideo.h"
|
#include "SDL_windowsvideo.h"
|
||||||
#include "SDL_windowsshape.h"
|
#include "SDL_windowsshape.h"
|
||||||
|
|
||||||
#include "../SDL_blit.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void AddRegion(HRGN *mask, int x1, int y1, int x2, int y2)
|
static void AddRegion(HRGN *mask, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
#include "SDL_x11video.h"
|
#include "SDL_x11video.h"
|
||||||
#include "SDL_x11shape.h"
|
#include "SDL_x11shape.h"
|
||||||
|
|
||||||
#include "../SDL_blit.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE
|
||||||
static Uint8 *GenerateShapeMask(SDL_Surface *shape)
|
static Uint8 *GenerateShapeMask(SDL_Surface *shape)
|
||||||
|
Reference in New Issue
Block a user