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)) {
259 if ((texture->
r & texture->
g & texture->
b) != 255) {
303 src = (
Uint8 *) pixels;
305 rect->
y * surface->
pitch +
327 *pitch = surface->
pitch;
391 renderer->
r, renderer->
g, renderer->
b, renderer->
a);
421 for (i = 0; i <
count; ++
i) {
422 final_points[
i].
x = (int)(x + points[i].x);
423 final_points[
i].
y = (int)(y + points[i].y);
426 for (i = 0; i <
count; ++
i) {
427 final_points[
i].
x = (int)points[i].
x;
428 final_points[
i].
y = (int)points[i].
y;
435 renderer->
r, renderer->
g, renderer->
b,
442 renderer->
r, renderer->
g, renderer->
b,
470 for (i = 0; i <
count; ++
i) {
471 final_points[
i].
x = (int)(x + points[i].x);
472 final_points[
i].
y = (int)(y + points[i].y);
475 for (i = 0; i <
count; ++
i) {
476 final_points[
i].
x = (int)points[i].
x;
477 final_points[
i].
y = (int)points[i].
y;
484 renderer->
r, renderer->
g, renderer->
b,
491 renderer->
r, renderer->
g, renderer->
b,
518 for (i = 0; i <
count; ++
i) {
519 final_rects[
i].
x = (int)(x + rects[i].x);
520 final_rects[
i].
y = (int)(y + rects[i].y);
521 final_rects[
i].
w =
SDL_max((
int)rects[i].
w, 1);
522 final_rects[
i].
h =
SDL_max((
int)rects[i].
h, 1);
525 for (i = 0; i <
count; ++
i) {
526 final_rects[
i].
x = (int)rects[i].
x;
527 final_rects[
i].
y = (int)rects[i].
y;
528 final_rects[
i].
w =
SDL_max((
int)rects[i].
w, 1);
529 final_rects[
i].
h =
SDL_max((
int)rects[i].
h, 1);
535 renderer->
r, renderer->
g, renderer->
b,
541 renderer->
r, renderer->
g, renderer->
b,
562 final_rect.
x = (int)(renderer->
viewport.
x + dstrect->
x);
563 final_rect.y = (int)(renderer->
viewport.
y + dstrect->
y);
565 final_rect.x = (int)dstrect->
x;
566 final_rect.y = (
int)dstrect->
y;
568 final_rect.w = (int)dstrect->
w;
569 final_rect.h = (
int)dstrect->
h;
571 if ( srcrect->
w == final_rect.w && srcrect->
h == final_rect.h ) {
587 if (!hint || *hint ==
'0' ||
SDL_strcasecmp(hint,
"nearest") == 0) {
603 int retval, dstwidth, dstheight, abscenterx, abscentery;
604 double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
611 final_rect.
x = (int)(renderer->
viewport.
x + dstrect->
x);
612 final_rect.
y = (int)(renderer->
viewport.
y + dstrect->
y);
614 final_rect.
x = (int)dstrect->
x;
615 final_rect.
y = (
int)dstrect->
y;
617 final_rect.
w = (int)dstrect->
w;
618 final_rect.
h = (
int)dstrect->
h;
621 tmp_rect = final_rect;
624 if (srcrect->
w == final_rect.
w && srcrect->
h == final_rect.
h && srcrect->
x == 0 && srcrect->
y == 0) {
625 surface_scaled =
src;
637 if (!surface_scaled) {
673 retval =
SDL_BlitScaled(blit_src, srcrect, surface_scaled, &tmp_rect);
674 if (blit_src != src) {
681 surface_rotated =
SDLgfx_rotateSurface(surface_scaled, angle, dstwidth/2, dstheight/2,
GetScaleQuality(), flip &
SDL_FLIP_HORIZONTAL, flip &
SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
682 if(surface_rotated) {
684 abscenterx = final_rect.
x + (int)center->
x;
685 abscentery = final_rect.
y + (
int)center->
y;
690 px = final_rect.
x - abscenterx;
691 py = final_rect.
y - abscentery;
692 p1x = px * cangle - py * sangle + abscenterx;
693 p1y = px * sangle + py * cangle + abscentery;
696 px = final_rect.
x + final_rect.
w - abscenterx;
697 py = final_rect.
y - abscentery;
698 p2x = px * cangle - py * sangle + abscenterx;
699 p2y = px * sangle + py * cangle + abscentery;
702 px = final_rect.
x - abscenterx;
703 py = final_rect.
y + final_rect.
h - abscentery;
704 p3x = px * cangle - py * sangle + abscenterx;
705 p3y = px * sangle + py * cangle + abscentery;
708 px = final_rect.
x + final_rect.
w - abscenterx;
709 py = final_rect.
y + final_rect.
h - abscentery;
710 p4x = px * cangle - py * sangle + abscenterx;
711 p4y = px * sangle + py * cangle + abscentery;
713 tmp_rect.x = (int)
MIN(
MIN(p1x, p2x),
MIN(p3x, p4x));
714 tmp_rect.y = (int)
MIN(
MIN(p1y, p2y),
MIN(p3y, p4y));
715 tmp_rect.w = dstwidth;
716 tmp_rect.h = dstheight;
723 if (surface_scaled != src) {
745 final_rect.
w = rect->
w;
746 final_rect.
h = rect->
h;
750 if (rect->
x < 0 || rect->
x+rect->
w > surface->
w ||
751 rect->
y < 0 || rect->
y+rect->
h > surface->
h) {
752 return SDL_SetError(
"Tried to read outside of surface bounds");
757 rect->
y * surface->
pitch +
761 src_format, src_pixels, surface->
pitch,
762 format, pixels, pitch);
static int SW_SetTextureAlphaMod(SDL_Renderer *renderer, SDL_Texture *texture)
int(* RenderDrawLines)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
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
GLdouble GLdouble GLdouble r
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)
static int SW_UpdateViewport(SDL_Renderer *renderer)
GLint GLint GLint GLint GLint x
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
#define SDL_ConvertSurface
GLuint GLuint GLsizei count
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
static SDL_Window * window
GLenum GLenum GLuint texture
The structure that defines a point.
A collection of pixels used in software blitting.
static int SW_SetTextureColorMod(SDL_Renderer *renderer, SDL_Texture *texture)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static int SW_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
static int SW_RenderDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
uint32_t Uint32
An unsigned 32-bit integer type.
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)
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)
static SDL_BlendMode blendMode
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)
SDL_RenderDriver SW_RenderDriver
void * SDL_calloc(size_t nmemb, size_t size)
static void SW_RenderPresent(SDL_Renderer *renderer)
GLint GLint GLint GLint GLint GLint y
static void SW_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
static int GetScaleQuality(void)
static SDL_Renderer * renderer
#define SDL_SetSurfaceColorMod
uint8_t Uint8
An unsigned 8-bit integer type.
#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)
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
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)
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
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)
SDL_Rect rects[MAX_RECTS]
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)
GLubyte GLubyte GLubyte GLubyte w
#define SDL_ConvertPixels
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
void(* RenderPresent)(SDL_Renderer *renderer)
#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)
GLboolean GLboolean GLboolean b
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
GLfloat GLfloat GLfloat GLfloat h
SDL_bool clipping_enabled
A rectangle, with the origin at the upper left.