Index: src/codec/SkRawCodec.cpp |
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp |
index c7de3172863876cdbf1ec0e2d5a2d0111e6ddc3f..da3c28c549ff617cc74df0effb9ff18177eca023 100644 |
--- a/src/codec/SkRawCodec.cpp |
+++ b/src/codec/SkRawCodec.cpp |
@@ -267,13 +267,10 @@ |
return false; |
} |
- // Try to read at least 8192 bytes to avoid to many small reads. |
- const size_t kMinSizeToRead = 8192; |
- const size_t sizeRequested = newSize - fStreamBuffer.bytesWritten(); |
- const size_t sizeToRead = SkTMax(kMinSizeToRead, sizeRequested); |
- SkAutoSTMalloc<kMinSizeToRead, uint8> tempBuffer(sizeToRead); |
+ const size_t sizeToRead = newSize - fStreamBuffer.bytesWritten(); |
+ SkAutoTMalloc<uint8> tempBuffer(sizeToRead); |
const size_t bytesRead = fStream->read(tempBuffer.get(), sizeToRead); |
- if (bytesRead < sizeRequested) { |
+ if (bytesRead != sizeToRead) { |
return false; |
} |
return fStreamBuffer.write(tempBuffer.get(), bytesRead); |
@@ -441,6 +438,9 @@ |
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); |