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

Issue 1490923005: Allow SkStream::peek() to partially succeed (Closed)

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

Description

Allow SkStream::peek() to partially succeed If the stream can peek less than requested, peek that amount. Return the number of bytes peeked. This simplifies crrev.com/1472123002. For a stream that is smaller than 14 bytes, it can successfully peek, meaning the client will not need to fall back to read() + rewind(), which may fail if the stream can peek but not rewind. This CL revives code from patch set 3 of crrev.com/1044953002, where I initially introduced peek() (including tests). Add a test for SkFrontBufferedStream that verifies that peeking does not make rewind() fail (i.e. by reading past the internal buffer). BUG=skia:3257 Committed: https://skia.googlesource.com/skia/+/d61c384342aaf7facf31b948db98acc32d81d21b

Patch Set 1 #

Total comments: 14

Patch Set 2 : Respond to Ben's comments in patch set 1 #

Total comments: 2

Patch Set 3 : Remove whitespace #

Total comments: 2

Patch Set 4 : Use the correct return type #

Unified diffs Side-by-side diffs Delta from patch set Stats (+93 lines, -55 lines) Patch
M include/core/SkStream.h View 1 2 2 chunks +9 lines, -8 lines 0 comments Download
M src/core/SkStream.cpp View 1 2 chunks +15 lines, -18 lines 0 comments Download
M src/utils/SkFrontBufferedStream.cpp View 2 chunks +10 lines, -8 lines 0 comments Download
M tests/StreamTest.cpp View 1 2 3 7 chunks +59 lines, -21 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 21 (6 generated)
scroggo
5 years ago (2015-12-04 22:25:14 UTC) #2
reed1
Do we have to comment-out the parameter names (hard to read) ?
5 years ago (2015-12-07 14:43:58 UTC) #3
msarett
On 2015/12/07 14:43:58, reed1 wrote: > Do we have to comment-out the parameter names (hard ...
5 years ago (2015-12-07 15:41:03 UTC) #4
scroggo
On 2015/12/07 15:41:03, msarett wrote: > On 2015/12/07 14:43:58, reed1 wrote: > > Do we ...
5 years ago (2015-12-07 16:03:45 UTC) #5
bungeman-skia
https://codereview.chromium.org/1490923005/diff/1/src/core/SkStream.cpp File src/core/SkStream.cpp (right): https://codereview.chromium.org/1490923005/diff/1/src/core/SkStream.cpp#newcode373 src/core/SkStream.cpp:373: if (this->isAtEnd()) { This block seems redundant, though maybe ...
5 years ago (2015-12-07 16:17:36 UTC) #6
scroggo
https://codereview.chromium.org/1490923005/diff/1/src/core/SkStream.cpp File src/core/SkStream.cpp (right): https://codereview.chromium.org/1490923005/diff/1/src/core/SkStream.cpp#newcode373 src/core/SkStream.cpp:373: if (this->isAtEnd()) { On 2015/12/07 16:17:36, bungeman1 wrote: > ...
5 years ago (2015-12-07 16:52:02 UTC) #7
bungeman-skia
lgtm with nit https://codereview.chromium.org/1490923005/diff/20001/include/core/SkStream.h File include/core/SkStream.h (right): https://codereview.chromium.org/1490923005/diff/20001/include/core/SkStream.h#newcode79 include/core/SkStream.h:79: virtual size_t peek(void* /* buffer */, ...
5 years ago (2015-12-07 17:33:02 UTC) #8
scroggo
https://codereview.chromium.org/1490923005/diff/20001/include/core/SkStream.h File include/core/SkStream.h (right): https://codereview.chromium.org/1490923005/diff/20001/include/core/SkStream.h#newcode79 include/core/SkStream.h:79: virtual size_t peek(void* /* buffer */, size_t /* size ...
5 years ago (2015-12-07 18:10:32 UTC) #9
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1490923005/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1490923005/40001
5 years ago (2015-12-07 18:35:12 UTC) #11
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: Build-Win-MSVC-x86-Debug-Trybot on client.skia.compile (JOB_FAILED, http://build.chromium.org/p/client.skia.compile/builders/Build-Win-MSVC-x86-Debug-Trybot/builds/4638)
5 years ago (2015-12-07 18:37:36 UTC) #13
bungeman-skia
https://codereview.chromium.org/1490923005/diff/40001/tests/StreamTest.cpp File tests/StreamTest.cpp (right): https://codereview.chromium.org/1490923005/diff/40001/tests/StreamTest.cpp#newcode225 tests/StreamTest.cpp:225: return bytesRead - bytesPeeked; SkToBool
5 years ago (2015-12-07 18:40:24 UTC) #14
scroggo
Mike, can I get an API review? https://codereview.chromium.org/1490923005/diff/40001/tests/StreamTest.cpp File tests/StreamTest.cpp (right): https://codereview.chromium.org/1490923005/diff/40001/tests/StreamTest.cpp#newcode225 tests/StreamTest.cpp:225: return bytesRead ...
5 years ago (2015-12-07 18:43:40 UTC) #15
reed1
lgtm
5 years ago (2015-12-07 19:12:54 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1490923005/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1490923005/60001
5 years ago (2015-12-07 19:22:42 UTC) #19
commit-bot: I haz the power
5 years ago (2015-12-07 19:37:15 UTC) #21
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as
https://skia.googlesource.com/skia/+/d61c384342aaf7facf31b948db98acc32d81d21b

Powered by Google App Engine
This is Rietveld 408576698