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

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: cc refactors to reduce duplication 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 f58f3c2d7add8598fe445712494c94050ceaebcd..41e57a21ad64c835bbad7e60639b24153c23838b 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1035,6 +1035,16 @@ 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(), true /* is_deffered_init */);
+ client_->DidUpdateCapabilitiesOnImplThread(success,
+ offscreen_context_provider);
+ return success;
+}
+
void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
client_->SetNeedsRedrawRectOnImplThread(damage_rect);
}
@@ -1398,8 +1408,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.
@@ -1418,12 +1428,14 @@ 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();
+}
- if (output_surface->capabilities().deferred_gl_initialization) {
+bool LayerTreeHostImpl::DoInitializeRenderer(
+ scoped_ptr<OutputSurface> output_surface,
+ bool is_deffered_init) {
+ if (output_surface->capabilities().deferred_gl_initialization &&
+ !is_deffered_init) {
// TODO(joth): Defer creating the Renderer too, until GL is initialized.
// See http://crbug.com/230197
renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL);
@@ -1434,8 +1446,8 @@ bool LayerTreeHostImpl::InitializeRenderer(
return false;
if (output_surface->capabilities().has_parent_compositor) {
- renderer_ = DelegatingRenderer::Create(this, output_surface.get(),
- resource_provider.get());
+ renderer_ = DelegatingRenderer::Create(
+ this, output_surface.get(), resource_provider.get());
} else if (output_surface->context3d()) {
renderer_ = GLRenderer::Create(this,
output_surface.get(),
@@ -1443,9 +1455,8 @@ bool LayerTreeHostImpl::InitializeRenderer(
settings_.highp_threshold_min,
settings_.force_direct_layer_drawing);
} else if (output_surface->software_device()) {
- renderer_ = SoftwareRenderer::Create(this,
- output_surface.get(),
- resource_provider.get());
+ renderer_ = SoftwareRenderer::Create(
+ this, output_surface.get(), resource_provider.get());
}
if (!renderer_)
return false;
@@ -1480,6 +1491,19 @@ bool LayerTreeHostImpl::InitializeRenderer(
return true;
}
+bool LayerTreeHostImpl::InitializeRenderer(
danakj 2013/05/24 19:02:30 Move this function up by the deferred init method?
+ 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(),
+ false /* is_deffered_init */);
+}
+
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