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

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

Issue 1703293002: Remove position from FrontBufferedStream (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix test_peeking_front_buffered_stream Created 4 years, 10 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 | tests/CodexTest.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"
11 11
12 class FrontBufferedStream : public SkStreamRewindable { 12 class FrontBufferedStream : public SkStreamRewindable {
13 public: 13 public:
14 // Called by Create. 14 // Called by Create.
15 FrontBufferedStream(SkStream*, size_t bufferSize); 15 FrontBufferedStream(SkStream*, size_t bufferSize);
16 16
17 size_t read(void* buffer, size_t size) override; 17 size_t read(void* buffer, size_t size) override;
18 18
19 size_t peek(void* buffer, size_t size) const override; 19 size_t peek(void* buffer, size_t size) const override;
20 20
21 bool isAtEnd() const override; 21 bool isAtEnd() const override;
22 22
23 bool rewind() override; 23 bool rewind() override;
24 24
25 bool hasPosition() const override { return true; }
26
27 size_t getPosition() const override { return fOffset; }
28
29 bool hasLength() const override { return fHasLength; } 25 bool hasLength() const override { return fHasLength; }
30 26
31 size_t getLength() const override { return fLength; } 27 size_t getLength() const override { return fLength; }
32 28
33 SkStreamRewindable* duplicate() const override { return nullptr; } 29 SkStreamRewindable* duplicate() const override { return nullptr; }
34 30
35 private: 31 private:
36 SkAutoTDelete<SkStream> fStream; 32 SkAutoTDelete<SkStream> fStream;
37 const bool fHasLength; 33 const bool fHasLength;
38 const size_t fLength; 34 const size_t fLength;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 203 }
208 204
209 if (size > 0 && !fStream->isAtEnd()) { 205 if (size > 0 && !fStream->isAtEnd()) {
210 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size); 206 SkDEBUGCODE(const size_t bytesReadDirectly =) this->readDirectlyFromStre am(dst, size);
211 SkDEBUGCODE(size -= bytesReadDirectly;) 207 SkDEBUGCODE(size -= bytesReadDirectly;)
212 SkASSERT(size + (fOffset - start) == totalSize); 208 SkASSERT(size + (fOffset - start) == totalSize);
213 } 209 }
214 210
215 return fOffset - start; 211 return fOffset - start;
216 } 212 }
OLDNEW
« no previous file with comments | « no previous file | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698