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

Unified Diff: src/core/SkVarAlloc.cpp

Issue 1090943004: O(1) SkPictureUtils::ApproxBytesUsed() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: const Created 5 years, 8 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 | « src/core/SkVarAlloc.h ('k') | src/utils/SkPictureUtils.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 fa89d38c23a286a03f4d28d92bb1996a428ae607..5d395d48418c234f8992ee36e5bc6ce1b0a86615 100644
--- a/src/core/SkVarAlloc.cpp
+++ b/src/core/SkVarAlloc.cpp
@@ -27,13 +27,15 @@ struct SkVarAlloc::Block {
};
SkVarAlloc::SkVarAlloc(size_t minLgSize)
- : fByte(NULL)
+ : fBytesAllocated(0)
+ , fByte(NULL)
, fRemaining(0)
, fLgSize(minLgSize)
, fBlock(NULL) {}
SkVarAlloc::SkVarAlloc(size_t minLgSize, char* storage, size_t len)
- : fByte(storage)
+ : fBytesAllocated(0)
+ , fByte(storage)
, fRemaining(len)
, fLgSize(minLgSize)
, fBlock(NULL) {}
@@ -54,6 +56,7 @@ void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) {
while (alloc < bytes + sizeof(Block)) {
alloc *= 2;
}
+ fBytesAllocated += alloc;
fBlock = Block::Alloc(fBlock, alloc, flags);
fByte = fBlock->data();
fRemaining = alloc - sizeof(Block);
@@ -65,23 +68,3 @@ void SkVarAlloc::makeSpace(size_t bytes, unsigned flags) {
//SkASSERT(alloc == malloc_usable_size(fBlock));
#endif
}
-
-static size_t heap_size(void* p) {
-#if defined(SK_BUILD_FOR_MAC)
- return malloc_size(p);
-#elif defined(SK_BUILD_FOR_UNIX) && !defined(__UCLIBC__)
- return malloc_usable_size(p);
-#elif defined(SK_BUILD_FOR_WIN32)
- return _msize(p);
-#else
- return 0; // Tough luck.
-#endif
-}
-
-size_t SkVarAlloc::approxBytesAllocated() const {
- size_t sum = 0;
- for (Block* b = fBlock; b; b = b->prev) {
- sum += heap_size(b);
- }
- return sum;
-}
« no previous file with comments | « src/core/SkVarAlloc.h ('k') | src/utils/SkPictureUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698