diff --git a/m133/include/gpu/ganesh/GrDirectContext.h b/m133/include/gpu/ganesh/GrDirectContext.h index f9fb6ad64e92f9f7b7c71c016cf8c812c44dad72..64de306a6e9b3096e87df5f81c572a0b74c350ec 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 685ec420979c6b59bc6983975f7414e0ebf18688..099fae95760b8ca98607bfecc88daac7e2143481 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 c7c1f255967870867e0f65caac2fbb3ca89134a2..83f32a9e1211f58e4fe2ba1e49fe8f259a636810 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 60384774f1c4a9d26e267ba04be319c35225bad3..55ff978c2f5b2cc9cefd546021ecf8f999e9587a 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;