Index: src/core/SkVarAlloc.cpp |
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp |
index a636c54198b1b2adbc298eefed90dc9556c37aac..5c3a41c6cf8af967531b16a55b4184d86d2b9b26 100644 |
--- a/src/core/SkVarAlloc.cpp |
+++ b/src/core/SkVarAlloc.cpp |
@@ -20,10 +20,11 @@ |
} |
}; |
-SkVarAlloc::SkVarAlloc() |
+SkVarAlloc::SkVarAlloc(size_t smallest, float growth) |
: fByte(NULL) |
- , fRemaining(0) |
- , fLgMinSize(0) |
+ , fLimit(NULL) |
+ , fSmallest(SkToUInt(smallest)) |
+ , fGrowth(growth) |
, fBlock(NULL) {} |
SkVarAlloc::~SkVarAlloc() { |
@@ -38,13 +39,14 @@ |
void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { |
SkASSERT(SkIsAlignPtr(bytes)); |
- size_t alloc = 1<<(fLgMinSize++); |
+ size_t alloc = fSmallest; |
while (alloc < bytes + sizeof(Block)) { |
alloc *= 2; |
} |
fBlock = Block::Alloc(fBlock, alloc, flags); |
fByte = fBlock->data(); |
- fRemaining = alloc - sizeof(Block); |
+ fLimit = fByte + alloc - sizeof(Block); |
+ fSmallest = SkToUInt(SkScalarTruncToInt(fSmallest * fGrowth)); |
#if defined(SK_BUILD_FOR_MAC) |
SkASSERT(alloc == malloc_good_size(alloc)); |