SDL  2.0
SDL_blit_copy.c File Reference
#include "../SDL_internal.h"
#include "SDL_video.h"
#include "SDL_blit.h"
#include "SDL_blit_copy.h"
+ Include dependency graph for SDL_blit_copy.c:

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.

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().

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 }
GLenum GLenum dst
Uint8 BytesPerPixel
Definition: SDL_pixels.h:320
GLfloat GLfloat GLfloat GLfloat h
int dst_pitch
Definition: SDL_blit.h:63
GLenum src
Uint8 * dst
Definition: SDL_blit.h:61
#define SDL_memcpy
uint8_t Uint8
Definition: SDL_stdinc.h:157
GLubyte GLubyte GLubyte GLubyte w
unsigned int uintptr_t
#define SDL_memmove
#define SDL_HasMMX
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
int src_pitch
Definition: SDL_blit.h:59
SDL_bool
Definition: SDL_stdinc.h:139
#define SDL_HasSSE