21 #include "../../SDL_internal.h" 23 #if !SDL_RENDER_DISABLED 25 #include "../SDL_sysrender.h" 173 renderer->
info = SW_RenderDriver.
info;
218 SDL_SetError(
"Software renderer doesn't have an output surface");
227 Uint32 Rmask, Gmask, Bmask, Amask;
230 (texture->
format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
262 if ((texture->
r & texture->
g & texture->
b) != 255) {
306 src = (
Uint8 *) pixels;
308 rect->
y * surface->
pitch +
330 *pitch = surface->
pitch;
399 renderer->
r, renderer->
g, renderer->
b, renderer->
a);
429 for (i = 0; i <
count; ++
i) {
430 final_points[
i].
x = (int)(x + points[i].x);
431 final_points[
i].
y = (int)(y + points[i].y);
434 for (i = 0; i <
count; ++
i) {
435 final_points[
i].
x = (int)points[i].
x;
436 final_points[
i].
y = (int)points[i].
y;
443 renderer->
r, renderer->
g, renderer->
b,
450 renderer->
r, renderer->
g, renderer->
b,
478 for (i = 0; i <
count; ++
i) {
479 final_points[
i].
x = (int)(x + points[i].x);
480 final_points[
i].
y = (int)(y + points[i].y);
483 for (i = 0; i <
count; ++
i) {
484 final_points[
i].
x = (int)points[i].
x;
485 final_points[
i].
y = (int)points[i].
y;
492 renderer->
r, renderer->
g, renderer->
b,
499 renderer->
r, renderer->
g, renderer->
b,
526 for (i = 0; i <
count; ++
i) {
527 final_rects[
i].
x = (int)(x + rects[i].x);
528 final_rects[
i].
y = (int)(y + rects[i].y);
529 final_rects[
i].
w =
SDL_max((
int)rects[i].
w, 1);
530 final_rects[
i].
h =
SDL_max((
int)rects[i].
h, 1);
533 for (i = 0; i <
count; ++
i) {
534 final_rects[
i].
x = (int)rects[i].
x;
535 final_rects[
i].
y = (int)rects[i].
y;
536 final_rects[
i].
w =
SDL_max((
int)rects[i].
w, 1);
537 final_rects[
i].
h =
SDL_max((
int)rects[i].
h, 1);
543 renderer->
r, renderer->
g, renderer->
b,
549 renderer->
r, renderer->
g, renderer->
b,
570 final_rect.x = (int)(renderer->
viewport.
x + dstrect->
x);
571 final_rect.y = (int)(renderer->
viewport.
y + dstrect->
y);
573 final_rect.x = (int)dstrect->
x;
574 final_rect.y = (
int)dstrect->
y;
576 final_rect.w = (int)dstrect->
w;
577 final_rect.h = (
int)dstrect->
h;
579 if ( srcrect->
w == final_rect.w && srcrect->
h == final_rect.h ) {
600 int retval = 0, dstwidth, dstheight, abscenterx, abscentery;
601 double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
603 Uint8 alphaMod, rMod, gMod, bMod;
613 final_rect.
x = (int)(renderer->
viewport.
x + dstrect->
x);
614 final_rect.
y = (int)(renderer->
viewport.
y + dstrect->
y);
616 final_rect.
x = (int)dstrect->
x;
617 final_rect.
y = (
int)dstrect->
y;
619 final_rect.
w = (int)dstrect->
w;
620 final_rect.
h = (
int)dstrect->
h;
622 tmp_rect = final_rect;
639 if (src_clone ==
NULL) {
656 if (!(srcrect->
w == final_rect.
w && srcrect->
h == final_rect.
h && srcrect->
x == 0 && srcrect->
y == 0)) {
661 if (!(srcrect->
w == src->
w && srcrect->
h == src->
h && srcrect->
x == 0 && srcrect->
y == 0)) {
682 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
693 if (!
retval && (blitRequired || applyModulation)) {
696 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
697 if (src_scaled ==
NULL) {
703 src_clone = src_scaled;
713 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);
714 if (src_rotated ==
NULL) {
719 mask_rotated =
SDLgfx_rotateSurface(
mask, angle, dstwidth/2, dstheight/2,
SDL_FALSE, 0, 0, dstwidth, dstheight, cangle, sangle);
720 if (mask_rotated ==
NULL) {
726 abscenterx = final_rect.
x + (int)center->
x;
727 abscentery = final_rect.
y + (
int)center->
y;
732 px = final_rect.
x - abscenterx;
733 py = final_rect.
y - abscentery;
734 p1x = px * cangle - py * sangle + abscenterx;
735 p1y = px * sangle + py * cangle + abscentery;
738 px = final_rect.
x + final_rect.
w - abscenterx;
739 py = final_rect.
y - abscentery;
740 p2x = px * cangle - py * sangle + abscenterx;
741 p2y = px * sangle + py * cangle + abscentery;
744 px = final_rect.
x - abscenterx;
745 py = final_rect.
y + final_rect.
h - abscentery;
746 p3x = px * cangle - py * sangle + abscenterx;
747 p3y = px * sangle + py * cangle + abscentery;
750 px = final_rect.
x + final_rect.
w - abscenterx;
751 py = final_rect.
y + final_rect.
h - abscentery;
752 p4x = px * cangle - py * sangle + abscenterx;
753 p4y = px * sangle + py * cangle + abscentery;
755 tmp_rect.x = (int)
MIN(
MIN(p1x, p2x),
MIN(p3x, p4x));
756 tmp_rect.y = (int)
MIN(
MIN(p1y, p2y),
MIN(p3y, p4y));
757 tmp_rect.w = dstwidth;
758 tmp_rect.h = dstheight;
785 mask_rect = tmp_rect;
795 src_rotated->format->BitsPerPixel, src_rotated->pitch,
796 src_rotated->format->Rmask, src_rotated->format->Gmask,
797 src_rotated->format->Bmask, 0);
798 if (src_rotated_rgb ==
NULL) {
809 if (src_rotated !=
NULL) {
821 if (src_clone !=
NULL) {
843 if (rect->
x < 0 || rect->
x+rect->
w > surface->
w ||
844 rect->
y < 0 || rect->
y+rect->
h > surface->
h) {
845 return SDL_SetError(
"Tried to read outside of surface bounds");
850 rect->
y * surface->
pitch +
854 src_format, src_pixels, surface->
pitch,
855 format, pixels, pitch);
static int SW_SetTextureAlphaMod(SDL_Renderer *renderer, SDL_Texture *texture)
int(* RenderDrawLines)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
int(* RenderDrawPoints)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
#define SDL_UnlockSurface
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
static int SW_RenderDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
#define SDL_PIXELLAYOUT(X)
GLint GLint GLint GLint GLint x
static int SW_UpdateViewport(SDL_Renderer *renderer)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
GLuint GLuint GLsizei count
GLfloat GLfloat GLfloat GLfloat h
The structure that defines a point.
A collection of pixels used in software blitting.
static int SW_SetTextureColorMod(SDL_Renderer *renderer, SDL_Texture *texture)
static int SW_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
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 local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
static int SW_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
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
#define SDL_IntersectRect
static int SW_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
static int SW_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
#define SDL_CreateRGBSurfaceFrom
int(* RenderClear)(SDL_Renderer *renderer)
void(* DestroyRenderer)(SDL_Renderer *renderer)
GLfixed GLfixed GLint GLint GLfixed points
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
int(* SetTextureBlendMode)(SDL_Renderer *renderer, SDL_Texture *texture)
#define SDL_GetSurfaceBlendMode
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
#define SDL_UpdateWindowSurface
int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
static int SW_SetTextureBlendMode(SDL_Renderer *renderer, SDL_Texture *texture)
int(* SetTextureColorMod)(SDL_Renderer *renderer, SDL_Texture *texture)
GLenum GLenum GLuint texture
SDL_RenderDriver SW_RenderDriver
static void SW_RenderPresent(SDL_Renderer *renderer)
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static SDL_Renderer * renderer
#define SDL_SetSurfaceColorMod
#define SDL_stack_alloc(type, count)
static SDL_Surface * SW_ActivateRenderer(SDL_Renderer *renderer)
static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
GLubyte GLubyte GLubyte GLubyte w
static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
static void SW_DestroyRenderer(SDL_Renderer *renderer)
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
#define SDL_GetWindowSurface
GLint GLint GLint GLint GLint GLint y
int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
#define SDL_PixelFormatEnumToMasks
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* UpdateViewport)(SDL_Renderer *renderer)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
static int SW_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
#define SDL_GetSurfaceAlphaMod
static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
#define SDL_SetSurfaceRLE
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)
int(* RenderCopy)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Window state change event data (event.window.*)
#define SDL_OutOfMemory()
static int SW_RenderClear(SDL_Renderer *renderer)
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, Uint32 color)
int(* RenderCopyEx)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
#define SDL_CreateRGBSurface
#define SDL_GetSurfaceColorMod
EGLSurface EGLNativeWindowType * window
int(* SetTextureAlphaMod)(SDL_Renderer *renderer, SDL_Texture *texture)
#define SDL_SetSurfaceBlendMode
The type used to identify a window.
static void SW_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
static SDL_Renderer * SW_CreateRenderer(SDL_Window *window, Uint32 flags)
static int SW_UpdateClipRect(SDL_Renderer *renderer)
#define SDL_ConvertPixels
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
void(* RenderPresent)(SDL_Renderer *renderer)
EGLSurface EGLint * rects
#define SDL_stack_free(data)
GLuint GLsizei GLsizei * length
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)
int(* UpdateClipRect)(SDL_Renderer *renderer)
int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle)
#define SDL_SetSurfaceAlphaMod
SDL_bool clipping_enabled
A rectangle, with the origin at the upper left.