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

Unified Diff: src/core/SkStream.cpp

Issue 1604963002: SkStream/Priv cleanups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update header description 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 | src/core/SkStreamPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStream.cpp
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index ef4c6baae437b7c0dd7d780b09bfc852b43377ec..9529308e8689ff135aa77e24dddb7639ec97a812 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -882,42 +882,6 @@ SkStreamAsset* SkStream::NewFromFile(const char path[]) {
}
// Declared in SkStreamPriv.h:
-size_t SkCopyStreamToStorage(SkAutoMalloc* storage, SkStream* stream) {
- SkASSERT(storage != nullptr);
- SkASSERT(stream != nullptr);
-
- if (stream->hasLength()) {
- const size_t length = stream->getLength();
- void* dst = storage->reset(length);
- if (stream->read(dst, length) != length) {
- return 0;
- }
- return length;
- }
-
- SkDynamicMemoryWStream tempStream;
- // Arbitrary buffer size.
-#if defined(GOOGLE3)
- // Stack frame size is limited in GOOGLE3.
- const size_t bufferSize = 8 * 1024; // 8KB
-#else
- const size_t bufferSize = 256 * 1024; // 256KB
-#endif
- char buffer[bufferSize];
- SkDEBUGCODE(size_t debugLength = 0;)
- do {
- size_t bytesRead = stream->read(buffer, bufferSize);
- tempStream.write(buffer, bytesRead);
- SkDEBUGCODE(debugLength += bytesRead);
- SkASSERT(tempStream.bytesWritten() == debugLength);
- } while (!stream->isAtEnd());
- const size_t length = tempStream.bytesWritten();
- void* dst = storage->reset(length);
- tempStream.copyTo(dst);
- return length;
-}
-
-// Declared in SkStreamPriv.h:
SkData* SkCopyStreamToData(SkStream* stream) {
SkASSERT(stream != nullptr);
@@ -935,34 +899,6 @@ SkData* SkCopyStreamToData(SkStream* stream) {
return tempStream.copyToData();
}
-SkStreamRewindable* SkStreamRewindableFromSkStream(SkStream* stream) {
- if (!stream) {
- return nullptr;
- }
- SkAutoTDelete<SkStreamRewindable> dupStream(stream->duplicate());
- if (dupStream) {
- return dupStream.detach();
- }
- stream->rewind();
- if (stream->hasLength()) {
- size_t length = stream->getLength();
- if (stream->hasPosition()) { // If stream has length, but can't rewind.
- length -= stream->getPosition();
- }
- SkAutoTUnref<SkData> data(SkData::NewFromStream(stream, length));
- return new SkMemoryStream(data.get());
- }
- 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());
- return tempStream.detachAsStream(); // returns a SkBlockMemoryStream,
- // cheaper than copying to SkData
-}
-
bool SkStreamCopy(SkWStream* out, SkStream* input) {
const char* base = static_cast<const char*>(input->getMemoryBase());
if (base && input->hasPosition() && input->hasLength()) {
« no previous file with comments | « no previous file | src/core/SkStreamPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698