Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid91"!).
Fixes Bugzilla #2986.
1 /* See COPYING.txt for the full license governing this code. */
3 * \file variator_common.c
5 * Source file for some common functionality used by variators.
9 #include "SDL_visualtest_variator_common.h"
12 SDLVisualTest_NextValue(SDLVisualTest_SUTOptionValue* var,
13 SDLVisualTest_SUTOption* opt)
17 SDLTest_LogError("var argument cannot be NULL");
22 SDLTest_LogError("opt argument cannot be NULL");
28 case SDL_SUT_OPTIONTYPE_BOOL:
31 var->bool_value = SDL_FALSE;
36 var->bool_value = SDL_TRUE;
41 case SDL_SUT_OPTIONTYPE_ENUM:
42 var->enumerated.index++;
43 if(!opt->data.enum_values[var->enumerated.index])
45 var->enumerated.index = 0;
51 case SDL_SUT_OPTIONTYPE_INT:
53 int increment = (opt->data.range.max - opt->data.range.min) /
54 SDL_SUT_INTEGER_OPTION_TEST_STEPS;
55 /* prevents infinite loop when rounding */
58 var->integer.value += increment;
59 if(var->integer.value > opt->data.range.max)
61 var->integer.value = opt->data.range.min;
68 case SDL_SUT_OPTIONTYPE_STRING:
76 SDLVisualTest_MakeStrFromVariation(SDLVisualTest_Variation* variation,
77 SDLVisualTest_SUTConfig* config,
78 char* buffer, int size)
81 SDLVisualTest_SUTOptionValue* vars;
82 SDLVisualTest_SUTOption* options;
85 SDLTest_LogError("variation argument cannot be NULL");
90 SDLTest_LogError("config argument cannot be NULL");
95 SDLTest_LogError("buffer argument cannot be NULL");
100 SDLTest_LogError("size argument should be positive");
106 options = config->options;
107 vars = variation->vars;
108 for(i = 0; i < variation->num_vars; i++)
111 if(index >= size - 1)
113 SDLTest_LogError("String did not fit in buffer size");
116 switch(options[i].type)
118 case SDL_SUT_OPTIONTYPE_BOOL:
119 if(vars[i].bool_value)
121 n = SDL_snprintf(buffer + index, size - index, "%s ",
125 SDLTest_LogError("SDL_snprintf() failed");
132 case SDL_SUT_OPTIONTYPE_ENUM:
133 if(vars[i].enumerated.on)
135 enum_index = vars[i].enumerated.index;
136 n = SDL_snprintf(buffer + index, size - index, "%s %s ",
137 options[i].name, options[i].data.enum_values[enum_index]);
142 case SDL_SUT_OPTIONTYPE_INT:
143 if(vars[i].integer.on)
145 n = SDL_snprintf(buffer + index, size - index, "%s %d ",
146 options[i].name, vars[i].integer.value);
151 case SDL_SUT_OPTIONTYPE_STRING:
152 if(vars[i].string.on)
154 n = SDL_snprintf(buffer + index, size - index, "%s %s ",
155 options[i].name, vars[i].string.value);
165 SDLVisualTest_InitVariation(SDLVisualTest_Variation* variation,
166 SDLVisualTest_SUTConfig* config)
169 SDLVisualTest_SUTOptionValue* vars;
170 SDLVisualTest_SUTOption* options;
173 SDLTest_LogError("variation argument cannot be NULL");
178 SDLTest_LogError("config argument cannot be NULL");
182 /* initialize the first variation */
183 if(config->num_options <= 0)
185 SDLTest_LogError("config->num_options must be positive");
188 variation->vars = (SDLVisualTest_SUTOptionValue*)SDL_malloc(config->num_options *
189 sizeof(SDLVisualTest_SUTOptionValue));
192 SDLTest_LogError("malloc() failed");
195 variation->num_vars = config->num_options;
196 vars = variation->vars;
197 options = config->options;
198 for(i = 0; i < variation->num_vars; i++)
200 switch(options[i].type)
202 case SDL_SUT_OPTIONTYPE_BOOL:
203 vars[i].bool_value = SDL_FALSE;
206 case SDL_SUT_OPTIONTYPE_ENUM:
207 vars[i].enumerated.on = SDL_TRUE;
208 vars[i].enumerated.index = 0;
211 case SDL_SUT_OPTIONTYPE_INT:
213 vars[i].integer.on = SDL_TRUE;
214 vars[i].integer.value = options[i].data.range.min;
218 case SDL_SUT_OPTIONTYPE_STRING:
219 vars[i].string.on = SDL_TRUE;
220 vars[i].string.value = options[i].name;