MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / best_color_mode

Function best_color_mode

platform/mac/pixelformat.cpp:242–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242static unsigned int best_color_mode(GLint modes, GLint color_size, GLint alpha_size, GLint color_float) {
243 int best = -1;
244
245 for (int i = 0; i < ARRAY_SIZE(color_modes); i++) {
246 if ((modes & color_modes[i].mode) && color_modes[i].color_bits >= color_size && color_modes[i].alpha_bits >= alpha_size && !color_modes[i].is_float == !color_float) {
247 if (best < 0) { /* no existing best choice */
248 best = i;
249 } else if (color_modes[i].color_bits == color_size && color_modes[i].alpha_bits == alpha_size) { /* candidate is exact match */
250 /* prefer it over a best which isn't exact or which has a higher bpp */
251 if (color_modes[best].color_bits != color_size || color_modes[best].alpha_bits != alpha_size || color_modes[i].bits_per_pixel < color_modes[best].bits_per_pixel) {
252 best = i;
253 }
254 } else if (color_modes[i].color_bits < color_modes[best].color_bits || (color_modes[i].color_bits == color_modes[best].color_bits && color_modes[i].alpha_bits < color_modes[best].alpha_bits)) { /* prefer closer */
255 best = i;
256 }
257 }
258 }
259
260 if (best < 0) {
261 /* Couldn't find a match. Return first one that renderer supports. */
262 for (int i = 0; i < ARRAY_SIZE(color_modes); i++) {
263 if (modes & color_modes[i].mode) {
264 return i;
265 }
266 }
267 }
268
269 return best;
270}
271
272
273static unsigned int best_accum_mode(GLint modes, GLint accum_size) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected