diff --git a/m133/include/gpu/ganesh/GrContextOptions.h b/m133/include/gpu/ganesh/GrContextOptions.h index a83f71b4d5926801c3e105bf6c81fd3682201a63..d31b20542cc0307dd0b8f85572e31b5f59208e56 100644 --- a/m133/include/gpu/ganesh/GrContextOptions.h +++ b/m133/include/gpu/ganesh/GrContextOptions.h @@ -214,6 +214,18 @@ struct SK_API GrContextOptions { GrDriverBugWorkarounds fDriverBugWorkarounds; +#ifdef SKIA_OHOS + /** + * At the end of the frame, cleaning up each small-sized texture can help avoid frequent memory + * overruns and the issue of excessive time consumption during cleanup at the end of animations. + * However, enabling this feature will cause small textures to be redrawn every frame. If the te + * xture rendering on the current device is time-consuming, it is not recommended to enable this + * feature, as it may lead to performance issues. + */ + //OH ISSUE :cache small Texture on UnUni devices + bool clearSmallTexture = true; +#endif + /** Construct mipmaps manually, via repeated downsampling draw-calls. This is used when the driver's implementation (glGenerateMipmap) contains bugs. This requires mipmap level control (ie desktop or ES3). */ diff --git a/m133/src/gpu/ganesh/GrTextureProxy.cpp b/m133/src/gpu/ganesh/GrTextureProxy.cpp index ba7f5bb31fc7a579299ca20352d3bf788df5af56..e7068a84c0a972bf2cb7eca9a5eed8d7637f893d 100644 --- a/m133/src/gpu/ganesh/GrTextureProxy.cpp +++ b/m133/src/gpu/ganesh/GrTextureProxy.cpp @@ -115,6 +115,29 @@ GrTextureProxy::~GrTextureProxy() { // message to (Note: in this case we don't want to remove its cached resource). if (fUniqueKey.isValid() && fProxyProvider) { sk_sp invalidGpuResource; +#ifdef SKIA_OHOS + //OH ISSUE :cache small Texture on UnUni devices + auto context = fProxyProvider->getfImageContext(); + bool clearSmallTexture = true; + if (context) { + clearSmallTexture = context->priv().options().clearSmallTexture; + auto direct = context->asDirectContext(); + if (direct) { + GrResourceProvider* resourceProvider = direct->priv().resourceProvider(); + if (resourceProvider) { + invalidGpuResource = resourceProvider->findByUniqueKey(fUniqueKey); + } + } + } + // less than 1024 Bytes resources will be delated + if (invalidGpuResource && clearSmallTexture && invalidGpuResource->gpuMemorySize() < 1024) { + fProxyProvider->processInvalidUniqueKey( + fUniqueKey, this, GrProxyProvider::InvalidateGPUResource::kYes); + } else { + fProxyProvider->processInvalidUniqueKey( + fUniqueKey, this, GrProxyProvider::InvalidateGPUResource::kNo); + } +#else auto direct = fProxyProvider->getfImageContext()->asDirectContext(); if (direct) { GrResourceProvider* resourceProvider = direct->priv().resourceProvider(); @@ -130,6 +153,7 @@ GrTextureProxy::~GrTextureProxy() { fProxyProvider->processInvalidUniqueKey( fUniqueKey, this, GrProxyProvider::InvalidateGPUResource::kNo); } +#endif } else { SkASSERT(!fProxyProvider); }