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