texture: average and constant color handling

New get_texture_info queries:
* "averagecolor", "averagealpha" -- retrieve the average color/alpha of
  a texture. (Fail the query if there was no metadata giving this
  information -- we do NOT compute an expensive average of the whole
  texture on the fly. It happens at maketx time or not at all.)
* "constantcolor", "constantalpha" -- retrieve the value of color/alpha if
  it's a texture with the same value in all pixels, fail the query if it's
  not known to be a constant-valued texture.

maketx is modified to compute the average color and store it in the
metadata, also minor tweaks to the existing functionality where it
stores whether/if it's a constant-valued texture. There is some
refinement and refactoring of how these metadata are stored and
retrieved.

If average color is requested by get_texture_info, it's trivial if the
texture was created by the new maketx that embeds the metadata. If not
(if it's an "old" texture), it will lazily retrieve the 1x1 MIPmap level
and use the value of that single pixel (which should be a reasonably
accurate average of the whole original input texture) to initialize the
average. If it neither has the metadata nor is a MIPmap with a 1x1 level,
then the query will fail.

We also modify texture calls to take a significant shortcut if doing
texture lookups on a constant-valued texture (as long as the wrap mode
is not black!), and this turns out to speed up texture lookups on
constant-valued textures by a factor of 10!

New stat to say how many textures were constant.