Call GrContext::performDeferredCleanup from viewer
Bug: skia:
Change-Id: I723c5efdd746d6182dee0511795f7eca3b6066d3
Reviewed-on: https://skia-review.googlesource.com/c/167180
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/tools/sk_app/Window.cpp b/tools/sk_app/Window.cpp
index 862ee1a..7359b31 100644
--- a/tools/sk_app/Window.cpp
+++ b/tools/sk_app/Window.cpp
@@ -130,7 +130,7 @@
return fWindowContext->stencilBits();
}
-const GrContext* Window::getGrContext() const {
+GrContext* Window::getGrContext() const {
if (!fWindowContext) {
return nullptr;
}
diff --git a/tools/sk_app/Window.h b/tools/sk_app/Window.h
index 29d90c6..e1fb0ad 100644
--- a/tools/sk_app/Window.h
+++ b/tools/sk_app/Window.h
@@ -183,7 +183,7 @@
int stencilBits() const;
// Returns null if there is not a GPU backend or if the backend is not yet created.
- const GrContext* getGrContext() const;
+ GrContext* getGrContext() const;
protected:
Window();
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 2bc8ee3..bf779e9 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1215,6 +1215,11 @@
fCommands.drawHelp(canvas);
this->drawImGui();
+
+ if (GrContext* ctx = fWindow->getGrContext()) {
+ // Clean out cache items that haven't been used in more than 10 seconds.
+ ctx->performDeferredCleanup(std::chrono::seconds(10));
+ }
}
void Viewer::onResize(int width, int height) {