Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3666)

Unified Diff: cc/output/gl_renderer.cc

Issue 2252163003: Update Context Client Visibility to use Scoped Pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 98e7eb1c8b06c288ced51168bedbf3931e995ea4..57859106989fe924c21c5b25ba3a3f15935f1bc9 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -47,7 +47,6 @@
#include "cc/resources/resource_pool.h"
#include "cc/resources/scoped_resource.h"
#include "gpu/GLES2/gl2extchromium.h"
-#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/gpu_memory_allocation.h"
#include "media/base/media_switches.h"
@@ -145,6 +144,28 @@ BlendMode BlendModeFromSkXfermode(SkXfermode::Mode mode) {
}
}
+void UpdateVisibilityForContextProvider(
+ ContextProvider* context_provider,
+ std::unique_ptr<gpu::ContextSupport::ScopedVisibility>* scoped_visibility,
+ bool is_visible) {
+ if (is_visible && *scoped_visibility)
danakj 2016/08/18 21:39:44 These 2 can be combined as is_visible == *scoped_v
ericrk 2016/08/19 17:23:18 good point
+ return;
+ if (!is_visible && !*scoped_visibility)
+ return;
+
+ gpu::ContextSupport* context_support = context_provider->ContextSupport();
+
+ if (is_visible)
+ *scoped_visibility = context_support->ClientBecameVisible();
+ else
+ context_support->ClientBecameNotVisible(std::move(*scoped_visibility));
+
+ bool aggressively_free_resources = !context_support->AnyClientsVisible();
+ if (aggressively_free_resources)
+ context_provider->DeleteCachedResources();
+ context_support->SetAggressivelyFreeResources(aggressively_free_resources);
+}
+
// Smallest unit that impact anti-aliasing output. We use this to
// determine when anti-aliasing is unnecessary.
const float kAntiAliasingEpsilon = 1.0f / 1024.0f;
@@ -417,6 +438,10 @@ GLRenderer::~GLRenderer() {
pending_async_read_pixels_.pop_back();
}
+ // Set our visibility to false to ensure we clean up context resources.
+ UpdateVisibilityForContextProvider(output_surface_->context_provider(),
+ &context_client_visibility_, false);
+
CleanupSharedObjects();
}
@@ -440,15 +465,8 @@ void GLRenderer::DidChangeVisibility() {
PrepareGeometry(NO_BINDING);
- // Handle cleanup of resources on the ContextProvider. The compositor
- // ContextProvider is not shared, so always pass 0 for the client_id.
- // TODO(crbug.com/487471): Update this when we share compositor
- // ContextProviders.
- context_support_->SetClientVisible(0 /* client_id */, visible_);
- bool aggressively_free_resources = !context_support_->AnyClientsVisible();
- if (aggressively_free_resources)
- output_surface_->context_provider()->DeleteCachedResources();
- context_support_->SetAggressivelyFreeResources(aggressively_free_resources);
+ UpdateVisibilityForContextProvider(output_surface_->context_provider(),
+ &context_client_visibility_, visible_);
}
void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); }

Powered by Google App Engine
This is Rietveld 408576698