Migrate the API of GrDirectContext about resource memory limit (flutter/engine#31977)

This commit is contained in:
ColdPaleLight
2022-03-15 07:50:10 +08:00
committed by GitHub
parent c92b7bcf52
commit aa63b8f801
8 changed files with 8 additions and 18 deletions

View File

@@ -824,9 +824,7 @@ void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) {
return;
}
int max_resources;
context->getResourceCacheLimits(&max_resources, nullptr);
context->setResourceCacheLimits(max_resources, max_bytes);
context->setResourceCacheLimit(max_bytes);
}
}
@@ -836,9 +834,7 @@ std::optional<size_t> Rasterizer::GetResourceCacheMaxBytes() const {
}
GrDirectContext* context = surface_->GetContext();
if (context) {
size_t max_bytes;
context->getResourceCacheLimits(nullptr, &max_bytes);
return max_bytes;
return context->getResourceCacheLimit();
}
return std::nullopt;
}

View File

@@ -23,7 +23,7 @@ sk_sp<GrDirectContext> ShellIOManager::CreateCompatibleResourceLoadingContext(
if (auto context = GrDirectContext::MakeGL(gl_interface, options)) {
// Do not cache textures created by the image decoder. These textures
// should be deleted when they are no longer referenced by an SkImage.
context->setResourceCacheLimits(0, 0);
context->setResourceCacheLimit(0);
return context;
}
#endif

View File

@@ -125,8 +125,7 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
return false;
}
context->setResourceCacheLimits(vulkan::kGrCacheMaxCount,
vulkan::kGrCacheMaxByteSize);
context->setResourceCacheLimit(vulkan::kGrCacheMaxByteSize);
context_ = context;

View File

@@ -25,9 +25,6 @@
namespace flutter {
// Default maximum number of budgeted resources in the cache.
static const int kGrCacheMaxCount = 8192;
// Default maximum number of bytes of GPU memory of budgeted resources in the
// cache.
// The shell will dynamically increase or decrease this cache based on the
@@ -54,7 +51,7 @@ sk_sp<GrDirectContext> GPUSurfaceGL::MakeGLContext(
return nullptr;
}
context->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize);
context->setResourceCacheLimit(kGrCacheMaxByteSize);
PersistentCache::GetCacheForProcess()->PrecompileKnownSkSLs(context.get());

View File

@@ -60,7 +60,7 @@ FLUTTER_ASSERT_ARC
return nil;
}
_resourceContext->setResourceCacheLimits(0u, 0u);
_resourceContext->setResourceCacheLimit(0u);
}
return self;
}

View File

@@ -22,7 +22,6 @@ namespace flutter_runner {
namespace {
constexpr int kGrCacheMaxCount = 8192;
// Tuning advice:
// If you see the following 3 things happening simultaneously in a trace:
// * Over budget ("flutter", "GPURasterizer::Draw") durations
@@ -150,7 +149,7 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) {
}
// Use local limits specified in this file above instead of flutter defaults.
context_->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize);
context_->setResourceCacheLimit(kGrCacheMaxByteSize);
surface_pool_ =
std::make_unique<VulkanSurfacePool>(*this, context_, scenic_session);

View File

@@ -15,7 +15,6 @@
namespace vulkan {
static const int kGrCacheMaxCount = 8192;
static const size_t kGrCacheMaxByteSize = 512 * (1 << 20);
class VulkanDevice;

View File

@@ -123,7 +123,7 @@ bool VulkanWindow::CreateSkiaGrContext() {
return false;
}
context->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize);
context->setResourceCacheLimit(kGrCacheMaxByteSize);
skia_gr_context_ = context;