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

Unified Diff: src/images/SkStreamHelpers.cpp

Issue 340783013: Switch SkPDFStream's internal storage from SkStream to SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 6 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 | « src/images/SkStreamHelpers.h ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkStreamHelpers.cpp
diff --git a/src/images/SkStreamHelpers.cpp b/src/images/SkStreamHelpers.cpp
deleted file mode 100644
index c7c66b4b0fa95fa2e8398c84ba1165d674082aac..0000000000000000000000000000000000000000
--- a/src/images/SkStreamHelpers.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkData.h"
-#include "SkStream.h"
-#include "SkStreamHelpers.h"
-#include "SkTypes.h"
-
-size_t CopyStreamToStorage(SkAutoMalloc* storage, SkStream* stream) {
- SkASSERT(storage != NULL);
- SkASSERT(stream != NULL);
-
- 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.
- const size_t bufferSize = 256 * 1024; // 256KB
- 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;
-}
-
-SkData *CopyStreamToData(SkStream* stream) {
- SkASSERT(stream != NULL);
-
- if (stream->hasLength()) {
- const size_t length = stream->getLength();
- void* dst = sk_malloc_throw(length);
- if (stream->read(dst, length) != length) {
- return 0;
- }
- return SkData::NewFromMalloc(dst, length);
- }
-
- SkDynamicMemoryWStream tempStream;
- // Arbitrary buffer size.
- const size_t bufferSize = 256 * 1024; // 256KB
- 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());
- return tempStream.copyToData();
-}
« no previous file with comments | « src/images/SkStreamHelpers.h ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698