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

Side by Side Diff: src/core/SkStream.cpp

Issue 1298243002: SkPDF/Deflate: clean up old SkFlate code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-18 (Tuesday) 16:19:01 EDT Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkStream.h" 10 #include "SkStream.h"
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 SkDynamicMemoryWStream tempStream; 943 SkDynamicMemoryWStream tempStream;
944 const size_t bufferSize = 4096; 944 const size_t bufferSize = 4096;
945 char buffer[bufferSize]; 945 char buffer[bufferSize];
946 do { 946 do {
947 size_t bytesRead = stream->read(buffer, bufferSize); 947 size_t bytesRead = stream->read(buffer, bufferSize);
948 tempStream.write(buffer, bytesRead); 948 tempStream.write(buffer, bytesRead);
949 } while (!stream->isAtEnd()); 949 } while (!stream->isAtEnd());
950 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, 950 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream,
951 // cheaper than copying to SkData 951 // cheaper than copying to SkData
952 } 952 }
953
954 bool SkStreamCopy(SkWStream* out, SkStream* input) {
955 const char* base = static_cast<const char*>(input->getMemoryBase());
956 if (base && input->hasPosition() && input->hasLength()) {
957 // Shortcut that avoids the while loop.
958 size_t position = input->getPosition();
959 size_t length = input->getLength();
960 SkASSERT(length >= position);
961 return out->write(&base[position], length - position);
962 }
963 char scratch[4096];
964 size_t count;
965 while (true) {
966 count = input->read(scratch, sizeof(scratch));
967 if (0 == count) {
968 return true;
969 }
970 if (!out->write(scratch, count)) {
971 return false;
972 }
973 }
974 }
OLDNEW
« no previous file with comments | « gyp/tests.gypi ('k') | src/core/SkStreamPriv.h » ('j') | tests/StreamTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698