DescriptionRefactor ImageDecoder factories
The vast majority of ImageDecoder::create clients do something along
these lines:
sniffResult = ImageDecoder::determineImageType(data);
decoder = ImageDecoder::create(sniffResult, ...);
if (decoder)
decoder->setData(data, ...);
I.e.
1) we start off with some data in a SharedBuffer
2) we call determineImageType() on that data, to figure the codec type
3) we instantiate the decoder
4) and, finally, we pass the data to the new decoder using setData()
The downsides are
a) determineImageType() allocates a temporary SegmentReader in order
to use FastSegmentReader for signature consolidation; this reader is
then thrown away and recreated in setData() (because internally
ImageDecoder stores a SegmentReader).
b) unnecessarily verbose/stateful decoder construction sequence
This CL expands the create() factory to fuse all these steps. We get
to reuse a single SegmentReader, and the construction is now atomic.
We also get to remove determineImageType from the public ImageDecoder
API.
Refactoring only, no functional changes expected.
Committed: https://crrev.com/9e2e0f5824975f43ad9374ea5e97100b77925fc1
Cr-Commit-Position: refs/heads/master@{#413736}
Patch Set 1 #Patch Set 2 : rebased #Patch Set 3 : cleanup #
Total comments: 15
Patch Set 4 : review #Patch Set 5 : review #Messages
Total messages: 41 (31 generated)
|