Mercurial > hg > dmlib
annotate src/dmblitfunc.h @ 2306:e798a41f27a5
Clean up some code duplication.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 08 Jul 2019 12:25:46 +0300 |
parents | b5cd0435e186 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Sprite / surface blitting functions | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
863 | 5 * (C) Copyright 2011-2015 Tecnic Software productions (TNSP) |
0 | 6 */ |
7 | |
8 // ======================================================================= | |
9 // DMD_NONE | |
10 // ======================================================================= | |
11 | |
85 | 12 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to8 |
13 #define DM_BLITFUNC_SRC_BYTES 1 | |
14 #define DM_BLITFUNC_DST_BYTES 1 | |
15 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
16 #define DM_BLITFUNC_DST_TYPE Uint8 | |
0 | 17 |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
18 #define DM_BLITFUNC_INNER *dp++ = sp[FP_GETH16(xv)]; |
0 | 19 |
20 #include "dmscaledblit.h" | |
21 | |
22 // ----------------------------------------------------------------------- | |
23 | |
85 | 24 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32 |
25 #define DM_BLITFUNC_SRC_BYTES 1 | |
26 #define DM_BLITFUNC_DST_BYTES 4 | |
27 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
28 #define DM_BLITFUNC_DST_TYPE Uint32 | |
0 | 29 |
85 | 30 #define DM_BLITFUNC_VARS const Uint32 *pal; |
31 #define DM_BLITFUNC_INIT \ | |
0 | 32 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
33 pal = (Uint32 *) src->format->palette->colors; | |
34 | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
35 #define DM_BLITFUNC_INNER *dp++ = pal[sp[FP_GETH16(xv)]]; |
0 | 36 |
37 #include "dmscaledblit.h" | |
38 | |
39 // ----------------------------------------------------------------------- | |
40 | |
85 | 41 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32 |
42 #define DM_BLITFUNC_SRC_BYTES 4 | |
43 #define DM_BLITFUNC_DST_BYTES 4 | |
44 #define DM_BLITFUNC_SRC_TYPE Uint32 | |
45 #define DM_BLITFUNC_DST_TYPE Uint32 | |
46 #define DM_BLITFUNC_INIT | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
47 #define DM_BLITFUNC_INNER *dp++ = sp[FP_GETH16(xv)]; |
0 | 48 |
49 #include "dmscaledblit.h" | |
50 | |
51 | |
52 // ======================================================================= | |
53 // DMD_TRANSPARENT | |
54 // ======================================================================= | |
55 | |
85 | 56 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to8Transparent |
57 #define DM_BLITFUNC_SRC_BYTES 1 | |
58 #define DM_BLITFUNC_DST_BYTES 1 | |
59 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
60 #define DM_BLITFUNC_DST_TYPE Uint8 | |
0 | 61 |
85 | 62 #define DM_BLITFUNC_INNER \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
63 *dp = sp[FP_GETH16(xv)] ? sp[FP_GETH16(xv)] : *dp; dp++; |
0 | 64 |
65 #include "dmscaledblit.h" | |
66 | |
67 // ----------------------------------------------------------------------- | |
68 | |
85 | 69 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Transparent |
70 #define DM_BLITFUNC_SRC_BYTES 1 | |
71 #define DM_BLITFUNC_DST_BYTES 4 | |
72 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
73 #define DM_BLITFUNC_DST_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
74 #define DM_BLITFUNC_VARS const DMColor *pal; |
85 | 75 #define DM_BLITFUNC_INIT \ |
0 | 76 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
77 pal = (DMColor *) src->format->palette->colors; |
0 | 78 |
85 | 79 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
80 const DMColor q = pal[sp[FP_GETH16(xv)]]; \ |
0 | 81 dp->r += ((q.r - dp->r) * q.a) >> 8; \ |
82 dp->g += ((q.g - dp->g) * q.a) >> 8; \ | |
83 dp->b += ((q.b - dp->b) * q.a) >> 8; \ | |
84 dp->a = q.a; \ | |
85 dp++; | |
86 | |
87 #include "dmscaledblit.h" | |
88 | |
89 | |
90 // ----------------------------------------------------------------------- | |
91 | |
85 | 92 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32Transparent |
93 #define DM_BLITFUNC_SRC_BYTES 4 | |
94 #define DM_BLITFUNC_DST_BYTES 4 | |
0 | 95 |
96 #ifdef DM_USE_SIMD | |
85 | 97 #define DM_BLITFUNC_VARS \ |
21 | 98 const Uint32 qpdmask = 0xff000000; \ |
12
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
99 const Uint64 qpdrm = 0xff00ff00ff00ffULL; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
100 |
85 | 101 #define DM_BLITFUNC_SRC_TYPE Uint32 |
102 #define DM_BLITFUNC_DST_TYPE Uint32 | |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
103 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
104 __asm__( \ |
0 | 105 "movd %2, %%mm1\n" \ |
12
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
106 \ |
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
107 "movd %3, %%mm2\n" \ |
13
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
108 "movq %%mm1, %%mm5\n" \ |
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
109 "pand %%mm2, %%mm5\n" \ |
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
110 "psrlw $8, %%mm5\n" \ |
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
111 "punpcklwd %%mm5, %%mm5\n" \ |
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
112 "punpckhwd %%mm5, %%mm5\n" \ |
0 | 113 \ |
13
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
114 "pxor %%mm2, %%mm2\n" \ |
0 | 115 "movd %1, %%mm3\n" \ |
116 "punpcklbw %%mm2, %%mm1\n" \ | |
13
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
117 "punpcklbw %%mm2, %%mm3\n" \ |
12
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
118 \ |
0 | 119 "psubw %%mm3, %%mm1\n" \ |
12
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
120 "pmullw %%mm5, %%mm1\n" \ |
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
121 "psraw $8, %%mm1\n" \ |
35b0c83af3ca
MMX-version of scaled 32-bit RGBA alpha blending blit works now.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
122 "paddw %%mm3, %%mm1\n" \ |
13
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
123 "pand %4, %%mm1\n" \ |
0 | 124 "packuswb %%mm2, %%mm1\n" \ |
125 "movd %%mm1, %0\n" \ | |
126 : "=m" (*dp) \ | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
127 : "m" (*dp), "m" (sp[FP_GETH16(xv)]), "m" (qpdmask), "m" (qpdrm) \ |
17
a60fe802636a
Add register clobbers to SIMD inline asm.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
128 : "memory", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5" ); dp++; |
0 | 129 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
130 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
13
07bace8425d9
Optimize the scaled RGBA alpha blit MMX version further.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
131 |
0 | 132 #else |
21 | 133 |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
134 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
135 #define DM_BLITFUNC_DST_TYPE DMColor |
85 | 136 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
137 const DMColor q = sp[FP_GETH16(xv)]; \ |
0 | 138 dp->r += ((q.r - dp->r) * q.a) >> 8; \ |
139 dp->g += ((q.g - dp->g) * q.a) >> 8; \ | |
140 dp->b += ((q.b - dp->b) * q.a) >> 8; \ | |
141 dp->a = q.a; \ | |
142 dp++; | |
1305
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
143 |
0 | 144 #endif |
145 | |
146 #include "dmscaledblit.h" | |
147 | |
148 // ----------------------------------------------------------------------- | |
149 | |
85 | 150 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentX |
151 #define DM_BLITFUNC_SRC_BYTES 4 | |
152 #define DM_BLITFUNC_DST_BYTES 4 | |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
153 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
154 #define DM_BLITFUNC_DST_TYPE DMColor |
85 | 155 #define DM_BLITFUNC_INIT |
0 | 156 |
85 | 157 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
158 const DMColor q = sp[FP_GETH16(xv)]; \ |
14
a40c266a71a2
Bitshift less in dmScaledBlitSurface32to32TransparentX()
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
159 dp->r = (q.r * q.a + dp->r * dp->a) >> 8; \ |
a40c266a71a2
Bitshift less in dmScaledBlitSurface32to32TransparentX()
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
160 dp->g = (q.g * q.a + dp->g * dp->a) >> 8; \ |
a40c266a71a2
Bitshift less in dmScaledBlitSurface32to32TransparentX()
Matti Hamalainen <ccr@tnsp.org>
parents:
13
diff
changeset
|
161 dp->b = (q.b * q.a + dp->b * dp->a) >> 8; \ |
0 | 162 dp->a = q.a ? q.a : dp->a; \ |
163 dp++; | |
164 | |
165 #include "dmscaledblit.h" | |
166 | |
167 | |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
168 // ----------------------------------------------------------------------- |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
169 |
85 | 170 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32TransparentGA |
171 #define DM_BLITFUNC_SRC_BYTES 4 | |
172 #define DM_BLITFUNC_DST_BYTES 4 | |
173 #define DM_BLITFUNC_ARGS , Uint32 alpha | |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
174 |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
175 #ifdef DM_USE_SIMD |
85 | 176 #define DM_BLITFUNC_VARS \ |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
177 const Uint32 qpdmask = 0xff000000; \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
178 const Uint64 qpdrm = 0xff00ff00ff00ffULL; |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
179 |
85 | 180 #define DM_BLITFUNC_SRC_TYPE Uint32 |
181 #define DM_BLITFUNC_DST_TYPE Uint32 | |
182 #define DM_BLITFUNC_INNER_INIT \ | |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
183 __asm__( \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
184 "movd %0, %%mm4\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
185 "punpcklwd %%mm4, %%mm4\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
186 "punpckldq %%mm4, %%mm4\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
187 : \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
188 : "m" (alpha) \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
189 : "%mm4" ); |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
190 |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
191 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
192 __asm__( \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
193 "movd %2, %%mm1\n" \ |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
194 \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
195 "movd %3, %%mm2\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
196 "movq %%mm1, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
197 "pand %%mm2, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
198 "psrlw $8, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
199 "punpcklwd %%mm5, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
200 "punpckhwd %%mm5, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
201 \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
202 "pmullw %%mm4, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
203 "psrlw $8, %%mm5\n" \ |
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
204 \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
205 "pxor %%mm2, %%mm2\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
206 "movd %1, %%mm3\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
207 "punpcklbw %%mm2, %%mm1\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
208 "punpcklbw %%mm2, %%mm3\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
209 \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
210 "psubw %%mm3, %%mm1\n" \ |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
211 "pmullw %%mm5, %%mm1\n" \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
212 "psraw $8, %%mm1\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
213 "paddw %%mm3, %%mm1\n" \ |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
214 "pand %4, %%mm1\n" \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
215 "packuswb %%mm2, %%mm1\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
216 "movd %%mm1, %0\n" \ |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
217 : "=m" (*dp) \ |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
218 : "m" (*dp), "m" (sp[FP_GETH16(xv)]), "m" (qpdmask), "m" (qpdrm) \ |
128
afa28947e400
Improve transparent GA alpha scaled blitting function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
219 : "memory", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5" ); dp++; |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
220 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
221 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
222 |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
223 #else |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
224 |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
225 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
226 #define DM_BLITFUNC_DST_TYPE DMColor |
85 | 227 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
228 const DMColor q = sp[FP_GETH16(xv)]; \ |
1305
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
229 const int a = (alpha * q.a) >> 8; \ |
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
230 dp->r += ((q.r - dp->r) * a) >> 8; \ |
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
231 dp->g += ((q.g - dp->g) * a) >> 8; \ |
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
232 dp->b += ((q.b - dp->b) * a) >> 8; \ |
582d49915059
A macro was missing a \ .. fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
233 dp->a = a; \ |
18
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
234 dp++; |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
235 #endif |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
236 |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
237 #include "dmscaledblit.h" |
022eee2e7de6
Add dmScaledBlitSurface32to32TransparentGA().
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
238 |
0 | 239 // ======================================================================= |
240 // DMD_SATURATE | |
241 // ======================================================================= | |
242 | |
85 | 243 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to8Saturate |
244 #define DM_BLITFUNC_SRC_BYTES 1 | |
245 #define DM_BLITFUNC_DST_BYTES 1 | |
246 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
247 #define DM_BLITFUNC_DST_TYPE Uint8 | |
248 #define DM_BLITFUNC_INNER \ | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
249 const int q = sp[FP_GETH16(xv)] + *dp; \ |
81
ba1987562a73
Fix 8to8 saturated scaled blit function.
Matti Hamalainen <ccr@tnsp.org>
parents:
21
diff
changeset
|
250 *(dp++) = q < 256 ? q : 255; |
ba1987562a73
Fix 8to8 saturated scaled blit function.
Matti Hamalainen <ccr@tnsp.org>
parents:
21
diff
changeset
|
251 |
0 | 252 #include "dmscaledblit.h" |
253 | |
254 // ----------------------------------------------------------------------- | |
255 | |
85 | 256 #define DM_BLITFUNC_NAME dmScaledBlitSurface8to32Saturate |
257 #define DM_BLITFUNC_SRC_BYTES 1 | |
258 #define DM_BLITFUNC_DST_BYTES 4 | |
259 #define DM_BLITFUNC_SRC_TYPE Uint8 | |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
260 #define DM_BLITFUNC_DST_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
261 #define DM_BLITFUNC_VARS const DMColor *pal; |
85 | 262 #define DM_BLITFUNC_INIT \ |
0 | 263 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
264 pal = (DMColor *) src->format->palette->colors; |
0 | 265 |
266 #ifdef DM_USE_SIMD | |
85 | 267 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
268 __asm__("movd %2, %%mm1\n" \ |
0 | 269 "movd %1, %%mm2\n" \ |
270 "paddusb %%mm2, %%mm1\n" \ | |
271 "movd %%mm1, %0\n" \ | |
272 : "=m" (*dp) \ | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
273 : "m" (*dp), "m" (pal[sp[FP_GETH16(xv)]]) \ |
17
a60fe802636a
Add register clobbers to SIMD inline asm.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
274 : "memory", "%mm1", "%mm2" ); dp++; |
0 | 275 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
276 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
0 | 277 #else |
85 | 278 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
279 const DMColor q = pal[sp[FP_GETH16(xv)]]; \ |
0 | 280 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ |
281 dp->r = qr < 256 ? qr : 255; \ | |
282 dp->g = qg < 256 ? qg : 255; \ | |
283 dp->b = qb < 256 ? qb : 255; \ | |
284 dp->a = q.a; \ | |
285 dp++; | |
286 #endif | |
287 | |
288 #include "dmscaledblit.h" | |
289 | |
290 // ----------------------------------------------------------------------- | |
291 | |
85 | 292 #define DM_BLITFUNC_NAME dmScaledBlitSurface32to32Saturate |
293 #define DM_BLITFUNC_SRC_BYTES 4 | |
294 #define DM_BLITFUNC_DST_BYTES 4 | |
295 #define DM_BLITFUNC_INIT | |
0 | 296 |
297 #ifdef DM_USE_SIMD | |
85 | 298 #define DM_BLITFUNC_SRC_TYPE Uint32 |
299 #define DM_BLITFUNC_DST_TYPE Uint32 | |
300 #define DM_BLITFUNC_INNER \ | |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
301 __asm__("movd %2, %%mm1\n" \ |
0 | 302 "movd %1, %%mm2\n" \ |
303 "paddusb %%mm2, %%mm1\n" \ | |
304 "movd %%mm1, %0\n" \ | |
305 : "=m" (*dp) \ | |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
306 : "m" (*dp), "m" (sp[FP_GETH16(xv)]) \ |
17
a60fe802636a
Add register clobbers to SIMD inline asm.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
307 : "memory", "%mm1", "%mm2" ); dp++; |
0 | 308 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
309 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
0 | 310 #else |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
311 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
312 #define DM_BLITFUNC_DST_TYPE DMColor |
85 | 313 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
314 const DMColor q = sp[FP_GETH16(xv)]; \ |
0 | 315 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ |
316 dp->r = qr < 256 ? qr : 255; \ | |
317 dp->g = qg < 256 ? qg : 255; \ | |
318 dp->b = qb < 256 ? qb : 255; \ | |
319 dp->a = q.a; \ | |
320 dp++; | |
321 #endif | |
322 | |
323 #include "dmscaledblit.h" | |
324 | |
325 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
326 |
0 | 327 // ======================================================================= |
328 // ======================================================================= | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
329 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
330 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
331 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
332 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
333 // DMD_NONE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
334 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
335 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
336 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
337 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
338 #define DM_BLITFUNC_DST_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
339 #define DM_BLITFUNC_SRC_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
340 #define DM_BLITFUNC_DST_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
341 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
342 #define DM_BLITFUNC_INNER *dp++ = sp[xv]; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
343 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
344 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
345 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
346 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
347 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
348 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
349 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
350 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
351 #define DM_BLITFUNC_SRC_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
352 #define DM_BLITFUNC_DST_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
353 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
354 #define DM_BLITFUNC_VARS const Uint32 *pal; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
355 #define DM_BLITFUNC_INIT \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
356 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
357 pal = (Uint32 *) src->format->palette->colors; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
358 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
359 #define DM_BLITFUNC_INNER *dp++ = pal[sp[xv]]; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
360 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
361 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
362 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
363 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
364 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
365 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface32to32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
366 #define DM_BLITFUNC_SRC_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
367 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
368 #define DM_BLITFUNC_SRC_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
369 #define DM_BLITFUNC_DST_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
370 #define DM_BLITFUNC_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
371 #define DM_BLITFUNC_INNER *dp++ = sp[xv]; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
372 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
373 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
374 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
375 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
376 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
377 // DMD_TRANSPARENT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
378 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
379 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
380 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to8Transparent |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
381 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
382 #define DM_BLITFUNC_DST_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
383 #define DM_BLITFUNC_SRC_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
384 #define DM_BLITFUNC_DST_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
385 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
386 #define DM_BLITFUNC_INNER \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
387 *dp = sp[xv] ? sp[xv] : *dp; dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
388 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
389 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
390 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
391 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
392 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
393 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Transparent |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
394 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
395 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
396 #define DM_BLITFUNC_SRC_TYPE Uint8 |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
397 #define DM_BLITFUNC_DST_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
398 #define DM_BLITFUNC_VARS const DMColor *pal; |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
399 #define DM_BLITFUNC_INIT \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
400 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
401 pal = (DMColor *) src->format->palette->colors; |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
402 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
403 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
404 const DMColor q = pal[sp[xv]]; \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
405 dp->r += ((q.r - dp->r) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
406 dp->g += ((q.g - dp->g) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
407 dp->b += ((q.b - dp->b) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
408 dp->a = q.a; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
409 dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
410 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
411 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
412 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
413 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
414 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
415 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
416 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface32to32Transparent |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
417 #define DM_BLITFUNC_SRC_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
418 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
419 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
420 #ifdef DM_USE_SIMD |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
421 #define DM_BLITFUNC_VARS \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
422 const Uint32 qpdmask = 0xff000000; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
423 const Uint64 qpdrm = 0xff00ff00ff00ffULL; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
424 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
425 #define DM_BLITFUNC_SRC_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
426 #define DM_BLITFUNC_DST_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
427 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
428 __asm__( \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
429 "movd %2, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
430 \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
431 "movd %3, %%mm2\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
432 "movq %%mm1, %%mm5\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
433 "pand %%mm2, %%mm5\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
434 "psrlw $8, %%mm5\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
435 "punpcklwd %%mm5, %%mm5\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
436 "punpckhwd %%mm5, %%mm5\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
437 \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
438 "pxor %%mm2, %%mm2\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
439 "movd %1, %%mm3\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
440 "punpcklbw %%mm2, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
441 "punpcklbw %%mm2, %%mm3\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
442 \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
443 "psubw %%mm3, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
444 "pmullw %%mm5, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
445 "psraw $8, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
446 "paddw %%mm3, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
447 "pand %4, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
448 "packuswb %%mm2, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
449 "movd %%mm1, %0\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
450 : "=m" (*dp) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
451 : "m" (*dp), "m" (sp[xv]), "m" (qpdmask), "m" (qpdrm) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
452 : "memory", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5" ); dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
453 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
454 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
455 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
456 #else |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
457 |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
458 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
459 #define DM_BLITFUNC_DST_TYPE DMColor |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
460 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
461 const DMColor q = sp[xv]; \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
462 dp->r += ((q.r - dp->r) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
463 dp->g += ((q.g - dp->g) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
464 dp->b += ((q.b - dp->b) * q.a) >> 8; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
465 dp->a = q.a; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
466 dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
467 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
468 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
469 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
470 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
471 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
472 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
473 // DMD_SATURATE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
474 // ======================================================================= |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
475 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
476 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to8Saturate |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
477 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
478 #define DM_BLITFUNC_DST_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
479 #define DM_BLITFUNC_SRC_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
480 #define DM_BLITFUNC_DST_TYPE Uint8 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
481 #define DM_BLITFUNC_INNER \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
482 const int q = sp[xv] + *dp; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
483 *(dp++) = q < 256 ? q : 255; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
484 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
485 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
486 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
487 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
488 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
489 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface8to32Saturate |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
490 #define DM_BLITFUNC_SRC_BYTES 1 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
491 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
492 #define DM_BLITFUNC_SRC_TYPE Uint8 |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
493 #define DM_BLITFUNC_DST_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
494 #define DM_BLITFUNC_VARS const DMColor *pal; |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
495 #define DM_BLITFUNC_INIT \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
496 if (src->format->palette == NULL || src->format->palette->ncolors < 256) return -2; \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
497 pal = (DMColor *) src->format->palette->colors; |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
498 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
499 #ifdef DM_USE_SIMD |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
500 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
501 __asm__("movd %2, %%mm1\n" \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
502 "movd %1, %%mm2\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
503 "paddusb %%mm2, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
504 "movd %%mm1, %0\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
505 : "=m" (*dp) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
506 : "m" (*dp), "m" (pal[sp[xv]]) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
507 : "memory", "%mm1", "%mm2" ); dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
508 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
509 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
510 #else |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
511 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
512 const DMColor q = pal[sp[xv]]; \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
513 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
514 dp->r = qr < 256 ? qr : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
515 dp->g = qg < 256 ? qg : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
516 dp->b = qb < 256 ? qb : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
517 dp->a = q.a; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
518 dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
519 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
520 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
521 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
522 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
523 // ----------------------------------------------------------------------- |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
524 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
525 #define DM_BLITFUNC_NAME dmUnscaledBlitSurface32to32Saturate |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
526 #define DM_BLITFUNC_SRC_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
527 #define DM_BLITFUNC_DST_BYTES 4 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
528 #define DM_BLITFUNC_INIT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
529 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
530 #ifdef DM_USE_SIMD |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
531 #define DM_BLITFUNC_SRC_TYPE Uint32 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
532 #define DM_BLITFUNC_DST_TYPE Uint32 |
232
79dac918c81e
Modularize line clipping etc. a lot, and export all line drawing and
Matti Hamalainen <ccr@tnsp.org>
parents:
128
diff
changeset
|
533 #define DM_BLITFUNC_INNER \ |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
534 __asm__("movd %2, %%mm1\n" \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
535 "movd %1, %%mm2\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
536 "paddusb %%mm2, %%mm1\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
537 "movd %%mm1, %0\n" \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
538 : "=m" (*dp) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
539 : "m" (*dp), "m" (sp[xv]) \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
540 : "memory", "%mm1", "%mm2" ); dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
541 |
2038
b5cd0435e186
Use __asm__() instead of "GCC-specific" asm() for inline assembly.
Matti Hamalainen <ccr@tnsp.org>
parents:
1305
diff
changeset
|
542 #define DM_BLITFUNC_FINISH __asm__("emms\n"); |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
543 #else |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
544 #define DM_BLITFUNC_SRC_TYPE DMColor |
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
545 #define DM_BLITFUNC_DST_TYPE DMColor |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
546 #define DM_BLITFUNC_INNER \ |
971
f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
Matti Hamalainen <ccr@tnsp.org>
parents:
863
diff
changeset
|
547 const DMColor q = sp[xv]; \ |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
548 const int qr = dp->r + q.r, qg = dp->g + q.g, qb = dp->b + q.b; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
549 dp->r = qr < 256 ? qr : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
550 dp->g = qg < 256 ? qg : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
551 dp->b = qb < 256 ? qb : 255; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
552 dp->a = q.a; \ |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
553 dp++; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
554 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
555 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
556 #include "dmunscaledblit.h" |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
557 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
558 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
92
diff
changeset
|
559 // ======================================================================= |