54 if (surface ==
NULL) {
90 if (surface->
w && surface->
h) {
131 if (surface !=
NULL) {
136 surface->
pitch = pitch;
146 return SDL_SetError(
"SDL_SetSurfacePalette() passed a NULL surface");
261 for (y = surface->
h; y--;) {
263 for (x = surface->
w; x--;) {
264 if ((*spot &
mask) == ckey) {
269 row += surface->
pitch / 2;
285 for (y = surface->
h; y--;) {
287 for (x = surface->
w; x--;) {
288 if ((*spot & mask) == ckey) {
293 row += surface->
pitch / 4;
319 if (r != 0xFF || g != 0xFF || b != 0xFF) {
434 switch (surface->
map->
465 full_rect.
w = surface->
w;
466 full_rect.
h = surface->
h;
479 if (surface && rect) {
500 if ((src->
map->
dst != dst) ||
514 return (src->
map->
blit(src, srcrect, dst, dstrect));
523 int srcx, srcy,
w,
h;
527 return SDL_SetError(
"SDL_UpperBlit: passed a NULL surface");
530 return SDL_SetError(
"Surfaces must not be locked during blit");
534 if (dstrect ==
NULL) {
535 fulldst.
x = fulldst.
y = 0;
552 maxw = src->
w - srcx;
563 maxh = src->
h - srcy;
578 dx = clip->
x - dstrect->
x;
584 dx = dstrect->
x + w - clip->
x - clip->
w;
588 dy = clip->
y - dstrect->
y;
594 dy = dstrect->
y + h - clip->
y - clip->
h;
599 if (w > 0 && h > 0) {
603 sr.
w = dstrect->
w =
w;
604 sr.
h = dstrect->
h =
h;
607 dstrect->
w = dstrect->
h = 0;
615 SDL_Rect final_src, final_dst, fulldst;
619 return SDL_SetError(
"SDL_UpperBlitScaled: passed a NULL surface");
622 return SDL_SetError(
"Surfaces must not be locked during blit");
626 if (dstrect ==
NULL) {
627 fulldst.
x = fulldst.
y = 0;
637 final_src.
x = srcrect->
x;
638 final_src.
w = srcrect->
w;
639 if (final_src.
x < 0) {
640 final_src.
w += final_src.
x;
643 maxw = src->
w - final_src.
x;
644 if (maxw < final_src.
w)
647 final_src.
y = srcrect->
y;
648 final_src.
h = srcrect->
h;
649 if (final_src.
y < 0) {
650 final_src.
h += final_src.
y;
653 maxh = src->
h - final_src.
y;
654 if (maxh < final_src.
h)
658 final_src.
x = final_src.
y = 0;
659 final_src.
w = src->
w;
660 final_src.
h = src->
h;
667 final_dst.
x = dstrect->
x;
668 final_dst.
w = dstrect->
w;
669 if (final_dst.
x < 0) {
670 final_dst.
w += final_dst.
x;
673 maxw = dst->
w - final_dst.
x;
674 if (maxw < final_dst.
w)
677 final_dst.
y = dstrect->
y;
678 final_dst.
h = dstrect->
h;
679 if (final_dst.
y < 0) {
680 final_dst.
h += final_dst.
y;
683 maxh = dst->
h - final_dst.
y;
684 if (maxh < final_dst.
h)
687 final_dst.
x = final_dst.
y = 0;
688 final_dst.
w = dst->
w;
689 final_dst.
h = dst->
h;
692 if (final_dst.
w > 0 && final_dst.
h > 0) {
707 static const Uint32 complex_copy_flags = (
714 int dstW = dstrect->
w;
715 int dstH = dstrect->
h;
723 full_rect.
w = dst->
w;
724 full_rect.
h = dst->
h;
730 if ( dstW != final_dst.
w ) {
736 if ( dstH != final_dst.
h ) {
744 full_rect.
w = src->
w;
745 full_rect.
h = src->
h;
832 if (convert ==
NULL) {
860 bounds.
w = surface->
w;
861 bounds.
h = surface->
h;
890 }
else if (format->
Amask) {
899 if (set_colorkey_by_color) {
901 Uint8 keyR, keyG, keyB, keyA;
904 &keyG, &keyB, &keyA);
964 surface->
pitch = pitch;
970 blitmap->
info.
r = 0xFF;
971 blitmap->
info.
g = 0xFF;
972 blitmap->
info.
b = 0xFF;
973 blitmap->
info.
a = 0xFF;
974 surface->
map = blitmap;
985 Uint32 src_format,
const void *
src,
int src_pitch,
986 Uint32 dst_format,
void *
dst,
int dst_pitch)
992 void *nonconst_src = (
void *) src;
1003 if (src_format == dst_format) {
1007 switch (src_format) {
1023 while (height-- > 0) {
1025 src = (
Uint8*)src + src_pitch;
1026 dst = (
Uint8*)dst + dst_pitch;
1033 &src_surface, &src_fmt, &src_blitmap)) {
1037 &dst_surface, &dst_fmt, &dst_blitmap)) {
1046 return SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
1055 if (surface ==
NULL) {
1064 while (surface->
locked > 0) {
#define SDL_COPY_MODULATE_COLOR
DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in blit operations.
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in blit operations.
GLfloat GLfloat GLfloat GLfloat h
#define SDL_COPY_COLORKEY
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format)
Free an SDL_PixelFormat structure.
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
Set the palette for a pixel format structure.
DECLSPEC int SDLCALL 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.
#define SDL_ISPIXELFORMAT_INDEXED(format)
DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
A collection of pixels used in software blitting.
DECLSPEC void SDLCALL SDL_free(void *mem)
DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette *palette)
Free a palette created with SDL_AllocPalette().
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
EGLSurface EGLint EGLint EGLint EGLint height
static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface)
DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
Convert a bpp and RGBA masks to an enumerated pixel format.
#define SDL_BYTESPERPIXEL(X)
Uint32 dst_palette_version
DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len)
#define SDL_COPY_RLE_COLORKEY
#define SDL_InvalidParamError(param)
DECLSPEC int SDLCALL SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
Maps an RGBA quadruple to a pixel value for a given pixel format.
Uint32 src_palette_version
#define SDL_COPY_RLE_DESIRED
void SDL_InvalidateMap(SDL_BlitMap *map)
uint32_t Uint32
An unsigned 32-bit integer type.
DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface)
#define SDL_ALPHA_TRANSPARENT
GLenum GLenum GLvoid * row
DECLSPEC SDL_PixelFormat *SDLCALL SDL_AllocFormat(Uint32 pixel_format)
Create an SDL_PixelFormat structure from a pixel format enum.
DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
Calculate the intersection of two rectangles.
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
EGLSurface EGLint EGLint EGLint width
DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
GLint GLenum GLsizei GLsizei GLsizei depth
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *src, const SDL_PixelFormat *fmt, Uint32 flags)
GLclampf GLclampf GLclampf alpha
DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
DECLSPEC int SDLCALL SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *src, Uint32 pixel_format, Uint32 flags)
int SDL_RLESurface(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
EGLSurface EGLint EGLint y
#define SDL_OutOfMemory()
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
Get the RGBA components from a pixel of the specified format.
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors)
Create a palette structure with the specified number of color entries.
#define SDL_COPY_MODULATE_ALPHA
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_COPY_RLE_ALPHAKEY
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
SDL_BlitMap * SDL_AllocBlitMap(void)
DECLSPEC int SDLCALL SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble b
GLint GLint GLint GLint GLint w
uint16_t Uint16
An unsigned 16-bit integer type.
int SDL_CalculatePitch(SDL_Surface *surface)
DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
#define SDL_ISPIXELFORMAT_FOURCC(format)
void SDL_FreeBlitMap(SDL_BlitMap *map)
DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
#define SDL_Unsupported()
A rectangle, with the origin at the upper left.
static __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)
DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect)
Perform a fast, low quality, stretch blit between two surfaces of the same pixel format.
DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.