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

Unified Diff: src/core/SkVarAlloc.h

Issue 721313002: Deparameterize SkVarAlloc. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes: update unit test, remove unused header, start at 16 bytes Created 6 years, 1 month 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 | « src/core/SkRecord.h ('k') | src/core/SkVarAlloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkVarAlloc.h
diff --git a/src/core/SkVarAlloc.h b/src/core/SkVarAlloc.h
index 0a7864b37a878e265c7e12eccdee4ee03123d331..19b2d75e76ca2467eb1a38eb55df269b0a548049 100644
--- a/src/core/SkVarAlloc.h
+++ b/src/core/SkVarAlloc.h
@@ -5,22 +5,21 @@
class SkVarAlloc : SkNoncopyable {
public:
- // SkVarAlloc will never allocate less than smallest bytes at a time.
- // When it allocates a new block, it will be at least growth times bigger than the last.
- SkVarAlloc(size_t smallest, float growth);
+ SkVarAlloc();
~SkVarAlloc();
// Returns contiguous bytes aligned at least for pointers. You may pass SK_MALLOC_THROW, etc.
char* alloc(size_t bytes, unsigned sk_malloc_flags) {
bytes = SkAlignPtr(bytes);
- if (fByte + bytes > fLimit) {
+ if (bytes > fRemaining) {
this->makeSpace(bytes, sk_malloc_flags);
}
- SkASSERT(fByte + bytes <= fLimit);
+ SkASSERT(bytes <= fRemaining);
char* ptr = fByte;
fByte += bytes;
+ fRemaining -= bytes;
return ptr;
}
@@ -28,10 +27,8 @@ private:
void makeSpace(size_t bytes, unsigned flags);
char* fByte;
- const char* fLimit;
-
- unsigned fSmallest;
- const float fGrowth;
+ unsigned fRemaining;
+ unsigned fLgMinSize;
struct Block;
Block* fBlock;
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkVarAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698