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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 14772021: cc::OutputSurfaceClient::InitializeForGL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dedup and refactor code Created 7 years, 7 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/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index fa6664a6623ecaaac1e6ceefb598bbc500da7b55..5e2b00b9330d23a818603e1a92d6985cd3e6ce39 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1020,6 +1020,18 @@ void LayerTreeHostImpl::SetManagedMemoryPolicy(
client_->SetNeedsCommitOnImplThread();
}
+bool LayerTreeHostImpl::InitializeForGL(
+ scoped_refptr<ContextProvider> offscreen_context_provider) {
+ scoped_ptr<OutputSurface> output_surface = CleanupForRendererInitialization();
+ bool success = DoInitializeRenderer(output_surface.Pass());
+ if (success) {
+ resource_provider_->set_offscreen_context_provider(
+ offscreen_context_provider);
+ client_->DidUpdateCapabilitiesOnImplThread();
+ }
+ return success;
+}
+
void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
client_->SetNeedsRedrawRectOnImplThread(damage_rect);
}
@@ -1379,8 +1391,8 @@ ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
return actual;
}
-bool LayerTreeHostImpl::InitializeRenderer(
- scoped_ptr<OutputSurface> output_surface) {
+scoped_ptr<OutputSurface>
+LayerTreeHostImpl::CleanupForRendererInitialization() {
// Since we will create a new resource provider, we cannot continue to use
// the old resources (i.e. render_surfaces and texture IDs). Clear them
// before we destroy the old resource provider.
@@ -1399,11 +1411,11 @@ bool LayerTreeHostImpl::InitializeRenderer(
renderer_.reset();
tile_manager_.reset();
resource_provider_.reset();
- output_surface_.reset();
-
- if (!output_surface->BindToClient(this))
- return false;
+ return output_surface_.Pass();
+}
+bool LayerTreeHostImpl::DoInitializeRenderer(
+ scoped_ptr<OutputSurface> output_surface) {
scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create(
output_surface.get(), settings_.highp_threshold_min);
if (!resource_provider)
@@ -1451,6 +1463,18 @@ bool LayerTreeHostImpl::InitializeRenderer(
return true;
}
+bool LayerTreeHostImpl::InitializeRenderer(
+ scoped_ptr<OutputSurface> output_surface) {
+ scoped_ptr<OutputSurface> old_output_surface =
+ CleanupForRendererInitialization();
+ old_output_surface.reset();
+
+ if (!output_surface->BindToClient(this))
+ return false;
+
+ return DoInitializeRenderer(output_surface.Pass());
+}
+
void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) {
if (device_viewport_size == device_viewport_size_)
return;

Powered by Google App Engine
This is Rietveld 408576698