annotate src/video/SDL_blit_slow.c @ 4970:b9eed029844a

Include the Android Makefile in the distribution files
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jan 2011 12:15:16 -0800
parents 791b3256fb22
children e743b9c3f6d6
rev   line source
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3588
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_video.h"
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_blit.h"
4472
791b3256fb22 Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
26 #include "SDL_blit_slow.h"
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* The ONE TRUE BLITTER
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 * This puppy has to handle all the unoptimized cases - yes, it's slow.
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 */
2824
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
31 void
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
32 SDL_Blit_Slow(SDL_BlitInfo * info)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
33 {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
34 const int flags = info->flags;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
35 const Uint32 modulateR = info->r;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
36 const Uint32 modulateG = info->g;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
37 const Uint32 modulateB = info->b;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
38 const Uint32 modulateA = info->a;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
39 Uint32 srcpixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
40 Uint32 srcR, srcG, srcB, srcA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
41 Uint32 dstpixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
42 Uint32 dstR, dstG, dstB, dstA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
43 int srcy, srcx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
44 int posy, posx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
45 int incy, incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
46 SDL_PixelFormat *src_fmt = info->src_fmt;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
47 SDL_PixelFormat *dst_fmt = info->dst_fmt;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
48 int srcbpp = src_fmt->BytesPerPixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
49 int dstbpp = dst_fmt->BytesPerPixel;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
50
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
51 srcy = 0;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
52 posy = 0;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
53 incy = (info->src_h << 16) / info->dst_h;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
54 incx = (info->src_w << 16) / info->dst_w;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
55
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
56 while (info->dst_h--) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
57 Uint8 *src;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
58 Uint8 *dst = (Uint8 *) info->dst;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
59 int n = info->dst_w;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
60 srcx = -1;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
61 posx = 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
62 while (posy >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
63 ++srcy;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
64 posy -= 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
65 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
66 while (n--) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
67 if (posx >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
68 while (posx >= 0x10000L) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
69 ++srcx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
70 posx -= 0x10000L;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
71 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
72 src =
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
73 (info->src + (srcy * info->src_pitch) + (srcx * srcbpp));
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
74 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
75 if (src_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
76 DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
77 srcB, srcA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
78 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
79 DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
80 srcB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
81 srcA = 0xFF;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
82 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
83 if (flags & SDL_COPY_COLORKEY) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
84 /* srcpixel isn't set for 24 bpp */
3588
c5fe76962106 Fixed bug #843
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
85 if (srcbpp == 3) {
2824
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
86 srcpixel = (srcR << src_fmt->Rshift) |
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
87 (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
88 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
89 if (srcpixel == info->colorkey) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
90 posx += incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
91 dst += dstbpp;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
92 continue;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
93 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
94 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
95 if (dst_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
96 DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
97 dstB, dstA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
98 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
99 DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG,
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
100 dstB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
101 dstA = 0xFF;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
102 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
103
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
104 if (flags & SDL_COPY_MODULATE_COLOR) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
105 srcR = (srcR * modulateR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
106 srcG = (srcG * modulateG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
107 srcB = (srcB * modulateB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
108 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
109 if (flags & SDL_COPY_MODULATE_ALPHA) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
110 srcA = (srcA * modulateA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
111 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
112 if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
113 /* This goes away if we ever use premultiplied alpha */
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
114 if (srcA < 255) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
115 srcR = (srcR * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
116 srcG = (srcG * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
117 srcB = (srcB * srcA) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
118 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
119 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
120 switch (flags &
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
121 (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
122 SDL_COPY_MOD)) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
123 case 0:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
124 dstR = srcR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
125 dstG = srcG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
126 dstB = srcB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
127 dstA = srcA;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
128 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
129 case SDL_COPY_MASK:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
130 if (srcA) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
131 dstR = srcR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
132 dstG = srcG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
133 dstB = srcB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
134 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
135 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
136 case SDL_COPY_BLEND:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
137 dstR = srcR + ((255 - srcA) * dstR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
138 dstG = srcG + ((255 - srcA) * dstG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
139 dstB = srcB + ((255 - srcA) * dstB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
140 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
141 case SDL_COPY_ADD:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
142 dstR = srcR + dstR;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
143 if (dstR > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
144 dstR = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
145 dstG = srcG + dstG;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
146 if (dstG > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
147 dstG = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
148 dstB = srcB + dstB;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
149 if (dstB > 255)
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
150 dstB = 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
151 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
152 case SDL_COPY_MOD:
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
153 dstR = (srcR * dstR) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
154 dstG = (srcG * dstG) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
155 dstB = (srcB * dstB) / 255;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
156 break;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
157 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
158 if (dst_fmt->Amask) {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
159 ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
160 } else {
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
161 ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB);
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
162 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
163 posx += incx;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
164 dst += dstbpp;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
165 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
166 posy += incy;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
167 info->dst += info->dst_pitch;
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
168 }
4dba7aa7ea77 Added slow but complete blit fallback
Sam Lantinga <slouken@libsdl.org>
parents: 2256
diff changeset
169 }
2256
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170
e893d24ad8db Getting ready to add slow blitters. Everyone will love me. :)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 /* vi: set ts=4 sw=4 expandtab: */