From ab5a7627e28002cc2116263f3648128d8aedc77d Mon Sep 17 00:00:00 2001 From: li-kiao Date: Tue, 26 Aug 2025 06:17:46 +0000 Subject: [PATCH] =?UTF-8?q?=E7=BA=B9=E7=90=86=E4=B8=8A=E9=99=90=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4=EF=BC=8Cskia=E5=8D=87=E7=BA=A7=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: li-kiao Change-Id: I4a73e125d5ab3e0a57f5583e20464b87afaed2ee --- m133/include/gpu/ganesh/GrDirectContext.h | 5 +++++ m133/src/gpu/ganesh/GrDirectContext.cpp | 11 +++++++++++ m133/src/gpu/ganesh/GrResourceCache.cpp | 8 ++++++++ m133/src/gpu/ganesh/GrResourceCache.h | 20 +++++++++++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/m133/include/gpu/ganesh/GrDirectContext.h b/m133/include/gpu/ganesh/GrDirectContext.h index f9fb6ad64e..64de306a6e 100644 --- a/m133/include/gpu/ganesh/GrDirectContext.h +++ b/m133/include/gpu/ganesh/GrDirectContext.h @@ -969,6 +969,11 @@ public: */ std::set getAllGrGpuResourceTags() const; +#ifdef SKIA_OHOS + // OH ISSUE: set purgeable resource max count limit. + void setPurgeableResourceLimit(int purgeableMaxCount); +#endif + // OH ISSUE: get the memory information of the updated pid. void getUpdatedMemoryMap(std::unordered_map &out); diff --git a/m133/src/gpu/ganesh/GrDirectContext.cpp b/m133/src/gpu/ganesh/GrDirectContext.cpp index 685ec42097..099fae9576 100644 --- a/m133/src/gpu/ganesh/GrDirectContext.cpp +++ b/m133/src/gpu/ganesh/GrDirectContext.cpp @@ -646,6 +646,17 @@ std::set GrDirectContext::getAllGrGpuResourceTags() const { return {}; } +#ifdef SKIA_OHOS +// OH ISSUE: set purgeable resource max count limit. +void GrDirectContext::setPurgeableResourceLimit(int purgeableMaxCount) +{ + ASSERT_SINGLE_OWNER + if (fResourceCache) { + fResourceCache->setPurgeableResourceLimit(purgeableMaxCount); + } +} +#endif + // OH ISSUE: get the memory information of the updated pid. void GrDirectContext::getUpdatedMemoryMap(std::unordered_map &out) { diff --git a/m133/src/gpu/ganesh/GrResourceCache.cpp b/m133/src/gpu/ganesh/GrResourceCache.cpp index c7c1f25596..83f32a9e12 100644 --- a/m133/src/gpu/ganesh/GrResourceCache.cpp +++ b/m133/src/gpu/ganesh/GrResourceCache.cpp @@ -634,6 +634,14 @@ std::set GrResourceCache::getAllGrGpuResourceTags() const { return result; } +#ifdef SKIA_OHOS +// OH ISSUE: set purgeable resource max count limit. +void GrResourceCache::setPurgeableResourceLimit(int purgeableMaxCount) +{ + fPurgeableMaxCount = purgeableMaxCount; +} +#endif + // OH ISSUE: get the memory information of the updated pid. void GrResourceCache::getUpdatedMemoryMap(std::unordered_map &out) { diff --git a/m133/src/gpu/ganesh/GrResourceCache.h b/m133/src/gpu/ganesh/GrResourceCache.h index 60384774f1..55ff978c2f 100644 --- a/m133/src/gpu/ganesh/GrResourceCache.h +++ b/m133/src/gpu/ganesh/GrResourceCache.h @@ -239,7 +239,15 @@ public: */ bool purgeToMakeHeadroom(size_t desiredHeadroomBytes); - bool overBudget() const { return fBudgetedBytes > fMaxBytes; } + bool overBudget() const + { +#ifdef SKIA_OHOS + return (fBudgetedBytes > fMaxBytes) || + (fPurgeableQueue.count() > fPurgeableMaxCount); // OH ISSUE: purgeable resources count limit. +#else + return fBudgetedBytes > fMaxBytes; +#endif + } /** * Purge unlocked resources from the cache until the the provided byte count has been reached @@ -321,6 +329,11 @@ public: std::set getAllGrGpuResourceTags() const; // Get the tag of all GPU resources +#ifdef SKIA_OHOS + // OH ISSUE: set purgeable resource max count limit. + void setPurgeableResourceLimit(int purgeableMaxCount); +#endif + // OH ISSUE: get the memory information of the updated pid. void getUpdatedMemoryMap(std::unordered_map &out); @@ -498,6 +511,11 @@ private: // our budget, used in purgeAsNeeded() size_t fMaxBytes = kDefaultMaxSize; +#ifdef SKIA_OHOS + // OH ISSUE: purgeable queue max count limit, used in purgeAsNeeded() + int fPurgeableMaxCount = INT32_MAX; +#endif + #if GR_CACHE_STATS int fHighWaterCount = 0; size_t fHighWaterBytes = 0; -- Gitee