do not merge

read/write fDither in flattening/unflatten, otherwise it is uninitialized

http://b/issue?id=2187714&query=2187714

ImageRefs get flattened by the picture code when we serialize a picture, which we do sometimes
in the browser so we can unserialize it and show something right away after the browser has been
killed (due to low-memory).

With this dither field uninitialized, we pass it down to the SkImageDecoder_libpng.cpp, by way of
calling setDitherImage() on the codec. Now the codec has this random value. It, in turn, passes it
to the ScaledBitmapSampler, which says the follow, as it computes an index into a table of
function pointers.

int index = 0;
if (dither) {
    index += 1;
}

GCC (at least the current 4.4 version) has optimized that into just (effectively)

    index = dither;

Thus the index is some random value, and hence the wacky functions that sometimes appear in the
stack traces when we crash, since we walk off the end of the local function-ptr table and load
some other function-ptr.

This change (read/write the dither value from/to the stream) was recently added to MR2, fixing a
bug where we lost the dithering (i.e. the random value turned out to be 0, and the caller expected
1)
1 file changed