21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
25 #include "../SDL_sysrender.h"
88 *
w =
data->surface->w;
91 *
h =
data->surface->h;
101 SDL_SetError(
"Software renderer doesn't have an output surface");
109 Uint32 Rmask, Gmask, Bmask, Amask;
112 (
texture->format, &
bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
227 verts->y = (
int)
points->y;
259 verts->y = (
int)
rects->y;
287 verts->
x = (
int)dstrect->
x;
288 verts->
y = (
int)dstrect->
y;
290 verts->
w = (
int)dstrect->
w;
291 verts->
h = (
int)dstrect->
h;
345 int retval = 0, dstwidth, dstheight, abscenterx, abscentery;
346 double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
348 Uint8 alphaMod, rMod, gMod, bMod;
359 tmp_rect.w = final_rect->
w;
360 tmp_rect.h = final_rect->
h;
373 src->format->Rmask,
src->format->Gmask,
374 src->format->Bmask,
src->format->Amask);
375 if (src_clone ==
NULL) {
392 if (!(srcrect->
w == final_rect->
w && srcrect->
h == final_rect->
h && srcrect->
x == 0 && srcrect->
y == 0)) {
397 if (!(srcrect->
w ==
src->w && srcrect->
h ==
src->h && srcrect->
x == 0 && srcrect->
y == 0)) {
418 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
429 if (!
retval && (blitRequired || applyModulation)) {
432 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
433 if (src_scaled ==
NULL) {
439 src_clone = src_scaled;
449 src_rotated =
SDLgfx_rotateSurface(src_clone,
angle, dstwidth/2, dstheight/2, (
texture->scaleMode ==
SDL_ScaleModeNearest) ? 0 : 1, flip &
SDL_FLIP_HORIZONTAL, flip &
SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
450 if (src_rotated ==
NULL) {
455 mask_rotated =
SDLgfx_rotateSurface(
mask,
angle, dstwidth/2, dstheight/2,
SDL_FALSE, 0, 0, dstwidth, dstheight, cangle, sangle);
456 if (mask_rotated ==
NULL) {
462 abscenterx = final_rect->
x + (
int)center->
x;
463 abscentery = final_rect->
y + (
int)center->
y;
468 px = final_rect->
x - abscenterx;
469 py = final_rect->
y - abscentery;
470 p1x = px * cangle - py * sangle + abscenterx;
471 p1y = px * sangle + py * cangle + abscentery;
474 px = final_rect->
x + final_rect->
w - abscenterx;
475 py = final_rect->
y - abscentery;
476 p2x = px * cangle - py * sangle + abscenterx;
477 p2y = px * sangle + py * cangle + abscentery;
480 px = final_rect->
x - abscenterx;
481 py = final_rect->
y + final_rect->
h - abscentery;
482 p3x = px * cangle - py * sangle + abscenterx;
483 p3y = px * sangle + py * cangle + abscentery;
486 px = final_rect->
x + final_rect->
w - abscenterx;
487 py = final_rect->
y + final_rect->
h - abscentery;
488 p4x = px * cangle - py * sangle + abscenterx;
489 p4y = px * sangle + py * cangle + abscentery;
493 tmp_rect.w = dstwidth;
494 tmp_rect.h = dstheight;
521 mask_rect = tmp_rect;
531 src_rotated->format->BitsPerPixel, src_rotated->pitch,
532 src_rotated->format->Rmask, src_rotated->format->Gmask,
533 src_rotated->format->Bmask, 0);
534 if (src_rotated_rgb ==
NULL) {
545 if (src_rotated !=
NULL) {
557 if (src_clone !=
NULL) {
577 if (colormod || alphamod || blending) {
595 if (cliprect !=
NULL) {
599 clip_rect.
w = cliprect->
w;
600 clip_rect.
h = cliprect->
h;
716 if ( srcrect->
w == dstrect->
w && srcrect->
h == dstrect->
h ) {
765 return SDL_SetError(
"Tried to read outside of surface bounds");
768 src_format =
surface->format->format;
774 src_format, src_pixels,
surface->pitch,
#define SDL_assert(condition)
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_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
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_DrawLines(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)
#define SDL_SetSurfaceRLE
#define SDL_GetWindowSize
#define SDL_GetSurfaceBlendMode
#define SDL_SetSurfaceColorMod
#define SDL_GetSurfaceAlphaMod
#define SDL_SetSurfaceAlphaMod
#define SDL_SetSurfaceBlendMode
#define SDL_UpdateWindowSurface
#define SDL_UnlockSurface
#define SDL_PixelFormatEnumToMasks
#define SDL_CreateRGBSurfaceFrom
#define SDL_GetSurfaceColorMod
#define SDL_CreateRGBSurface
#define SDL_GetWindowSurface
#define SDL_IntersectRect
#define SDL_ConvertPixels
#define SDL_OutOfMemory()
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLfixed GLfixed GLint GLint GLfixed points
GLboolean GLboolean GLboolean GLboolean a
GLenum GLenum GLuint texture
GLuint GLsizei GLsizei * length
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
#define SDL_PIXELLAYOUT(X)
@ SDL_PIXELFORMAT_RGBA8888
@ SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_BGRA8888
@ SDL_PIXELFORMAT_ARGB8888
void * SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset)
@ SDL_RENDERER_TARGETTEXTURE
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
@ SDL_TEXTUREACCESS_STATIC
SDL_ScaleMode
The scaling mode for a texture.
static SDL_Renderer * SW_CreateRenderer(SDL_Window *window, Uint32 flags)
static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
static void SW_RenderPresent(SDL_Renderer *renderer)
static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static int SW_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
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)
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)
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
static void PrepTextureForCopy(const SDL_RenderCommand *cmd)
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
SDL_RenderDriver SW_RenderDriver
static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
static SDL_Surface * SW_ActivateRenderer(SDL_Renderer *renderer)
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_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
static void SW_DestroyRenderer(SDL_Renderer *renderer)
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle)
SDL_Surface * SDLgfx_rotateSurface(SDL_Surface *src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle)
@ SDL_RENDERCMD_SETCLIPRECT
@ SDL_RENDERCMD_DRAW_LINES
@ SDL_RENDERCMD_SETVIEWPORT
@ SDL_RENDERCMD_DRAW_POINTS
@ SDL_RENDERCMD_FILL_RECTS
@ SDL_RENDERCMD_SETDRAWCOLOR
@ SDL_WINDOWEVENT_SIZE_CHANGED
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
EGLSurface EGLNativeWindowType * window
EGLSurface EGLint * rects
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
The structure that defines a point (floating point)
A rectangle, with the origin at the upper left (floating point).
The structure that defines a point (integer)
A rectangle, with the origin at the upper left (integer).
struct SDL_RenderCommand::@38::@42 color
struct SDL_RenderCommand * next
struct SDL_RenderCommand::@38::@39 viewport
struct SDL_RenderCommand::@38::@41 draw
SDL_RenderCommandType command
union SDL_RenderCommand::@38 data
struct SDL_RenderCommand::@38::@40 cliprect
int(* QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
int(* QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
void(* SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
void(* DestroyRenderer)(SDL_Renderer *renderer)
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
void(* RenderPresent)(SDL_Renderer *renderer)
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
int(* QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
int(* QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
int(* RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
int(* QueueCopyEx)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
int(* QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
A collection of pixels used in software blitting.
Window state change event data (event.window.*)
The type used to identify a window.
const SDL_Rect * viewport
const SDL_Rect * cliprect
SDL_bool surface_cliprect_dirty
static SDL_Renderer * renderer
typedef int(__stdcall *FARPROC)()