Simplified internal SDL_Surface structure

This commit is contained in:
Sam Lantinga
2024-09-30 22:15:38 -07:00
parent 1f3a0d12e6
commit 3234a3b902
52 changed files with 514 additions and 519 deletions

View File

@@ -23,6 +23,8 @@
#ifndef SDL_sysrender_h_
#define SDL_sysrender_h_
#include "../video/SDL_surface_c.h"
#include "SDL_yuv_sw_c.h"
// Set up for C function definitions, even when using C++

View File

@@ -25,7 +25,7 @@
#if SDL_HAVE_YUV
#include "SDL_yuv_sw_c.h"
#include "../video/SDL_blit.h"
#include "../video/SDL_surface_c.h"
#include "../video/SDL_yuv_c.h"
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h)

View File

@@ -26,8 +26,6 @@
#include "SDL_shaders_gpu.h"
#include "SDL_hashtable.h"
typedef struct GPU_PipelineParameters
{
SDL_BlendMode blend_mode;

View File

@@ -25,7 +25,6 @@
#include "../../video/SDL_sysvideo.h" // For SDL_RecreateWindow
#include <SDL3/SDL_opengles2.h>
#include "../SDL_sysrender.h"
#include "../../video/SDL_blit.h"
#include "../../video/SDL_pixels_c.h"
#include "SDL_shaders_gles2.h"

View File

@@ -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,
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;
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,
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;
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) {
// Perform clipping
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
return true;
}
rect = &clipped;
} else {
rect = &dst->internal->clip_rect;
rect = &dst->clip_rect;
}
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);
}
switch (dst->internal->format->bits_per_pixel) {
switch (dst->fmt->bits_per_pixel) {
case 15:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x7C00:
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
}
break;
case 16:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0xF800:
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
}
break;
case 32:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x00FF0000:
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
return SDL_BlendFillRect_XRGB8888(dst, rect, blendMode, r, g, b, a);
} else {
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;
}
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
} else {
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
if (dst->internal->format->bits_per_pixel < 8) {
if (dst->fmt->bits_per_pixel < 8) {
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?
switch (dst->internal->format->bits_per_pixel) {
switch (dst->fmt->bits_per_pixel) {
case 15:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x7C00:
func = SDL_BlendFillRect_RGB555;
}
break;
case 16:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0xF800:
func = SDL_BlendFillRect_RGB565;
}
break;
case 32:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x00FF0000:
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
func = SDL_BlendFillRect_XRGB8888;
} else {
func = SDL_BlendFillRect_ARGB8888;
@@ -351,7 +351,7 @@ bool SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_
}
if (!func) {
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
func = SDL_BlendFillRect_RGB;
} else {
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) {
// Perform clipping
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
if (!SDL_GetRectIntersection(&rects[i], &dst->clip_rect, &rect)) {
continue;
}
result = func(dst, &rect, blendMode, r, g, b, a);

View File

@@ -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,
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
const SDL_PixelFormatDetails *fmt = dst->fmt;
unsigned r, g, b, a, inva;
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,
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
const SDL_PixelFormatDetails *fmt = dst->fmt;
unsigned r, g, b, a, inva;
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,
bool draw_end)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
const SDL_PixelFormatDetails *fmt = dst->fmt;
unsigned r, g, b, a, inva;
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");
}
func = SDL_CalculateBlendLineFunc(dst->internal->format);
func = SDL_CalculateBlendLineFunc(dst->fmt);
if (!func) {
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
}
// Perform clipping
// 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;
}
@@ -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");
}
func = SDL_CalculateBlendLineFunc(dst->internal->format);
func = SDL_CalculateBlendLineFunc(dst->fmt);
if (!func) {
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
// 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;
}

View File

