Commit 274eb4f8 authored by Brian Salomon's avatar Brian Salomon Committed by Commit Bot

Perform Skia's deferred cleanup in ContextCacheController::ClientBecameBusy

Bug: 883507
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I76f00baa70afd29585f2d4f3a71aa2a05126a4a9
Reviewed-on: https://chromium-review.googlesource.com/1224674
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591922}
parent d465724a
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/viz/common/gpu/context_cache_controller.h" #include "components/viz/common/gpu/context_cache_controller.h"
#include <chrono>
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -14,6 +16,7 @@ ...@@ -14,6 +16,7 @@
namespace viz { namespace viz {
namespace { namespace {
static const int kIdleCleanupDelaySeconds = 1; static const int kIdleCleanupDelaySeconds = 1;
static const int kOldResourceCleanupDelaySeconds = 30;
} // namespace } // namespace
ContextCacheController::ScopedToken::ScopedToken() = default; ContextCacheController::ScopedToken::ScopedToken() = default;
...@@ -109,6 +112,13 @@ void ContextCacheController::ClientBecameNotBusy( ...@@ -109,6 +112,13 @@ void ContextCacheController::ClientBecameNotBusy(
DCHECK_GT(num_clients_busy_, 0u); DCHECK_GT(num_clients_busy_, 0u);
--num_clients_busy_; --num_clients_busy_;
// Here we ask GrContext to free any resources that haven't been used in
// a long while even if it is under budget.
if (gr_context_) {
gr_context_->performDeferredCleanup(
std::chrono::seconds(kOldResourceCleanupDelaySeconds));
}
// If we have become idle and we are visible, queue a task to drop resources // If we have become idle and we are visible, queue a task to drop resources
// after a delay. If are not visible, we have already dropped resources. // after a delay. If are not visible, we have already dropped resources.
if (num_clients_busy_ == 0 && num_clients_visible_ > 0 && task_runner_) { if (num_clients_busy_ == 0 && num_clients_visible_ > 0 && task_runner_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment