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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1028 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1029 } else { 1029 } else {
1030 DCHECK(proxy_->IsImplThread()); 1030 DCHECK(proxy_->IsImplThread());
1031 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1031 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1032 } 1032 }
1033 1033
1034 if (needs_commit) 1034 if (needs_commit)
1035 client_->SetNeedsCommitOnImplThread(); 1035 client_->SetNeedsCommitOnImplThread();
1036 } 1036 }
1037 1037
1038 bool LayerTreeHostImpl::InitializeForGL(
1039 scoped_refptr<ContextProvider> offscreen_context_provider) {
1040 scoped_ptr<OutputSurface> output_surface = CleanupForRendererInitialization();
1041 bool success =
1042 DoInitializeRenderer(output_surface.Pass(), true /* is_deffered_init */);
1043 client_->DidUpdateCapabilitiesOnImplThread(success,
1044 offscreen_context_provider);
1045 return success;
1046 }
1047
1038 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) { 1048 void LayerTreeHostImpl::SetNeedsRedrawRect(gfx::Rect damage_rect) {
1039 client_->SetNeedsRedrawRectOnImplThread(damage_rect); 1049 client_->SetNeedsRedrawRectOnImplThread(damage_rect);
1040 } 1050 }
1041 1051
1042 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase, 1052 void LayerTreeHostImpl::OnVSyncParametersChanged(base::TimeTicks timebase,
1043 base::TimeDelta interval) { 1053 base::TimeDelta interval) {
1044 client_->OnVSyncParametersChanged(timebase, interval); 1054 client_->OnVSyncParametersChanged(timebase, interval);
1045 } 1055 }
1046 1056
1047 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) { 1057 void LayerTreeHostImpl::BeginFrame(base::TimeTicks frame_time) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 return managed_memory_policy_; 1401 return managed_memory_policy_;
1392 1402
1393 ManagedMemoryPolicy actual = managed_memory_policy_; 1403 ManagedMemoryPolicy actual = managed_memory_policy_;
1394 actual.priority_cutoff_when_not_visible = 1404 actual.priority_cutoff_when_not_visible =
1395 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING; 1405 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING;
1396 actual.priority_cutoff_when_visible = 1406 actual.priority_cutoff_when_visible =
1397 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY; 1407 ManagedMemoryPolicy::CUTOFF_ALLOW_REQUIRED_ONLY;
1398 return actual; 1408 return actual;
1399 } 1409 }
1400 1410
1401 bool LayerTreeHostImpl::InitializeRenderer( 1411 scoped_ptr<OutputSurface>
1402 scoped_ptr<OutputSurface> output_surface) { 1412 LayerTreeHostImpl::CleanupForRendererInitialization() {
1403 // Since we will create a new resource provider, we cannot continue to use 1413 // Since we will create a new resource provider, we cannot continue to use
1404 // the old resources (i.e. render_surfaces and texture IDs). Clear them 1414 // the old resources (i.e. render_surfaces and texture IDs). Clear them
1405 // before we destroy the old resource provider. 1415 // before we destroy the old resource provider.
1406 if (active_tree_->root_layer()) 1416 if (active_tree_->root_layer())
1407 ClearRenderSurfaces(); 1417 ClearRenderSurfaces();
1408 if (active_tree_->root_layer()) 1418 if (active_tree_->root_layer())
1409 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer()); 1419 SendDidLoseOutputSurfaceRecursive(active_tree_->root_layer());
1410 if (pending_tree_ && pending_tree_->root_layer()) 1420 if (pending_tree_ && pending_tree_->root_layer())
1411 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer()); 1421 SendDidLoseOutputSurfaceRecursive(pending_tree_->root_layer());
1412 if (recycle_tree_ && recycle_tree_->root_layer()) 1422 if (recycle_tree_ && recycle_tree_->root_layer())
1413 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer()); 1423 SendDidLoseOutputSurfaceRecursive(recycle_tree_->root_layer());
1414 if (resource_provider_) 1424 if (resource_provider_)
1415 resource_provider_->DidLoseOutputSurface(); 1425 resource_provider_->DidLoseOutputSurface();
1416 1426
1417 // Note: order is important here. 1427 // Note: order is important here.
1418 renderer_.reset(); 1428 renderer_.reset();
1419 tile_manager_.reset(); 1429 tile_manager_.reset();
1420 resource_provider_.reset(); 1430 resource_provider_.reset();
1421 output_surface_.reset(); 1431 return output_surface_.Pass();
1432 }
1422 1433
1423 if (!output_surface->BindToClient(this)) 1434 bool LayerTreeHostImpl::DoInitializeRenderer(
1424 return false; 1435 scoped_ptr<OutputSurface> output_surface,
1425 1436 bool is_deffered_init) {
1426 if (output_surface->capabilities().deferred_gl_initialization) { 1437 if (output_surface->capabilities().deferred_gl_initialization &&
1438 !is_deffered_init) {
1427 // TODO(joth): Defer creating the Renderer too, until GL is initialized. 1439 // TODO(joth): Defer creating the Renderer too, until GL is initialized.
1428 // See http://crbug.com/230197 1440 // See http://crbug.com/230197
1429 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL); 1441 renderer_ = SoftwareRenderer::Create(this, output_surface.get(), NULL);
1430 } else { 1442 } else {
1431 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( 1443 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create(
1432 output_surface.get(), settings_.highp_threshold_min); 1444 output_surface.get(), settings_.highp_threshold_min);
1433 if (!resource_provider) 1445 if (!resource_provider)
1434 return false; 1446 return false;
1435 1447
1436 if (output_surface->capabilities().has_parent_compositor) { 1448 if (output_surface->capabilities().has_parent_compositor) {
1437 renderer_ = DelegatingRenderer::Create(this, output_surface.get(), 1449 renderer_ = DelegatingRenderer::Create(
1438 resource_provider.get()); 1450 this, output_surface.get(), resource_provider.get());
1439 } else if (output_surface->context3d()) { 1451 } else if (output_surface->context3d()) {
1440 renderer_ = GLRenderer::Create(this, 1452 renderer_ = GLRenderer::Create(this,
1441 output_surface.get(), 1453 output_surface.get(),
1442 resource_provider.get(), 1454 resource_provider.get(),
1443 settings_.highp_threshold_min, 1455 settings_.highp_threshold_min,
1444 settings_.force_direct_layer_drawing); 1456 settings_.force_direct_layer_drawing);
1445 } else if (output_surface->software_device()) { 1457 } else if (output_surface->software_device()) {
1446 renderer_ = SoftwareRenderer::Create(this, 1458 renderer_ = SoftwareRenderer::Create(
1447 output_surface.get(), 1459 this, output_surface.get(), resource_provider.get());
1448 resource_provider.get());
1449 } 1460 }
1450 if (!renderer_) 1461 if (!renderer_)
1451 return false; 1462 return false;
1452 1463
1453 if (settings_.impl_side_painting) { 1464 if (settings_.impl_side_painting) {
1454 bool using_map_image = GetRendererCapabilities().using_map_image; 1465 bool using_map_image = GetRendererCapabilities().using_map_image;
1455 tile_manager_ = TileManager::Create(this, 1466 tile_manager_ = TileManager::Create(this,
1456 resource_provider.get(), 1467 resource_provider.get(),
1457 settings_.num_raster_threads, 1468 settings_.num_raster_threads,
1458 settings_.use_color_estimator, 1469 settings_.use_color_estimator,
(...skipping 14 matching lines...) Expand all
1473 1484
1474 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs 1485 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs
1475 // to be initialized to get max texture size. 1486 // to be initialized to get max texture size.
1476 active_tree_->set_needs_update_draw_properties(); 1487 active_tree_->set_needs_update_draw_properties();
1477 if (pending_tree_) 1488 if (pending_tree_)
1478 pending_tree_->set_needs_update_draw_properties(); 1489 pending_tree_->set_needs_update_draw_properties();
1479 1490
1480 return true; 1491 return true;
1481 } 1492 }
1482 1493
1494 bool LayerTreeHostImpl::InitializeRenderer(
danakj 2013/05/24 19:02:30 Move this function up by the deferred init method?
1495 scoped_ptr<OutputSurface> output_surface) {
1496 scoped_ptr<OutputSurface> old_output_surface =
1497 CleanupForRendererInitialization();
1498 old_output_surface.reset();
1499
1500 if (!output_surface->BindToClient(this))
1501 return false;
1502
1503 return DoInitializeRenderer(output_surface.Pass(),
1504 false /* is_deffered_init */);
1505 }
1506
1483 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) { 1507 void LayerTreeHostImpl::SetViewportSize(gfx::Size device_viewport_size) {
1484 if (device_viewport_size == device_viewport_size_) 1508 if (device_viewport_size == device_viewport_size_)
1485 return; 1509 return;
1486 1510
1487 if (pending_tree_ && device_viewport_size_ != device_viewport_size) 1511 if (pending_tree_ && device_viewport_size_ != device_viewport_size)
1488 active_tree_->SetViewportSizeInvalid(); 1512 active_tree_->SetViewportSizeInvalid();
1489 1513
1490 device_viewport_size_ = device_viewport_size; 1514 device_viewport_size_ = device_viewport_size;
1491 1515
1492 UpdateMaxScrollOffset(); 1516 UpdateMaxScrollOffset();
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 } 2260 }
2237 2261
2238 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) { 2262 void LayerTreeHostImpl::SetDebugState(const LayerTreeDebugState& debug_state) {
2239 if (debug_state_.continuous_painting != debug_state.continuous_painting) 2263 if (debug_state_.continuous_painting != debug_state.continuous_painting)
2240 paint_time_counter_->ClearHistory(); 2264 paint_time_counter_->ClearHistory();
2241 2265
2242 debug_state_ = debug_state; 2266 debug_state_ = debug_state;
2243 } 2267 }
2244 2268
2245 } // namespace cc 2269 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698