Index: src/core/SkVarAlloc.cpp |
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp |
index 8f84b95743e5ba54d80b39ec34c0c7c2b4f1c502..ba5d6f50b05a12e83aec99bed1a7ff636c299948 100644 |
--- a/src/core/SkVarAlloc.cpp |
+++ b/src/core/SkVarAlloc.cpp |
@@ -7,11 +7,6 @@ |
#include <malloc.h> |
#endif |
-enum { |
- kMinLgSize = 4, // The smallest block we'd ever want to allocate is 16B, |
- kMaxLgSize = 16, // and we see no benefit allocating blocks larger than 64K. |
-}; |
- |
struct SkVarAlloc::Block { |
Block* prev; |
char* data() { return (char*)(this + 1); } |
@@ -24,10 +19,10 @@ struct SkVarAlloc::Block { |
} |
}; |
-SkVarAlloc::SkVarAlloc() |
+SkVarAlloc::SkVarAlloc(size_t minLgSize) |
: fByte(NULL) |
, fRemaining(0) |
- , fLgSize(kMinLgSize) |
+ , fLgSize(minLgSize) |
, fBlock(NULL) {} |
SkVarAlloc::~SkVarAlloc() { |
@@ -42,7 +37,7 @@ SkVarAlloc::~SkVarAlloc() { |
void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { |
SkASSERT(SkIsAlignPtr(bytes)); |
- size_t alloc = 1<<fLgSize; |
+ size_t alloc = 1<<fLgSize++; |
while (alloc < bytes + sizeof(Block)) { |
alloc *= 2; |
} |
@@ -50,10 +45,6 @@ void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) { |
fByte = fBlock->data(); |
fRemaining = alloc - sizeof(Block); |
- if (fLgSize < kMaxLgSize) { |
- fLgSize++; |
- } |
- |
#if defined(SK_BUILD_FOR_MAC) |
SkASSERT(alloc == malloc_good_size(alloc)); |
#elif defined(SK_BUILD_FOR_UNIX) |