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

Unified Diff: include/core/SkRWBuffer.h

Issue 1871953002: Fixes for SkRWBuffer (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkRWBuffer.cpp » ('j') | tests/DataRefTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRWBuffer.h
diff --git a/include/core/SkRWBuffer.h b/include/core/SkRWBuffer.h
index 106e572587d8dcaa13d84e792bef40444e207696..7cf0b9b82c203bac09a4dd7db7d1461a5601393e 100644
--- a/include/core/SkRWBuffer.h
+++ b/include/core/SkRWBuffer.h
@@ -53,22 +53,30 @@ public:
private:
const SkBufferBlock* fBlock;
size_t fRemaining;
+ const SkROBuffer* fBuffer;
scroggo 2016/04/08 16:15:28 SkROBuffer is a const class, so should I remove th
};
private:
- SkROBuffer(const SkBufferHead* head, size_t used);
+ SkROBuffer(const SkBufferHead* head, size_t used, const SkBufferBlock* tail);
virtual ~SkROBuffer();
- const SkBufferHead* fHead;
- const size_t fUsed;
+ const SkBufferHead* fHead;
+ const size_t fUsed;
+
+ // Final block that existed when this object was created. It is the only block that may
+ // have more bytes in it than this object knows about. Store its fUsed amount at creation
+ // time, so it can be read later without racing with a writer updating it.
+ const SkBufferBlock* fTail;
+ const size_t fTailUsed;
scroggo 2016/04/08 16:15:29 I'm not a huge fan of this name, but I don't have
friend class SkRWBuffer;
};
/**
* Accumulates bytes of memory that are "appended" to it, growing internal storage as needed.
- * The growth is done such that at any time, a RBuffer or StreamAsset can be snapped off, which
- * can see the previously stored bytes, but which will be unaware of any future writes.
+ * The growth is done such that at any time in the writer's thread, an RBuffer or StreamAsset
+ * can be snapped off (and safely passed to another thread). The RBuffer/StreamAsset snapshot
+ * can see the previously stored bytes, but will be unaware of any future writes.
*/
class SK_API SkRWBuffer {
public:
« no previous file with comments | « no previous file | src/core/SkRWBuffer.cpp » ('j') | tests/DataRefTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698