21 #include "../SDL_internal.h"
33 sizeof(
int) ==
sizeof(
Sint32) &&
sizeof(
size_t) >=
sizeof(
Sint32));
49 pitch = (pitch + 7) / 8;
52 pitch = (pitch + 1) / 2;
57 pitch = (pitch + 3) & ~3;
76 if (surface ==
NULL) {
112 if (surface->
w && surface->
h) {
181 if (surface !=
NULL) {
186 surface->
pitch = pitch;
204 if (surface !=
NULL) {
209 surface->
pitch = pitch;
219 return SDL_SetError(
"SDL_SetSurfacePalette() passed a NULL surface");
353 for (y = surface->
h; y--;) {
355 for (x = surface->
w; x--;) {
356 if ((*spot &
mask) == ckey) {
361 row += surface->
pitch / 2;
377 for (y = surface->
h; y--;) {
379 for (x = surface->
w; x--;) {
380 if ((*spot & mask) == ckey) {
385 row += surface->
pitch / 4;
411 if (r != 0xFF || g != 0xFF || b != 0xFF) {
526 switch (surface->
map->
557 full_rect.
w = surface->
w;
558 full_rect.
h = surface->
h;
571 if (surface && rect) {
592 if ((src->
map->
dst != dst) ||
606 return (src->
map->
blit(src, srcrect, dst, dstrect));
615 int srcx, srcy,
w,
h;
619 return SDL_SetError(
"SDL_UpperBlit: 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;
644 maxw = src->
w - srcx;
655 maxh = src->
h - srcy;
670 dx = clip->
x - dstrect->
x;
676 dx = dstrect->
x + w - clip->
x - clip->
w;
680 dy = clip->
y - dstrect->
y;
686 dy = dstrect->
y + h - clip->
y - clip->
h;
697 if (w > 0 && h > 0) {
701 sr.
w = dstrect->
w =
w;
702 sr.
h = dstrect->
h =
h;
705 dstrect->
w = dstrect->
h = 0;
713 double src_x0, src_y0, src_x1, src_y1;
714 double dst_x0, dst_y0, dst_x1, dst_y1;
716 double scaling_w, scaling_h;
722 return SDL_SetError(
"SDL_UpperBlitScaled: passed a NULL surface");
725 return SDL_SetError(
"Surfaces must not be locked during blit");
728 if (
NULL == srcrect) {
736 if (
NULL == dstrect) {
744 if (dst_w == src_w && dst_h == src_h) {
749 scaling_w = (double)dst_w / src_w;
750 scaling_h = (double)dst_h / src_h;
752 if (
NULL == dstrect) {
760 dst_x1 = dst_x0 + dst_w - 1;
761 dst_y1 = dst_y0 + dst_h - 1;
764 if (
NULL == srcrect) {
772 src_x1 = src_x0 + src_w - 1;
773 src_y1 = src_y0 + src_h - 1;
778 dst_x0 -= src_x0 * scaling_w;
782 if (src_x1 >= src->
w) {
783 dst_x1 -= (src_x1 - src->
w + 1) * scaling_w;
788 dst_y0 -= src_y0 * scaling_h;
792 if (src_y1 >= src->
h) {
793 dst_y1 -= (src_y1 - src->
h + 1) * scaling_h;
807 src_x0 -= dst_x0 / scaling_w;
812 src_x1 -= (dst_x1 - dst->
clip_rect.
w + 1) / scaling_w;
817 src_y0 -= dst_y0 / scaling_h;
822 src_y1 -= (dst_y1 - dst->
clip_rect.
h + 1) / scaling_h;
839 final_dst.
w = (int)
SDL_floor(dst_x1 - dst_x0 + 1.5);
840 final_dst.
h = (int)
SDL_floor(dst_y1 - dst_y0 + 1.5);
848 *dstrect = final_dst;
850 if (final_dst.
w == 0 || final_dst.
h == 0 ||
851 final_src.
w <= 0 || final_src.
h <= 0) {
867 static const Uint32 complex_copy_flags = (
976 if (convert ==
NULL) {
1004 bounds.
w = surface->
w;
1005 bounds.
h = surface->
h;
1034 }
else if (format->
Amask) {
1043 if (set_colorkey_by_color) {
1046 int converted_colorkey = 0;
1132 surface->
pitch = pitch;
1138 blitmap->
info.
r = 0xFF;
1139 blitmap->
info.
g = 0xFF;
1140 blitmap->
info.
b = 0xFF;
1141 blitmap->
info.
a = 0xFF;
1142 surface->
map = blitmap;
1153 Uint32 src_format,
const void *
src,
int src_pitch,
1154 Uint32 dst_format,
void *
dst,
int dst_pitch)
1160 void *nonconst_src = (
void *) src;
1179 if (src_format == dst_format) {
1183 for (i = height; i--;) {
1185 src = (
const Uint8*)src + src_pitch;
1186 dst = (
Uint8*)dst + dst_pitch;
1193 &src_surface, &src_fmt, &src_blitmap)) {
1197 &dst_surface, &dst_fmt, &dst_blitmap)) {
1206 return SDL_LowerBlit(&src_surface, &rect, &dst_surface, &rect);
1215 if (surface ==
NULL) {
1226 while (surface->
locked > 0) {