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

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

Issue 387863005: Move SkPDFStream back to SkStream to save memory. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simpler changes Created 6 years, 5 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
« no previous file with comments | « no previous file | src/core/SkStreamPriv.h » ('j') | src/pdf/SkPDFStream.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 900
901 SkDynamicMemoryWStream tempStream; 901 SkDynamicMemoryWStream tempStream;
902 const size_t bufferSize = 4096; 902 const size_t bufferSize = 4096;
903 char buffer[bufferSize]; 903 char buffer[bufferSize];
904 do { 904 do {
905 size_t bytesRead = stream->read(buffer, bufferSize); 905 size_t bytesRead = stream->read(buffer, bufferSize);
906 tempStream.write(buffer, bytesRead); 906 tempStream.write(buffer, bytesRead);
907 } while (!stream->isAtEnd()); 907 } while (!stream->isAtEnd());
908 return tempStream.copyToData(); 908 return tempStream.copyToData();
909 } 909 }
910
911 SkStreamRewindable* SkStreamToStreamRewindable(SkStream* stream) {
bungeman-skia 2014/07/11 21:43:38 I would prefer this to be SkStreamRewindableFromSk
hal.canary 2014/07/12 00:58:49 Done.
912 if (!stream) {
913 return NULL;
914 }
915 SkAutoTUnref<SkStreamRewindable> dupStream(stream->duplicate());
916 if (dupStream) {
917 return dupStream.detach();
918 }
919 if (stream->hasLength()) {
920 size_t length = stream->getLength();
921 SkAutoMalloc allocMemory(length);
922 SkAssertResult(stream->rewind());
bungeman-skia 2014/07/11 21:43:38 I wouldn't assert this, just because a stream has
hal.canary 2014/07/12 00:58:49 Done.
923 SkAssertResult(length == stream->read(allocMemory.get(), length));
924 SkAssertResult(stream->rewind());
bungeman-skia 2014/07/11 21:43:38 I see no reason to try to leave this in a known st
hal.canary 2014/07/12 00:58:49 Done.
925 SkAutoTUnref<SkData> data(
926 SkData::NewFromMalloc(allocMemory.get(), length));
927 return SkNEW_ARGS(SkMemoryStream, (data.get()));
928 }
929 SkAssertResult(stream->rewind());
930 SkDynamicMemoryWStream tempStream;
931 const size_t bufferSize = 4096;
932 char buffer[bufferSize];
933 do {
934 size_t bytesRead = stream->read(buffer, bufferSize);
935 tempStream.write(buffer, bytesRead);
936 } while (!stream->isAtEnd());
937 SkAssertResult(stream->rewind());
bungeman-skia 2014/07/11 21:43:38 Same as above (line 924), I see no reason to try t
hal.canary 2014/07/12 00:58:49 Done.
938 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream,
939 // cheaper than copying to SkData
940 }
OLDNEW
« no previous file with comments | « no previous file | src/core/SkStreamPriv.h » ('j') | src/pdf/SkPDFStream.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698