Sanitize bitmaps produced by libgif

Motivation: fix the bug linked to below.

Some rare GIFs in the wild have a color table of size smaller than 256
and have one or more pixels with values that index out side of the
colortable.  Since it would be expensive to check the index every time
we do a color lookup, we sanitize it at the source, in
SkImageDecoder_libgif.cpp.  The new function sanitize_indexed_bitmap
checks each pixel to see if the index is outside of its allowed mask,
and if so, sets that pixel to point at color 0.

The bit mask optimization in this function relies on the fact that GIF
requires the color table size to be a power of 2.

To test:

	$ skia_images_gif_suppressDecoderWarnings=0 \
		..../render_pictures \
		--bbh grid 256 256 --clone 1 --config 8888 --mode tile 256 256 \
	    -r ..../http___www_cafe24_com_.skp -w /tmp

	This should show verbose errors.

BUG=skia:1946
R=robertphillips@google.com

Review URL: https://codereview.chromium.org/103343006

git-svn-id: http://skia.googlecode.com/svn/trunk@12786 2bbb7eff-a529-9590-31e7-b0007b416f81
1 file changed