Chromium Code Reviews| Index: src/codec/SkRawCodec.cpp |
| diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp |
| index f400b19d89ed0b4eb6a6dba3afedc316d9bf8e5e..faba5d4f00dc9566841d4e2fdbd127e9cf105f3f 100644 |
| --- a/src/codec/SkRawCodec.cpp |
| +++ b/src/codec/SkRawCodec.cpp |
| @@ -267,10 +267,13 @@ private: |
| return false; |
| } |
| - const size_t sizeToRead = newSize - fStreamBuffer.bytesWritten(); |
| - SkAutoTMalloc<uint8> tempBuffer(sizeToRead); |
| + // Try to read at least 256 bytes to avoid to many small reads. |
|
adaubert
2016/01/28 14:20:25
FYI: In Snapseed we usually read 8192, same applie
yujieqin
2016/01/28 14:27:44
I don't have preference here. msarett@ & scroggo@,
msarett
2016/01/28 16:23:44
I guess how much we need really depends on the ima
scroggo
2016/01/28 16:49:58
As Matt suggested, the ideal number will depend on
msarett
2016/01/28 17:00:35
In the case that Piex can find a preview, I think
|
| + const size_t minSizeToRead = 256; |
|
scroggo
2016/01/28 16:49:57
nit: This is effectively a constant, which we woul
yujieqin
2016/02/01 16:25:19
Done.
|
| + const size_t sizeMustRead = newSize - fStreamBuffer.bytesWritten(); |
|
scroggo
2016/01/28 16:49:58
nit: These names don't distinguish themselves very
yujieqin
2016/02/01 16:25:19
Done.
|
| + const size_t sizeToRead = SkTMax(minSizeToRead, sizeMustRead); |
| + SkAutoSTMalloc<minSizeToRead, uint8> tempBuffer(sizeToRead); |
| const size_t bytesRead = fStream->read(tempBuffer.get(), sizeToRead); |
| - if (bytesRead != sizeToRead) { |
| + if (bytesRead < sizeMustRead) { |
| return false; |
| } |
| return fStreamBuffer.write(tempBuffer.get(), bytesRead); |
| @@ -438,9 +441,6 @@ private: |
| SkCodec* SkRawCodec::NewFromStream(SkStream* stream) { |
| SkAutoTDelete<SkRawStream> rawStream(new SkRawStream(stream)); |
| ::piex::PreviewImageData imageData; |
| - // FIXME: ::piex::GetPreviewImageData() calls GetData() frequently with small amounts, |
| - // resulting in many calls to bufferMoreData(). Could we make this more efficient by grouping |
| - // smaller requests together? |
| if (::piex::IsRaw(rawStream.get())) { |
| ::piex::Error error = ::piex::GetPreviewImageData(rawStream.get(), &imageData); |