diff options
author | Robert Phillips <robertphillips@google.com> | 2017-11-01 17:32:39 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-02 12:22:41 +0000 |
commit | 8186cbee6cffb45c0c8ecade2f2c75a1fd8db0f8 (patch) | |
tree | 8e2e294f6b3aaa59a60fafadfc3f8bd987751f58 /src/gpu/GrResourceAllocator.h | |
parent | ce54bcecc2a64dbda2417c0ee6bcb68f1a21c047 (diff) |
Make the intervals in GrResourceAllocator use SkArenaAlloc
Change-Id: I3190396fe34c01c232654fcb225dbf76df3137b4
Reviewed-on: https://skia-review.googlesource.com/66463
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrResourceAllocator.h')
-rw-r--r-- | src/gpu/GrResourceAllocator.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h index 966359c85e..3be4836ca9 100644 --- a/src/gpu/GrResourceAllocator.h +++ b/src/gpu/GrResourceAllocator.h @@ -11,6 +11,8 @@ #include "GrGpuResourcePriv.h" #include "GrSurface.h" #include "GrSurfaceProxy.h" + +#include "SkArenaAlloc.h" #include "SkTDynamicHash.h" #include "SkTMultiMap.h" @@ -86,6 +88,16 @@ private: SkASSERT(proxy); } + void resetTo(GrSurfaceProxy* proxy, unsigned int start, unsigned int end) { + SkASSERT(proxy); + + fProxy = proxy; + fProxyID = proxy->uniqueID().asUInt(); + fStart = start; + fEnd = end; + fNext = nullptr; + } + // for SkTDynamicHash static const uint32_t& GetKey(const Interval& intvl) { return intvl.fProxyID; @@ -103,11 +115,8 @@ private: public: IntervalList() = default; ~IntervalList() { - while (fHead) { - Interval* temp = fHead; - fHead = temp->fNext; - delete temp; - } + // The only time we delete an IntervalList is in the GrResourceAllocator dtor. + // Since the arena allocator will clean up for us we don't bother here. } bool empty() const { return !SkToBool(fHead); } @@ -120,6 +129,9 @@ private: Interval* fHead = nullptr; }; + // Gathered statistics indicate that 99% of flushes will be covered by <= 12 Intervals + static const int kInitialArenaSize = 12 * sizeof(Interval); + GrResourceProvider* fResourceProvider; FreePoolMultiMap fFreePool; // Recently created/used GrSurfaces IntvlHash fIntvlHash; // All the intervals, hashed by proxyID @@ -129,6 +141,10 @@ private: // (sorted by increasing end) unsigned int fNumOps = 0; SkDEBUGCODE(bool fAssigned = false;) + + char fStorage[kInitialArenaSize]; + SkArenaAlloc fIntervalAllocator { fStorage, kInitialArenaSize, 0 }; + Interval* fFreeIntervalList = nullptr; }; #endif // GrResourceAllocator_DEFINED |