SDL  2.0
SDL_blit_slow.h File Reference
#include "../SDL_internal.h"
+ Include dependency graph for SDL_blit_slow.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void SDL_Blit_Slow (SDL_BlitInfo *info)
 

Function Documentation

void SDL_Blit_Slow ( SDL_BlitInfo info)

Definition at line 31 of file SDL_blit_slow.c.

References SDL_BlitInfo::a, SDL_PixelFormat::Amask, ASSEMBLE_RGB, ASSEMBLE_RGBA, SDL_BlitInfo::b, SDL_PixelFormat::Bshift, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, DISEMBLE_RGB, DISEMBLE_RGBA, SDL_BlitInfo::dst, SDL_BlitInfo::dst_fmt, SDL_BlitInfo::dst_h, SDL_BlitInfo::dst_pitch, SDL_BlitInfo::dst_w, blit_table::dstB, blit_table::dstbpp, blit_table::dstG, blit_table::dstR, SDL_BlitInfo::flags, SDL_BlitInfo::g, SDL_PixelFormat::Gshift, SDL_BlitInfo::r, SDL_PixelFormat::Rshift, SDL_COPY_ADD, SDL_COPY_BLEND, SDL_COPY_COLORKEY, SDL_COPY_MOD, SDL_COPY_MODULATE_ALPHA, SDL_COPY_MODULATE_COLOR, SDL_BlitInfo::src, SDL_BlitInfo::src_fmt, SDL_BlitInfo::src_h, SDL_BlitInfo::src_pitch, SDL_BlitInfo::src_w, blit_table::srcB, blit_table::srcG, and blit_table::srcR.

Referenced by SDL_CalculateBlit().

