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

Side by Side Diff: include/core/SkRWBuffer.h

Issue 1856033002: Add SK_API to SkROBuffer::Iter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkRWBuffer_DEFINED 8 #ifndef SkRWBuffer_DEFINED
9 #define SkRWBuffer_DEFINED 9 #define SkRWBuffer_DEFINED
10 10
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 12
13 struct SkBufferBlock; 13 struct SkBufferBlock;
14 struct SkBufferHead; 14 struct SkBufferHead;
15 class SkRWBuffer; 15 class SkRWBuffer;
16 class SkStreamAsset; 16 class SkStreamAsset;
17 17
18 /** 18 /**
19 * Contains a read-only, thread-sharable block of memory. To access the memory, the caller must 19 * Contains a read-only, thread-sharable block of memory. To access the memory, the caller must
20 * instantiate a local iterator, as the memory is stored in 1 or more contiguou s blocks. 20 * instantiate a local iterator, as the memory is stored in 1 or more contiguou s blocks.
21 */ 21 */
22 class SK_API SkROBuffer : public SkRefCnt { 22 class SK_API SkROBuffer : public SkRefCnt {
23 public: 23 public:
24 /** 24 /**
25 * Return the logical length of the data owned/shared by this buffer. It ma y be stored in 25 * Return the logical length of the data owned/shared by this buffer. It ma y be stored in
26 * multiple contiguous blocks, accessible via the iterator. 26 * multiple contiguous blocks, accessible via the iterator.
27 */ 27 */
28 size_t size() const { return fUsed; } 28 size_t size() const { return fUsed; }
29 29
30 class Iter { 30 class SK_API Iter {
31 public: 31 public:
32 Iter(const SkROBuffer*); 32 Iter(const SkROBuffer*);
33 33
34 void reset(const SkROBuffer*); 34 void reset(const SkROBuffer*);
35 35
36 /** 36 /**
37 * Return the current continuous block of memory, or nullptr if the ite rator is exhausted 37 * Return the current continuous block of memory, or nullptr if the ite rator is exhausted
38 */ 38 */
39 const void* data() const; 39 const void* data() const;
40 40
(...skipping 10 matching lines...) Expand all
51 bool next(); 51 bool next();
52 52
53 private: 53 private:
54 const SkBufferBlock* fBlock; 54 const SkBufferBlock* fBlock;
55 size_t fRemaining; 55 size_t fRemaining;
56 }; 56 };
57 57
58 private: 58 private:
59 SkROBuffer(const SkBufferHead* head, size_t used); 59 SkROBuffer(const SkBufferHead* head, size_t used);
60 virtual ~SkROBuffer(); 60 virtual ~SkROBuffer();
61 61
62 const SkBufferHead* fHead; 62 const SkBufferHead* fHead;
63 const size_t fUsed; 63 const size_t fUsed;
64 64
65 friend class SkRWBuffer; 65 friend class SkRWBuffer;
66 }; 66 };
67 67
68 /** 68 /**
69 * Accumulates bytes of memory that are "appended" to it, growing internal stor age as needed. 69 * Accumulates bytes of memory that are "appended" to it, growing internal stor age as needed.
70 * The growth is done such that at any time, a RBuffer or StreamAsset can be sn apped off, which 70 * The growth is done such that at any time, a RBuffer or StreamAsset can be sn apped off, which
71 * can see the previously stored bytes, but which will be unaware of any future writes. 71 * can see the previously stored bytes, but which will be unaware of any future writes.
72 */ 72 */
73 class SK_API SkRWBuffer { 73 class SK_API SkRWBuffer {
74 public: 74 public:
75 SkRWBuffer(size_t initialCapacity = 0); 75 SkRWBuffer(size_t initialCapacity = 0);
76 ~SkRWBuffer(); 76 ~SkRWBuffer();
77 77
78 size_t size() const { return fTotalUsed; } 78 size_t size() const { return fTotalUsed; }
79 void append(const void* buffer, size_t length); 79 void append(const void* buffer, size_t length);
80 void* append(size_t length); 80 void* append(size_t length);
81 81
82 SkROBuffer* newRBufferSnapshot() const; 82 SkROBuffer* newRBufferSnapshot() const;
83 SkStreamAsset* newStreamSnapshot() const; 83 SkStreamAsset* newStreamSnapshot() const;
84 84
85 #ifdef SK_DEBUG 85 #ifdef SK_DEBUG
86 void validate() const; 86 void validate() const;
87 #else 87 #else
88 void validate() const {} 88 void validate() const {}
89 #endif 89 #endif
90 90
91 private: 91 private:
92 SkBufferHead* fHead; 92 SkBufferHead* fHead;
93 SkBufferBlock* fTail; 93 SkBufferBlock* fTail;
94 size_t fTotalUsed; 94 size_t fTotalUsed;
95 }; 95 };
96 96
97 #endif 97 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698