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

Unified Diff: src/codec/SkRawCodec.cpp

Issue 1644893003: Avoid too small reads to bufferMoreData() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698