mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-30 20:31:59 +00:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
(cherry picked from commit 5750bcb174)
This commit is contained in:
@@ -25,10 +25,8 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB555(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB565(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
@@ -280,13 +272,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendfillrect_h_ */
|
||||
|
||||
|
||||
@@ -26,11 +26,9 @@
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
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_bool draw_end)
|
||||
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_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -133,10 +131,9 @@ SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB555(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -238,10 +235,9 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB565(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -343,10 +339,9 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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_bool draw_end)
|
||||
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_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -449,10 +444,9 @@ SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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_bool draw_end)
|
||||
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_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
@@ -555,10 +549,9 @@ SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_RGB888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -660,10 +653,9 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_BlendLine_ARGB8888(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
@@ -765,14 +757,13 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*BlendLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
typedef void (*BlendLineFunc)(SDL_Surface *dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
|
||||
static BlendLineFunc
|
||||
SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
@@ -802,9 +793,8 @@ SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
@@ -827,9 +817,8 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -847,8 +836,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -863,8 +852,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
|
||||
if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) {
|
||||
SDL_BlendPoint(dst, points[count - 1].x, points[count - 1].y,
|
||||
blendMode, r, g, b, a);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendline_h_ */
|
||||
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB555(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB565(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
@@ -274,9 +266,8 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendpoint_h_ */
|
||||
|
||||
|
||||
@@ -26,77 +26,93 @@
|
||||
* and in the blend and add case, the RGB values are premultiplied by a.
|
||||
*/
|
||||
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a) * (_b)) / 255)
|
||||
|
||||
#define DRAW_FASTSETPIXEL(type) \
|
||||
*pixel = (type) color
|
||||
*pixel = (type)color
|
||||
|
||||
#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
|
||||
#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
|
||||
#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
|
||||
|
||||
#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
|
||||
*(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp) = (type) color
|
||||
*(type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp) = (type)color
|
||||
|
||||
#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
|
||||
#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
|
||||
#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
|
||||
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; \
|
||||
(void)sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr += r; if (sr > 0xff) sr = 0xff; \
|
||||
sg += g; if (sg > 0xff) sg = 0xff; \
|
||||
sb += b; if (sb > 0xff) sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
(void)sa; \
|
||||
getpixel; \
|
||||
sr += r; \
|
||||
if (sr > 0xff) \
|
||||
sr = 0xff; \
|
||||
sg += g; \
|
||||
if (sg > 0xff) \
|
||||
sg = 0xff; \
|
||||
sb += b; \
|
||||
if (sb > 0xff) \
|
||||
sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
(void)sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); if (sr > 0xff) sr = 0xff; \
|
||||
sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); if (sg > 0xff) sg = 0xff; \
|
||||
sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); if (sb > 0xff) sb = 0xff; \
|
||||
sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); if (sa > 0xff) sa = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; \
|
||||
sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); \
|
||||
if (sr > 0xff) \
|
||||
sr = 0xff; \
|
||||
sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); \
|
||||
if (sg > 0xff) \
|
||||
sg = 0xff; \
|
||||
sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); \
|
||||
if (sb > 0xff) \
|
||||
sb = 0xff; \
|
||||
sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); \
|
||||
if (sa > 0xff) \
|
||||
sa = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y)*dst->pitch + (x)*bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB555
|
||||
@@ -105,19 +121,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB555 \
|
||||
DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB555 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB555 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -143,19 +159,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB565 \
|
||||
DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB565 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB565 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -181,19 +197,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB888 \
|
||||
DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB888 \
|
||||
#define DRAW_SETPIXEL_MUL_RGB888 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
@@ -219,19 +235,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_ARGB8888 \
|
||||
DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_ARGB8888 \
|
||||
#define DRAW_SETPIXEL_MUL_ARGB8888 \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
@@ -257,19 +273,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGB \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB \
|
||||
#define DRAW_SETPIXEL_MUL_RGB \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
@@ -303,7 +319,6 @@ do { \
|
||||
#define DRAW_SETPIXELXY4_MUL_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGB)
|
||||
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGBA
|
||||
*/
|
||||
@@ -311,19 +326,19 @@ do { \
|
||||
#define DRAW_SETPIXEL_RGBA \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGBA \
|
||||
#define DRAW_SETPIXEL_MUL_RGBA \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
@@ -349,284 +364,301 @@ do { \
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2 - x1 + 1) : (x2 - x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1 - x2 + 1) : (x1 - x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2-y1+1) : (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1-y2+1) : (y1-y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2 - y1 + 1) : (y2 - y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1 - y2 + 1) : (y1 - y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1-y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2 - y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1 - y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; y1 = y2; y2 = Temp; \
|
||||
Temp = x1; x1 = x2; x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; \
|
||||
y1 = y2; \
|
||||
y2 = Temp; \
|
||||
Temp = x1; \
|
||||
x1 = x2; \
|
||||
x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef AA_LINES
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
#else
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define fill rect macro
|
||||
*/
|
||||
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 3: op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 2: op; pixel++; SDL_FALLTHROUGH; \
|
||||
case 1: op; pixel++; \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ \
|
||||
int n = (width + 3) / 4; \
|
||||
switch (width & 3) { \
|
||||
case 0: \
|
||||
do { \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 3: \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 2: \
|
||||
op; \
|
||||
pixel++; \
|
||||
SDL_FALLTHROUGH; \
|
||||
case 1: \
|
||||
op; \
|
||||
pixel++; \
|
||||
} while (--n > 0); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -26,10 +26,8 @@
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
int length;
|
||||
@@ -37,13 +35,13 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1);
|
||||
length = draw_end ? (x2 - x1 + 1) : (x2 - x1);
|
||||
} else {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
|
||||
if (!draw_end) {
|
||||
++pixel;
|
||||
}
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2);
|
||||
length = draw_end ? (x1 - x2 + 1) : (x1 - x2);
|
||||
}
|
||||
SDL_memset(pixel, color, length);
|
||||
} else if (x1 == x2) {
|
||||
@@ -55,9 +53,8 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
@@ -67,7 +64,7 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
@@ -85,9 +82,8 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
@@ -97,7 +93,7 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
@@ -117,12 +113,11 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*DrawLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
typedef void (*DrawLineFunc)(SDL_Surface *dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
|
||||
static DrawLineFunc
|
||||
SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 1:
|
||||
@@ -138,8 +133,7 @@ SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
@@ -162,9 +156,8 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -182,8 +175,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -198,8 +191,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
|
||||
if (points[0].x != points[count - 1].x || points[0].y != points[count - 1].y) {
|
||||
SDL_DrawPoint(dst, points[count - 1].x, points[count - 1].y, color);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
extern int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawline_h_ */
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
@@ -61,9 +59,8 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
extern int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawpoint_h_ */
|
||||
|
||||
|
||||
@@ -50,11 +50,9 @@ typedef struct
|
||||
SDL_Surface *window;
|
||||
} SW_RenderData;
|
||||
|
||||
|
||||
static SDL_Surface *
|
||||
SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
static SDL_Surface *SW_ActivateRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (!data->surface) {
|
||||
data->surface = data->window;
|
||||
@@ -68,10 +66,9 @@ SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
return data->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
data->surface = NULL;
|
||||
@@ -79,10 +76,9 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data->surface) {
|
||||
if (w) {
|
||||
@@ -102,14 +98,12 @@ SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
return SDL_SetError("Software renderer doesn't have an output surface");
|
||||
}
|
||||
|
||||
static int
|
||||
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
if (!SDL_PixelFormatEnumToMasks(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
@@ -133,11 +127,10 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
@@ -145,10 +138,10 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_LockSurface(surface);
|
||||
}
|
||||
src = (Uint8 *) pixels;
|
||||
dst = (Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
src = (Uint8 *)pixels;
|
||||
dst = (Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
length = rect->w * surface->format->BytesPerPixel;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
@@ -161,52 +154,46 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
static void SW_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
if (texture) {
|
||||
data->surface = (SDL_Surface *) texture->driverdata;
|
||||
data->surface = (SDL_Surface *)texture->driverdata;
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
static int SW_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
|
||||
{
|
||||
SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first);
|
||||
SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -223,10 +210,9 @@ SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
|
||||
static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
@@ -245,11 +231,10 @@ SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRe
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_FRect *dstrect)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -279,12 +264,11 @@ typedef struct CopyExData
|
||||
float scale_y;
|
||||
} CopyExData;
|
||||
|
||||
static int
|
||||
SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_FRect *dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
{
|
||||
CopyExData *verts = (CopyExData *) SDL_AllocateRenderVertices(renderer, sizeof (CopyExData), 0, &cmd->data.draw.first);
|
||||
CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
@@ -307,18 +291,17 @@ SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * te
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Rect *dstrect,
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
int retval;
|
||||
/* Renderer scaling, if needed */
|
||||
if (scale_x != 1.0f || scale_y != 1.0f) {
|
||||
SDL_Rect r;
|
||||
r.x = (int)((float) dstrect->x * scale_x);
|
||||
r.y = (int)((float) dstrect->y * scale_y);
|
||||
r.w = (int)((float) dstrect->w * scale_x);
|
||||
r.h = (int)((float) dstrect->h * scale_y);
|
||||
r.x = (int)((float)dstrect->x * scale_x);
|
||||
r.y = (int)((float)dstrect->y * scale_y);
|
||||
r.w = (int)((float)dstrect->w * scale_x);
|
||||
r.h = (int)((float)dstrect->h * scale_y);
|
||||
retval = SDL_PrivateUpperBlitScaled(src, srcrect, surface, &r, scaleMode);
|
||||
} else {
|
||||
retval = SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
@@ -326,12 +309,11 @@ Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surface, SDL_Re
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * final_rect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Texture *texture,
|
||||
const SDL_Rect *srcrect, const SDL_Rect *final_rect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, float scale_x, float scale_y)
|
||||
{
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
SDL_Rect tmp_rect;
|
||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||
@@ -441,18 +423,18 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
double cangle, sangle;
|
||||
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, center,
|
||||
&rect_dest, &cangle, &sangle);
|
||||
&rect_dest, &cangle, &sangle);
|
||||
src_rotated = SDLgfx_rotateSurface(src_clone, angle,
|
||||
(texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
(texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (src_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask != NULL) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle,
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (mask_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
@@ -535,7 +517,6 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
typedef struct GeometryFillData
|
||||
{
|
||||
SDL_Point dst;
|
||||
@@ -549,18 +530,17 @@ typedef struct GeometryCopyData
|
||||
SDL_Color color;
|
||||
} GeometryCopyData;
|
||||
|
||||
static int
|
||||
SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y)
|
||||
{
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
void *verts;
|
||||
int sz = texture ? sizeof (GeometryCopyData) : sizeof (GeometryFillData);
|
||||
int sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
||||
|
||||
verts = (void *) SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
verts = (void *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
@@ -569,7 +549,7 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
size_indices = indices ? size_indices : 0;
|
||||
|
||||
if (texture) {
|
||||
GeometryCopyData *ptr = (GeometryCopyData *) verts;
|
||||
GeometryCopyData *ptr = (GeometryCopyData *)verts;
|
||||
for (i = 0; i < count; i++) {
|
||||
int j;
|
||||
float *xy_;
|
||||
@@ -585,10 +565,10 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
uv_ = (float *)((char*)uv + j * uv_stride);
|
||||
uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
|
||||
ptr->src.x = (int)(uv_[0] * texture->w);
|
||||
ptr->src.y = (int)(uv_[1] * texture->h);
|
||||
@@ -600,9 +580,9 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
ptr->color = col_;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *) verts;
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
int j;
|
||||
@@ -618,8 +598,8 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
j = i;
|
||||
}
|
||||
|
||||
xy_ = (float *)((char*)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char*)color + j * color_stride);
|
||||
xy_ = (float *)((char *)xy + j * xy_stride);
|
||||
col_ = *(SDL_Color *)((char *)color + j * color_stride);
|
||||
|
||||
ptr->dst.x = (int)(xy_[0] * scale_x);
|
||||
ptr->dst.y = (int)(xy_[1] * scale_y);
|
||||
@@ -628,13 +608,12 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
ptr->color = col_;
|
||||
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
static void PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
@@ -642,7 +621,7 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
const SDL_bool colormod = ((r & g & b) != 0xFF);
|
||||
const SDL_bool alphamod = (a != 0xFF);
|
||||
const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
|
||||
@@ -657,13 +636,12 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
SDL_SetSurfaceBlendMode(surface, blend);
|
||||
}
|
||||
|
||||
static void
|
||||
SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
{
|
||||
if (drawstate->surface_cliprect_dirty) {
|
||||
const SDL_Rect *viewport = drawstate->viewport;
|
||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
|
||||
if (cliprect != NULL) {
|
||||
SDL_Rect clip_rect;
|
||||
@@ -680,8 +658,7 @@ SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
@@ -696,43 +673,48 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
break; /* Not used in this backend. */
|
||||
}
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR:
|
||||
{
|
||||
break; /* Not used in this backend. */
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
drawstate.viewport = &cmd->data.viewport.rect;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETVIEWPORT:
|
||||
{
|
||||
drawstate.viewport = &cmd->data.viewport.rect;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
case SDL_RENDERCMD_CLEAR:
|
||||
{
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
case SDL_RENDERCMD_DRAW_POINTS:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
@@ -888,64 +870,220 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY: {
|
||||
int i;
|
||||
SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
if (texture) {
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
GeometryCopyData *ptr = (GeometryCopyData *) verts;
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_BlitTriangle(
|
||||
src,
|
||||
&(ptr[0].src), &(ptr[1].src), &(ptr[2].src),
|
||||
surface,
|
||||
&(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst),
|
||||
ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *) verts;
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendPoints(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendLines(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS:
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
verts[i].y += drawstate.viewport->y;
|
||||
}
|
||||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY:
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const SDL_Rect *srcrect = verts;
|
||||
SDL_Rect *dstrect = verts + 1;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
dstrect->x += drawstate.viewport->x;
|
||||
dstrect->y += drawstate.viewport->y;
|
||||
}
|
||||
|
||||
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
|
||||
SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
} else {
|
||||
/* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
|
||||
* to avoid potentially frequent RLE encoding/decoding.
|
||||
*/
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
|
||||
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
|
||||
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
|
||||
/* Scale to an intermediate surface, then blit */
|
||||
if (tmp) {
|
||||
SDL_Rect r;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint8 alphaMod, rMod, gMod, bMod;
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
r.x = 0;
|
||||
r.y = 0;
|
||||
r.w = dstrect->w;
|
||||
r.h = dstrect->h;
|
||||
|
||||
SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE);
|
||||
SDL_SetSurfaceColorMod(src, 255, 255, 255);
|
||||
SDL_SetSurfaceAlphaMod(src, 255);
|
||||
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
|
||||
|
||||
SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod);
|
||||
SDL_SetSurfaceAlphaMod(tmp, alphaMod);
|
||||
SDL_SetSurfaceBlendMode(tmp, blendmode);
|
||||
|
||||
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||
SDL_FreeSurface(tmp);
|
||||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
}
|
||||
} else {
|
||||
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX:
|
||||
{
|
||||
CopyExData *copydata = (CopyExData *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
SetDrawState(surface, &drawstate);
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
}
|
||||
|
||||
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, ©data->srcrect,
|
||||
©data->dstrect, copydata->angle, ©data->center, copydata->flip,
|
||||
copydata->scale_x, copydata->scale_y);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
int i;
|
||||
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
const int count = (int)cmd->data.draw.count;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
if (texture) {
|
||||
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
GeometryCopyData *ptr = (GeometryCopyData *)verts;
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_BlitTriangle(
|
||||
src,
|
||||
&(ptr[0].src), &(ptr[1].src), &(ptr[2].src),
|
||||
surface,
|
||||
&(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst),
|
||||
ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
trianglepoint_2_fixedpoint(&vp);
|
||||
for (i = 0; i < count; i++) {
|
||||
ptr[i].dst.x += vp.x;
|
||||
ptr[i].dst.y += vp.y;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i += 3, ptr += 3) {
|
||||
SDL_SW_FillTriangle(surface, &(ptr[0].dst), &(ptr[1].dst), &(ptr[2].dst), blend, ptr[0].color, ptr[1].color, ptr[2].color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
@@ -954,9 +1092,8 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 format, void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
Uint32 src_format;
|
||||
@@ -970,23 +1107,22 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
* SDL_RenderReadPixels.
|
||||
*/
|
||||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
if (rect->x < 0 || rect->x + rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y + rect->h > surface->h) {
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
src_pixels = (void*)((Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
src_pixels = (void *)((Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
|
||||
return SDL_ConvertPixels(rect->w, rect->h,
|
||||
src_format, src_pixels, surface->pitch,
|
||||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderPresent(SDL_Renderer * renderer)
|
||||
static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
@@ -996,25 +1132,23 @@ SW_RenderPresent(SDL_Renderer * renderer)
|
||||
return SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyRenderer(SDL_Renderer * renderer)
|
||||
static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SW_RenderData *data = (SW_RenderData *)renderer->driverdata;
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
SW_CreateRendererForSurface(SDL_Surface *surface)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
@@ -1024,13 +1158,13 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
@@ -1048,9 +1182,9 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = SW_SetRenderTarget;
|
||||
renderer->QueueSetViewport = SW_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = SW_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueFillRects = SW_QueueFillRects;
|
||||
renderer->QueueCopy = SW_QueueCopy;
|
||||
renderer->QueueCopyEx = SW_QueueCopyEx;
|
||||
@@ -1068,8 +1202,7 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static SDL_Renderer *
|
||||
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
{
|
||||
const char *hint;
|
||||
SDL_Surface *surface;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
|
||||
extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
/* !
|
||||
\brief A 32 bit RGBA pixel.
|
||||
*/
|
||||
typedef struct tColorRGBA {
|
||||
typedef struct tColorRGBA
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
@@ -57,7 +58,8 @@ typedef struct tColorRGBA {
|
||||
/* !
|
||||
\brief A 8bit Y/palette pixel.
|
||||
*/
|
||||
typedef struct tColorY {
|
||||
typedef struct tColorY
|
||||
{
|
||||
Uint8 y;
|
||||
} tColorY;
|
||||
|
||||
@@ -76,8 +78,7 @@ to a situation where the program can segfault.
|
||||
/* !
|
||||
\brief Returns colorkey info for a surface
|
||||
*/
|
||||
static Uint32
|
||||
get_colorkey(SDL_Surface *src)
|
||||
static Uint32 get_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
@@ -87,8 +88,8 @@ get_colorkey(SDL_Surface *src)
|
||||
}
|
||||
|
||||
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
|
||||
static void
|
||||
rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy) {
|
||||
static void rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy)
|
||||
{
|
||||
sx -= center->x;
|
||||
sy -= center->y;
|
||||
|
||||
@@ -111,9 +112,8 @@ rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint
|
||||
\param sangle The cosine of the angle
|
||||
|
||||
*/
|
||||
void
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
{
|
||||
int minx, maxx, miny, maxy;
|
||||
double radangle;
|
||||
@@ -129,16 +129,16 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
/*
|
||||
* Determine destination width and height by rotating a source box, at pixel center
|
||||
*/
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(width - 0.5, height - 0.5, sinangle, cosangle, center, &x3, &y3);
|
||||
|
||||
minx = (int)SDL_floor( SDL_min( SDL_min(x0, x1), SDL_min(x2, x3) ) );
|
||||
maxx = (int)SDL_ceil( SDL_max( SDL_max(x0, x1), SDL_max(x2, x3) ) );
|
||||
minx = (int)SDL_floor(SDL_min(SDL_min(x0, x1), SDL_min(x2, x3)));
|
||||
maxx = (int)SDL_ceil(SDL_max(SDL_max(x0, x1), SDL_max(x2, x3)));
|
||||
|
||||
miny = (int)SDL_floor( SDL_min( SDL_min(y0, y1), SDL_min(y2, y3) ) );
|
||||
maxy = (int)SDL_ceil( SDL_max( SDL_max(y0, y1), SDL_max(y2, y3) ) );
|
||||
miny = (int)SDL_floor(SDL_min(SDL_min(y0, y1), SDL_min(y2, y3)));
|
||||
maxy = (int)SDL_ceil(SDL_max(SDL_max(y0, y1), SDL_max(y2, y3)));
|
||||
|
||||
rect_dest->w = maxx - minx;
|
||||
rect_dest->h = maxy - miny;
|
||||
@@ -151,20 +151,20 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle / 90);
|
||||
if (angle90 == angle / 90) { /* if the angle is a multiple of 90 degrees */
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
}
|
||||
|
||||
if (angle90 & 1) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
} else {
|
||||
rect_dest->w = width;
|
||||
rect_dest->w = width;
|
||||
rect_dest->h = height;
|
||||
*cangle = angle90 == 0 ? 1 : -1;
|
||||
*sangle = 0;
|
||||
@@ -174,19 +174,37 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
static void
|
||||
computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
{
|
||||
int pitch = flipy ? -src->pitch : src->pitch;
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
|
||||
case 0:
|
||||
*sincx = bpp;
|
||||
*sincy = pitch - src->w * *sincx;
|
||||
*signx = *signy = 1;
|
||||
break;
|
||||
case 1:
|
||||
*sincx = -pitch;
|
||||
*sincy = bpp - *sincx * src->h;
|
||||
*signx = 1;
|
||||
*signy = -1;
|
||||
break;
|
||||
case 2:
|
||||
*sincx = -bpp;
|
||||
*sincy = -src->w * *sincx - pitch;
|
||||
*signx = *signy = -1;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
*sincx = pitch;
|
||||
*sincy = -*sincx * src->h - bpp;
|
||||
*signx = -1;
|
||||
*signy = 1;
|
||||
break;
|
||||
}
|
||||
if (flipx) {
|
||||
*signx = -*signx;
|
||||
@@ -197,34 +215,34 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w * sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8 *)src->pixels, *dp = (Uint8 *)dst->pixels, *de; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
|
||||
if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (src->h-1)*src->pitch; \
|
||||
if (signx < 0) \
|
||||
sp += (src->w - 1) * sizeof(pixelType); \
|
||||
if (signy < 0) \
|
||||
sp += (src->h - 1) * src->pitch; \
|
||||
\
|
||||
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
|
||||
if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use SDL_memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
sp += dst->w*sizeof(pixelType); \
|
||||
dp += dst->w*sizeof(pixelType); \
|
||||
SDL_memcpy(dp, sp, dst->w * sizeof(pixelType)); \
|
||||
sp += dst->w * sizeof(pixelType); \
|
||||
dp += dst->w * sizeof(pixelType); \
|
||||
} else { \
|
||||
for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType*)dp = *(pixelType*)sp; \
|
||||
for (de = dp + dst->w * sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType *)dp = *(pixelType *)sp; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
static void transformSurfaceRGBA90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorRGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorY);
|
||||
}
|
||||
@@ -250,32 +268,31 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorRGBA c00, c01, c10, c11, cswap;
|
||||
tColorRGBA *pc, *sp;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorRGBA*) dst->pixels;
|
||||
pc = (tColorRGBA *)dst->pixels;
|
||||
gap = dst->pitch - dst->w * 4;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
if (smooth) {
|
||||
int y;
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
@@ -293,28 +310,36 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w - 1)) && (dy < (src->h - 1))) {
|
||||
int ex, ey;
|
||||
int t1, t2;
|
||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
|
||||
sp = (tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx;
|
||||
c00 = *sp;
|
||||
sp += 1;
|
||||
c01 = *sp;
|
||||
sp += (src->pitch/4);
|
||||
sp += (src->pitch / 4);
|
||||
c11 = *sp;
|
||||
sp -= 1;
|
||||
c10 = *sp;
|
||||
if (flipx) {
|
||||
cswap = c00; c00=c01; c01=cswap;
|
||||
cswap = c10; c10=c11; c11=cswap;
|
||||
cswap = c00;
|
||||
c00 = c01;
|
||||
c01 = cswap;
|
||||
cswap = c10;
|
||||
c10 = c11;
|
||||
c11 = cswap;
|
||||
}
|
||||
if (flipy) {
|
||||
cswap = c00; c00=c10; c10=cswap;
|
||||
cswap = c01; c01=c11; c11=cswap;
|
||||
cswap = c00;
|
||||
c00 = c10;
|
||||
c10 = cswap;
|
||||
cswap = c01;
|
||||
c01 = c11;
|
||||
c11 = cswap;
|
||||
}
|
||||
/*
|
||||
* Interpolate colors
|
||||
*/
|
||||
* Interpolate colors
|
||||
*/
|
||||
ex = (sdx & 0xffff);
|
||||
ey = (sdy & 0xffff);
|
||||
t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
|
||||
@@ -334,7 +359,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
} else {
|
||||
int y;
|
||||
@@ -360,7 +385,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,35 +408,34 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorY *pc;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
int y;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorY*) dst->pixels;
|
||||
pc = (tColorY *)dst->pixels;
|
||||
gap = dst->pitch - dst->w;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h);
|
||||
/*
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
int x;
|
||||
double src_x = (rect_dest->x + 0 + 0.5 - center->x);
|
||||
@@ -438,7 +462,6 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
|
||||
|
||||
@@ -466,8 +489,8 @@ When using the NONE and MOD modes, color and alpha modulation must be applied be
|
||||
*/
|
||||
|
||||
SDL_Surface *
|
||||
SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
{
|
||||
SDL_Surface *rz_dst;
|
||||
int is8bit, angle90;
|
||||
@@ -494,8 +517,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
sangleinv = sangle*65536.0;
|
||||
cangleinv = cangle*65536.0;
|
||||
sangleinv = sangle * 65536.0;
|
||||
cangleinv = cangle * 65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
rz_dst = NULL;
|
||||
@@ -557,8 +580,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
* the off-by-one problem in transformSurfaceRGBA that expresses itself when the rotation is near
|
||||
* multiples of 90 degrees.
|
||||
*/
|
||||
angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) {
|
||||
angle90 = (int)(angle / 90);
|
||||
if (angle90 == angle / 90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
@@ -582,7 +605,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceRGBA(src, rz_dst, (int)sangleinv, (int)cangleinv,
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#ifndef SDL_rotate_h_
|
||||
#define SDL_rotate_h_
|
||||
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
|
||||
@@ -33,16 +33,15 @@
|
||||
* But, if increased too much, it overflows (srcx, srcy) coordinates used for filling with texture.
|
||||
* (which could be turned to int64).
|
||||
*/
|
||||
#define FP_BITS 1
|
||||
#define FP_BITS 1
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo * info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
|
||||
#if 0
|
||||
int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
|
||||
@@ -114,7 +113,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a) {
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a)
|
||||
{
|
||||
a->x <<= FP_BITS;
|
||||
a->y <<= FP_BITS;
|
||||
}
|
||||
@@ -146,7 +146,6 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
r->h = (max_y - min_y);
|
||||
}
|
||||
|
||||
|
||||
/* Triangle rendering, using Barycentric coordinates (w0, w1, w2)
|
||||
*
|
||||
* The cross product isn't computed from scratch at each iteration,
|
||||
@@ -154,53 +153,51 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
*
|
||||
*/
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *) dst_ptr + x * dstbpp; \
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *)dst_ptr + x * dstbpp;
|
||||
|
||||
/* Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles */
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); \
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area);
|
||||
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a); \
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a);
|
||||
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area);
|
||||
|
||||
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
} \
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
@@ -265,12 +262,11 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
SDL_IntersectRect(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
int format = dst->format->format;
|
||||
|
||||
/* need an alpha format */
|
||||
if (! dst->format->Amask) {
|
||||
if (!dst->format->Amask) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
@@ -323,7 +319,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -346,7 +342,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
if (dst->format->Amask) {
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
} else {
|
||||
//color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
// color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
}
|
||||
} else {
|
||||
@@ -362,7 +358,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
} else if (dstbpp == 3) {
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -397,7 +393,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_MAPPED_COLOR
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -433,18 +429,12 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
int ret = 0;
|
||||
int src_locked = 0;
|
||||
@@ -584,7 +574,6 @@ int SDL_SW_BlitTriangle(
|
||||
d0d2_y = (d2->y - d0->y) << FP_BITS;
|
||||
d1d0_y = (d0->y - d1->y) << FP_BITS;
|
||||
|
||||
|
||||
d1d2_x = (d2->x - d1->x) << FP_BITS;
|
||||
d2d0_x = (d0->x - d2->x) << FP_BITS;
|
||||
d0d1_x = (d1->x - d0->x) << FP_BITS;
|
||||
@@ -608,7 +597,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -629,7 +618,7 @@ int SDL_SW_BlitTriangle(
|
||||
s2_x_area.x = s2->x * area;
|
||||
s2_x_area.y = s2->y * area;
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || ! is_uniform) {
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
|
||||
SDL_BlitInfo *info = &src->map->info;
|
||||
@@ -651,12 +640,11 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.b = c0.b;
|
||||
tmp_info.a = c0.a;
|
||||
|
||||
|
||||
tmp_info.flags &= ~(SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA);
|
||||
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
tmp_info.flags |= SDL_COPY_MODULATE_COLOR;
|
||||
}
|
||||
|
||||
@@ -667,17 +655,17 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.colorkey = info->colorkey;
|
||||
|
||||
/* src */
|
||||
tmp_info.src = (Uint8 *) src_ptr;
|
||||
tmp_info.src = (Uint8 *)src_ptr;
|
||||
tmp_info.src_pitch = src_pitch;
|
||||
|
||||
/* dst */
|
||||
tmp_info.dst = (Uint8 *) dst_ptr;
|
||||
tmp_info.dst = (Uint8 *)dst_ptr;
|
||||
tmp_info.dst_pitch = dst_pitch;
|
||||
|
||||
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
|
||||
goto end;
|
||||
}
|
||||
@@ -686,7 +674,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint32 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -694,7 +682,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
dptr[0] = sptr[3 * srcx];
|
||||
dptr[1] = sptr[3 * srcx + 1];
|
||||
dptr[2] = sptr[3 * srcx + 2];
|
||||
@@ -704,7 +692,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint16 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -712,7 +700,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -729,13 +717,13 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf)
|
||||
{
|
||||
if (pf->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return FORMAT_2101010;
|
||||
} else if (pf->Amask) {
|
||||
@@ -745,12 +733,11 @@ static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
{
|
||||
const int flags = info->flags;
|
||||
Uint32 modulateR = info->r;
|
||||
@@ -796,7 +783,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
if (srcbpp == 3) {
|
||||
srcpixel = (srcR << src_fmt->Rshift) |
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
}
|
||||
if ((srcpixel & rgbmask) == ckey) {
|
||||
continue;
|
||||
@@ -813,7 +800,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
}
|
||||
|
||||
if (! is_uniform) {
|
||||
if (!is_uniform) {
|
||||
TRIANGLE_GET_COLOR
|
||||
modulateR = r;
|
||||
modulateG = g;
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
extern int SDL_SW_FillTriangle(SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user