Skip to content

Commit

Permalink
Migrate the API of GrDirectContext about resource memory limit (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdPaleLight authored Mar 14, 2022
1 parent 57c05b3 commit 0cf0ea0
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 18 deletions.
8 changes: 2 additions & 6 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion shell/common/shell_io_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions shell/common/shell_test_platform_view_vulkan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() {
return false;
}

context->setResourceCacheLimits(vulkan::kGrCacheMaxCount,
vulkan::kGrCacheMaxByteSize);
context->setResourceCacheLimit(vulkan::kGrCacheMaxByteSize);

context_ = context;

Expand Down
5 changes: 1 addition & 4 deletions shell/gpu/gpu_surface_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,7 +51,7 @@ sk_sp<GrDirectContext> GPUSurfaceGL::MakeGLContext(
return nullptr;
}

context->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize);
context->setResourceCacheLimit(kGrCacheMaxByteSize);

PersistentCache::GetCacheForProcess()->PrecompileKnownSkSLs(context.get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (instancetype)initWithMTLDevice:(id<MTLDevice>)device
return nil;
}

_resourceContext->setResourceCacheLimits(0u, 0u);
_resourceContext->setResourceCacheLimit(0u);
}
return self;
}
Expand Down
3 changes: 1 addition & 2 deletions shell/platform/fuchsia/flutter/vulkan_surface_producer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion vulkan/vulkan_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace vulkan {

static const int kGrCacheMaxCount = 8192;
static const size_t kGrCacheMaxByteSize = 512 * (1 << 20);

class VulkanDevice;
Expand Down
2 changes: 1 addition & 1 deletion vulkan/vulkan_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool VulkanWindow::CreateSkiaGrContext() {
return false;
}

context->setResourceCacheLimits(kGrCacheMaxCount, kGrCacheMaxByteSize);
context->setResourceCacheLimit(kGrCacheMaxByteSize);

skia_gr_context_ = context;

Expand Down

0 comments on commit 0cf0ea0

Please sign in to comment.