Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 rendering_stats_instrumentation)); | 162 rendering_stats_instrumentation)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 LayerTreeHostImpl::LayerTreeHostImpl( | 165 LayerTreeHostImpl::LayerTreeHostImpl( |
| 166 const LayerTreeSettings& settings, | 166 const LayerTreeSettings& settings, |
| 167 LayerTreeHostImplClient* client, | 167 LayerTreeHostImplClient* client, |
| 168 Proxy* proxy, | 168 Proxy* proxy, |
| 169 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 169 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 170 : client_(client), | 170 : client_(client), |
| 171 proxy_(proxy), | 171 proxy_(proxy), |
| 172 output_surface_lost_(true), | |
| 172 input_handler_client_(NULL), | 173 input_handler_client_(NULL), |
| 173 did_lock_scrolling_layer_(false), | 174 did_lock_scrolling_layer_(false), |
| 174 should_bubble_scrolls_(false), | 175 should_bubble_scrolls_(false), |
| 175 wheel_scrolling_(false), | 176 wheel_scrolling_(false), |
| 176 manage_tiles_needed_(false), | 177 manage_tiles_needed_(false), |
| 177 root_layer_scroll_offset_delegate_(NULL), | 178 root_layer_scroll_offset_delegate_(NULL), |
| 178 settings_(settings), | 179 settings_(settings), |
| 179 visible_(true), | 180 visible_(true), |
| 180 cached_managed_memory_policy_( | 181 cached_managed_memory_policy_( |
| 181 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1340 bool LayerTreeHostImpl::IsContextLost() { | 1341 bool LayerTreeHostImpl::IsContextLost() { |
| 1341 DCHECK(proxy_->IsImplThread()); | 1342 DCHECK(proxy_->IsImplThread()); |
| 1342 return renderer_ && renderer_->IsContextLost(); | 1343 return renderer_ && renderer_->IsContextLost(); |
| 1343 } | 1344 } |
| 1344 | 1345 |
| 1345 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { | 1346 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { |
| 1346 return renderer_->Capabilities(); | 1347 return renderer_->Capabilities(); |
| 1347 } | 1348 } |
| 1348 | 1349 |
| 1349 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1350 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
| 1350 if (frame.has_no_damage) | 1351 if (frame.has_no_damage || output_surface_lost_) |
|
Sami
2013/08/30 13:49:06
Could you explain why we'd need to avoid swapping
brianderson
2013/09/03 22:51:47
This was a change I pulled in from the big patch "
| |
| 1351 return false; | 1352 return false; |
| 1352 renderer_->SwapBuffers(); | 1353 renderer_->SwapBuffers(); |
| 1353 active_tree_->ClearLatencyInfo(); | 1354 active_tree_->ClearLatencyInfo(); |
| 1354 return true; | 1355 return true; |
| 1355 } | 1356 } |
| 1356 | 1357 |
| 1357 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1358 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
| 1358 if (output_surface_) | 1359 if (output_surface_) |
| 1359 output_surface_->SetNeedsBeginFrame(enable); | 1360 output_surface_->SetNeedsBeginFrame(enable); |
| 1360 } | 1361 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1383 } | 1384 } |
| 1384 | 1385 |
| 1385 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { | 1386 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { |
| 1386 return settings(); | 1387 return settings(); |
| 1387 } | 1388 } |
| 1388 | 1389 |
| 1389 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1390 void LayerTreeHostImpl::DidLoseOutputSurface() { |
| 1390 // TODO(jamesr): The renderer_ check is needed to make some of the | 1391 // TODO(jamesr): The renderer_ check is needed to make some of the |
| 1391 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1392 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
| 1392 // important) in production. We should adjust the test to not need this. | 1393 // important) in production. We should adjust the test to not need this. |
| 1394 output_surface_lost_ = true; | |
| 1393 if (renderer_) | 1395 if (renderer_) |
| 1394 client_->DidLoseOutputSurfaceOnImplThread(); | 1396 client_->DidLoseOutputSurfaceOnImplThread(); |
| 1395 } | 1397 } |
| 1396 | 1398 |
| 1397 void LayerTreeHostImpl::Readback(void* pixels, | 1399 void LayerTreeHostImpl::Readback(void* pixels, |
| 1398 gfx::Rect rect_in_device_viewport) { | 1400 gfx::Rect rect_in_device_viewport) { |
| 1399 DCHECK(renderer_); | 1401 DCHECK(renderer_); |
| 1400 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); | 1402 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); |
| 1401 } | 1403 } |
| 1402 | 1404 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 // before we destroy the old resource provider. | 1619 // before we destroy the old resource provider. |
| 1618 ReleaseTreeResources(); | 1620 ReleaseTreeResources(); |
| 1619 if (resource_provider_) | 1621 if (resource_provider_) |
| 1620 resource_provider_->DidLoseOutputSurface(); | 1622 resource_provider_->DidLoseOutputSurface(); |
| 1621 | 1623 |
| 1622 // Note: order is important here. | 1624 // Note: order is important here. |
| 1623 renderer_.reset(); | 1625 renderer_.reset(); |
| 1624 tile_manager_.reset(); | 1626 tile_manager_.reset(); |
| 1625 resource_provider_.reset(); | 1627 resource_provider_.reset(); |
| 1626 output_surface_.reset(); | 1628 output_surface_.reset(); |
| 1629 output_surface_lost_ = true; | |
| 1627 | 1630 |
| 1628 if (!output_surface->BindToClient(this)) | 1631 if (!output_surface->BindToClient(this)) |
| 1629 return false; | 1632 return false; |
| 1630 | 1633 |
| 1631 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1634 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
| 1632 output_surface.get(), settings_.highp_threshold_min); | 1635 output_surface.get(), settings_.highp_threshold_min); |
| 1633 if (!resource_provider) | 1636 if (!resource_provider) |
| 1634 return false; | 1637 return false; |
| 1635 | 1638 |
| 1636 if (output_surface->capabilities().deferred_gl_initialization) | 1639 if (output_surface->capabilities().deferred_gl_initialization) |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1662 } | 1665 } |
| 1663 | 1666 |
| 1664 int max_frames_pending = | 1667 int max_frames_pending = |
| 1665 output_surface->capabilities().max_frames_pending; | 1668 output_surface->capabilities().max_frames_pending; |
| 1666 if (max_frames_pending <= 0) | 1669 if (max_frames_pending <= 0) |
| 1667 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1670 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
| 1668 output_surface->SetMaxFramesPending(max_frames_pending); | 1671 output_surface->SetMaxFramesPending(max_frames_pending); |
| 1669 | 1672 |
| 1670 resource_provider_ = resource_provider.Pass(); | 1673 resource_provider_ = resource_provider.Pass(); |
| 1671 output_surface_ = output_surface.Pass(); | 1674 output_surface_ = output_surface.Pass(); |
| 1675 output_surface_lost_ = false; | |
| 1672 | 1676 |
| 1673 client_->OnCanDrawStateChanged(CanDraw()); | 1677 client_->OnCanDrawStateChanged(CanDraw()); |
| 1674 | 1678 |
| 1675 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1679 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
| 1676 // to be initialized to get max texture size. | 1680 // to be initialized to get max texture size. |
| 1677 active_tree_->set_needs_update_draw_properties(); | 1681 active_tree_->set_needs_update_draw_properties(); |
| 1678 if (pending_tree_) | 1682 if (pending_tree_) |
| 1679 pending_tree_->set_needs_update_draw_properties(); | 1683 pending_tree_->set_needs_update_draw_properties(); |
| 1680 | 1684 |
| 1681 return true; | 1685 return true; |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2577 | 2581 |
| 2578 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2582 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2579 UIResourceId uid) const { | 2583 UIResourceId uid) const { |
| 2580 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2584 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2581 if (iter != ui_resource_map_.end()) | 2585 if (iter != ui_resource_map_.end()) |
| 2582 return iter->second; | 2586 return iter->second; |
| 2583 return 0; | 2587 return 0; |
| 2584 } | 2588 } |
| 2585 | 2589 |
| 2586 } // namespace cc | 2590 } // namespace cc |
| OLD | NEW |