Mercurial > hg > dmlib
annotate src/dmblit.c @ 2294:7f6ba3b32f54
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Jul 2019 10:28:43 +0300 |
parents | a3023fe79c43 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
3 * -- Sprite / surface blitting functions | |
4 * Programmed and designed by Matti 'ccr' Hamalainen | |
5 * (C) Copyright 2011 Tecnic Software productions (TNSP) | |
6 */ | |
7 #include "dmlib.h" | |
8 | |
9 //#define DM_CLIP_DEBUG | |
10 | |
11 typedef struct | |
12 { | |
13 int v0, v1, voffs, vadd; | |
14 DMFixedPoint32 vdelta; | |
15 } DMQValue; | |
16 | |
17 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
18 int dmScaledClipCoord(DMQValue *pv, int v0, int v1, int v2, int clipMin, int clipMax) |
0 | 19 { |
20 DMFixedPoint32 a, b; | |
21 | |
22 // Basic bounds check | |
23 if (v1 < 1 || v2 < 1 || v0 + v2 < clipMin || v0 >= clipMax) | |
24 { | |
25 #ifdef DM_CLIPDEBUG | |
26 printf("out of bounds\n"); | |
27 #endif | |
28 return -1; | |
29 } | |
30 | |
31 // Calculate delta | |
32 FP_SETHL(a, v1, 0); | |
33 FP_CONV(b, v2); | |
34 FP_DIV_R(pv->vdelta, a, b); | |
35 | |
36 // Perform clipping | |
37 if (v0 + v2 >= clipMax) | |
38 { | |
39 pv->vadd = v0; | |
40 pv->v1 = clipMax; | |
41 } | |
42 else | |
43 { | |
44 pv->vadd = clipMax - v2; | |
45 pv->v1 = v0 + v2; | |
46 } | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
47 |
0 | 48 if (v0 < clipMin) |
49 { | |
50 pv->voffs = clipMin - v0; | |
51 pv->v0 = clipMin; | |
52 pv->vadd -= v0 + clipMin; | |
53 } | |
54 else | |
55 { | |
56 pv->voffs = 0; | |
57 pv->v0 = v0; | |
58 } | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
59 |
0 | 60 #ifdef DM_CLIP_DEBUG |
61 printf("dmClipCoord(%d, (%d, %d), [%d, %d]): vdelta=", | |
62 v0, v1, v2, clipMin, clipMax); | |
63 FP_PRINTF(pv->vdelta); | |
64 printf(", v0=%d, v1=%d, voffs=%d, vadd=%d\n", | |
65 pv->v0, pv->v1, pv->voffs, pv->vadd); | |
66 #endif | |
67 | |
68 return 0; | |
69 } | |
70 | |
82 | 71 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
72 int dmUnscaledClipCoord(DMQValue *pv, int v0, int v1, int clipMin, int clipMax) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
73 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
74 // Basic bounds check |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
75 if (v1 < 1 || v0 + v1 < clipMin || v0 >= clipMax) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
76 return -1; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
77 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
78 // Perform clipping |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
79 if (v0 + v1 >= clipMax) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
80 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
81 pv->vadd = v0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
82 pv->v1 = clipMax; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
83 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
84 else |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
85 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
86 pv->vadd = clipMax - v1; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
87 pv->v1 = v0 + v1; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
88 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
89 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
90 if (v0 < clipMin) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
91 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
92 pv->voffs = clipMin - v0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
93 pv->v0 = clipMin; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
94 pv->vadd -= v0 + clipMin; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
95 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
96 else |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
97 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
98 pv->voffs = 0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
99 pv->v0 = v0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
100 } |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
101 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
102 return 0; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
103 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
104 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
105 |
0 | 106 #include "dmblitfunc.h" |
107 | |
82 | 108 |
0 | 109 static const DMScaledBlitFunc dmScaledBlitTable[DMD_NMODES][DMD_NBITDEPTHS][DMD_NBITDEPTHS] = |
110 { | |
111 // DMD_NONE | |
112 { | |
113 { dmScaledBlitSurface8to8 , dmScaledBlitSurface8to32 }, | |
114 { NULL , dmScaledBlitSurface32to32 }, | |
115 }, | |
116 // DMD_TRANSPARENT | |
117 { | |
118 { dmScaledBlitSurface8to8Transparent , dmScaledBlitSurface8to32Transparent }, | |
119 { NULL , dmScaledBlitSurface32to32Transparent }, | |
120 }, | |
121 // DMD_SATURATE | |
122 { | |
123 { dmScaledBlitSurface8to8Saturate , dmScaledBlitSurface8to32Saturate }, | |
124 { NULL , dmScaledBlitSurface32to32Saturate }, | |
125 }, | |
126 #if 0 | |
127 // DMD_NONE | DMD_ANTIALIAS | |
128 { | |
129 { dmScaledBlitSurface8to8Antialias , dmScaledBlitSurface8to32Antialias }, | |
130 { NULL , dmScaledBlitSurface32to32Antialias }, | |
131 }, | |
132 // DMD_TRANSPARENT | DMD_ANTIALIAS | |
133 { | |
134 { dmScaledBlitSurface8to8AATransp , dmScaledBlitSurface8to32AATransparent }, | |
135 { NULL , dmScaledBlitSurface32to32AATransparent }, | |
136 }, | |
137 // DMD_SATURATE | DMD_ANTIALIAS | |
138 { | |
139 { dmScaledBlitSurface8to8AASaturate , dmScaledBlitSurface8to32AASaturate }, | |
140 { NULL , dmScaledBlitSurface32to32AASaturate }, | |
141 }, | |
142 #endif | |
143 }; | |
144 | |
145 static const int ndmScaledBlitTable = sizeof(dmScaledBlitTable) / sizeof(dmScaledBlitTable[0]); | |
146 | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
147 |
0 | 148 DMScaledBlitFunc dmGetScaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode) |
149 { | |
150 int isrc, idst; | |
151 if (src == NULL || dst == NULL || mode < 0 || mode >= ndmScaledBlitTable) | |
152 return NULL; | |
153 | |
154 isrc = dmBitsPerPixel2Index(src->BitsPerPixel); | |
155 idst = dmBitsPerPixel2Index(dst->BitsPerPixel); | |
156 if (isrc < 0 || idst < 0) | |
157 return NULL; | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
158 |
0 | 159 return dmScaledBlitTable[mode][isrc][idst]; |
160 } | |
161 | |
162 | |
163 int dmScaledBlitSurfaceAny(SDL_Surface *src, const int x0, const int y0, const int dwidth, const int dheight, SDL_Surface *dst, int mode) | |
164 { | |
165 DMScaledBlitFunc bfunc = dmGetScaledBlitFunc(src->format, dst->format, mode); | |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
166 |
0 | 167 if (bfunc == NULL) |
168 return -15; | |
169 | |
170 return bfunc(src, x0, y0, dwidth, dheight, dst); | |
171 } | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
172 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
173 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
174 static const DMUnscaledBlitFunc dmUnscaledBlitTable[DMD_NMODES][DMD_NBITDEPTHS][DMD_NBITDEPTHS] = |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
175 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
176 // DMD_NONE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
177 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
178 { dmUnscaledBlitSurface8to8 , dmUnscaledBlitSurface8to32 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
179 { NULL , dmUnscaledBlitSurface32to32 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
180 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
181 // DMD_TRANSPARENT |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
182 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
183 { dmUnscaledBlitSurface8to8Transparent, dmUnscaledBlitSurface8to32Transparent }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
184 { NULL , dmUnscaledBlitSurface32to32Transparent }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
185 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
186 // DMD_SATURATE |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
187 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
188 { dmUnscaledBlitSurface8to8Saturate , dmUnscaledBlitSurface8to32Saturate }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
189 { NULL , dmUnscaledBlitSurface32to32Saturate }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
190 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
191 #if 0 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
192 // DMD_NONE | DMD_ANTIALIAS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
193 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
194 { dmUnscaledBlitSurface8to8Antialias , dmUnscaledBlitSurface8to32Antialias }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
195 { NULL , dmUnscaledBlitSurface32to32Antialias }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
196 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
197 // DMD_TRANSPARENT | DMD_ANTIALIAS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
198 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
199 { dmUnscaledBlitSurface8to8AATransp , dmUnscaledBlitSurface8to32AATransparent }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
200 { NULL , dmUnscaledBlitSurface32to32AATransparent }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
201 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
202 // DMD_SATURATE | DMD_ANTIALIAS |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
203 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
204 { dmUnscaledBlitSurface8to8AASaturate , dmUnscaledBlitSurface8to32AASaturate }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
205 { NULL , dmUnscaledBlitSurface32to32AASaturate }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
206 }, |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
207 #endif |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
208 }; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
209 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
210 static const int ndmUnscaledBlitTable = sizeof(dmUnscaledBlitTable) / sizeof(dmUnscaledBlitTable[0]); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
211 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
212 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
213 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
214 DMUnscaledBlitFunc dmGetUnscaledBlitFunc(SDL_PixelFormat *src, SDL_PixelFormat *dst, int mode) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
215 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
216 int isrc, idst; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
217 if (src == NULL || dst == NULL || mode < 0 || mode >= ndmUnscaledBlitTable) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
218 return NULL; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
219 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
220 isrc = dmBitsPerPixel2Index(src->BitsPerPixel); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
221 idst = dmBitsPerPixel2Index(dst->BitsPerPixel); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
222 if (isrc < 0 || idst < 0) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
223 return NULL; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
224 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
225 return dmUnscaledBlitTable[mode][isrc][idst]; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
226 } |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
227 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
228 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
229 int dmUnscaledBlitSurfaceAny(SDL_Surface *src, const int x0, const int y0, SDL_Surface *dst, int mode) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
230 { |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
231 DMUnscaledBlitFunc bfunc = dmGetUnscaledBlitFunc(src->format, dst->format, mode); |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
232 |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
233 if (bfunc == NULL) |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
234 return -15; |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
235 |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
236 return bfunc(src, x0, y0, dst); |
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
237 } |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
238 |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
239 |
1601
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
240 SDL_Surface *dmConvertScaledSurface(SDL_Surface *src, SDL_PixelFormat *fmt, const int dwidth, const int dheight) |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
241 { |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
242 // Create the target surface |
1601
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
243 SDL_Surface *result = SDL_CreateRGBSurface( |
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
244 0, dwidth, dheight, fmt->BitsPerPixel, |
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
245 fmt->Rmask, fmt->Gmask, fmt->Bmask, fmt->Amask); |
a3023fe79c43
Change dmConvertScaledSurface() interface by remove flags.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
246 |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
247 if (result == NULL) |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
248 return NULL; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
249 |
610
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
250 // Use scaled blitting to convert the scaled image .. |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
251 dmScaledBlitSurfaceAny(src, 0, 0, dwidth, dheight, result, DMD_NONE); |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
252 |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
253 return result; |
e74ad60b1e85
Add new scaled surface conversion function.
Matti Hamalainen <ccr@tnsp.org>
parents:
95
diff
changeset
|
254 } |