comparison src/dmblitfunc.h @ 971:f654435df15e

Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor struct definition.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Feb 2015 06:10:16 +0200
parents 27949209238b
children e06abfde6c39
comparison
equal deleted inserted replaced
970:6c33c92de066 971:f654435df15e
68 68
69 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Transparent 69 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Transparent
70 #define DM_BLITFUNC_SRC_BYTES 1 70 #define DM_BLITFUNC_SRC_BYTES 1
71 #define DM_BLITFUNC_DST_BYTES 4 71 #define DM_BLITFUNC_DST_BYTES 4
72 #define DM_BLITFUNC_SRC_TYPE Uint8 72 #define DM_BLITFUNC_SRC_TYPE Uint8
73 #define DM_BLITFUNC_DST_TYPE DMRGBA32 73 #define DM_BLITFUNC_DST_TYPE DMColor
74 #define DM_BLITFUNC_VARS const DMRGBA32 *pal; 74 #define DM_BLITFUNC_VARS const DMColor *pal;
75 #define DM_BLITFUNC_INIT \ 75 #define DM_BLITFUNC_INIT \
76 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ 76 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \
77 pal = (DMRGBA32 *) src->format->palette->colors; 77 pal = (DMColor *) src->format->palette->colors;
78 78
79 #define DM_BLITFUNC_INNER \ 79 #define DM_BLITFUNC_INNER \
80 const DMRGBA32 q = pal[sp[FP_GETH16(xv)]]; \ 80 const DMColor q = pal[sp[FP_GETH16(xv)]]; \
81 dp->r += ((q.r - dp->r) * q.a) >> 8; \ 81 dp->r += ((q.r - dp->r) * q.a) >> 8; \
82 dp->g += ((q.g - dp->g) * q.a) >> 8; \ 82 dp->g += ((q.g - dp->g) * q.a) >> 8; \
83 dp->b += ((q.b - dp->b) * q.a) >> 8; \ 83 dp->b += ((q.b - dp->b) * q.a) >> 8; \
84 dp->a = q.a; \ 84 dp->a = q.a; \
85 dp++; 85 dp++;
129 129
130 #define DM_BLITFUNC_FINISH asm("emms\n"); 130 #define DM_BLITFUNC_FINISH asm("emms\n");
131 131
132 #else 132 #else
133 133
134 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 134 #define DM_BLITFUNC_SRC_TYPE DMColor
135 #define DM_BLITFUNC_DST_TYPE DMRGBA32 135 #define DM_BLITFUNC_DST_TYPE DMColor
136 #define DM_BLITFUNC_INNER \ 136 #define DM_BLITFUNC_INNER \
137 const DMRGBA32 q = sp[FP_GETH16(xv)]; \ 137 const DMColor q = sp[FP_GETH16(xv)]; \
138 dp->r += ((q.r - dp->r) * q.a) >> 8; \ 138 dp->r += ((q.r - dp->r) * q.a) >> 8; \
139 dp->g += ((q.g - dp->g) * q.a) >> 8; \ 139 dp->g += ((q.g - dp->g) * q.a) >> 8; \
140 dp->b += ((q.b - dp->b) * q.a) >> 8; \ 140 dp->b += ((q.b - dp->b) * q.a) >> 8; \
141 dp->a = q.a; \ 141 dp->a = q.a; \
142 dp++; 142 dp++;
147 // ----------------------------------------------------------------------- 147 // -----------------------------------------------------------------------
148 148
149 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentX 149 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentX
150 #define DM_BLITFUNC_SRC_BYTES 4 150 #define DM_BLITFUNC_SRC_BYTES 4
151 #define DM_BLITFUNC_DST_BYTES 4 151 #define DM_BLITFUNC_DST_BYTES 4
152 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 152 #define DM_BLITFUNC_SRC_TYPE DMColor
153 #define DM_BLITFUNC_DST_TYPE DMRGBA32 153 #define DM_BLITFUNC_DST_TYPE DMColor
154 #define DM_BLITFUNC_INIT 154 #define DM_BLITFUNC_INIT
155 155
156 #define DM_BLITFUNC_INNER \ 156 #define DM_BLITFUNC_INNER \
157 const DMRGBA32 q = sp[FP_GETH16(xv)]; \ 157 const DMColor q = sp[FP_GETH16(xv)]; \
158 dp->r = (q.r * q.a + dp->r * dp->a) >> 8; \ 158 dp->r = (q.r * q.a + dp->r * dp->a) >> 8; \
159 dp->g = (q.g * q.a + dp->g * dp->a) >> 8; \ 159 dp->g = (q.g * q.a + dp->g * dp->a) >> 8; \
160 dp->b = (q.b * q.a + dp->b * dp->a) >> 8; \ 160 dp->b = (q.b * q.a + dp->b * dp->a) >> 8; \
161 dp->a = q.a ? q.a : dp->a; \ 161 dp->a = q.a ? q.a : dp->a; \
162 dp++; 162 dp++;
219 219
220 #define DM_BLITFUNC_FINISH asm("emms\n"); 220 #define DM_BLITFUNC_FINISH asm("emms\n");
221 221
222 #else 222 #else
223 223
224 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 224 #define DM_BLITFUNC_SRC_TYPE DMColor
225 #define DM_BLITFUNC_DST_TYPE DMRGBA32 225 #define DM_BLITFUNC_DST_TYPE DMColor
226 #define DM_BLITFUNC_INNER \ 226 #define DM_BLITFUNC_INNER \
227 const DMRGBA32 q = sp[FP_GETH16(xv)]; \ 227 const DMColor q = sp[FP_GETH16(xv)]; \
228 const int a = (alpha * q.a) >> 8; \ 228 const int a = (alpha * q.a) >> 8; \
229 dp->r += ((q.r - dp->r) * a) >> 8; \ 229 dp->r += ((q.r - dp->r) * a) >> 8; \
230 dp->g += ((q.g - dp->g) * a) >> 8; \ 230 dp->g += ((q.g - dp->g) * a) >> 8; \
231 dp->b += ((q.b - dp->b) * a) >> 8; \ 231 dp->b += ((q.b - dp->b) * a) >> 8; \
232 dp->a = a; 232 dp->a = a;
254 254
255 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Saturate 255 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Saturate
256 #define DM_BLITFUNC_SRC_BYTES 1 256 #define DM_BLITFUNC_SRC_BYTES 1
257 #define DM_BLITFUNC_DST_BYTES 4 257 #define DM_BLITFUNC_DST_BYTES 4
258 #define DM_BLITFUNC_SRC_TYPE Uint8 258 #define DM_BLITFUNC_SRC_TYPE Uint8
259 #define DM_BLITFUNC_DST_TYPE DMRGBA32 259 #define DM_BLITFUNC_DST_TYPE DMColor
260 #define DM_BLITFUNC_VARS const DMRGBA32 *pal; 260 #define DM_BLITFUNC_VARS const DMColor *pal;
261 #define DM_BLITFUNC_INIT \ 261 #define DM_BLITFUNC_INIT \
262 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ 262 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \
263 pal = (DMRGBA32 *) src->format->palette->colors; 263 pal = (DMColor *) src->format->palette->colors;
264 264
265 #ifdef DM_USE_SIMD 265 #ifdef DM_USE_SIMD
266 #define DM_BLITFUNC_INNER \ 266 #define DM_BLITFUNC_INNER \
267 asm("movd %2, %%mm1\n" \ 267 asm("movd %2, %%mm1\n" \
268 "movd %1, %%mm2\n" \ 268 "movd %1, %%mm2\n" \
273 : "memory", "%mm1", "%mm2" ); dp++; 273 : "memory", "%mm1", "%mm2" ); dp++;
274 274
275 #define DM_BLITFUNC_FINISH asm("emms\n"); 275 #define DM_BLITFUNC_FINISH asm("emms\n");
276 #else 276 #else
277 #define DM_BLITFUNC_INNER \ 277 #define DM_BLITFUNC_INNER \
278 const DMRGBA32 q = pal[sp[FP_GETH16(xv)]]; \ 278 const DMColor q = pal[sp[FP_GETH16(xv)]]; \
279 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ 279 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \
280 dp->r = qr < 256 ? qr : 255; \ 280 dp->r = qr < 256 ? qr : 255; \
281 dp->g = qg < 256 ? qg : 255; \ 281 dp->g = qg < 256 ? qg : 255; \
282 dp->b = qb < 256 ? qb : 255; \ 282 dp->b = qb < 256 ? qb : 255; \
283 dp->a = q.a; \ 283 dp->a = q.a; \
305 : "m" (*dp), "m" (sp[FP_GETH16(xv)]) \ 305 : "m" (*dp), "m" (sp[FP_GETH16(xv)]) \
306 : "memory", "%mm1", "%mm2" ); dp++; 306 : "memory", "%mm1", "%mm2" ); dp++;
307 307
308 #define DM_BLITFUNC_FINISH asm("emms\n"); 308 #define DM_BLITFUNC_FINISH asm("emms\n");
309 #else 309 #else
310 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 310 #define DM_BLITFUNC_SRC_TYPE DMColor
311 #define DM_BLITFUNC_DST_TYPE DMRGBA32 311 #define DM_BLITFUNC_DST_TYPE DMColor
312 #define DM_BLITFUNC_INNER \ 312 #define DM_BLITFUNC_INNER \
313 const DMRGBA32 q = sp[FP_GETH16(xv)]; \ 313 const DMColor q = sp[FP_GETH16(xv)]; \
314 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ 314 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \
315 dp->r = qr < 256 ? qr : 255; \ 315 dp->r = qr < 256 ? qr : 255; \
316 dp->g = qg < 256 ? qg : 255; \ 316 dp->g = qg < 256 ? qg : 255; \
317 dp->b = qb < 256 ? qb : 255; \ 317 dp->b = qb < 256 ? qb : 255; \
318 dp->a = q.a; \ 318 dp->a = q.a; \
391 391
392 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Transparent 392 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Transparent
393 #define DM_BLITFUNC_SRC_BYTES 1 393 #define DM_BLITFUNC_SRC_BYTES 1
394 #define DM_BLITFUNC_DST_BYTES 4 394 #define DM_BLITFUNC_DST_BYTES 4
395 #define DM_BLITFUNC_SRC_TYPE Uint8 395 #define DM_BLITFUNC_SRC_TYPE Uint8
396 #define DM_BLITFUNC_DST_TYPE DMRGBA32 396 #define DM_BLITFUNC_DST_TYPE DMColor
397 #define DM_BLITFUNC_VARS const DMRGBA32 *pal; 397 #define DM_BLITFUNC_VARS const DMColor *pal;
398 #define DM_BLITFUNC_INIT \ 398 #define DM_BLITFUNC_INIT \
399 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ 399 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \
400 pal = (DMRGBA32 *) src->format->palette->colors; 400 pal = (DMColor *) src->format->palette->colors;
401 401
402 #define DM_BLITFUNC_INNER \ 402 #define DM_BLITFUNC_INNER \
403 const DMRGBA32 q = pal[sp[xv]]; \ 403 const DMColor q = pal[sp[xv]]; \
404 dp->r += ((q.r - dp->r) * q.a) >> 8; \ 404 dp->r += ((q.r - dp->r) * q.a) >> 8; \
405 dp->g += ((q.g - dp->g) * q.a) >> 8; \ 405 dp->g += ((q.g - dp->g) * q.a) >> 8; \
406 dp->b += ((q.b - dp->b) * q.a) >> 8; \ 406 dp->b += ((q.b - dp->b) * q.a) >> 8; \
407 dp->a = q.a; \ 407 dp->a = q.a; \
408 dp++; 408 dp++;
452 452
453 #define DM_BLITFUNC_FINISH asm("emms\n"); 453 #define DM_BLITFUNC_FINISH asm("emms\n");
454 454
455 #else 455 #else
456 456
457 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 457 #define DM_BLITFUNC_SRC_TYPE DMColor
458 #define DM_BLITFUNC_DST_TYPE DMRGBA32 458 #define DM_BLITFUNC_DST_TYPE DMColor
459 #define DM_BLITFUNC_INNER \ 459 #define DM_BLITFUNC_INNER \
460 const DMRGBA32 q = sp[xv]; \ 460 const DMColor q = sp[xv]; \
461 dp->r += ((q.r - dp->r) * q.a) >> 8; \ 461 dp->r += ((q.r - dp->r) * q.a) >> 8; \
462 dp->g += ((q.g - dp->g) * q.a) >> 8; \ 462 dp->g += ((q.g - dp->g) * q.a) >> 8; \
463 dp->b += ((q.b - dp->b) * q.a) >> 8; \ 463 dp->b += ((q.b - dp->b) * q.a) >> 8; \
464 dp->a = q.a; \ 464 dp->a = q.a; \
465 dp++; 465 dp++;
487 487
488 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Saturate 488 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Saturate
489 #define DM_BLITFUNC_SRC_BYTES 1 489 #define DM_BLITFUNC_SRC_BYTES 1
490 #define DM_BLITFUNC_DST_BYTES 4 490 #define DM_BLITFUNC_DST_BYTES 4
491 #define DM_BLITFUNC_SRC_TYPE Uint8 491 #define DM_BLITFUNC_SRC_TYPE Uint8
492 #define DM_BLITFUNC_DST_TYPE DMRGBA32 492 #define DM_BLITFUNC_DST_TYPE DMColor
493 #define DM_BLITFUNC_VARS const DMRGBA32 *pal; 493 #define DM_BLITFUNC_VARS const DMColor *pal;
494 #define DM_BLITFUNC_INIT \ 494 #define DM_BLITFUNC_INIT \
495 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ 495 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \
496 pal = (DMRGBA32 *) src->format->palette->colors; 496 pal = (DMColor *) src->format->palette->colors;
497 497
498 #ifdef DM_USE_SIMD 498 #ifdef DM_USE_SIMD
499 #define DM_BLITFUNC_INNER \ 499 #define DM_BLITFUNC_INNER \
500 asm("movd %2, %%mm1\n" \ 500 asm("movd %2, %%mm1\n" \
501 "movd %1, %%mm2\n" \ 501 "movd %1, %%mm2\n" \
506 : "memory", "%mm1", "%mm2" ); dp++; 506 : "memory", "%mm1", "%mm2" ); dp++;
507 507
508 #define DM_BLITFUNC_FINISH asm("emms\n"); 508 #define DM_BLITFUNC_FINISH asm("emms\n");
509 #else 509 #else
510 #define DM_BLITFUNC_INNER \ 510 #define DM_BLITFUNC_INNER \
511 const DMRGBA32 q = pal[sp[xv]]; \ 511 const DMColor q = pal[sp[xv]]; \
512 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ 512 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \
513 dp->r = qr < 256 ? qr : 255; \ 513 dp->r = qr < 256 ? qr : 255; \
514 dp->g = qg < 256 ? qg : 255; \ 514 dp->g = qg < 256 ? qg : 255; \
515 dp->b = qb < 256 ? qb : 255; \ 515 dp->b = qb < 256 ? qb : 255; \
516 dp->a = q.a; \ 516 dp->a = q.a; \
538 : "m" (*dp), "m" (sp[xv]) \ 538 : "m" (*dp), "m" (sp[xv]) \
539 : "memory", "%mm1", "%mm2" ); dp++; 539 : "memory", "%mm1", "%mm2" ); dp++;
540 540
541 #define DM_BLITFUNC_FINISH asm("emms\n"); 541 #define DM_BLITFUNC_FINISH asm("emms\n");
542 #else 542 #else
543 #define DM_BLITFUNC_SRC_TYPE DMRGBA32 543 #define DM_BLITFUNC_SRC_TYPE DMColor
544 #define DM_BLITFUNC_DST_TYPE DMRGBA32 544 #define DM_BLITFUNC_DST_TYPE DMColor
545 #define DM_BLITFUNC_INNER \ 545 #define DM_BLITFUNC_INNER \
546 const DMRGBA32 q = sp[xv]; \ 546 const DMColor q = sp[xv]; \
547 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ 547 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \
548 dp->r = qr < 256 ? qr : 255; \ 548 dp->r = qr < 256 ? qr : 255; \
549 dp->g = qg < 256 ? qg : 255; \ 549 dp->g = qg < 256 ? qg : 255; \
550 dp->b = qb < 256 ? qb : 255; \ 550 dp->b = qb < 256 ? qb : 255; \
551 dp->a = q.a; \ 551 dp->a = q.a; \