21 #include "../SDL_internal.h"
33 sizeof(
int) ==
sizeof(
Sint32) &&
sizeof(
size_t) >=
sizeof(
Sint32));
50 pitch = (pitch + 3) & ~3;
221 return SDL_SetError(
"SDL_SetSurfacePalette() passed a NULL surface");
345 switch (
surface->format->BytesPerPixel) {
359 if ((*spot &
mask) == ckey) {
397 if ((*spot &
mask) == ckey) {
441 if (
r != 0xFF ||
g != 0xFF ||
b != 0xFF) {
598 surface->clip_rect = full_rect;
628 if ((
src->map->dst !=
dst) ||
629 (
dst->format->palette &&
630 src->map->dst_palette_version !=
dst->format->palette->version) ||
631 (
src->format->palette &&
632 src->map->src_palette_version !=
src->format->palette->version)) {
642 return (
src->map->blit(
src, srcrect,
dst, dstrect));
651 int srcx, srcy,
w,
h;
655 return SDL_SetError(
"SDL_UpperBlit: passed a NULL surface");
657 if (
src->locked ||
dst->locked) {
658 return SDL_SetError(
"Surfaces must not be locked during blit");
662 if (dstrect ==
NULL) {
663 fulldst.
x = fulldst.
y = 0;
680 maxw =
src->w - srcx;
691 maxh =
src->h - srcy;
706 dx = clip->
x - dstrect->
x;
712 dx = dstrect->
x +
w - clip->
x - clip->
w;
716 dy = clip->
y - dstrect->
y;
722 dy = dstrect->
y +
h - clip->
y - clip->
h;
733 if (
w > 0 &&
h > 0) {
737 sr.
w = dstrect->
w =
w;
738 sr.
h = dstrect->
h =
h;
741 dstrect->
w = dstrect->
h = 0;
749 double src_x0, src_y0, src_x1, src_y1;
750 double dst_x0, dst_y0, dst_x1, dst_y1;
752 double scaling_w, scaling_h;
758 return SDL_SetError(
"SDL_UpperBlitScaled: passed a NULL surface");
760 if (
src->locked ||
dst->locked) {
761 return SDL_SetError(
"Surfaces must not be locked during blit");
764 if (
NULL == srcrect) {
772 if (
NULL == dstrect) {
780 if (dst_w == src_w && dst_h == src_h) {
785 scaling_w = (double)dst_w / src_w;
786 scaling_h = (double)dst_h / src_h;
788 if (
NULL == dstrect) {
796 dst_x1 = dst_x0 + dst_w - 1;
797 dst_y1 = dst_y0 + dst_h - 1;
800 if (
NULL == srcrect) {
808 src_x1 = src_x0 + src_w - 1;
809 src_y1 = src_y0 + src_h - 1;
814 dst_x0 -= src_x0 * scaling_w;
818 if (src_x1 >=
src->w) {
819 dst_x1 -= (src_x1 -
src->w + 1) * scaling_w;
824 dst_y0 -= src_y0 * scaling_h;
828 if (src_y1 >=
src->h) {
829 dst_y1 -= (src_y1 -
src->h + 1) * scaling_h;
837 dst_x0 -=
dst->clip_rect.x;
838 dst_x1 -=
dst->clip_rect.x;
839 dst_y0 -=
dst->clip_rect.y;
840 dst_y1 -=
dst->clip_rect.y;
843 src_x0 -= dst_x0 / scaling_w;
847 if (dst_x1 >=
dst->clip_rect.w) {
848 src_x1 -= (dst_x1 -
dst->clip_rect.w + 1) / scaling_w;
849 dst_x1 =
dst->clip_rect.w - 1;
853 src_y0 -= dst_y0 / scaling_h;
857 if (dst_y1 >=
dst->clip_rect.h) {
858 src_y1 -= (dst_y1 -
dst->clip_rect.h + 1) / scaling_h;
859 dst_y1 =
dst->clip_rect.h - 1;
863 dst_x0 +=
dst->clip_rect.x;
864 dst_x1 +=
dst->clip_rect.x;
865 dst_y0 +=
dst->clip_rect.y;
866 dst_y1 +=
dst->clip_rect.y;
884 *dstrect = final_dst;
886 if (final_dst.
w == 0 || final_dst.
h == 0 ||
887 final_src.
w <= 0 || final_src.
h <= 0) {
903 static const Uint32 complex_copy_flags = (
914 if ( !(
src->map->info.flags & complex_copy_flags) &&
915 src->format->format ==
dst->format->format &&
988 int palette_ck_value = 0;
1004 for (
i = 0;
i <
format->palette->ncolors; ++
i) {
1005 if ((
format->palette->colors[
i].r != 0xFF) ||
1006 (
format->palette->colors[
i].g != 0xFF) ||
1007 (
format->palette->colors[
i].b != 0xFF))
1010 if (
i ==
format->palette->ncolors) {
1021 if (convert ==
NULL) {
1034 copy_flags =
surface->map->info.flags;
1035 copy_color.
r =
surface->map->info.r;
1036 copy_color.
g =
surface->map->info.g;
1037 copy_color.
b =
surface->map->info.b;
1038 copy_color.
a =
surface->map->info.a;
1058 SDL_bool is_opaque, has_alpha_channel;
1062 if (!has_alpha_channel) {
1073 for (
i = 0;
i <
surface->format->palette->ncolors;
i++) {
1074 palette_saved_alpha[
i] =
surface->format->palette->colors[
i].a;
1085 palette_ck_value =
surface->format->palette->colors[
surface->map->info.colorkey].a;
1093 if (palette_ck_transform) {
1094 surface->format->palette->colors[
surface->map->info.colorkey].a = palette_ck_value;
1098 if (palette_saved_alpha) {
1100 for (
i = 0;
i <
surface->format->palette->ncolors;
i++) {
1101 surface->format->palette->colors[
i].a = palette_saved_alpha[
i];
1116 surface->map->info.r = copy_color.
r;
1117 surface->map->info.g = copy_color.
g;
1118 surface->map->info.b = copy_color.
b;
1119 surface->map->info.a = copy_color.
a;
1120 surface->map->info.flags = copy_flags;
1133 if (
surface->format->palette) {
1135 surface->format->palette->ncolors <=
format->palette->ncolors &&
1140 }
else if (!
format->palette) {
1155 if (set_colorkey_by_color) {
1158 int converted_colorkey = 0;
1167 if (
surface->format->palette) {
1188 if (convert_colorkey) {
1198 (palette_has_alpha &&
format->Amask) ||
1253 blitmap->
info.
r = 0xFF;
1254 blitmap->
info.
g = 0xFF;
1255 blitmap->
info.
b = 0xFF;
1256 blitmap->
info.
a = 0xFF;
1268 Uint32 src_format,
const void *
src,
int src_pitch,
1269 Uint32 dst_format,
void *
dst,
int dst_pitch)
1275 void *nonconst_src = (
void *)
src;
1302 if (src_format == dst_format) {
1316 &src_surface, &src_fmt, &src_blitmap)) {
1320 &dst_surface, &dst_fmt, &dst_blitmap)) {
1353 if (--
surface->refcount > 0) {
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
int SDL_RLESurface(SDL_Surface *surface)
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
#define SDL_COPY_RLE_ALPHAKEY
#define SDL_COPY_RLE_DESIRED
#define SDL_COPY_MODULATE_COLOR
#define SDL_COPY_COLORKEY
#define SDL_COPY_MODULATE_ALPHA
#define SDL_COPY_RLE_COLORKEY
#define SDL_SetPixelFormatPalette
#define SDL_MasksToPixelFormatEnum
#define SDL_IntersectRect
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_OutOfMemory()
#define SDL_Unsupported()
#define SDL_InvalidParamError(param)
int uint32_t uint32_t uint32_t pixel_format
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
GLint GLint GLsizei width
GLint GLint GLsizei GLsizei GLsizei depth
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat alpha
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
void SDL_FreeBlitMap(SDL_BlitMap *map)
void SDL_InvalidateMap(SDL_BlitMap *map)
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
SDL_BlitMap * SDL_AllocBlitMap(void)
void SDL_InvalidateAllBlitMap(SDL_Surface *surface)
#define SDL_BYTESPERPIXEL(X)
#define SDL_BITSPERPIXEL(X)
#define SDL_ALPHA_TRANSPARENT
#define SDL_ISPIXELFORMAT_INDEXED(format)
@ SDL_PIXELFORMAT_UNKNOWN
#define SDL_ISPIXELFORMAT_FOURCC(format)
#define SDL_stack_alloc(type, count)
#define SDL_stack_free(data)
#define SDL_MAX_SINT32
A signed 32-bit integer type.
SDL_bool SDL_HasSurfaceRLE(SDL_Surface *surface)
Returns whether the surface is RLE enabled.
SDL_Surface * SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
static Sint64 SDL_CalculatePitch(Uint32 format, int width)
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
Get the blend mode used for blit operations.
int SDL_UpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alpha)
SDL_Surface * SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format, Uint32 flags)
int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
Set the palette used by a surface.
SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
SDL_bool SDL_HasColorKey(SDL_Surface *surface)
Returns whether the surface has a color key.
int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
Sets the RLE acceleration hint for a surface.
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, sizeof(int)==sizeof(Sint32) &&sizeof(size_t) >=sizeof(Sint32))
SDL_Surface * SDL_DuplicateSurface(SDL_Surface *surface)
int SDL_LockSurface(SDL_Surface *surface)
Sets up a surface for directly accessing the pixels.
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
Get the additional alpha value used in blit operations.
void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
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.
void SDL_UnlockSurface(SDL_Surface *surface)
int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
Sets the color key (transparent pixel) in a blittable surface.
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
Get the additional color value used in blit operations.
int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
Gets the color key (transparent pixel) in a blittable surface.
int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
Set an additional alpha value used in 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.
int SDL_LowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_Surface * SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
void SDL_FreeSurface(SDL_Surface *surface)
SDL_Surface * SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
Set the blend mode used for blit operations.
int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
SDL_Surface * SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
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_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
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
A rectangle, with the origin at the upper left (integer).
A collection of pixels used in software blitting.
static SDL_BlendMode blendMode
typedef int(__stdcall *FARPROC)()