diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-17 14:25:43 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-17 14:25:43 +0000 |
commit | f9a90847820a8ec4a3c97a2b544c622e3ca6b09a (patch) | |
tree | 9bb856ff61518c7425f57fe7d095d3bbe693017e | |
parent | 07ea2db0260d8e6cd2bf605571b68b1c574b5a77 (diff) |
Decrease SkClipStack memory allocations & deallocations
http://codereview.appspot.com/6443138
git-svn-id: http://skia.googlecode.com/svn/trunk@5151 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkClipStack.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp index add46e483d..e8ff6e8adc 100644 --- a/src/core/SkClipStack.cpp +++ b/src/core/SkClipStack.cpp @@ -439,18 +439,24 @@ struct SkClipStack::Rec { } }; +// This constant determines how many Rec's are allocated together as a block in +// the deque. As such it needs to balance allocating too much memory vs. +// incurring allocation/deallocation thrashing. It should roughly correspond to +// the deepest save/restore stack we expect to see. +static const int kDefaultRecordAllocCnt = 8; SkClipStack::SkClipStack() - : fDeque(sizeof(Rec)) + : fDeque(sizeof(Rec), kDefaultRecordAllocCnt) , fSaveCount(0) { } -SkClipStack::SkClipStack(const SkClipStack& b) : fDeque(sizeof(Rec)) { +SkClipStack::SkClipStack(const SkClipStack& b) + : fDeque(sizeof(Rec), kDefaultRecordAllocCnt) { *this = b; } SkClipStack::SkClipStack(const SkRect& r) - : fDeque(sizeof(Rec)) + : fDeque(sizeof(Rec), kDefaultRecordAllocCnt) , fSaveCount(0) { if (!r.isEmpty()) { this->clipDevRect(r, SkRegion::kReplace_Op, false); @@ -458,7 +464,7 @@ SkClipStack::SkClipStack(const SkRect& r) } SkClipStack::SkClipStack(const SkIRect& r) - : fDeque(sizeof(Rec)) + : fDeque(sizeof(Rec), kDefaultRecordAllocCnt) , fSaveCount(0) { if (!r.isEmpty()) { SkRect temp; |