SDL 2.0
SDL_blit_copy.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void SDL_BlitCopy (SDL_BlitInfo *info)
 

Function Documentation

◆ SDL_BlitCopy()

void SDL_BlitCopy ( SDL_BlitInfo info)

Definition at line 91 of file SDL_blit_copy.c.

92{
93 SDL_bool overlap;
94 Uint8 *src, *dst;
95 int w, h;
96 int srcskip, dstskip;
97
98 w = info->dst_w * info->dst_fmt->BytesPerPixel;
99 h = info->dst_h;
100 src = info->src;
101 dst = info->dst;
102 srcskip = info->src_pitch;
103 dstskip = info->dst_pitch;
104
105 /* Properly handle overlapping blits */
106 if (src < dst) {
107 overlap = (dst < (src + h*srcskip));
108 } else {
109 overlap = (src < (dst + h*dstskip));
110 }
111 if (overlap) {
112 if ( dst < src ) {
113 while ( h-- ) {
114 SDL_memmove(dst, src, w);
115 src += srcskip;
116 dst += dstskip;
117 }
118 } else {
119 src += ((h-1) * srcskip);
120 dst += ((h-1) * dstskip);
121 while ( h-- ) {
122 SDL_memmove(dst, src, w);
123 src -= srcskip;
124 dst -= dstskip;
125 }
126 }
127 return;
128 }
129
130#ifdef __SSE__
131 if (SDL_HasSSE() &&
132 !((uintptr_t) src & 15) && !(srcskip & 15) &&
133 !((uintptr_t) dst & 15) && !(dstskip & 15)) {
134 while (h--) {
135 SDL_memcpySSE(dst, src, w);
136 src += srcskip;
137 dst += dstskip;
138 }
139 return;
140 }
141#endif
142
143#ifdef __MMX__
144 if (SDL_HasMMX() && !(srcskip & 7) && !(dstskip & 7)) {
145 while (h--) {
146 SDL_memcpyMMX(dst, src, w);
147 src += srcskip;
148 dst += dstskip;
149 }
150 _mm_empty();
151 return;
152 }
153#endif
154
155 while (h--) {
156 SDL_memcpy(dst, src, w);
157 src += srcskip;
158 dst += dstskip;
159 }
160}
unsigned int uintptr_t
#define SDL_HasMMX
#define SDL_HasSSE
#define SDL_memcpy
#define SDL_memmove
GLenum src
GLenum GLenum dst
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
SDL_bool
Definition: SDL_stdinc.h:162
uint8_t Uint8
Definition: SDL_stdinc.h:179
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
int src_pitch
Definition: SDL_blit.h:59
int dst_pitch
Definition: SDL_blit.h:63
Uint8 * src
Definition: SDL_blit.h:57
Uint8 * dst
Definition: SDL_blit.h:61
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320

References SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_pitch, SDL_BlitInfo::dst_w, SDL_HasMMX, SDL_HasSSE, SDL_memcpy, SDL_memmove, SDL_BlitInfo::src, and SDL_BlitInfo::src_pitch.

Referenced by SDL_CalculateBlit().