Mercurial > sdl-ios-xcode
comparison test/automated/render/render.c @ 3739:651b261e591d gsoc2009_unit_tests
Wrapper around return codes to check to see if is supported.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 02 Aug 2009 15:49:55 +0000 |
parents | c875baafce36 |
children | e451d5d288e9 |
comparison
equal
deleted
inserted
replaced
3738:c875baafce36 | 3739:651b261e591d |
---|---|
28 | 28 |
29 /* | 29 /* |
30 * Prototypes. | 30 * Prototypes. |
31 */ | 31 */ |
32 static int render_compare( const char *msg, const SurfaceImage_t *s ); | 32 static int render_compare( const char *msg, const SurfaceImage_t *s ); |
33 static int render_isSupported( int code ); | |
33 static int render_hasDrawColor (void); | 34 static int render_hasDrawColor (void); |
34 static int render_hasBlendModes (void); | 35 static int render_hasBlendModes (void); |
35 static int render_hasTexColor (void); | 36 static int render_hasTexColor (void); |
36 static int render_hasTexAlpha (void); | 37 static int render_hasTexAlpha (void); |
37 static int render_clearScreen (void); | 38 static int render_clearScreen (void); |
105 return 0; | 106 return 0; |
106 } | 107 } |
107 | 108 |
108 | 109 |
109 /** | 110 /** |
111 * @brief Checks to see if functionality is supported. | |
112 */ | |
113 static int render_isSupported( int code ) | |
114 { | |
115 return (code == 0); | |
116 } | |
117 | |
118 | |
119 /** | |
110 * @brief Test to see if we can vary the draw colour. | 120 * @brief Test to see if we can vary the draw colour. |
111 */ | 121 */ |
112 static int render_hasDrawColor (void) | 122 static int render_hasDrawColor (void) |
113 { | 123 { |
114 int ret; | 124 int ret, fail; |
115 Uint8 r, g, b, a; | 125 Uint8 r, g, b, a; |
116 | 126 |
127 fail = 0; | |
128 | |
117 /* Set colour. */ | 129 /* Set colour. */ |
118 ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 ); | 130 ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 ); |
119 ret |= SDL_GetRenderDrawColor( &r, &g, &b, &a ); | 131 if (!render_isSupported(ret)) |
132 fail = 1; | |
133 ret = SDL_GetRenderDrawColor( &r, &g, &b, &a ); | |
134 if (!render_isSupported(ret)) | |
135 fail = 1; | |
120 /* Restore natural. */ | 136 /* Restore natural. */ |
121 ret |= SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE ); | 137 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE ); |
138 if (!render_isSupported(ret)) | |
139 fail = 1; | |
122 | 140 |
123 /* Something failed, consider not available. */ | 141 /* Something failed, consider not available. */ |
124 if (ret != 0) | 142 if (fail) |
125 return 0; | 143 return 0; |
126 /* Not set properly, consider failed. */ | 144 /* Not set properly, consider failed. */ |
127 else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) | 145 else if ((r != 100) || (g != 100) || (b != 100) || (a != 100)) |
128 return 0; | 146 return 0; |
129 return 1; | 147 return 1; |
133 /** | 151 /** |
134 * @brief Test to see if we can vary the blend mode. | 152 * @brief Test to see if we can vary the blend mode. |
135 */ | 153 */ |
136 static int render_hasBlendModes (void) | 154 static int render_hasBlendModes (void) |
137 { | 155 { |
156 int fail; | |
138 int ret; | 157 int ret; |
139 int mode; | 158 int mode; |
140 | 159 |
141 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND ); | 160 fail = 0; |
142 ret |= SDL_GetRenderDrawBlendMode( &mode ); | 161 |
143 ret |= (mode != SDL_BLENDMODE_BLEND); | 162 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND ); |
144 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD ); | 163 if (!render_isSupported(ret)) |
145 ret |= SDL_GetRenderDrawBlendMode( &mode ); | 164 fail = 1; |
146 ret |= (mode != SDL_BLENDMODE_ADD); | 165 ret = SDL_GetRenderDrawBlendMode( &mode ); |
147 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD ); | 166 if (!render_isSupported(ret)) |
148 ret |= SDL_GetRenderDrawBlendMode( &mode ); | 167 fail = 1; |
149 ret |= (mode != SDL_BLENDMODE_MOD); | 168 ret = (mode != SDL_BLENDMODE_BLEND); |
150 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK ); | 169 if (!render_isSupported(ret)) |
151 ret |= SDL_GetRenderDrawBlendMode( &mode ); | 170 fail = 1; |
152 ret |= (mode != SDL_BLENDMODE_MASK); | 171 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD ); |
153 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); | 172 if (!render_isSupported(ret)) |
154 ret |= SDL_GetRenderDrawBlendMode( &mode ); | 173 fail = 1; |
155 ret |= (mode != SDL_BLENDMODE_NONE); | 174 ret = SDL_GetRenderDrawBlendMode( &mode ); |
156 | 175 if (!render_isSupported(ret)) |
157 return !ret; | 176 fail = 1; |
177 ret = (mode != SDL_BLENDMODE_ADD); | |
178 if (!render_isSupported(ret)) | |
179 fail = 1; | |
180 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD ); | |
181 if (!render_isSupported(ret)) | |
182 fail = 1; | |
183 ret = SDL_GetRenderDrawBlendMode( &mode ); | |
184 if (!render_isSupported(ret)) | |
185 fail = 1; | |
186 ret = (mode != SDL_BLENDMODE_MOD); | |
187 if (!render_isSupported(ret)) | |
188 fail = 1; | |
189 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK ); | |
190 if (!render_isSupported(ret)) | |
191 fail = 1; | |
192 ret = SDL_GetRenderDrawBlendMode( &mode ); | |
193 if (!render_isSupported(ret)) | |
194 fail = 1; | |
195 ret = (mode != SDL_BLENDMODE_MASK); | |
196 if (!render_isSupported(ret)) | |
197 fail = 1; | |
198 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE ); | |
199 if (!render_isSupported(ret)) | |
200 fail = 1; | |
201 ret = SDL_GetRenderDrawBlendMode( &mode ); | |
202 if (!render_isSupported(ret)) | |
203 fail = 1; | |
204 ret = (mode != SDL_BLENDMODE_NONE); | |
205 if (!render_isSupported(ret)) | |
206 fail = 1; | |
207 | |
208 return !fail; | |
158 } | 209 } |
159 | 210 |
160 | 211 |
161 /** | 212 /** |
162 * @brief Loads the test face. | 213 * @brief Loads the test face. |
182 /** | 233 /** |
183 * @brief Test to see if can set texture colour mode. | 234 * @brief Test to see if can set texture colour mode. |
184 */ | 235 */ |
185 static int render_hasTexColor (void) | 236 static int render_hasTexColor (void) |
186 { | 237 { |
238 int fail; | |
187 int ret; | 239 int ret; |
188 SDL_TextureID tface; | 240 SDL_TextureID tface; |
189 Uint8 r, g, b; | 241 Uint8 r, g, b; |
190 | 242 |
191 /* Get test face. */ | 243 /* Get test face. */ |
192 tface = render_loadTestFace(); | 244 tface = render_loadTestFace(); |
193 if (tface == 0) | 245 if (tface == 0) |
194 return 0; | 246 return 0; |
195 | 247 |
196 /* See if supported. */ | 248 /* See if supported. */ |
197 ret = SDL_SetTextureColorMod( tface, 100, 100, 100 ); | 249 fail = 0; |
198 ret |= SDL_GetTextureColorMod( tface, &r, &g, &b ); | 250 ret = SDL_SetTextureColorMod( tface, 100, 100, 100 ); |
251 if (!render_isSupported(ret)) | |
252 fail = 1; | |
253 ret = SDL_GetTextureColorMod( tface, &r, &g, &b ); | |
254 if (!render_isSupported(ret)) | |
255 fail = 1; | |
199 | 256 |
200 /* Clean up. */ | 257 /* Clean up. */ |
201 SDL_DestroyTexture( tface ); | 258 SDL_DestroyTexture( tface ); |
202 | 259 |
203 if (ret) | 260 if (fail) |
204 return 0; | 261 return 0; |
205 else if ((r != 100) || (g != 100) || (b != 100)) | 262 else if ((r != 100) || (g != 100) || (b != 100)) |
206 return 0; | 263 return 0; |
207 return 1; | 264 return 1; |
208 } | 265 } |
211 /** | 268 /** |
212 * @brief Test to see if we can vary the alpha of the texture. | 269 * @brief Test to see if we can vary the alpha of the texture. |
213 */ | 270 */ |
214 static int render_hasTexAlpha (void) | 271 static int render_hasTexAlpha (void) |
215 { | 272 { |
273 int fail; | |
216 int ret; | 274 int ret; |
217 SDL_TextureID tface; | 275 SDL_TextureID tface; |
218 Uint8 a; | 276 Uint8 a; |
219 | 277 |
220 /* Get test face. */ | 278 /* Get test face. */ |
221 tface = render_loadTestFace(); | 279 tface = render_loadTestFace(); |
222 if (tface == 0) | 280 if (tface == 0) |
223 return 0; | 281 return 0; |
224 | 282 |
225 /* See if supported. */ | 283 /* See if supported. */ |
226 ret = SDL_SetTextureAlphaMod( tface, 100 ); | 284 fail = 0; |
227 ret |= SDL_GetTextureAlphaMod( tface, &a ); | 285 ret = SDL_SetTextureAlphaMod( tface, 100 ); |
286 if (!render_isSupported(ret)) | |
287 fail = 1; | |
288 ret = SDL_GetTextureAlphaMod( tface, &a ); | |
289 if (!render_isSupported(ret)) | |
290 fail = 1; | |
228 | 291 |
229 /* Clean up. */ | 292 /* Clean up. */ |
230 SDL_DestroyTexture( tface ); | 293 SDL_DestroyTexture( tface ); |
231 | 294 |
232 if (ret) | 295 if (fail) |
233 return 0; | 296 return 0; |
234 else if (a != 100) | 297 else if (a != 100) |
235 return 0; | 298 return 0; |
236 return 1; | 299 return 1; |
237 } | 300 } |