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

Side by Side Diff: src/utils/SkFrontBufferedStream.cpp

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) Created 4 years, 9 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/utils/SkCanvasStateUtils.cpp ('k') | src/utils/win/SkDWriteFontFileStream.cpp » ('j') | 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 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkFrontBufferedStream.h" 8 #include "SkFrontBufferedStream.h"
9 #include "SkStream.h" 9 #include "SkStream.h"
10 #include "SkTemplates.h" 10 #include "SkTemplates.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 SkASSERT(size > 0); 140 SkASSERT(size > 0);
141 // If we get here, we have buffered all that can be buffered. 141 // If we get here, we have buffered all that can be buffered.
142 SkASSERT(fBufferSize == fBufferedSoFar && fOffset >= fBufferSize); 142 SkASSERT(fBufferSize == fBufferedSoFar && fOffset >= fBufferSize);
143 143
144 const size_t bytesReadDirectly = fStream->read(dst, size); 144 const size_t bytesReadDirectly = fStream->read(dst, size);
145 fOffset += bytesReadDirectly; 145 fOffset += bytesReadDirectly;
146 146
147 // If we have read past the end of the buffer, rewinding is no longer 147 // If we have read past the end of the buffer, rewinding is no longer
148 // supported, so we can go ahead and free the memory. 148 // supported, so we can go ahead and free the memory.
149 if (bytesReadDirectly > 0) { 149 if (bytesReadDirectly > 0) {
150 sk_free(fBuffer.detach()); 150 sk_free(fBuffer.release());
151 } 151 }
152 152
153 return bytesReadDirectly; 153 return bytesReadDirectly;
154 } 154 }
155 155
156 size_t FrontBufferedStream::peek(void* dst, size_t size) const { 156 size_t FrontBufferedStream::peek(void* dst, size_t size) const {
157 // Keep track of the offset so we can return to it. 157 // Keep track of the offset so we can return to it.
158 const size_t start = fOffset; 158 const size_t start = fOffset;
159 159
160 if (start >= fBufferSize) { 160 if (start >= fBufferSize) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 204
205 if (size > 0 && !fStream->isAtEnd()) { 205 if (size > 0 && !fStream->isAtEnd()) {
206 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size); 206 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size);
207 SkDEBUGCODE(size -= bytesReadDirectly;) 207 SkDEBUGCODE(size -= bytesReadDirectly;)
208 SkASSERT(size + (fOffset - start) == totalSize); 208 SkASSERT(size + (fOffset - start) == totalSize);
209 } 209 }
210 210
211 return fOffset - start; 211 return fOffset - start;
212 } 212 }
OLDNEW
« no previous file with comments | « src/utils/SkCanvasStateUtils.cpp ('k') | src/utils/win/SkDWriteFontFileStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698