Consolidate SkStream copying methods

Make SkCopyStreamToData call SkStreamCopy, removing duplicate code.

The former still has its own method of copying with a length, since
it saves one copy.

BUG=skia:4788
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1640793002

Review URL: https://codereview.chromium.org/1640793002
This commit is contained in:
scroggo 2016-01-27 10:51:56 -08:00 committed by Commit bot
parent 2bbc343c14
commit 440c5a98de

View File

@ -890,12 +890,9 @@ SkData* SkCopyStreamToData(SkStream* stream) {
}
SkDynamicMemoryWStream tempStream;
const size_t bufferSize = 4096;
char buffer[bufferSize];
do {
size_t bytesRead = stream->read(buffer, bufferSize);
tempStream.write(buffer, bytesRead);
} while (!stream->isAtEnd());
if (!SkStreamCopy(&tempStream, stream)) {
return nullptr;
}
return tempStream.copyToData();
}