Skip to content

Latest commit

 

History

History
7681 lines (7347 loc) · 285 KB

SDL_blit_auto.c

File metadata and controls

7681 lines (7347 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
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"
Jan 23, 2020
Jan 23, 2020
24
25
#if SDL_HAVE_BLIT_AUTO
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
72
73
/* *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
74
Uint32 srcR, srcG, srcB;
75
76
77
78
79
80
81
82
83
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
84
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
85
86
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
Jan 16, 2020
Jan 16, 2020
87
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
88
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
89
90
91
dstR = srcR;
dstG = srcG;
dstB = srcB;
92
93
94
95
96
97
98
99
100
101
102
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
103
104
105
106
107
case SDL_COPY_MUL:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
Oct 30, 2019
Oct 30, 2019
109
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
110
111
112
113
114
115
116
117
118
119
120
121
122
*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
123
Uint32 srcR, srcG, srcB;
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
152
153
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
154
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
155
156
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
Jan 16, 2020
Jan 16, 2020
157
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
158
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
159
160
161
dstR = srcR;
dstG = srcG;
dstB = srcB;
162
163
164
165
166
167
168
169
170
171
172
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
173
174
175
176
177
case SDL_COPY_MUL:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
Oct 30, 2019
Oct 30, 2019
179
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
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
208
209
*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
210
pixel = (R << 16) | (G << 8) | B;
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
260
261
*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
262
pixel = (R << 16) | (G << 8) | B;
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
*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
280
281
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
282
283
284
285
286
287
288
289
290
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
291
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
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
307
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
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
323
324
325
326
327
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
329
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
*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
347
348
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
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
377
378
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
379
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
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
395
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
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
411
412
413
414
415
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
417
dstpixel = (dstR << 16) | (dstG << 8) | dstB;
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
458
459
*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
460
pixel = (B << 16) | (G << 8) | R;
461
462
463
464
465
466
467
468
469
470
471
472
473
*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
474
Uint32 srcR, srcG, srcB;
475
476
477
478
479
480
481
482
483
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
484
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
485
486
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
Jan 16, 2020
Jan 16, 2020
487
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
488
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
489
490
491
dstR = srcR;
dstG = srcG;
dstB = srcB;
492
493
494
495
496
497
498
499
500
501
502
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
503
504
505
506
507
case SDL_COPY_MUL:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
Oct 30, 2019
Oct 30, 2019
509
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
510
511
512
513
514
515
516
517
518
519
520
521
522
*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
523
Uint32 srcR, srcG, srcB;
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
552
553
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
554
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
555
556
dstpixel = *dst;
dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel;
Jan 16, 2020
Jan 16, 2020
557
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
558
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
559
560
561
dstR = srcR;
dstG = srcG;
dstB = srcB;
562
563
564
565
566
567
568
569
570
571
572
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
573
574
575
576
577
case SDL_COPY_MUL:
dstR = (srcR * dstR) / 255;
dstG = (srcG * dstG) / 255;
dstB = (srcB * dstB) / 255;
break;
Oct 30, 2019
Oct 30, 2019
579
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
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
608
609
*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
610
pixel = (B << 16) | (G << 8) | R;
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
660
661
*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
662
pixel = (B << 16) | (G << 8) | R;
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
*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
680
681
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
682
683
684
685
686
687
688
689
690
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
691
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
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
707
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
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
723
724
725
726
727
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
729
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
*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
747
748
const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
Uint32 srcR, srcG, srcB;
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
777
778
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
779
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
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
795
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
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
811
812
813
814
815
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
817
dstpixel = (dstB << 16) | (dstG << 8) | dstR;
818
819
820
821
822
823
824
825
826
827
828
829
*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
830
831
const Uint32 A = 0xFF;
Uint32 R, G, B;
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
858
859
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
860
R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
Oct 30, 2019
Oct 30, 2019
861
pixel = (A << 24) | (R << 16) | (G << 8) | B;
862
863
864
865
866
867
868
869
870
871
872
873
874
*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
875
Uint32 srcR, srcG, srcB;
876
877
878
879
880
881
882
883
884
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
885
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
886
887
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
Jan 16, 2020
Jan 16, 2020
888
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
889
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
890
891
892
893
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
894
895
896
897
898
899
900
901
902
903
904
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
905
906
907
908
909
910
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
912
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
913
914
915
916
917
918
919
920
921
922
923
924
925
*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
926
Uint32 srcR, srcG, srcB;
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
955
956
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
957
srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
958
959
dstpixel = *dst;
dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24);
Jan 16, 2020
Jan 16, 2020
960
switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) {
961
case SDL_COPY_BLEND:
Oct 24, 2019
Oct 24, 2019
962
963
964
965
dstR = srcR;
dstG = srcG;
dstB = srcB;
dstA = 0xFF;
966
967
968
969
970
971
972
973
974
975
976
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
977
978
979
980
981
982
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
984
dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB;
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*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;