Use C++ style comments consistently in SDL source code
Implemented using this script:
find . -type f -exec sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' {} \;
git checkout \
core/linux/SDL_evdev_kbd_default_keymap.h \
events/imKStoUCS.* \
hidapi \
joystick/controller_type.c \
joystick/controller_type.h \
joystick/hidapi/steam/controller_constants.h \
joystick/hidapi/steam/controller_structs.h \
joystick/SDL_gamepad_db.h \
libm \
render/*/*Shader*.h \
render/vitagxm/SDL_render_vita_gxm_shaders.h \
render/metal/SDL_shaders_metal_*.h \
stdlib/SDL_malloc.c \
stdlib/SDL_qsort.c \
stdlib/SDL_strtokr.c \
test/ \
video/directx/SDL_d3d12_xbox_cmacros.h \
video/directx/d3d12.h \
video/directx/d3d12sdklayers.h \
video/khronos \
video/x11/edid-parse.c \
video/x11/xsettings-client.* \
video/yuv2rgb
sed -i'' -e 's,/\* *\([^*]*\)\*/ *$,// \1,' -e 's, \+$,,' hidapi/SDL_hidapi.c
This commit is contained in:
@@ -243,14 +243,14 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
return SDL_InvalidParamError("SDL_BlendFillRect(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
// If 'rect' == NULL, then fill the whole surface
|
||||
if (rect) {
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
} else {
|
||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -313,7 +313,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
@@ -324,7 +324,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
// FIXME: Does this function pointer slow things down significantly?
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->internal->format->Rmask) {
|
||||
@@ -362,7 +362,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
@@ -371,4 +371,4 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
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_ */
|
||||
#endif // SDL_blendfillrect_h_
|
||||
|
||||
@@ -900,7 +900,7 @@ static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fm
|
||||
} else {
|
||||
return SDL_BlendLine_RGB2;
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
case 4:
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (fmt->Amask) {
|
||||
@@ -933,8 +933,8 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -967,13 +967,13 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
// Draw the end if it was clipped
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
@@ -985,4 +985,4 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
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_ */
|
||||
#endif // SDL_blendline_h_
|
||||
|
||||
@@ -241,12 +241,12 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
@@ -280,7 +280,7 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
||||
} else {
|
||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
// break; -Wunreachable-code-break
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -309,7 +309,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
@@ -320,7 +320,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
// FIXME: Does this function pointer slow things down significantly?
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->internal->format->Rmask) {
|
||||
@@ -376,4 +376,4 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
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_ */
|
||||
#endif // SDL_blendpoint_h_
|
||||
|
||||
@@ -424,7 +424,7 @@
|
||||
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
// Horizontal line
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -446,7 +446,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
// Vertical line
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -468,7 +468,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
// Diagonal line
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
@@ -503,7 +503,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
// Bresenham's line algorithm
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
@@ -563,7 +563,7 @@
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
// 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; \
|
||||
|
||||
@@ -146,8 +146,8 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -180,13 +180,13 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
// Perform clipping
|
||||
// FIXME: We don't actually want to clip, as it may change line slope
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if the whole line is a single point or it was clipped */
|
||||
// Draw the end if the whole line is a single point or it was clipped
|
||||
draw_end = ((x1 == x2) && (y1 == y2)) || (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
@@ -197,4 +197,4 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
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_ */
|
||||
#endif // SDL_drawline_h_
|
||||
|
||||
@@ -31,12 +31,12 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
// Perform clipping
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
@@ -71,7 +71,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
// This function doesn't work on surfaces < 8 bpp
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
@@ -106,4 +106,4 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@
|
||||
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_ */
|
||||
#endif // SDL_drawpoint_h_
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "SDL_triangle.h"
|
||||
#include "../../video/SDL_pixels_c.h"
|
||||
|
||||
/* SDL surface based renderer implementation */
|
||||
// SDL surface based renderer implementation
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -189,7 +189,7 @@ static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
static int SW_QueueNoOp(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)
|
||||
@@ -301,7 +301,7 @@ static int Blit_to_Screen(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *surf
|
||||
float scale_x, float scale_y, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
int retval;
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
if (scale_x != 1.0f || scale_y != 1.0f) {
|
||||
SDL_Rect r;
|
||||
r.x = (int)((float)dstrect->x * scale_x);
|
||||
@@ -363,29 +363,29 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
/* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */
|
||||
// SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted.
|
||||
if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* If scaling and cropping is necessary, it has to be taken care of before the rotation. */
|
||||
// If scaling and cropping is necessary, it has to be taken care of before the rotation.
|
||||
if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* srcrect is not selecting the whole src surface, so cropping is needed */
|
||||
// srcrect is not selecting the whole src surface, so cropping is needed
|
||||
if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes. */
|
||||
// The color and alpha modulation has to be applied before the rotation when using the NONE, MOD or MUL blend modes.
|
||||
if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) {
|
||||
applyModulation = SDL_TRUE;
|
||||
SDL_SetSurfaceAlphaMod(src_clone, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod);
|
||||
}
|
||||
|
||||
/* Opaque surfaces are much easier to handle with the NONE blend mode. */
|
||||
// Opaque surfaces are much easier to handle with the NONE blend mode.
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) {
|
||||
isOpaque = SDL_TRUE;
|
||||
}
|
||||
@@ -419,7 +419,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
}
|
||||
}
|
||||
|
||||
/* SDLgfx_rotateSurface is going to make decisions depending on the blend mode. */
|
||||
// SDLgfx_rotateSurface is going to make decisions depending on the blend mode.
|
||||
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
||||
|
||||
if (!retval) {
|
||||
@@ -435,7 +435,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
// 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);
|
||||
@@ -455,11 +455,11 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
if (blendmode != SDL_BLENDMODE_NONE || isOpaque) {
|
||||
if (applyModulation == SDL_FALSE) {
|
||||
/* If the modulation wasn't already applied, make it happen now. */
|
||||
// If the modulation wasn't already applied, make it happen now.
|
||||
SDL_SetSurfaceAlphaMod(src_rotated, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod);
|
||||
}
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
} else {
|
||||
/* The NONE blend mode requires three steps to get the pixels onto the destination surface.
|
||||
@@ -469,7 +469,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
SDL_Rect mask_rect = tmp_rect;
|
||||
SDL_SetSurfaceBlendMode(mask_rotated, SDL_BLENDMODE_NONE);
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(mask_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
/* The next step copies the alpha value. This is done with the BLEND blend mode and
|
||||
@@ -478,7 +478,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
*/
|
||||
SDL_SetSurfaceColorMod(src_rotated, 0, 0, 0);
|
||||
mask_rect = tmp_rect;
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated, NULL, surface, &mask_rect, scale_x, scale_y, texture->scaleMode);
|
||||
if (!retval) {
|
||||
/* The last step gets the color values in place. The ADD blend mode simply adds them to
|
||||
@@ -491,7 +491,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
/* Renderer scaling, if needed */
|
||||
// Renderer scaling, if needed
|
||||
retval = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
SDL_DestroySurface(src_rotated_rgb);
|
||||
}
|
||||
@@ -637,7 +637,7 @@ static void PrepTextureForCopy(const SDL_RenderCommand *cmd, SW_DrawStateCache *
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
}
|
||||
|
||||
/* !!! FIXME: we can probably avoid some of these calls. */
|
||||
// !!! FIXME: we can probably avoid some of these calls.
|
||||
SDL_SetSurfaceColorMod(surface, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(surface, a);
|
||||
SDL_SetSurfaceBlendMode(surface, blend);
|
||||
@@ -648,7 +648,7 @@ 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_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
SDL_assert_release(viewport != NULL); // the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT
|
||||
|
||||
if (cliprect && viewport) {
|
||||
SDL_Rect clip_rect;
|
||||
@@ -667,7 +667,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
|
||||
static void SW_InvalidateCachedState(SDL_Renderer *renderer)
|
||||
{
|
||||
/* SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here! */
|
||||
// SW_DrawStateCache only lives during SW_RunCommandQueue, so nothing to do here!
|
||||
}
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const Uint8 g = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.g * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f);
|
||||
const Uint8 b = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.b * cmd->data.color.color_scale, 0.0f, 1.0f) * 255.0f);
|
||||
const Uint8 a = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.a, 0.0f, 1.0f) * 255.0f);
|
||||
/* By definition the clear ignores the clip rect */
|
||||
// By definition the clear ignores the clip rect
|
||||
SDL_SetSurfaceClipRect(surface, NULL);
|
||||
SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
@@ -737,7 +737,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -765,7 +765,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -793,7 +793,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
@@ -822,7 +822,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
dstrect->x += drawstate.viewport->x;
|
||||
dstrect->y += drawstate.viewport->y;
|
||||
@@ -836,10 +836,10 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
*/
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
|
||||
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||
// 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_CreateSurface(dstrect->w, dstrect->h, src->format);
|
||||
/* Scale to an intermediate surface, then blit */
|
||||
// Scale to an intermediate surface, then blit
|
||||
if (tmp) {
|
||||
SDL_Rect r;
|
||||
SDL_BlendMode blendmode;
|
||||
@@ -866,7 +866,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||
SDL_DestroySurface(tmp);
|
||||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
// No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy()
|
||||
}
|
||||
} else {
|
||||
SDL_BlitSurfaceScaled(src, srcrect, surface, dstrect, texture->scaleMode);
|
||||
@@ -881,7 +881,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
@@ -910,7 +910,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
@@ -934,7 +934,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
} else {
|
||||
GeometryFillData *ptr = (GeometryFillData *)verts;
|
||||
|
||||
/* Apply viewport */
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
@@ -1019,7 +1019,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
/* Prefer the format used by the framebuffer by default. */
|
||||
// Prefer the format used by the framebuffer by default.
|
||||
SDL_AddSupportedTextureFormat(renderer, format);
|
||||
|
||||
switch (format) {
|
||||
@@ -1140,7 +1140,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
renderer->QueueSetViewport = SW_QueueNoOp;
|
||||
renderer->QueueSetDrawColor = SW_QueueNoOp;
|
||||
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;
|
||||
@@ -1169,7 +1169,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
||||
|
||||
static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props)
|
||||
{
|
||||
/* Set the vsync hint based on our flags, if it's not already set */
|
||||
// Set the vsync hint based on our flags, if it's not already set
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
const SDL_bool no_hint_set = (!hint || !*hint);
|
||||
|
||||
@@ -1183,7 +1183,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
||||
|
||||
SDL_Surface *surface = SDL_GetWindowSurface(window);
|
||||
|
||||
/* Reset the vsync hint if we set it above */
|
||||
// Reset the vsync hint if we set it above
|
||||
if (no_hint_set) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
@@ -1199,4 +1199,4 @@ SDL_RenderDriver SW_RenderDriver = {
|
||||
SW_CreateRenderer, SDL_SOFTWARE_RENDERER
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
|
||||
extern int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SDL_PropertiesID create_props);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
#endif // SDL_render_sw_c_h_
|
||||
|
||||
@@ -40,7 +40,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
#include "../../video/SDL_blit.h"
|
||||
|
||||
/* ---- Internally used structures */
|
||||
// ---- Internally used structures
|
||||
|
||||
/**
|
||||
A 32 bit RGBA pixel.
|
||||
@@ -85,7 +85,7 @@ static Uint32 get_colorkey(SDL_Surface *src)
|
||||
return key;
|
||||
}
|
||||
|
||||
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
|
||||
// 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)
|
||||
{
|
||||
sx -= center->x;
|
||||
@@ -143,24 +143,24 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S
|
||||
rect_dest->x = minx;
|
||||
rect_dest->y = miny;
|
||||
|
||||
/* reverse the angle because our rotations are clockwise */
|
||||
// reverse the angle because our rotations are clockwise
|
||||
*sangle = -sinangle;
|
||||
*cangle = cosangle;
|
||||
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
// 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 */
|
||||
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 */
|
||||
angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
}
|
||||
|
||||
if (angle90 & 1) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
*sangle = angle90 == 1 ? -1 : 1; // reversed because our rotations are clockwise
|
||||
} else {
|
||||
rect_dest->w = width;
|
||||
rect_dest->h = height;
|
||||
@@ -171,7 +171,7 @@ void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const S
|
||||
}
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
// 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)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
switch (angle) { // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
case 0:
|
||||
*sincx = bpp;
|
||||
*sincy = pitch - src->w * *sincx;
|
||||
@@ -212,7 +212,7 @@ static void computeSourceIncrements90(SDL_Surface *src, int bpp, int angle, int
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
// 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; \
|
||||
@@ -495,7 +495,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
int colorKeyAvailable = SDL_FALSE;
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
// Sanity check
|
||||
if (!SDL_SurfaceValid(src)) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -505,41 +505,41 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
colorKeyAvailable = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
|
||||
// This function requires a 32-bit surface or 8-bit surface with a colorkey
|
||||
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
// Calculate target factors from sine/cosine and zoom
|
||||
sangleinv = sangle * 65536.0;
|
||||
cangleinv = cangle * 65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
// Alloc space to completely contain the rotated surface
|
||||
rz_dst = NULL;
|
||||
if (is8bit) {
|
||||
/* Target surface is 8 bit */
|
||||
// Target surface is 8 bit
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
if (rz_dst) {
|
||||
SDL_SetSurfacePalette(rz_dst, src->internal->palette);
|
||||
}
|
||||
} else {
|
||||
/* Target surface is 32 bit with source RGBA ordering */
|
||||
// Target surface is 32 bit with source RGBA ordering
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
// Check target
|
||||
if (!rz_dst) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Adjust for guard rows */
|
||||
// Adjust for guard rows
|
||||
rz_dst->h = rect_dest->h;
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
|
||||
if (colorKeyAvailable == SDL_TRUE) {
|
||||
/* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */
|
||||
// If available, the colorkey will be used to discard the pixels that are outside of the rotated area.
|
||||
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
|
||||
} else if (blendmode == SDL_BLENDMODE_NONE) {
|
||||
@@ -559,7 +559,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
|
||||
SDL_SetSurfaceBlendMode(rz_dst, blendmode);
|
||||
|
||||
/* Lock source surface */
|
||||
// Lock source surface
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
SDL_DestroySurface(rz_dst);
|
||||
@@ -575,7 +575,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
if (angle90 == angle / 90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
angle90 += 4; // 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -583,7 +583,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
|
||||
if (is8bit) {
|
||||
/* Call the 8-bit transformation routine to do the rotation */
|
||||
// Call the 8-bit transformation routine to do the rotation
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceY90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
@@ -591,7 +591,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
flipx, flipy, rect_dest, center);
|
||||
}
|
||||
} else {
|
||||
/* Call the 32-bit transformation routine to do the rotation */
|
||||
// Call the 32-bit transformation routine to do the rotation
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
@@ -600,13 +600,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlock source surface */
|
||||
// Unlock source surface
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
/* Return rotated surface */
|
||||
// Return rotated surface
|
||||
return rz_dst;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -27,4 +27,4 @@ extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smo
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
#endif // SDL_rotate_h_
|
||||
|
||||
@@ -87,13 +87,13 @@ int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* cross product AB x AC */
|
||||
// cross product AB x AC
|
||||
static Sint64 cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int c_y)
|
||||
{
|
||||
return ((Sint64)(b->x - a->x)) * ((Sint64)(c_y - a->y)) - ((Sint64)(b->y - a->y)) * ((Sint64)(c_x - a->x));
|
||||
}
|
||||
|
||||
/* check for top left rules */
|
||||
// check for top left rules
|
||||
static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
{
|
||||
if (is_clockwise) {
|
||||
@@ -114,8 +114,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* x = (y << FP_BITS) */
|
||||
/* prevent runtime error: left shift of negative value */
|
||||
// x = (y << FP_BITS)
|
||||
// prevent runtime error: left shift of negative value
|
||||
#define PRECOMP(x, y) \
|
||||
val = y; \
|
||||
if (val >= 0) { \
|
||||
@@ -133,21 +133,21 @@ void trianglepoint_2_fixedpoint(SDL_Point *a)
|
||||
PRECOMP(a->y, a->y);
|
||||
}
|
||||
|
||||
/* bounding rect of three points (in fixed point) */
|
||||
// bounding rect of three points (in fixed point)
|
||||
static void bounding_rect_fixedpoint(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r)
|
||||
{
|
||||
int min_x = SDL_min(a->x, SDL_min(b->x, c->x));
|
||||
int max_x = SDL_max(a->x, SDL_max(b->x, c->x));
|
||||
int min_y = SDL_min(a->y, SDL_min(b->y, c->y));
|
||||
int max_y = SDL_max(a->y, SDL_max(b->y, c->y));
|
||||
/* points are in fixed point, shift back */
|
||||
// points are in fixed point, shift back
|
||||
r->x = min_x >> FP_BITS;
|
||||
r->y = min_y >> FP_BITS;
|
||||
r->w = (max_x - min_x) >> FP_BITS;
|
||||
r->h = (max_y - min_y) >> FP_BITS;
|
||||
}
|
||||
|
||||
/* bounding rect of three points */
|
||||
// bounding rect of three points
|
||||
static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Point *c, SDL_Rect *r)
|
||||
{
|
||||
int min_x = SDL_min(a->x, SDL_min(b->x, c->x));
|
||||
@@ -180,7 +180,7 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
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 */
|
||||
// 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); \
|
||||
@@ -253,12 +253,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
is_uniform = COLOR_EQ(c0, c1) && COLOR_EQ(c1, c2);
|
||||
|
||||
/* Flat triangle */
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the destination, if needed */
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
@@ -271,7 +271,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
bounding_rect_fixedpoint(d0, d1, d2, &dstrect);
|
||||
|
||||
{
|
||||
/* Clip triangle rect with surface rect */
|
||||
// Clip triangle rect with surface rect
|
||||
SDL_Rect rect;
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
@@ -281,7 +281,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
// Clip triangle with surface clip rect
|
||||
SDL_Rect rect;
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
|
||||
@@ -290,12 +290,12 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
SDL_PixelFormat format = dst->format;
|
||||
|
||||
/* need an alpha format */
|
||||
// need an alpha format
|
||||
if (!SDL_ISPIXELFORMAT_ALPHA(format)) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
/* Use an intermediate surface */
|
||||
// Use an intermediate surface
|
||||
tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format);
|
||||
if (!tmp) {
|
||||
ret = -1;
|
||||
@@ -314,7 +314,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
dst_pitch = tmp->pitch;
|
||||
|
||||
} else {
|
||||
/* Write directly to destination surface */
|
||||
// Write directly to destination surface
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
@@ -335,7 +335,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
PRECOMP(d0d1_x, d1->x - d0->x)
|
||||
}
|
||||
|
||||
/* Starting point for rendering, at the middle of a pixel */
|
||||
// Starting point for rendering, at the middle of a pixel
|
||||
{
|
||||
SDL_Point p;
|
||||
p.x = dstrect.x;
|
||||
@@ -348,7 +348,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
w2_row = cross_product(d0, d1, p.x, p.y);
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
// Handle anti-clockwise triangles
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
@@ -361,7 +361,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
w2_row *= -1;
|
||||
}
|
||||
|
||||
/* Add a bias to respect top-left rasterization rule */
|
||||
// Add a bias to respect top-left rasterization rule
|
||||
bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1);
|
||||
bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1);
|
||||
bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1);
|
||||
@@ -507,12 +507,12 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
area = cross_product(d0, d1, d2->x, d2->y);
|
||||
|
||||
/* Flat triangle */
|
||||
// Flat triangle
|
||||
if (area == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Lock the destination, if needed */
|
||||
// Lock the destination, if needed
|
||||
if (SDL_MUSTLOCK(dst)) {
|
||||
if (SDL_LockSurface(dst) < 0) {
|
||||
ret = -1;
|
||||
@@ -522,7 +522,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
}
|
||||
|
||||
/* Lock the source, if needed */
|
||||
// Lock the source, if needed
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
ret = -1;
|
||||
@@ -538,7 +538,7 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blend);
|
||||
|
||||
/* TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 */
|
||||
// TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1
|
||||
if (texture_address_mode == SDL_TEXTURE_ADDRESS_CLAMP) {
|
||||
SDL_Rect srcrect;
|
||||
int maxx, maxy;
|
||||
@@ -577,18 +577,18 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
// Clip triangle with surface clip rect
|
||||
SDL_Rect rect;
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_GetRectIntersection(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
/* Set destination pointer */
|
||||
// Set destination pointer
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
|
||||
/* Set source pointer */
|
||||
// Set source pointer
|
||||
src_ptr = (const int *)src->pixels;
|
||||
src_pitch = src->pitch;
|
||||
|
||||
@@ -612,7 +612,7 @@ int SDL_SW_BlitTriangle(
|
||||
s2s0_y = s0->y - s2->y;
|
||||
s2s1_y = s1->y - s2->y;
|
||||
|
||||
/* Starting point for rendering, at the middle of a pixel */
|
||||
// Starting point for rendering, at the middle of a pixel
|
||||
{
|
||||
SDL_Point p;
|
||||
p.x = dstrect.x;
|
||||
@@ -625,7 +625,7 @@ int SDL_SW_BlitTriangle(
|
||||
w2_row = cross_product(d0, d1, p.x, p.y);
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
// Handle anti-clockwise triangles
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
@@ -638,7 +638,7 @@ int SDL_SW_BlitTriangle(
|
||||
w2_row *= -1;
|
||||
}
|
||||
|
||||
/* Add a bias to respect top-left rasterization rule */
|
||||
// Add a bias to respect top-left rasterization rule
|
||||
bias_w0 = (is_top_left(d1, d2, is_clockwise) ? 0 : -1);
|
||||
bias_w1 = (is_top_left(d2, d0, is_clockwise) ? 0 : -1);
|
||||
bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1);
|
||||
@@ -660,7 +660,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
// Use SDL_BlitTriangle_Slow
|
||||
|
||||
SDL_BlitInfo *info = &src->internal->map.info;
|
||||
SDL_BlitInfo tmp_info;
|
||||
@@ -695,12 +695,12 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
tmp_info.colorkey = info->colorkey;
|
||||
|
||||
/* src */
|
||||
// src
|
||||
tmp_info.src_surface = src_surface;
|
||||
tmp_info.src = (Uint8 *)src_ptr;
|
||||
tmp_info.src_pitch = src_pitch;
|
||||
|
||||
/* dst */
|
||||
// dst
|
||||
tmp_info.dst = dst_ptr;
|
||||
tmp_info.dst_pitch = dst_pitch;
|
||||
|
||||
@@ -827,12 +827,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB);
|
||||
srcA = 0xFF;
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
srcpixel = *((Uint32 *)(src));
|
||||
RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA);
|
||||
}
|
||||
if (flags & SDL_COPY_COLORKEY) {
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
// srcpixel isn't set for 24 bpp
|
||||
if (srcbpp == 3) {
|
||||
srcpixel = (srcR << src_fmt->Rshift) |
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
@@ -848,12 +848,12 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
|
||||
dstA = 0xFF;
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
dstpixel = *((Uint32 *) (dst));
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
}
|
||||
} else {
|
||||
/* don't care */
|
||||
// don't care
|
||||
dstR = dstG = dstB = dstA = 0;
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
srcA = (srcA * modulateA) / 255;
|
||||
}
|
||||
if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
|
||||
/* This goes away if we ever use premultiplied alpha */
|
||||
// This goes away if we ever use premultiplied alpha
|
||||
if (srcA < 255) {
|
||||
srcR = (srcR * srcA) / 255;
|
||||
srcG = (srcG * srcA) / 255;
|
||||
@@ -933,7 +933,7 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
|
||||
ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
|
||||
} else {
|
||||
/* SDL_PIXELFORMAT_ARGB2101010 */
|
||||
// SDL_PIXELFORMAT_ARGB2101010
|
||||
Uint32 pixel;
|
||||
ARGB2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA);
|
||||
*(Uint32 *)dst = pixel;
|
||||
@@ -942,4 +942,4 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
TRIANGLE_END_LOOP
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW */
|
||||
#endif // SDL_VIDEO_RENDER_SW
|
||||
|
||||
@@ -40,4 +40,4 @@ extern int SDL_SW_BlitTriangle(
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
#endif /* SDL_triangle_h_ */
|
||||
#endif // SDL_triangle_h_
|
||||
|
||||
Reference in New Issue
Block a user