Fix dead-lock issue attempting to decode

During serialization, if DecodingImageGenerator::onRefEncodedData()
returns nullptr, this may require the serialization code to decode so
it can have something to then encode and serialize.

This can cause a deadlock if the DecodingImageGenerator is using
discardable memory, which cannot be used from certain threads (where
serialization may be occurring).

Currently, onRefEncodedData() returns nullptr if !m_allDataReceived.
This was to fix crbug.com/568016, but that has been further fixed by
crrev.com/1970773002, which avoids calling onRefEncodedData() to pass
it to the GPU, since even if m_allDataReceived is true, we do not yet
support any GPU texture formats.

This change returns the encoded data even if the data has not all been
received, except if the GrContext argument is not NULL for the future
when the GPU starts calling it again.

This will result in serializing the existing data and avoid the
deadlock.

BUG=607227,623475

Review-Url: https://codereview.chromium.org/2108163003
Cr-Commit-Position: refs/heads/master@{#402963}
1 file changed