[Mesa-dev] [PATCH 07/14] mesa: use swapBytes parameter in _mesa_format_matches_format_and_type()

Jose Fonseca jfonseca at vmware.com
Fri Jan 27 10:36:36 PST 2012



----- Original Message -----
> On 01/27/2012 01:33 AM, Jose Fonseca wrote:
> > Brian,
> >
> > This is probably right but a tad verbose, and error prone.
> >
> > I'm not sure what's the best way to simplify this though. It's not
> > possible to canonize the comparisons because there are missing
> > combinations.
> >
> > But I think that at least using ternary operators would make the
> > code
> > more compact and help ensuring thar cases don't follow through the
> > cracks. For example:
> 
> At the top of the function, why not just do:
> 
>      if (swapBytes && type == GL_UNSIGNED_INT_8_8_8_8)
>          type = GL_UNSIGNED_INT_8_8_8_8_REV;
>      else if (swapBytes && type == GL_UNSIGNED_INT_8_8_8_8_REV)
>          type = GL_UNSIGNED_INT_8_8_8_8;

I tought that too. But one would need to toggle swapBytes too, to avoid considering swapBytes twice (e.g., in BGRA vs RGBA), and then you'd also need to make sure that all paths can handle the toggled swapBytes...

Jose


More information about the mesa-dev mailing list