Commit 938dd44d authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

Clean up Skia GrContext caches in GLRenderer

This CL adds GrContext that used in GLRenderer for filtering to cache
controller and adds ClientBecameBusy/ClientBecameNotBusy to support
cleaning GrContext caches.

Bug: 1004924
Change-Id: I97e69ca5f05a41f2663eb02935468e3a9bbc852d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1824252
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700240}
parent 60afbb92
...@@ -69,6 +69,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer { ...@@ -69,6 +69,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
// Public interface implemented by subclasses. // Public interface implemented by subclasses.
virtual void SwapBuffers(std::vector<ui::LatencyInfo> latency_info) = 0; virtual void SwapBuffers(std::vector<ui::LatencyInfo> latency_info) = 0;
virtual void SwapBuffersSkipped() {}
virtual void SwapBuffersComplete() {} virtual void SwapBuffersComplete() {}
virtual void DidReceiveTextureInUseResponses( virtual void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) {} const gpu::TextureInUseResponses& responses) {}
......
...@@ -637,6 +637,8 @@ bool Display::DrawAndSwap() { ...@@ -637,6 +637,8 @@ bool Display::DrawAndSwap() {
} }
} }
renderer_->SwapBuffersSkipped();
TRACE_EVENT_ASYNC_END1("viz,benchmark", "Graphics.Pipeline.DrawAndSwap", TRACE_EVENT_ASYNC_END1("viz,benchmark", "Graphics.Pipeline.DrawAndSwap",
swapped_trace_id_, "status", "canceled"); swapped_trace_id_, "status", "canceled");
--swapped_trace_id_; --swapped_trace_id_;
......
...@@ -378,9 +378,13 @@ GLRenderer::GLRenderer( ...@@ -378,9 +378,13 @@ GLRenderer::GLRenderer(
GLRenderer::~GLRenderer() { GLRenderer::~GLRenderer() {
CleanupSharedObjects(); CleanupSharedObjects();
auto* context_provider = output_surface_->context_provider();
auto* cache_controller = context_provider->CacheController();
if (context_busy_) {
cache_controller->ClientBecameNotBusy(std::move(context_busy_));
}
if (context_visibility_) { if (context_visibility_) {
auto* context_provider = output_surface_->context_provider();
auto* cache_controller = context_provider->CacheController();
cache_controller->ClientBecameNotVisibleDuringShutdown( cache_controller->ClientBecameNotVisibleDuringShutdown(
std::move(context_visibility_)); std::move(context_visibility_));
} }
...@@ -479,6 +483,12 @@ void GLRenderer::ClearFramebuffer() { ...@@ -479,6 +483,12 @@ void GLRenderer::ClearFramebuffer() {
void GLRenderer::BeginDrawingFrame() { void GLRenderer::BeginDrawingFrame() {
TRACE_EVENT0("viz", "GLRenderer::BeginDrawingFrame"); TRACE_EVENT0("viz", "GLRenderer::BeginDrawingFrame");
if (!context_busy_) {
context_busy_ = output_surface_->context_provider()
->CacheController()
->ClientBecameBusy();
}
scoped_refptr<ResourceFence> read_lock_fence; scoped_refptr<ResourceFence> read_lock_fence;
if (use_sync_query_) { if (use_sync_query_) {
read_lock_fence = sync_queries_.StartNewFrame(); read_lock_fence = sync_queries_.StartNewFrame();
...@@ -2957,6 +2967,18 @@ void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) { ...@@ -2957,6 +2967,18 @@ void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {
output_surface_->SwapBuffers(std::move(output_frame)); output_surface_->SwapBuffers(std::move(output_frame));
swap_buffer_rect_ = gfx::Rect(); swap_buffer_rect_ = gfx::Rect();
if (context_busy_) {
output_surface_->context_provider()->CacheController()->ClientBecameNotBusy(
std::move(context_busy_));
}
}
void GLRenderer::SwapBuffersSkipped() {
if (context_busy_) {
output_surface_->context_provider()->CacheController()->ClientBecameNotBusy(
std::move(context_busy_));
}
} }
void GLRenderer::SwapBuffersComplete() { void GLRenderer::SwapBuffersComplete() {
......
...@@ -69,6 +69,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -69,6 +69,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
bool use_swap_with_bounds() const { return use_swap_with_bounds_; } bool use_swap_with_bounds() const { return use_swap_with_bounds_; }
void SwapBuffers(std::vector<ui::LatencyInfo> latency_info) override; void SwapBuffers(std::vector<ui::LatencyInfo> latency_info) override;
void SwapBuffersSkipped() override;
void SwapBuffersComplete() override; void SwapBuffersComplete() override;
void DidReceiveTextureInUseResponses( void DidReceiveTextureInUseResponses(
...@@ -386,6 +387,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -386,6 +387,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
gpu::gles2::GLES2Interface* gl_; gpu::gles2::GLES2Interface* gl_;
gpu::ContextSupport* context_support_; gpu::ContextSupport* context_support_;
std::unique_ptr<ContextCacheController::ScopedVisibility> context_visibility_; std::unique_ptr<ContextCacheController::ScopedVisibility> context_visibility_;
std::unique_ptr<ContextCacheController::ScopedBusy> context_busy_;
TextureDeleter texture_deleter_; TextureDeleter texture_deleter_;
GLRendererCopier copier_; GLRendererCopier copier_;
......
...@@ -172,6 +172,7 @@ class GrContext* VizProcessContextProvider::GrContext() { ...@@ -172,6 +172,7 @@ class GrContext* VizProcessContextProvider::GrContext() {
gr_context_ = std::make_unique<skia_bindings::GrContextForGLES2Interface>( gr_context_ = std::make_unique<skia_bindings::GrContextForGLES2Interface>(
ContextGL(), ContextSupport(), ContextCapabilities(), ContextGL(), ContextSupport(), ContextCapabilities(),
max_resource_cache_bytes, max_glyph_cache_texture_bytes); max_resource_cache_bytes, max_glyph_cache_texture_bytes);
cache_controller_->SetGrContext(gr_context_->get());
return gr_context_->get(); return gr_context_->get();
} }
......
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