Skip to content

tests: add rgb[] alias in color_float

Pekka Paalanen requested to merge pq/weston:mr/color-float into main

Individual struct fields are inconvenient to index into, yet most operations on a color just repeat the same for each of RGB channel. Being able to index into RGB avoids repeating the same code for each channel.

Alpha channel is left as separate, since it is almost never handled the same as RGB.

The union keeps the old .r, .g and .b addressing working. The static asserts ensure the aliasing is correct.

This change should make code easier to read.

This change requires gnu99 or c11 standard. gnu99 is already the default in top-level meson.build.


The big question here is, is this an improvement or just churn?

@vitalyp, could you review this for correctness and readability, please?

@derekf, what do you think of the readability change here? No need to understand any color stuff. ;-)

Merge request reports