aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkFrontBufferedStream.cpp
Commit message (Collapse)AuthorAge
* Allow SkStream::peek() to partially succeedGravatar scroggo2015-12-07
| | | | | | | | | | | | | | | | | | | | 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 Review URL: https://codereview.chromium.org/1490923005
* Style Change: NULL->nullptrGravatar halcanary2015-08-27
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316233002 Review URL: https://codereview.chromium.org/1316233002
* Style Change: SkNEW->new; SkDELETE->deleteGravatar halcanary2015-08-26
| | | | | | DOCS_PREVIEW= https://skia.org/?cl=1316123003 Review URL: https://codereview.chromium.org/1316123003
* Add a method to read a stream without advancing it.Gravatar scroggo2015-04-02
| | | | | | | | | | | | | | | | | | | | | Add a virtual method on SkStream which will do a "peek" some bytes, so that those bytes are read, but the next call to read will be unaffected. Implement peek for SkMemoryStream, where the implementation is simple and obvious. Implement peek on SkFrontBufferedStream. Add tests. Motivated by decoding streams which cannot be rewound. TBR=reed@google.com BUG=skia:3257 Review URL: https://codereview.chromium.org/1044953002
* C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla}Gravatar mtklein2015-03-25
| | | | | | | | | NOPRESUBMIT=true BUG=skia: DOCS_PREVIEW= https://skia.org/?cl=1037793002 Review URL: https://codereview.chromium.org/1037793002
* Make SkStream *not* ref counted.Gravatar scroggo2015-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SkStream is a stateful object, so it does not make sense for it to have multiple owners. Make SkStream inherit directly from SkNoncopyable. Update methods which previously called SkStream::ref() (e.g. SkImageDecoder::buildTileIndex() and SkFrontBufferedStream::Create(), which required the existing owners to call SkStream::unref()) to take ownership of their SkStream parameters and delete when done (including on failure). Switch all SkAutoTUnref<SkStream>s to SkAutoTDelete<SkStream>s. In some cases this means heap allocating streams that were previously stack allocated. Respect ownership rules of SkTypeface::CreateFromStream() and SkImageDecoder::buildTileIndex(). Update the comments for exceptional methods which do not affect the ownership of their SkStream parameters (e.g. SkPicture::CreateFromStream() and SkTypeface::Deserialize()) to be explicit about ownership. Remove test_stream_life, which tested that buildTileIndex() behaved correctly when SkStream was a ref counted object. The test does not make sense now that it is not. In SkPDFStream, remove the SkMemoryStream member. Instead of using it, create a new SkMemoryStream to pass to fDataStream (which is now an SkAutoTDelete). Make other pdf rasterizers behave like SkPDFDocumentToBitmap. SkPDFDocumentToBitmap delete the SkStream, so do the same in the following pdf rasterizers: SkPopplerRasterizePDF SkNativeRasterizePDF SkNoRasterizePDF Requires a change to Android, which currently treats SkStreams as ref counted objects. Review URL: https://codereview.chromium.org/849103004
* Fix up all the easy virtual ... SK_OVERRIDE cases.Gravatar mtklein2015-01-09
| | | | | | | | | | | | This fixes every case where virtual and SK_OVERRIDE were on the same line, which should be the bulk of cases. We'll have to manually clean up the rest over time unless I level up in regexes. for f in (find . -type f); perl -p -i -e 's/virtual (.*)SK_OVERRIDE/\1SK_OVERRIDE/g' $f; end BUG=skia: Review URL: https://codereview.chromium.org/806653007
* Check SkStream::isAtEnd before attempting to read.Gravatar scroggo2014-10-21
| | | | | | | | | | In FrontBufferedStream, when attempting to read and buffer more data, do not try to read if the underlying stream is at the end. Prevents a bug where we continue trying to read a stream that has nothing more to read. Review URL: https://codereview.chromium.org/665303002
* Add an assert that we still have a buffer to readFromBuffer().Gravatar mtklein2014-10-21
| | | | | | | | sk_free(fBuffer.detach()) means fBuffer will be left as NULL, not a zero-length malloc. BUG=skia: Review URL: https://codereview.chromium.org/669813002
* Allow buffered stream to work with an offset.Gravatar commit-bot@chromium.org2014-02-10
| | | | | | | | | | | | | | If the stream being buffered is buffered from somewhere other than the start, the SkFrontBufferedStream needs to take that into account when reporting its length. R=djsollen@google.com, bungeman@google.com, reed@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/157103002 git-svn-id: http://skia.googlecode.com/svn/trunk@13388 2bbb7eff-a529-9590-31e7-b0007b416f81
* Hide implementation details: SkFrontBufferedStreamGravatar scroggo@google.com2013-11-12
| | | | | | | | R=reed@google.com Review URL: https://codereview.chromium.org/25581002 git-svn-id: http://skia.googlecode.com/svn/trunk@12256 2bbb7eff-a529-9590-31e7-b0007b416f81
* Fix a warning.Gravatar scroggo@google.com2013-09-26
| | | | git-svn-id: http://skia.googlecode.com/svn/trunk@11489 2bbb7eff-a529-9590-31e7-b0007b416f81
* Add a buffered SkStream class.Gravatar scroggo@google.com2013-09-26
This is used by Android to buffer an input stream which may not otherwise be able to rewind. Add a test for the new class. R=bungeman@google.com, mtklein@google.com, reed@google.com Review URL: https://codereview.chromium.org/23717055 git-svn-id: http://skia.googlecode.com/svn/trunk@11488 2bbb7eff-a529-9590-31e7-b0007b416f81