@@ -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,
Uint8 g, Uint8 b, Uint8 a)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
const SDL_PixelFormatDetails *fmt = dst->fmt;
unsigned inva = 0xff - a;
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,
Uint8 g, Uint8 b, Uint8 a)
{
const SDL_PixelFormatDetails *fmt = dst->internal->format;
const SDL_PixelFormatDetails *fmt = dst->fmt;
unsigned inva = 0xff - a;
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
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
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);
}
switch (dst->internal->format->bits_per_pixel) {
switch (dst->fmt->bits_per_pixel) {
case 15:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x7C00:
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
}
break;
case 16:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0xF800:
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
}
break;
case 32:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x00FF0000:
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
return SDL_BlendPoint_XRGB8888(dst, x, y, blendMode, r, g, b, a);
} else {
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;
}
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
} else {
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
if (dst->internal->format->bits_per_pixel < 8) {
if (dst->fmt->bits_per_pixel < 8) {
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?
switch (dst->internal->format->bits_per_pixel) {
switch (dst->fmt->bits_per_pixel) {
case 15:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x7C00:
func = SDL_BlendPoint_RGB555;
break;
}
break;
case 16:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0xF800:
func = SDL_BlendPoint_RGB565;
break;
}
break;
case 32:
switch (dst->internal->format->Rmask) {
switch (dst->fmt->Rmask) {
case 0x00FF0000:
if (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
func = SDL_BlendPoint_XRGB8888;
} else {
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 (!dst->internal->format->Amask) {
if (!dst->fmt->Amask) {
func = SDL_BlendPoint_RGB;
} else {
func = SDL_BlendPoint_RGBA;
}
}
minx = dst->internal->clip_rect.x;
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
miny = dst->internal->clip_rect.y;
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
minx = dst->clip_rect.x;
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
miny = dst->clip_rect.y;
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
for (i = 0; i < count; ++i) {
x = points[i].x;

View File

@@ -20,7 +20,7 @@
*/
#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,
* and in the blend and add case, the RGB values are premultiplied by a.
@@ -428,7 +428,7 @@
#define HLINE(type, op, draw_end) \
{ \
int length; \
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
type *pixel; \
if (x1 <= x2) { \
pixel = (type *)dst->pixels + y1 * pitch + x1; \
@@ -450,7 +450,7 @@
#define VLINE(type, op, draw_end) \
{ \
int length; \
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
type *pixel; \
if (y1 <= y2) { \
pixel = (type *)dst->pixels + y1 * pitch + x1; \
@@ -472,7 +472,7 @@
#define DLINE(type, op, draw_end) \
{ \
int length; \
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel); \
type *pixel; \
if (y1 <= y2) { \
pixel = (type *)dst->pixels + y1 * pitch + x1; \
@@ -692,7 +692,7 @@
do { \
int width = rect->w; \
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; \
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
while (height--) { \

View File

@@ -31,7 +31,7 @@ static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
{
if (y1 == y2) {
int length;
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel);
int pitch = (dst->pitch / dst->fmt->bytes_per_pixel);
Uint8 *pixel;
if (x1 <= x2) {
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);
} else {
Uint8 _r, _g, _b, _a;
const SDL_PixelFormatDetails *fmt = dst->internal->format;
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
const SDL_PixelFormatDetails *fmt = dst->fmt;
SDL_GetRGBA(color, fmt, dst->palette, &_r, &_g, &_b, &_a);
if (fmt->Rmask == 0x7C00) {
AALINE(x1, y1, x2, y2,
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);
} else {
Uint8 _r, _g, _b, _a;
const SDL_PixelFormatDetails *fmt = dst->internal->format;
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
const SDL_PixelFormatDetails *fmt = dst->fmt;
SDL_GetRGBA(color, fmt, dst->palette, &_r, &_g, &_b, &_a);
if (fmt->Rmask == 0x00FF0000) {
if (!fmt->Amask) {
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");
}
func = SDL_CalculateDrawLineFunc(dst->internal->format);
func = SDL_CalculateDrawLineFunc(dst->fmt);
if (!func) {
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
}
// Perform clipping
// 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;
}
@@ -168,7 +168,7 @@ bool SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
return SDL_InvalidParamError("SDL_DrawLines(): dst");
}
func = SDL_CalculateDrawLineFunc(dst->internal->format);
func = SDL_CalculateDrawLineFunc(dst->fmt);
if (!func) {
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
// 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;
}

View File

@@ -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
if (dst->internal->format->bits_per_pixel < 8) {
if (dst->fmt->bits_per_pixel < 8) {
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
}
// Perform clipping
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
return true;
}
switch (dst->internal->format->bytes_per_pixel) {
switch (dst->fmt->bytes_per_pixel) {
case 1:
DRAW_FASTSETPIXELXY1(x, y);
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
if (dst->internal->format->bits_per_pixel < 8) {
if (dst->fmt->bits_per_pixel < 8) {
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
}
minx = dst->internal->clip_rect.x;
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
miny = dst->internal->clip_rect.y;
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
minx = dst->clip_rect.x;
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
miny = dst->clip_rect.y;
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
for (i = 0; i < count; ++i) {
x = points[i].x;
@@ -88,7 +88,7 @@ bool SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32
continue;
}
switch (dst->internal->format->bytes_per_pixel) {
switch (dst->fmt->bytes_per_pixel) {
case 1:
DRAW_FASTSETPIXELXY1(x, y);
break;

View File

@@ -142,8 +142,8 @@ static bool SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
src = (Uint8 *)pixels;
dst = (Uint8 *)surface->pixels +
rect->y * surface->pitch +
rect->x * surface->internal->format->bytes_per_pixel;
length = (size_t)rect->w * surface->internal->format->bytes_per_pixel;
rect->x * surface->fmt->bytes_per_pixel;
length = (size_t)rect->w * surface->fmt->bytes_per_pixel;
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
@@ -162,7 +162,7 @@ static bool SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
*pixels =
(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;
return true;
}
@@ -364,7 +364,7 @@ static bool SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Te
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
// 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;
}
@@ -984,7 +984,7 @@ static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
pixels = (void *)((Uint8 *)surface->pixels +
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);
}

View File

@@ -38,7 +38,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
#include "SDL_rotate.h"
#include "../../video/SDL_blit.h"
#include "../../video/SDL_surface_c.h"
// ---- 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
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
is8bit = src->fmt->bits_per_pixel == 8 && colorKeyAvailable;
if (!(is8bit || (src->fmt->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
return NULL;
}
@@ -521,7 +521,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
// Target surface is 8 bit
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
if (rz_dst) {
SDL_SetSurfacePalette(rz_dst, src->internal->palette);
SDL_SetSurfacePalette(rz_dst, src->palette);
}
} else {
// Target surface is 32 bit with source RGBA ordering

View File

@@ -26,7 +26,7 @@
#include "SDL_triangle.h"
#include "../../video/SDL_blit.h"
#include "../../video/SDL_surface_c.h"
/* fixed points bits 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);
dstbpp = tmp->internal->format->bytes_per_pixel;
dstbpp = tmp->fmt->bytes_per_pixel;
dst_ptr = (Uint8 *)tmp->pixels;
dst_pitch = tmp->pitch;
} else {
// 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_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;
SDL_Palette *palette;
if (tmp) {
format = tmp->internal->format;
palette = tmp->internal->palette;
format = tmp->fmt;
palette = tmp->palette;
} else {
format = dst->internal->format;
palette = dst->internal->palette;
format = dst->fmt;
palette = dst->palette;
}
if (dstbpp == 4) {
TRIANGLE_BEGIN_LOOP
@@ -584,7 +584,7 @@ bool SDL_SW_BlitTriangle(
}
// 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_pitch = dst->pitch;
@@ -662,13 +662,13 @@ bool SDL_SW_BlitTriangle(
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
// Use SDL_BlitTriangle_Slow
SDL_BlitInfo *info = &src->internal->map.info;
SDL_BlitInfo *info = &src->map.info;
SDL_BlitInfo tmp_info;
SDL_zero(tmp_info);
tmp_info.src_fmt = src->internal->format;
tmp_info.dst_fmt = dst->internal->format;
tmp_info.src_fmt = src->fmt;
tmp_info.dst_fmt = dst->fmt;
tmp_info.flags = info->flags;
/*
tmp_info.r = info->r;