I chose 16, as in my test case from android, the depth was
at least 9. Possibly we could make it even smaller if our
underlying impl (SkDeque) would never prune its allocations,
so that we don't malloc repeatedly if we save/restore/save/restore
across the boundary of the first/nth chunk...
BUG=skia:
Change-Id: Id3f0b900b1931f713f80a664f2b4b142f264be8d
Reviewed-on: https://skia-review.googlesource.com/9522
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Mike Reed <reed@google.com>
static const int kDefaultElementAllocCnt = 8;
SkClipStack::SkClipStack()
- : fDeque(sizeof(Element), kDefaultElementAllocCnt)
+ : fDeque(sizeof(Element), fStorage, sizeof(fStorage), kDefaultElementAllocCnt)
, fSaveCount(0) {
}
SkClipStack::SkClipStack(const SkClipStack& b)
- : fDeque(sizeof(Element), kDefaultElementAllocCnt) {
+ : fDeque(sizeof(Element), fStorage, sizeof(fStorage), kDefaultElementAllocCnt)
+{
*this = b;
}
private:
friend class Iter;
+ enum {
+ kPreallocCount = 16
+ };
+ intptr_t fStorage[kPreallocCount * sizeof(Element) / sizeof(intptr_t)];
SkDeque fDeque;
int fSaveCount;