Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
8014 lines (7681 loc) · 287 KB

SDL_blit_auto.c

File metadata and controls

8014 lines (7681 loc) · 287 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* *INDENT-OFF* */
#include "SDL_video.h"
Aug 17, 2007
Aug 17, 2007
28
29
30
#include "SDL_blit.h"
#include "SDL_blit_auto.h"
Aug 17, 2007
Aug 17, 2007
31
static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
33
const int flags = info->flags;
34
35
36
37
38
39
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
40
41
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
43
while (info->dst_h--) {
44
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
45
46
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
47
48
49
50
51
52
53
54
55
56
57
58
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
59
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
60
61
62
63
64
65
}
*dst = *src;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
66
info->dst += info->dst_pitch;
67
68
69
}
}
Aug 17, 2007
Aug 17, 2007
70
static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
72
const int flags = info->flags;
73
74
75
76
77
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
Aug 17, 2007
Aug 17, 2007
78
79
80
81
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
82
83
84
85
86
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
87
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
88
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
89
90
91
92
93
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
95
96
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
97
98
99
100
101
102
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
103
case SDL_COPY_BLEND:
104
105
106
107
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
108
case SDL_COPY_ADD:
109
110
111
112
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
113
case SDL_COPY_MOD:
114
115
116
117
118
119
120
121
122
123
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
*dst = dstpixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
124
125
info->src += info->src_pitch;
info->dst += info->dst_pitch;
126
127
128
}
}
Aug 17, 2007
Aug 17, 2007
129
static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
131
const int flags = info->flags;
132
133
134
135
136
137
138
139
140
141
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
142
143
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
145
while (info->dst_h--) {
146
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
147
148
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
149
150
151
152
153
154
155
156
157
158
159
160
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
161
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
162
163
164
165
166
}
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
167
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
168
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
169
170
171
172
173
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
175
176
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
177
178
179
180
181
182
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
183
case SDL_COPY_BLEND:
184
185
186
187
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
188
case SDL_COPY_ADD:
189
190
191
192
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
193
case SDL_COPY_MOD:
194
195
196
197
198
199
200
201
202
203
204
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
*dst = dstpixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
205
info->dst += info->dst_pitch;
206
207
208
}
}
Aug 17, 2007
Aug 17, 2007
209
static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
211
212
213
214
215
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
216
217
218
Uint32 pixel;
Uint32 R, G, B, A;
Aug 17, 2007
Aug 17, 2007
219
220
221
222
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
223
224
225
while (n--) {
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
Aug 17, 2007
Aug 17, 2007
226
if (flags & SDL_COPY_MODULATE_COLOR) {
227
228
229
230
R = (R * modulateR) / 255;
G = (G * modulateG) / 255;
B = (B * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
231
if (flags & SDL_COPY_MODULATE_ALPHA) {
Aug 28, 2006
Aug 28, 2006
232
233
A = (A * modulateA) / 255;
}
234
235
236
237
238
pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
239
240
info->src += info->src_pitch;
info->dst += info->dst_pitch;
241
242
243
}
}
Aug 17, 2007
Aug 17, 2007
244
static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
246
247
248
249
250
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
251
252
253
254
255
256
257
258
Uint32 pixel;
Uint32 R, G, B, A;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
259
260
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
262
while (info->dst_h--) {
263
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
264
265
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
266
267
268
269
270
271
272
273
274
275
276
277
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
278
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
279
280
281
}
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
Aug 17, 2007
Aug 17, 2007
282
if (flags & SDL_COPY_MODULATE_COLOR) {
283
284
285
286
R = (R * modulateR) / 255;
G = (G * modulateG) / 255;
B = (B * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
287
if (flags & SDL_COPY_MODULATE_ALPHA) {
Aug 28, 2006
Aug 28, 2006
288
289
A = (A * modulateA) / 255;
}
290
291
292
293
294
295
pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
*dst = pixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
296
info->dst += info->dst_pitch;
297
298
299
}
}
Aug 17, 2007
Aug 17, 2007
300
static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
302
303
304
305
306
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
307
308
309
310
311
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
Aug 17, 2007
Aug 17, 2007
312
313
314
315
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
316
317
318
319
320
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
321
if (flags & SDL_COPY_MODULATE_COLOR) {
322
323
324
325
srcR = (srcR * modulateR) / 255;
srcG = (srcG * modulateG) / 255;
srcB = (srcB * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
326
if (flags & SDL_COPY_MODULATE_ALPHA) {
327
328
srcA = (srcA * modulateA) / 255;
}
Aug 17, 2007
Aug 17, 2007
329
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
330
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
331
332
333
334
335
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
337
338
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
339
340
341
342
343
344
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
345
case SDL_COPY_BLEND:
346
347
348
349
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
350
case SDL_COPY_ADD:
351
352
353
354
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
355
case SDL_COPY_MOD:
356
357
358
359
360
361
362
363
364
365
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
*dst = dstpixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
366
367
info->src += info->src_pitch;
info->dst += info->dst_pitch;
368
369
370
}
}
Aug 17, 2007
Aug 17, 2007
371
static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
373
374
375
376
377
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
378
379
380
381
382
383
384
385
386
387
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
388
389
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
391
while (info->dst_h--) {
392
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
393
394
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
395
396
397
398
399
400
401
402
403
404
405
406
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
407
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
408
409
410
411
412
}
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
413
if (flags & SDL_COPY_MODULATE_COLOR) {
414
415
416
417
srcR = (srcR * modulateR) / 255;
srcG = (srcG * modulateG) / 255;
srcB = (srcB * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
418
if (flags & SDL_COPY_MODULATE_ALPHA) {
419
420
srcA = (srcA * modulateA) / 255;
}
Aug 17, 2007
Aug 17, 2007
421
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
422
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
423
424
425
426
427
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
429
430
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
431
432
433
434
435
436
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
437
case SDL_COPY_BLEND:
438
439
440
441
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
442
case SDL_COPY_ADD:
443
444
445
446
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
447
case SDL_COPY_MOD:
448
449
450
451
452
453
454
455
456
457
458
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
*dst = dstpixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
459
info->dst += info->dst_pitch;
460
461
462
}
}
Aug 17, 2007
Aug 17, 2007
463
static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
465
const int flags = info->flags;
466
467
468
469
470
471
472
473
Uint32 pixel;
Uint32 R, G, B, A;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
474
475
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
477
while (info->dst_h--) {
478
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
479
480
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
481
482
483
484
485
486
487
488
489
490
491
492
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
493
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
494
495
496
497
498
499
500
501
502
}
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
*dst = pixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
503
info->dst += info->dst_pitch;
504
505
506
}
}
Aug 17, 2007
Aug 17, 2007
507
static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
509
const int flags = info->flags;
510
511
512
513
514
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
Aug 17, 2007
Aug 17, 2007
515
516
517
518
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
519
520
521
522
523
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
524
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
525
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
526
527
528
529
530
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
532
533
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
534
535
536
537
538
539
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
540
case SDL_COPY_BLEND:
541
542
543
544
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
545
case SDL_COPY_ADD:
546
547
548
549
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
550
case SDL_COPY_MOD:
551
552
553
554
555
556
557
558
559
560
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
*dst = dstpixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
561
562
info->src += info->src_pitch;
info->dst += info->dst_pitch;
563
564
565
}
}
Aug 17, 2007
Aug 17, 2007
566
static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
568
const int flags = info->flags;
569
570
571
572
573
574
575
576
577
578
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
579
580
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
582
while (info->dst_h--) {
583
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
584
585
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
586
587
588
589
590
591
592
593
594
595
596
597
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
598
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
599
600
601
602
603
}
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
604
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
605
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
606
607
608
609
610
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
612
613
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
614
615
616
617
618
619
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
620
case SDL_COPY_BLEND:
621
622
623
624
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
625
case SDL_COPY_ADD:
626
627
628
629
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
630
case SDL_COPY_MOD:
631
632
633
634
635
636
637
638
639
640
641
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
*dst = dstpixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
642
info->dst += info->dst_pitch;
643
644
645
}
}
Aug 17, 2007
Aug 17, 2007
646
static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
648
649
650
651
652
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
653
654
655
Uint32 pixel;
Uint32 R, G, B, A;
Aug 17, 2007
Aug 17, 2007
656
657
658
659
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
660
661
662
while (n--) {
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
Aug 17, 2007
Aug 17, 2007
663
if (flags & SDL_COPY_MODULATE_COLOR) {
664
665
666
667
R = (R * modulateR) / 255;
G = (G * modulateG) / 255;
B = (B * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
668
if (flags & SDL_COPY_MODULATE_ALPHA) {
Aug 28, 2006
Aug 28, 2006
669
670
A = (A * modulateA) / 255;
}
671
672
673
674
675
pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
*dst = pixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
676
677
info->src += info->src_pitch;
info->dst += info->dst_pitch;
678
679
680
}
}
Aug 17, 2007
Aug 17, 2007
681
static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
683
684
685
686
687
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
688
689
690
691
692
693
694
695
Uint32 pixel;
Uint32 R, G, B, A;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
696
697
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
699
while (info->dst_h--) {
700
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
701
702
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
703
704
705
706
707
708
709
710
711
712
713
714
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
715
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
716
717
718
}
pixel = *src;
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
Aug 17, 2007
Aug 17, 2007
719
if (flags & SDL_COPY_MODULATE_COLOR) {
720
721
722
723
R = (R * modulateR) / 255;
G = (G * modulateG) / 255;
B = (B * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
724
if (flags & SDL_COPY_MODULATE_ALPHA) {
Aug 28, 2006
Aug 28, 2006
725
726
A = (A * modulateA) / 255;
}
727
728
729
730
731
732
pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
*dst = pixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
733
info->dst += info->dst_pitch;
734
735
736
}
}
Aug 17, 2007
Aug 17, 2007
737
static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
739
740
741
742
743
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
744
745
746
747
748
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
Aug 17, 2007
Aug 17, 2007
749
750
751
752
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
753
754
755
756
757
while (n--) {
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
758
if (flags & SDL_COPY_MODULATE_COLOR) {
759
760
761
762
srcR = (srcR * modulateR) / 255;
srcG = (srcG * modulateG) / 255;
srcB = (srcB * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
763
if (flags & SDL_COPY_MODULATE_ALPHA) {
764
765
srcA = (srcA * modulateA) / 255;
}
Aug 17, 2007
Aug 17, 2007
766
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
767
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
768
769
770
771
772
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
774
775
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
776
777
778
779
780
781
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
782
case SDL_COPY_BLEND:
783
784
785
786
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
787
case SDL_COPY_ADD:
788
789
790
791
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
792
case SDL_COPY_MOD:
793
794
795
796
797
798
799
800
801
802
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
*dst = dstpixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
803
804
info->src += info->src_pitch;
info->dst += info->dst_pitch;
805
806
807
}
}
Aug 17, 2007
Aug 17, 2007
808
static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
810
811
812
813
814
const int flags = info->flags;
const Uint32 modulateR = info->r;
const Uint32 modulateG = info->g;
const Uint32 modulateB = info->b;
const Uint32 modulateA = info->a;
815
816
817
818
819
820
821
822
823
824
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
825
826
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
828
while (info->dst_h--) {
829
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
830
831
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
832
833
834
835
836
837
838
839
840
841
842
843
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
844
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
845
846
847
848
849
}
srcpixel = *src;
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
Aug 17, 2007
Aug 17, 2007
850
if (flags & SDL_COPY_MODULATE_COLOR) {
851
852
853
854
srcR = (srcR * modulateR) / 255;
srcG = (srcG * modulateG) / 255;
srcB = (srcB * modulateB) / 255;
}
Aug 17, 2007
Aug 17, 2007
855
if (flags & SDL_COPY_MODULATE_ALPHA) {
856
857
srcA = (srcA * modulateA) / 255;
}
Aug 17, 2007
Aug 17, 2007
858
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
859
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
860
861
862
863
864
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
866
867
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
868
869
870
871
872
873
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
874
case SDL_COPY_BLEND:
875
876
877
878
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
879
case SDL_COPY_ADD:
880
881
882
883
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
884
case SDL_COPY_MOD:
885
886
887
888
889
890
891
892
893
894
895
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
*dst = dstpixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
896
info->dst += info->dst_pitch;
897
898
899
}
}
Nov 29, 2008
Nov 29, 2008
900
static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
902
const int flags = info->flags;
903
904
905
906
907
908
909
910
Uint32 pixel;
Uint32 R, G, B, A;
int srcy, srcx;
int posy, posx;
int incy, incx;
srcy = 0;
posy = 0;
Aug 17, 2007
Aug 17, 2007
911
912
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
Aug 17, 2007
Aug 17, 2007
914
while (info->dst_h--) {
915
Uint32 *src;
Aug 17, 2007
Aug 17, 2007
916
917
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
918
919
920
921
922
923
924
925
926
927
928
929
srcx = -1;
posx = 0x10000L;
while (posy >= 0x10000L) {
++srcy;
posy -= 0x10000L;
}
while (n--) {
if (posx >= 0x10000L) {
while (posx >= 0x10000L) {
++srcx;
posx -= 0x10000L;
}
Aug 17, 2007
Aug 17, 2007
930
src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
931
932
}
pixel = *src;
Nov 29, 2008
Nov 29, 2008
933
934
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
935
936
937
938
939
*dst = pixel;
posx += incx;
++dst;
}
posy += incy;
Aug 17, 2007
Aug 17, 2007
940
info->dst += info->dst_pitch;
941
942
943
}
}
Nov 29, 2008
Nov 29, 2008
944
static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
Aug 17, 2007
Aug 17, 2007
946
const int flags = info->flags;
947
948
949
950
951
Uint32 srcpixel;
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
Aug 17, 2007
Aug 17, 2007
952
953
954
955
while (info->dst_h--) {
Uint32 *src = (Uint32 *)info->src;
Uint32 *dst = (Uint32 *)info->dst;
int n = info->dst_w;
956
957
while (n--) {
srcpixel = *src;
Nov 29, 2008
Nov 29, 2008
958
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
959
dstpixel = *dst;
Nov 29, 2008
Nov 29, 2008
960
dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
Aug 17, 2007
Aug 17, 2007
961
if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
962
/* This goes away if we ever use premultiplied alpha */
Aug 28, 2006
Aug 28, 2006
963
964
965
966
967
if (srcA < 255) {
srcR = (srcR * srcA) / 255;
srcG = (srcG * srcA) / 255;
srcB = (srcB * srcA) / 255;
}
Aug 17, 2007
Aug 17, 2007
969
970
switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
case SDL_COPY_MASK:
Aug 28, 2006
Aug 28, 2006
971
972
973
974
975
976
if (srcA) {
dstR = srcR;
dstG = srcG;
dstB = srcB;
}
break;
Aug 17, 2007
Aug 17, 2007
977
case SDL_COPY_BLEND:
978
979
980
981
dstR = srcR + ((255 - srcA) * dstR) / 255;
dstG = srcG + ((255 - srcA) * dstG) / 255;
dstB = srcB + ((255 - srcA) * dstB) / 255;
break;
Aug 17, 2007
Aug 17, 2007
982
case SDL_COPY_ADD:
983
984
985
986
dstR = srcR + dstR; if (dstR > 255) dstR = 255;
dstG = srcG + dstG; if (dstG > 255) dstG = 255;
dstB = srcB + dstB; if (dstB > 255) dstB = 255;
break;
Aug 17, 2007
Aug 17, 2007
987
case SDL_COPY_MOD:
988
989
990
991
992
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
}
Nov 29, 2008
Nov 29, 2008
993
dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
994
995
996
997
*dst = dstpixel;
++src;
++dst;
}
Aug 17, 2007
Aug 17, 2007
998
999
info->src += info->src_pitch;
info->dst += info->dst_pitch;