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

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

Issue 563273003: remove confusing/unused stream methods (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 if (SK_BYTE_SENTINEL_FOR_U16 == byte) { 58 if (SK_BYTE_SENTINEL_FOR_U16 == byte) {
59 return this->readU16(); 59 return this->readU16();
60 } else if (SK_BYTE_SENTINEL_FOR_U32 == byte) { 60 } else if (SK_BYTE_SENTINEL_FOR_U32 == byte) {
61 return this->readU32(); 61 return this->readU32();
62 } else { 62 } else {
63 return byte; 63 return byte;
64 } 64 }
65 } 65 }
66 66
67 SkData* SkStream::readData() {
68 size_t size = this->readU32();
69 if (0 == size) {
70 return SkData::NewEmpty();
71 } else {
72 SkData* data = SkData::NewUninitialized(size);
73 this->read(data->writable_data(), size);
74 return data;
75 }
76 }
77
78 //////////////////////////////////////////////////////////////////////////////// ////// 67 //////////////////////////////////////////////////////////////////////////////// //////
79 68
80 SkWStream::~SkWStream() 69 SkWStream::~SkWStream()
81 { 70 {
82 } 71 }
83 72
84 void SkWStream::newline() 73 void SkWStream::newline()
85 { 74 {
86 this->write("\n", 1); 75 this->write("\n", 1);
87 } 76 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 171 }
183 stream->read(scratch, n); 172 stream->read(scratch, n);
184 if (!this->write(scratch, n)) { 173 if (!this->write(scratch, n)) {
185 return false; 174 return false;
186 } 175 }
187 length -= n; 176 length -= n;
188 } 177 }
189 return true; 178 return true;
190 } 179 }
191 180
192 bool SkWStream::writeData(const SkData* data) {
193 if (data) {
194 this->write32(SkToU32(data->size()));
195 this->write(data->data(), data->size());
196 } else {
197 this->write32(0);
198 }
199 return true;
200 }
201
202 /////////////////////////////////////////////////////////////////////////////// 181 ///////////////////////////////////////////////////////////////////////////////
203 182
204 SkFILEStream::SkFILEStream(const char file[]) : fName(file), fOwnership(kCallerP asses_Ownership) { 183 SkFILEStream::SkFILEStream(const char file[]) : fName(file), fOwnership(kCallerP asses_Ownership) {
205 fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : NULL; 184 fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : NULL;
206 } 185 }
207 186
208 SkFILEStream::SkFILEStream(FILE* file, Ownership ownership) 187 SkFILEStream::SkFILEStream(FILE* file, Ownership ownership)
209 : fFILE((SkFILE*)file) 188 : fFILE((SkFILE*)file)
210 , fOwnership(ownership) { 189 , fOwnership(ownership) {
211 } 190 }
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 SkDynamicMemoryWStream tempStream; 910 SkDynamicMemoryWStream tempStream;
932 const size_t bufferSize = 4096; 911 const size_t bufferSize = 4096;
933 char buffer[bufferSize]; 912 char buffer[bufferSize];
934 do { 913 do {
935 size_t bytesRead = stream->read(buffer, bufferSize); 914 size_t bytesRead = stream->read(buffer, bufferSize);
936 tempStream.write(buffer, bytesRead); 915 tempStream.write(buffer, bytesRead);
937 } while (!stream->isAtEnd()); 916 } while (!stream->isAtEnd());
938 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, 917 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream,
939 // cheaper than copying to SkData 918 // cheaper than copying to SkData
940 } 919 }
OLDNEW
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698