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

Unified Diff: src/core/SkVarAlloc.cpp

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/SkVarAlloc.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkVarAlloc.cpp
diff --git a/src/core/SkVarAlloc.cpp b/src/core/SkVarAlloc.cpp
index 5c3a41c6cf8af967531b16a55b4184d86d2b9b26..cc1fc1c734113072e9d57f93e75b8c110a626d81 100644
--- a/src/core/SkVarAlloc.cpp
+++ b/src/core/SkVarAlloc.cpp
@@ -1,5 +1,4 @@
#include "SkVarAlloc.h"
-#include "SkScalar.h"
// We use non-standard malloc diagnostic methods to make sure our allocations are sized well.
#if defined(SK_BUILD_FOR_MAC)
@@ -20,11 +19,10 @@ struct SkVarAlloc::Block {
}
};
-SkVarAlloc::SkVarAlloc(size_t smallest, float growth)
+SkVarAlloc::SkVarAlloc()
: fByte(NULL)
- , fLimit(NULL)
- , fSmallest(SkToUInt(smallest))
- , fGrowth(growth)
+ , fRemaining(0)
+ , fLgMinSize(4)
, fBlock(NULL) {}
SkVarAlloc::~SkVarAlloc() {
@@ -39,14 +37,13 @@ SkVarAlloc::~SkVarAlloc() {
void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) {
SkASSERT(SkIsAlignPtr(bytes));
- size_t alloc = fSmallest;
+ size_t alloc = 1<<(fLgMinSize++);
while (alloc < bytes + sizeof(Block)) {
alloc *= 2;
}
fBlock = Block::Alloc(fBlock, alloc, flags);
fByte = fBlock->data();
- fLimit = fByte + alloc - sizeof(Block);
- fSmallest = SkToUInt(SkScalarTruncToInt(fSmallest * fGrowth));
+ fRemaining = alloc - sizeof(Block);
#if defined(SK_BUILD_FOR_MAC)
SkASSERT(alloc == malloc_good_size(alloc));
« no previous file with comments | « src/core/SkVarAlloc.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698