Migrate resource cache methods to GrDirectContext
Cut and paste job. Change-Id: If9b7e0f74b16b2559dc4149f81720df96b09761e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325461 Auto-Submit: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
30c9b4cfb0
commit
3a508e94ef
@ -151,6 +151,57 @@ public:
|
||||
*/
|
||||
void releaseResourcesAndAbandonContext();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Resource Cache
|
||||
|
||||
/** DEPRECATED
|
||||
* Return the current GPU resource cache limits.
|
||||
*
|
||||
* @param maxResources If non-null, will be set to -1.
|
||||
* @param maxResourceBytes If non-null, returns maximum number of bytes of
|
||||
* video memory that can be held in the cache.
|
||||
*/
|
||||
void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const;
|
||||
|
||||
/**
|
||||
* Return the current GPU resource cache limit in bytes.
|
||||
*/
|
||||
size_t getResourceCacheLimit() const;
|
||||
|
||||
/**
|
||||
* Gets the current GPU resource cache usage.
|
||||
*
|
||||
* @param resourceCount If non-null, returns the number of resources that are held in the
|
||||
* cache.
|
||||
* @param maxResourceBytes If non-null, returns the total number of bytes of video memory held
|
||||
* in the cache.
|
||||
*/
|
||||
void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const;
|
||||
|
||||
/**
|
||||
* Gets the number of bytes in the cache consumed by purgeable (e.g. unlocked) resources.
|
||||
*/
|
||||
size_t getResourceCachePurgeableBytes() const;
|
||||
|
||||
/** DEPRECATED
|
||||
* Specify the GPU resource cache limits. If the current cache exceeds the maxResourceBytes
|
||||
* limit, it will be purged (LRU) to keep the cache within the limit.
|
||||
*
|
||||
* @param maxResources Unused.
|
||||
* @param maxResourceBytes The maximum number of bytes of video memory
|
||||
* that can be held in the cache.
|
||||
*/
|
||||
void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
|
||||
|
||||
/**
|
||||
* Specify the GPU resource cache limit. If the cache currently exceeds this limit,
|
||||
* it will be purged (LRU) to keep the cache within the limit.
|
||||
*
|
||||
* @param maxResourceBytes The maximum number of bytes of video memory
|
||||
* that can be held in the cache.
|
||||
*/
|
||||
void setResourceCacheLimit(size_t maxResourceBytes);
|
||||
|
||||
void freeGpuResources() override;
|
||||
|
||||
protected:
|
||||
|
@ -57,57 +57,6 @@ class SK_API GrContext : public GrRecordingContext {
|
||||
public:
|
||||
~GrContext() override;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Resource Cache
|
||||
|
||||
/** DEPRECATED
|
||||
* Return the current GPU resource cache limits.
|
||||
*
|
||||
* @param maxResources If non-null, will be set to -1.
|
||||
* @param maxResourceBytes If non-null, returns maximum number of bytes of
|
||||
* video memory that can be held in the cache.
|
||||
*/
|
||||
void getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const;
|
||||
|
||||
/**
|
||||
* Return the current GPU resource cache limit in bytes.
|
||||
*/
|
||||
size_t getResourceCacheLimit() const;
|
||||
|
||||
/**
|
||||
* Gets the current GPU resource cache usage.
|
||||
*
|
||||
* @param resourceCount If non-null, returns the number of resources that are held in the
|
||||
* cache.
|
||||
* @param maxResourceBytes If non-null, returns the total number of bytes of video memory held
|
||||
* in the cache.
|
||||
*/
|
||||
void getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const;
|
||||
|
||||
/**
|
||||
* Gets the number of bytes in the cache consumed by purgeable (e.g. unlocked) resources.
|
||||
*/
|
||||
size_t getResourceCachePurgeableBytes() const;
|
||||
|
||||
/** DEPRECATED
|
||||
* Specify the GPU resource cache limits. If the current cache exceeds the maxResourceBytes
|
||||
* limit, it will be purged (LRU) to keep the cache within the limit.
|
||||
*
|
||||
* @param maxResources Unused.
|
||||
* @param maxResourceBytes The maximum number of bytes of video memory
|
||||
* that can be held in the cache.
|
||||
*/
|
||||
void setResourceCacheLimits(int maxResources, size_t maxResourceBytes);
|
||||
|
||||
/**
|
||||
* Specify the GPU resource cache limit. If the cache currently exceeds this limit,
|
||||
* it will be purged (LRU) to keep the cache within the limit.
|
||||
*
|
||||
* @param maxResourceBytes The maximum number of bytes of video memory
|
||||
* that can be held in the cache.
|
||||
*/
|
||||
void setResourceCacheLimit(size_t maxResourceBytes);
|
||||
|
||||
/**
|
||||
* Frees GPU created by the context. Can be called to reduce GPU memory
|
||||
* pressure.
|
||||
|
@ -122,22 +122,6 @@ void GrContext::purgeUnlockedResources(size_t bytesToPurge, bool preferScratchRe
|
||||
fResourceCache->purgeUnlockedResources(bytesToPurge, preferScratchResources);
|
||||
}
|
||||
|
||||
void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
if (resourceCount) {
|
||||
*resourceCount = fResourceCache->getBudgetedResourceCount();
|
||||
}
|
||||
if (resourceBytes) {
|
||||
*resourceBytes = fResourceCache->getBudgetedResourceBytes();
|
||||
}
|
||||
}
|
||||
|
||||
size_t GrContext::getResourceCachePurgeableBytes() const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
return fResourceCache->getPurgeableBytes();
|
||||
}
|
||||
|
||||
size_t GrContext::ComputeImageSize(sk_sp<SkImage> image, GrMipmapped mipMapped, bool useNextPow2) {
|
||||
if (!image->isTextureBacked()) {
|
||||
return 0;
|
||||
@ -231,33 +215,6 @@ bool GrContext::supportsDistanceFieldText() const {
|
||||
return this->caps()->shaderCaps()->supportsDistanceFieldText();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (maxResources) {
|
||||
*maxResources = -1;
|
||||
}
|
||||
if (maxResourceBytes) {
|
||||
*maxResourceBytes = this->getResourceCacheLimit();
|
||||
}
|
||||
}
|
||||
|
||||
size_t GrContext::getResourceCacheLimit() const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
return fResourceCache->getMaxResourceBytes();
|
||||
}
|
||||
|
||||
void GrContext::setResourceCacheLimits(int unused, size_t maxResourceBytes) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
this->setResourceCacheLimit(maxResourceBytes);
|
||||
}
|
||||
|
||||
void GrContext::setResourceCacheLimit(size_t maxResourceBytes) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
fResourceCache->setLimit(maxResourceBytes);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void GrContext::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
@ -225,6 +225,47 @@ bool GrDirectContext::init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void GrDirectContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
if (resourceCount) {
|
||||
*resourceCount = fResourceCache->getBudgetedResourceCount();
|
||||
}
|
||||
if (resourceBytes) {
|
||||
*resourceBytes = fResourceCache->getBudgetedResourceBytes();
|
||||
}
|
||||
}
|
||||
|
||||
size_t GrDirectContext::getResourceCachePurgeableBytes() const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
return fResourceCache->getPurgeableBytes();
|
||||
}
|
||||
|
||||
void GrDirectContext::getResourceCacheLimits(int* maxResources, size_t* maxResourceBytes) const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (maxResources) {
|
||||
*maxResources = -1;
|
||||
}
|
||||
if (maxResourceBytes) {
|
||||
*maxResourceBytes = this->getResourceCacheLimit();
|
||||
}
|
||||
}
|
||||
|
||||
size_t GrDirectContext::getResourceCacheLimit() const {
|
||||
ASSERT_SINGLE_OWNER
|
||||
return fResourceCache->getMaxResourceBytes();
|
||||
}
|
||||
|
||||
void GrDirectContext::setResourceCacheLimits(int unused, size_t maxResourceBytes) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
this->setResourceCacheLimit(maxResourceBytes);
|
||||
}
|
||||
|
||||
void GrDirectContext::setResourceCacheLimit(size_t maxResourceBytes) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
fResourceCache->setLimit(maxResourceBytes);
|
||||
}
|
||||
|
||||
GrSmallPathAtlasMgr* GrDirectContext::onGetSmallPathAtlasMgr() {
|
||||
if (!fSmallPathAtlasMgr) {
|
||||
fSmallPathAtlasMgr = std::make_unique<GrSmallPathAtlasMgr>();
|
||||
|
Loading…
Reference in New Issue
Block a user