Skip to content

Latest commit

 

History

History
7677 lines (7345 loc) · 285 KB

SDL_blit_auto.c

File metadata and controls

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