32 {
33  const int flags = info->flags;
34  const Uint32 modulateR = info->r;
35  const Uint32 modulateG = info->g;
36  const Uint32 modulateB = info->b;
37  const Uint32 modulateA = info->a;
38  Uint32 srcpixel;
39  Uint32 srcR, srcG, srcB, srcA;
40  Uint32 dstpixel;
41  Uint32 dstR, dstG, dstB, dstA;
42  int srcy, srcx;
43  int posy, posx;
44  int incy, incx;
45  SDL_PixelFormat *src_fmt = info->src_fmt;
46  SDL_PixelFormat *dst_fmt = info->dst_fmt;
47  int srcbpp = src_fmt->BytesPerPixel;
48  int dstbpp = dst_fmt->BytesPerPixel;
49 
50  srcy = 0;
51  posy = 0;
52  incy = (info->src_h << 16) / info->dst_h;
53  incx = (info->src_w << 16) / info->dst_w;
54 
55  while (info->dst_h--) {
56  Uint8 *src = 0;
57  Uint8 *dst = (Uint8 *) info->dst;
58  int n = info->dst_w;
59  srcx = -1;
60  posx = 0x10000L;
61  while (posy >= 0x10000L) {
62  ++srcy;
63  posy -= 0x10000L;
64  }
65  while (n--) {
66  if (posx >= 0x10000L) {
67  while (posx >= 0x10000L) {
68  ++srcx;
69  posx -= 0x10000L;
70  }
71  src =
72  (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
73  }
74  if (src_fmt->Amask) {
75  DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
76  srcB, srcA);
77  } else {
78  DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
79  srcB);
80  srcA = 0xFF;
81  }
82  if (flags & SDL_COPY_COLORKEY) {
83  /* srcpixel isn't set for 24 bpp */
84  if (srcbpp == 3) {
85  srcpixel = (srcR << src_fmt->Rshift) |
86  (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
87  }
88  if (srcpixel == info->colorkey) {
89  posx += incx;
90  dst += dstbpp;
91  continue;
92  }
93  }
94  if (dst_fmt->Amask) {
95  DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
96  dstB, dstA);
97  } else {
98  DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
99  dstB);
100  dstA = 0xFF;
101  }
102 
103  if (flags & SDL_COPY_MODULATE_COLOR) {
104  srcR = (srcR * modulateR) / 255;
105  srcG = (srcG * modulateG) / 255;
106  srcB = (srcB * modulateB) / 255;
107  }
108  if (flags & SDL_COPY_MODULATE_ALPHA) {
109  srcA = (srcA * modulateA) / 255;
110  }
111  if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
112  /* This goes away if we ever use premultiplied sw_64 */
113  if (srcA < 255) {
114  srcR = (srcR * srcA) / 255;
115  srcG = (srcG * srcA) / 255;
116  srcB = (srcB * srcA) / 255;
117  }
118  }
119  switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) {
120  case 0:
121  dstR = srcR;
122  dstG = srcG;
123  dstB = srcB;
124  dstA = srcA;
125  break;
126  case SDL_COPY_BLEND:
127  dstR = srcR + ((255 - srcA) * dstR) / 255;
128  dstG = srcG + ((255 - srcA) * dstG) / 255;
129  dstB = srcB + ((255 - srcA) * dstB) / 255;
130  break;
131  case SDL_COPY_ADD:
132  dstR = srcR + dstR;
133  if (dstR > 255)
134  dstR = 255;
135  dstG = srcG + dstG;
136  if (dstG > 255)
137  dstG = 255;
138  dstB = srcB + dstB;
139  if (dstB > 255)
140  dstB = 255;
141  break;
142  case SDL_COPY_MOD:
143  dstR = (srcR * dstR) / 255;
144  dstG = (srcG * dstG) / 255;
145  dstB = (srcB * dstB) / 255;
146  break;
147  }
148  if (dst_fmt->Amask) {
149  ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
150  } else {
151  ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
152  }
153  posx += incx;
154  dst += dstbpp;
155  }
156  posy += incy;
157  info->dst += info->dst_pitch;
158  }
159 }
GLenum GLenum dst
Uint8 r
Definition: SDL_blit.h:70
#define SDL_COPY_MODULATE_COLOR
Definition: SDL_blit.h:34
Uint32 srcG
Definition: SDL_blit_N.c:2460
Uint32 srcB
Definition: SDL_blit_N.c:2460
Uint8 b
Definition: SDL_blit.h:70
#define SDL_COPY_COLORKEY
Definition: SDL_blit.h:39
GLdouble n
uint32_t Uint32
An unsigned 32-bit integer type.
Definition: SDL_stdinc.h:155
Uint32 dstB
Definition: SDL_blit_N.c:2462
Uint32 dstR
Definition: SDL_blit_N.c:2462
Uint8 BytesPerPixel
Definition: SDL_pixels.h:304
Uint8 g
Definition: SDL_blit.h:70
#define SDL_COPY_MOD
Definition: SDL_blit.h:38
SDL_PixelFormat * src_fmt
Definition: SDL_blit.h:65
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)
Definition: SDL_blit.h:401
int dst_pitch
Definition: SDL_blit.h:63
#define SDL_COPY_ADD
Definition: SDL_blit.h:37
Uint32 colorkey
Definition: SDL_blit.h:69
Uint8 * dst
Definition: SDL_blit.h:61
Uint32 srcR
Definition: SDL_blit_N.c:2460
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a)
Definition: SDL_blit.h:352
Uint32 dstG
Definition: SDL_blit_N.c:2462
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b)
Definition: SDL_blit.h:260
Uint8 * src
Definition: SDL_blit.h:57
SDL_PixelFormat * dst_fmt
Definition: SDL_blit.h:66
int src_pitch
Definition: SDL_blit.h:59
#define SDL_COPY_MODULATE_ALPHA
Definition: SDL_blit.h:35
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b)
Definition: SDL_blit.h:176
GLbitfield flags
GLenum src
#define SDL_COPY_BLEND
Definition: SDL_blit.h:36
Uint8 a
Definition: SDL_blit.h:70