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

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

Issue 1871953002: Fixes for SkRWBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Restore original test (in addition to threaded one) 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 | src/core/SkRWBuffer.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 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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 /** 47 /**
48 * Advance to the next contiguous block of memory, returning true if th ere is another 48 * Advance to the next contiguous block of memory, returning true if th ere is another
49 * block, or false if the iterator is exhausted. 49 * block, or false if the iterator is exhausted.
50 */ 50 */
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 const SkROBuffer* fBuffer;
56 }; 57 };
57 58
58 private: 59 private:
59 SkROBuffer(const SkBufferHead* head, size_t available); 60 SkROBuffer(const SkBufferHead* head, size_t available, const SkBufferBlock* fTail);
60 virtual ~SkROBuffer(); 61 virtual ~SkROBuffer();
61 62
62 const SkBufferHead* fHead; 63 const SkBufferHead* fHead;
63 const size_t fAvailable; 64 const size_t fAvailable;
65 const SkBufferBlock* fTail;
64 66
65 friend class SkRWBuffer; 67 friend class SkRWBuffer;
66 }; 68 };
67 69
68 /** 70 /**
69 * Accumulates bytes of memory that are "appended" to it, growing internal stor age as needed. 71 * 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 72 * The growth is done such that at any time in the writer's thread, an RBuffer or StreamAsset
71 * can see the previously stored bytes, but which will be unaware of any future writes. 73 * can be snapped off (and safely passed to another thread). The RBuffer/Stream Asset snapshot
74 * can see the previously stored bytes, but will be unaware of any future write s.
72 */ 75 */
73 class SK_API SkRWBuffer { 76 class SK_API SkRWBuffer {
74 public: 77 public:
75 SkRWBuffer(size_t initialCapacity = 0); 78 SkRWBuffer(size_t initialCapacity = 0);
76 ~SkRWBuffer(); 79 ~SkRWBuffer();
77 80
78 size_t size() const { return fTotalUsed; } 81 size_t size() const { return fTotalUsed; }
79 void append(const void* buffer, size_t length); 82 void append(const void* buffer, size_t length);
80 83
81 SkROBuffer* newRBufferSnapshot() const; 84 SkROBuffer* newRBufferSnapshot() const;
82 SkStreamAsset* newStreamSnapshot() const; 85 SkStreamAsset* newStreamSnapshot() const;
83 86
84 #ifdef SK_DEBUG 87 #ifdef SK_DEBUG
85 void validate() const; 88 void validate() const;
86 #else 89 #else
87 void validate() const {} 90 void validate() const {}
88 #endif 91 #endif
89 92
90 private: 93 private:
91 SkBufferHead* fHead; 94 SkBufferHead* fHead;
92 SkBufferBlock* fTail; 95 SkBufferBlock* fTail;
93 size_t fTotalUsed; 96 size_t fTotalUsed;
94 }; 97 };
95 98
96 #endif 99 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkRWBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698