Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(926)

Issue 1472123002: Make SkCodec support peek() and read() (Closed)

Created:
5 years ago by scroggo
Modified:
5 years ago
Reviewers:
msarett, reed1
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Make 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+171 lines, -76 lines) Patch
M include/codec/SkCodec.h View 1 2 3 4 5 6 7 8 1 chunk +25 lines, -0 lines 0 comments Download
M src/codec/SkBmpCodec.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -5 lines 0 comments Download
M src/codec/SkBmpCodec.cpp View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -4 lines 0 comments Download
M src/codec/SkCodec.cpp View 1 2 3 4 5 6 7 3 chunks +34 lines, -12 lines 0 comments Download
M src/codec/SkCodec_libgif.h View 1 2 3 4 5 6 7 1 chunk +1 line, -5 lines 0 comments Download
M src/codec/SkCodec_libgif.cpp View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -3 lines 0 comments Download
M src/codec/SkCodec_libico.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -5 lines 0 comments Download
M src/codec/SkCodec_libico.cpp View 1 2 3 4 5 6 7 8 2 chunks +3 lines, -6 lines 0 comments Download
M src/codec/SkCodec_libpng.h View 1 chunk +1 line, -1 line 0 comments Download
M src/codec/SkCodec_libpng.cpp View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -11 lines 0 comments Download
M src/codec/SkCodec_wbmp.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M src/codec/SkCodec_wbmp.cpp View 1 2 3 4 5 6 7 2 chunks +5 lines, -2 lines 0 comments Download
M src/codec/SkJpegCodec.h View 1 2 3 4 5 6 7 1 chunk +1 line, -6 lines 0 comments Download
M src/codec/SkJpegCodec.cpp View 1 2 3 4 5 6 7 1 chunk +2 lines, -4 lines 0 comments Download
M src/codec/SkWebpCodec.h View 1 2 3 4 5 6 7 1 chunk +3 lines, -1 line 0 comments Download
M src/codec/SkWebpCodec.cpp View 1 2 3 4 5 6 7 1 chunk +10 lines, -10 lines 0 comments Download
M tests/CodexTest.cpp View 1 2 3 4 5 6 7 8 2 chunks +77 lines, -0 lines 0 comments Download

Messages

Total messages: 26 (12 generated)
scroggo
https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp File src/codec/SkCodec.cpp (right): https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp#newcode46 src/codec/SkCodec.cpp:46: // 14 is enough to read all of the ...
5 years ago (2015-11-25 22:08:35 UTC) #5
msarett
lgtm https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp File src/codec/SkCodec.cpp (right): https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp#newcode46 src/codec/SkCodec.cpp:46: // 14 is enough to read all of ...
5 years ago (2015-11-30 14:08:11 UTC) #6
scroggo
https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp File src/codec/SkCodec.cpp (right): https://codereview.chromium.org/1472123002/diff/40001/src/codec/SkCodec.cpp#newcode46 src/codec/SkCodec.cpp:46: // 14 is enough to read all of the ...
5 years ago (2015-11-30 20:02:31 UTC) #7
scroggo
Please take another look. We should probably update the header's comments, too, describing what to ...
5 years ago (2015-12-01 22:33:49 UTC) #8
scroggo
On 2015/12/01 22:33:49, scroggo wrote: > Please take another look. > > We should probably ...
5 years ago (2015-12-04 22:15:04 UTC) #10
msarett
lgtm https://codereview.chromium.org/1472123002/diff/120001/src/codec/SkCodec.cpp File src/codec/SkCodec.cpp (right): https://codereview.chromium.org/1472123002/diff/120001/src/codec/SkCodec.cpp#newcode52 src/codec/SkCodec.cpp:52: SkASSERT(bytesToRead <= BufferedBytesNeeded()); So we only need 14 ...
5 years ago (2015-12-07 15:29:36 UTC) #11
scroggo
https://codereview.chromium.org/1472123002/diff/120001/src/codec/SkCodec.cpp File src/codec/SkCodec.cpp (right): https://codereview.chromium.org/1472123002/diff/120001/src/codec/SkCodec.cpp#newcode52 src/codec/SkCodec.cpp:52: SkASSERT(bytesToRead <= BufferedBytesNeeded()); On 2015/12/07 15:29:36, msarett wrote: > ...
5 years ago (2015-12-07 16:06:28 UTC) #12
scroggo
Mike, can you take a look at the API?
5 years ago (2015-12-07 21:46:21 UTC) #14
reed1
lgtm https://codereview.chromium.org/1472123002/diff/120001/include/codec/SkCodec.h File include/codec/SkCodec.h (right): https://codereview.chromium.org/1472123002/diff/120001/include/codec/SkCodec.h#newcode39 include/codec/SkCodec.h:39: static size_t BufferedBytesNeeded(); MinBufferedBytesNeeded? https://codereview.chromium.org/1472123002/diff/120001/src/codec/SkBmpCodec.h File src/codec/SkBmpCodec.h (right): ...
5 years ago (2015-12-08 15:04:58 UTC) #15
scroggo
https://codereview.chromium.org/1472123002/diff/120001/include/codec/SkCodec.h File include/codec/SkCodec.h (right): https://codereview.chromium.org/1472123002/diff/120001/include/codec/SkCodec.h#newcode39 include/codec/SkCodec.h:39: static size_t BufferedBytesNeeded(); On 2015/12/08 15:04:57, reed1 wrote: > ...
5 years ago (2015-12-08 18:35:44 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1472123002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1472123002/140001
5 years ago (2015-12-08 18:36:04 UTC) #19
commit-bot: I haz the power
Try jobs failed on following builders: Build-Ubuntu-GCC-Arm64-Debug-Android-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Ubuntu-GCC-Arm64-Debug-Android-Trybot/builds/2972) Build-Ubuntu-GCC-Arm7-Debug-Android-Trybot on client.skia.compile (JOB_FAILED, ...
5 years ago (2015-12-08 18:36:49 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1472123002/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1472123002/160001
5 years ago (2015-12-08 21:36:06 UTC) #24
commit-bot: I haz the power
5 years ago (2015-12-09 02:54:18 UTC) #26
Message was sent while issue was closed.
Committed patchset #9 (id:160001) as
https://skia.googlesource.com/skia/+/db30be2f9470d21fe37b63d145c1fcca9a6ad98c

Powered by Google App Engine
This is Rietveld 408576698