DescriptionMake SkCodec support peek() and read()
- Update SkCodec's dox to point out that some of the data must be
read twice in order to decode
- Add an accessor that reports how much is needed for reading twice
- Make SkCodec default to use peek()
If an input stream supports peek()ing, peek() instead of reading.
This way the stream need not implement rewind()
- Make SkCodec use read() + rewind() as a backup
So that streams without peek() implemented can still function
properly (assuming they can rewind).
- read everything we may need to determine the format once
In SkCodec::NewFromStream, peek()/read() 14 bytes, which is enough
to read all of the types we support. Pass the buffer to each subtype,
which will have enough info to determine whether it is the right
type. This simplifies the code and results in less reading and
rewinding.
- NOTE: SkWbmpCodec needs the following number of bytes for the header
+ 1 (type)
+ 1 (reserved)
+ 3 (width - bytes needed to support up to 0xFFFF)
+ 3 (height - bytes needed to support up to 0xFFFF)
= 8
- in SkWebpCodec, support using read + rewind as a backup if peek does
not work.
A change in Android will add peek() to JavaInputStreamAdapter.
BUG=skia:3257
Committed: https://skia.googlesource.com/skia/+/db30be2f9470d21fe37b63d145c1fcca9a6ad98c
Patch Set 1 #Patch Set 2 : Separate out wbmp second byte change #Patch Set 3 : Make IsWbmp call read_header #
Total comments: 7
Patch Set 4 : Update comment. Add tests #
Total comments: 2
Patch Set 5 : Call peek() that returns a size_t #Patch Set 6 : Update SkWebpCodec #
Total comments: 2
Patch Set 7 : Add comments, test, and accessor for needed buffer bytes #
Total comments: 8
Patch Set 8 : Respond to reed's comments in patch set 7 #Patch Set 9 : Rebase #
Messages
Total messages: 26 (12 generated)
|