Revert "Make SkPngCodec only read as much of the stream as necessary"

This reverts commit 2c65d5161260f3d45a63dcd92229bd09c8a12d53.

Reason for revert: Causing failures in Google3 ( and differences in Gold. This change was not intended to change the output.

Original change's description:
> Make SkPngCodec only read as much of the stream as necessary
> Previously, SkPngCodec assumed that the stream only contained one
> image, which ended at the end of the stream. It read the stream in
> arbitrarily-sized chunks, and then passed that data to libpng for
> processing.
> If a stream contains more than one image, this may result in reading
> beyond the end of the image, making future reads read the wrong data.
> Now, SkPngCodec starts by reading 8 bytes at a time. After the
> signature, 8 bytes is enough to know which chunk is next and how many
> bytes are in the chunk.
> When decoding the size, we stop when we reach IDAT, and when decoding
> the image, we stop when we reach IEND.
> This manual parsing is necessary to support APNG, which is planned in
> the future. It also allows us to remove the SK_GOOGLE3_PNG_HACK, which
> was a workaround for reading more than necessary at the beginning of
> the image.
> Add a test that simulates the issue, by decoding a special stream that
> reports an error if the codec attempts to read beyond the end.
> Temporarily disable the partial decoding tests for png. A larger change
> will be necessary to get those working again, and no clients are
> currently relying on incrementally decoding PNGs (i.e. decode part of
> an image, then decode further with more data).
> Bug: skia:5368
> BUG:34073812
> Change-Id: If832f7b20565411226fb5be3c305a4d16bf9269d
> Reviewed-on:
> Commit-Queue: Leon Scroggins <>
> Reviewed-by: Matt Sarett <>

Change-Id: I2f82e9960dda7bf5c646774df84320dadb7b930e
Reviewed-by: Leon Scroggins <>
Commit-Queue: Leon Scroggins <>
5 files changed