21 #include "../SDL_internal.h" 31 sizeof(
int) ==
sizeof(
Sint32) &&
sizeof(
size_t) >=
sizeof(
Sint32));
51 if (surface ==
NULL) {
71 surface->
pitch = (int)pitch;
96 if (surface->
w && surface->
h) {
165 if (surface !=
NULL) {
170 surface->
pitch = pitch;
188 if (surface !=
NULL) {
193 surface->
pitch = pitch;
203 return SDL_SetError(
"SDL_SetSurfacePalette() passed a NULL surface");
323 for (y = surface->
h; y--;) {
325 for (x = surface->
w; x--;) {
326 if ((*spot &
mask) == ckey) {
331 row += surface->
pitch / 2;
347 for (y = surface->
h; y--;) {
349 for (x = surface->
w; x--;) {
350 if ((*spot & mask) == ckey) {
355 row += surface->
pitch / 4;
381 if (r != 0xFF || g != 0xFF || b != 0xFF) {
496 switch (surface->
map->
527 full_rect.
w = surface->
w;
528 full_rect.
h = surface->
h;
541 if (surface && rect) {
562 if ((src->
map->
dst != dst) ||
576 return (src->
map->
blit(src, srcrect, dst, dstrect));
585 int srcx, srcy,
w,
h;
589 return SDL_SetError(
"SDL_UpperBlit: passed a NULL surface");
592 return SDL_SetError(
"Surfaces must not be locked during blit");
596 if (dstrect ==
NULL) {
597 fulldst.
x = fulldst.
y = 0;
614 maxw = src->
w - srcx;
625 maxh = src->
h - srcy;
640 dx = clip->
x - dstrect->
x;
646 dx = dstrect->
x + w - clip->
x - clip->
w;
650 dy = clip->
y - dstrect->
y;
656 dy = dstrect->
y + h - clip->
y - clip->
h;
667 if (w > 0 && h > 0) {
671 sr.
w = dstrect->
w =
w;
672 sr.
h = dstrect->
h =
h;
675 dstrect->
w = dstrect->
h = 0;
683 double src_x0, src_y0, src_x1, src_y1;
684 double dst_x0, dst_y0, dst_x1, dst_y1;
686 double scaling_w, scaling_h;
692 return SDL_SetError(
"SDL_UpperBlitScaled: passed a NULL surface");
695 return SDL_SetError(
"Surfaces must not be locked during blit");
698 if (
NULL == srcrect) {
706 if (
NULL == dstrect) {
714 if (dst_w == src_w && dst_h == src_h) {
719 scaling_w = (double)dst_w / src_w;
720 scaling_h = (double)dst_h / src_h;
722 if (
NULL == dstrect) {
730 dst_x1 = dst_x0 + dst_w - 1;
731 dst_y1 = dst_y0 + dst_h - 1;
734 if (
NULL == srcrect) {
742 src_x1 = src_x0 + src_w - 1;
743 src_y1 = src_y0 + src_h - 1;
748 dst_x0 -= src_x0 * scaling_w;
752 if (src_x1 >= src->
w) {
753 dst_x1 -= (src_x1 - src->
w + 1) * scaling_w;
758 dst_y0 -= src_y0 * scaling_h;
762 if (src_y1 >= src->
h) {
763 dst_y1 -= (src_y1 - src->
h + 1) * scaling_h;
777 src_x0 -= dst_x0 / scaling_w;
782 src_x1 -= (dst_x1 - dst->
clip_rect.
w + 1) / scaling_w;
787 src_y0 -= dst_y0 / scaling_h;
792 src_y1 -= (dst_y1 - dst->
clip_rect.
h + 1) / scaling_h;
804 final_src.
w = (int)
SDL_floor(src_x1 - src_x0 + 1.5);
805 final_src.
h = (int)
SDL_floor(src_y1 - src_y0 + 1.5);
809 final_dst.
w = (int)
SDL_floor(dst_x1 - dst_x0 + 1.5);
810 final_dst.
h = (int)
SDL_floor(dst_y1 - dst_y0 + 1.5);
818 *dstrect = final_dst;
820 if (final_dst.
w == 0 || final_dst.
h == 0 ||
821 final_src.
w <= 0 || final_src.
h <= 0) {
837 static const Uint32 complex_copy_flags = (
928 if (convert ==
NULL) {
956 bounds.
w = surface->
w;
957 bounds.
h = surface->
h;
986 }
else if (format->
Amask) {
995 if (set_colorkey_by_color) {
997 Uint8 keyR, keyG, keyB, keyA;
1000 &keyG, &keyB, &keyA);
1060 surface->
pitch = pitch;
1066 blitmap->
info.
r = 0xFF;
1067 blitmap->
info.
g = 0xFF;
1068 blitmap->
info.
b = 0xFF;
1069 blitmap->
info.
a = 0xFF;
1070 surface->
map = blitmap;
1081 Uint32 src_format,
const void *
src,
int src_pitch,
1082 Uint32 dst_format,
void *
dst,
int dst_pitch)
1088 void *nonconst_src = (
void *) src;
1099 if (src_format == dst_format) {
1103 switch (src_format) {
1123 for (i = height; i--;) {
1125 src = (
Uint8*)src + src_pitch;
1126 dst = (
Uint8*)dst + dst_pitch;
1135 for (i = height * 2; i--;) {
1137 src = (
Uint8*)src + src_pitch;
1138 dst = (
Uint8*)dst + dst_pitch;
1143 for (i = height; i--;) {
1145 src = (
Uint8*)src + src_pitch;
1146 dst = (
Uint8*)dst + dst_pitch;
1154 &src_surface, &src_fmt, &src_blitmap)) {
1158 &dst_surface, &dst_fmt, &dst_blitmap)) {
1167 return SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
1176 if (surface ==
NULL) {
1185 while (surface->
locked > 0) {
int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
#define SDL_COPY_MODULATE_COLOR
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
void SDL_UnlockSurface(SDL_Surface *surface)
SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
GLdouble GLdouble GLdouble r
#define SDL_COPY_COLORKEY
GLint GLint GLsizei width
int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
#define SDL_ISPIXELFORMAT_INDEXED(format)
GLint GLint GLint GLint GLint x
int SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format, Uint32 flags)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Sint64 SDL_CalculatePitch(SDL_Surface *surface)
#define SDL_MasksToPixelFormatEnum
SDL_Surface * SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format, Uint32 flags)
static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void *pixels, int pitch, SDL_Surface *surface, SDL_PixelFormat *format, SDL_BlitMap *blitmap)
int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
A collection of pixels used in software blitting.
int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
int SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface)
#define SDL_BYTESPERPIXEL(X)
Uint32 dst_palette_version
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
#define SDL_COPY_RLE_COLORKEY
#define SDL_MAX_SINT32
A signed 32-bit integer type.
uint32_t Uint32
An unsigned 32-bit integer type.
#define SDL_InvalidParamError(param)
GLint GLint GLsizei GLsizei height
#define SDL_IntersectRect
int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
GLfloat GLfloat GLfloat alpha
void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
Uint32 src_palette_version
#define SDL_COPY_RLE_DESIRED
static SDL_BlendMode blendMode
void SDL_InvalidateMap(SDL_BlitMap *map)
#define SDL_ALPHA_TRANSPARENT
SDL_Surface * SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
void * SDL_calloc(size_t nmemb, size_t size)
GLint GLint GLint GLint GLint GLint y
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int)==sizeof(Sint32) &&sizeof(size_t) >=sizeof(Sint32))
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
uint8_t Uint8
An unsigned 8-bit integer type.
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.
int SDL_ConvertPixels(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
Copy a block of pixels of one format to another format.
SDL_Surface * SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
void SDL_FreeSurface(SDL_Surface *surface)
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 SDL_RLESurface(SDL_Surface *surface)
#define SDL_OutOfMemory()
GLint GLint GLsizei GLsizei GLsizei depth
SDL_Surface * SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_COPY_MODULATE_ALPHA
#define SDL_COPY_RLE_ALPHAKEY
int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_BlitMap * SDL_AllocBlitMap(void)
uint16_t Uint16
An unsigned 16-bit integer type.
GLubyte GLubyte GLubyte GLubyte w
#define SDL_ISPIXELFORMAT_FOURCC(format)
SDL_Surface * SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
int64_t Sint64
A signed 64-bit integer type.
GLboolean GLboolean GLboolean b
void SDL_FreeBlitMap(SDL_BlitMap *map)
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
#define SDL_SetPixelFormatPalette
#define SDL_Unsupported()
GLfloat GLfloat GLfloat GLfloat h
A rectangle, with the origin at the upper left.