aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceAllocator.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-11-01 17:32:39 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-02 12:22:41 +0000
commit8186cbee6cffb45c0c8ecade2f2c75a1fd8db0f8 (patch)
tree8e2e294f6b3aaa59a60fafadfc3f8bd987751f58 /src/gpu/GrResourceAllocator.cpp
parentce54bcecc2a64dbda2417c0ee6bcb68f1a21c047 (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.cpp')
-rw-r--r--src/gpu/GrResourceAllocator.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp
index ba62854a3a..62f780b177 100644
--- a/src/gpu/GrResourceAllocator.cpp
+++ b/src/gpu/GrResourceAllocator.cpp
@@ -17,13 +17,19 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy,
if (Interval* intvl = fIntvlHash.find(proxy->uniqueID().asUInt())) {
// Revise the interval for an existing use
- SkASSERT(intvl->fEnd < start);
+ //SkASSERT(intvl->fEnd <= end);
intvl->fEnd = end;
return;
}
- // TODO: given the usage pattern an arena allocation scheme would work well here
- Interval* newIntvl = new Interval(proxy, start, end);
+ Interval* newIntvl;
+ if (fFreeIntervalList) {
+ newIntvl = fFreeIntervalList;
+ fFreeIntervalList = newIntvl->fNext;
+ newIntvl->resetTo(proxy, start, end);
+ } else {
+ newIntvl = fIntervalAllocator.make<Interval>(proxy, start, end);
+ }
fIntvlList.insertByIncreasingStart(newIntvl);
fIntvlHash.add(newIntvl);
@@ -109,7 +115,10 @@ void GrResourceAllocator::expire(unsigned int curIndex) {
while (!fActiveIntvls.empty() && fActiveIntvls.peekHead()->fEnd < curIndex) {
Interval* temp = fActiveIntvls.popHead();
this->freeUpSurface(temp->fProxy->priv().peekSurface());
- delete temp;
+
+ // Add temp to the free interval list so it can be reused
+ temp->fNext = fFreeIntervalList;
+ fFreeIntervalList = temp;
}
}