From 729ba5e83c0c342982c6a873d94bcda278a6b936 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 15 Mar 2021 12:34:31 -0400 Subject: [PATCH] Remove fAssignedSurface from GrResourceAllocator::Interval The surface on the proxy should be the source of truth here. Bug: skia:10877 Change-Id: Id2126a259202be4c426f2cbf8f025ef69dd50551 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384702 Reviewed-by: Robert Phillips Commit-Queue: Adlai Holler --- src/gpu/GrResourceAllocator.cpp | 21 +++++++-------------- src/gpu/GrResourceAllocator.h | 10 ---------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp index c5d17977d3..ca8e1d72a1 100644 --- a/src/gpu/GrResourceAllocator.cpp +++ b/src/gpu/GrResourceAllocator.cpp @@ -28,12 +28,6 @@ } #endif -void GrResourceAllocator::Interval::assign(sk_sp s) { - SkASSERT(!fAssignedSurface); - fAssignedSurface = s; - fProxy->priv().assign(std::move(s)); -} - void GrResourceAllocator::determineRecyclability() { for (Interval* cur = fIntvlList.peekHead(); cur; cur = cur->next()) { if (cur->proxy()->canSkipResourceAllocator()) { @@ -267,14 +261,12 @@ sk_sp GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy // to the free pool if possible. void GrResourceAllocator::expire(unsigned int curIndex) { while (!fActiveIntvls.empty() && fActiveIntvls.peekHead()->end() < curIndex) { - Interval* temp = fActiveIntvls.popHead(); - SkASSERT(!temp->next()); + Interval* intvl = fActiveIntvls.popHead(); + SkASSERT(!intvl->next()); - if (temp->wasAssignedSurface()) { - sk_sp surface = temp->detachSurface(); - - if (temp->isRecyclable()) { - this->recycleSurface(std::move(surface)); + if (GrSurface* surf = intvl->proxy()->peekSurface()) { + if (intvl->isRecyclable()) { + this->recycleSurface(sk_ref_sp(surf)); } } } @@ -329,7 +321,8 @@ bool GrResourceAllocator::assign() { cur->proxy()->uniqueID().asUInt()); #endif - cur->assign(std::move(surface)); + SkASSERT(!cur->proxy()->peekSurface()); + cur->proxy()->priv().assign(std::move(surface)); } else { SkASSERT(!cur->proxy()->isInstantiated()); fFailedInstantiation = true; diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h index c36495b70a..6abf126969 100644 --- a/src/gpu/GrResourceAllocator.h +++ b/src/gpu/GrResourceAllocator.h @@ -137,10 +137,6 @@ private: #endif } - ~Interval() { - SkASSERT(!fAssignedSurface); - } - const GrSurfaceProxy* proxy() const { return fProxy; } GrSurfaceProxy* proxy() { return fProxy; } @@ -166,10 +162,6 @@ private: } } - void assign(sk_sp); - bool wasAssignedSurface() const { return fAssignedSurface != nullptr; } - sk_sp detachSurface() { return std::move(fAssignedSurface); } - // for SkTDynamicHash static const uint32_t& GetKey(const Interval& intvl) { return intvl.fProxyID; @@ -177,8 +169,6 @@ private: static uint32_t Hash(const uint32_t& key) { return key; } private: - // TODO: Do we really need this variable? - sk_sp fAssignedSurface; GrSurfaceProxy* fProxy; uint32_t fProxyID; // This is here b.c. DynamicHash requires a ref to the key unsigned int fStart;