Go to the documentation of this file.
21 #include "../SDL_internal.h"
36 #if ((defined(_MSC_VER) && defined(_M_IX86)) || \
37 (defined(__WATCOMC__) && defined(__386__)) || \
38 (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES
44 #ifdef USE_ASM_STRETCH
47 #include <sys/types.h>
51 #define PAGE_ALIGNED __attribute__((__aligned__(4096)))
56 #if defined(_M_IX86) || defined(__i386__) || defined(__386__)
58 #define STORE_BYTE 0xAA
59 #define STORE_WORD 0xAB
60 #define LOAD_BYTE 0xAC
61 #define LOAD_WORD 0xAD
64 #error Need assembly opcodes for this architecture
67 static unsigned char copy_row[4096] PAGE_ALIGNED;
70 generate_rowbytes(
int src_w,
int dst_w,
int bpp)
82 unsigned char *eip, *fence;
83 unsigned char load, store;
86 if ((src_w == last.src_w) && (dst_w == last.dst_w) && (
bpp == last.bpp)) {
109 if (mprotect(copy_row,
sizeof(copy_row), PROT_READ | PROT_WRITE) < 0) {
110 return SDL_SetError(
"Couldn't make copy buffer writeable");
114 inc = (src_w << 16) / dst_w;
116 fence = copy_row +
sizeof(copy_row)-2;
117 for (
i = 0;
i < dst_w; ++
i) {
118 while (pos >= 0x10000L) {
141 if (mprotect(copy_row,
sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) {
142 return SDL_SetError(
"Couldn't make copy buffer executable");
151 #define DEFINE_COPY_ROW(name, type) \
152 static void name(type *src, int src_w, type *dst, int dst_w) \
159 inc = (src_w << 16) / dst_w; \
160 for ( i=dst_w; i>0; --i ) { \
161 while ( pos >= 0x10000L ) { \
181 Uint8 pixel[3] = { 0, 0, 0 };
184 inc = (src_w << 16) / dst_w;
185 for (
i = dst_w;
i > 0; --
i) {
186 while (pos >= 0x10000L) {
210 int src_row, dst_row;
215 #ifdef USE_ASM_STRETCH
221 const int bpp =
dst->format->BytesPerPixel;
223 if (
src->format->format !=
dst->format->format) {
224 return SDL_SetError(
"Only works with same format surfaces");
229 if ((srcrect->
x < 0) || (srcrect->
y < 0) ||
230 ((srcrect->
x + srcrect->
w) >
src->w) ||
231 ((srcrect->
y + srcrect->
h) >
src->h)) {
242 if ((dstrect->
x < 0) || (dstrect->
y < 0) ||
243 ((dstrect->
x + dstrect->
w) >
dst->w) ||
244 ((dstrect->
y + dstrect->
h) >
dst->h)) {
245 return SDL_SetError(
"Invalid destination blit rectangle");
259 return SDL_SetError(
"Unable to lock destination surface");
277 inc = (srcrect->
h << 16) / dstrect->
h;
278 src_row = srcrect->
y;
279 dst_row = dstrect->
y;
281 #ifdef USE_ASM_STRETCH
283 if ((
bpp == 3) || (generate_rowbytes(srcrect->
w, dstrect->
w,
bpp) < 0)) {
289 for (dst_maxrow = dst_row + dstrect->
h; dst_row < dst_maxrow; ++dst_row) {
290 dstp = (
Uint8 *)
dst->pixels + (dst_row *
dst->pitch)
291 + (dstrect->
x *
bpp);
292 while (pos >= 0x10000L) {
293 srcp = (
Uint8 *)
src->pixels + (src_row *
src->pitch)
294 + (srcrect->
x *
bpp);
298 #ifdef USE_ASM_STRETCH
301 __asm__ __volatile__(
"call *%4":
"=&D"(
u1),
"=&S"(
u2)
302 :
"0"(dstp),
"1"(srcp),
"r"(copy_row)
304 #elif defined(_MSC_VER) || defined(__WATCOMC__)
307 void *code = copy_row;
320 #error Need inline assembly for this compiler
326 copy_row1(srcp, srcrect->
w, dstp, dstrect->
w);
329 copy_row2((
Uint16 *) srcp, srcrect->
w,
336 copy_row4((
Uint32 *) srcp, srcrect->
w,
#define SDL_UnlockSurface
A collection of pixels used in software blitting.
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 *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
static void copy_row3(Uint8 *src, int src_w, Uint8 *dst, int dst_w)
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF mov
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).
#define DEFINE_COPY_ROW(name, type)
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
int 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.
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)