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

Unified Diff: include/core/SkChunkAlloc.h

Issue 967553003: Add rewind capability to SkChunkAlloc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix variable sizes/signs Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkChunkAlloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkChunkAlloc.h
diff --git a/include/core/SkChunkAlloc.h b/include/core/SkChunkAlloc.h
index e13e2b99c640368ebfbdc5f3e16f6e47f3620807..9699842e6b42a7fab28c9ef8f27fb92fe54fc4d7 100644
--- a/include/core/SkChunkAlloc.h
+++ b/include/core/SkChunkAlloc.h
@@ -22,6 +22,11 @@ public:
* pointers.
*/
void reset();
+ /**
+ * Reset to 0 used bytes preserving as much memory as possible.
+ * This invalidates all returned pointers.
+ */
+ void rewind();
enum AllocFailType {
kReturnNil_AllocFailType,
@@ -43,7 +48,8 @@ public:
size_t totalCapacity() const { return fTotalCapacity; }
size_t totalUsed() const { return fTotalUsed; }
- int blockCount() const { return fBlockCount; }
+ SkDEBUGCODE(int blockCount() const { return fBlockCount; })
+ SkDEBUGCODE(size_t totalLost() const { return fTotalLost; })
/**
* Returns true if the specified address is within one of the chunks, and
@@ -60,9 +66,13 @@ private:
size_t fChunkSize;
size_t fTotalCapacity;
size_t fTotalUsed; // will be <= fTotalCapacity
- int fBlockCount;
+ SkDEBUGCODE(int fBlockCount;)
+ SkDEBUGCODE(size_t fTotalLost;) // will be <= fTotalCapacity
Block* newBlock(size_t bytes, AllocFailType ftype);
+ Block* addBlockIfNecessary(size_t bytes, AllocFailType ftype);
+
+ SkDEBUGCODE(void validate();)
};
#endif
« no previous file with comments | « no previous file | src/core/SkChunkAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698