OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |