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 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 zero_budget_(false), | 249 zero_budget_(false), |
| 250 device_scale_factor_(1.f), | 250 device_scale_factor_(1.f), |
| 251 overhang_ui_resource_id_(0), | 251 overhang_ui_resource_id_(0), |
| 252 top_controls_layout_height_(0.f), | 252 top_controls_layout_height_(0.f), |
| 253 resourceless_software_draw_(false), | 253 resourceless_software_draw_(false), |
| 254 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 254 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
| 255 animation_registrar_(AnimationRegistrar::Create()), | 255 animation_registrar_(AnimationRegistrar::Create()), |
| 256 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 256 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 257 micro_benchmark_controller_(this), | 257 micro_benchmark_controller_(this), |
| 258 need_to_update_visible_tiles_before_draw_(false), | 258 need_to_update_visible_tiles_before_draw_(false), |
| 259 have_valid_output_surface_(false), | |
| 260 shared_bitmap_manager_(manager), | 259 shared_bitmap_manager_(manager), |
| 261 id_(id), | 260 id_(id), |
| 262 transfer_buffer_memory_limit_(0u) { | 261 transfer_buffer_memory_limit_(0u) { |
| 263 DCHECK(proxy_->IsImplThread()); | 262 DCHECK(proxy_->IsImplThread()); |
| 264 DidVisibilityChange(this, visible_); | 263 DidVisibilityChange(this, visible_); |
| 265 animation_registrar_->set_supports_scroll_animations( | 264 animation_registrar_->set_supports_scroll_animations( |
| 266 proxy_->SupportsImplScrolling()); | 265 proxy_->SupportsImplScrolling()); |
| 267 | 266 |
| 268 SetDebugState(settings.initial_debug_state); | 267 SetDebugState(settings.initial_debug_state); |
| 269 | 268 |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1608 // Once all layers have been drawn, pending texture uploads should no | 1607 // Once all layers have been drawn, pending texture uploads should no |
| 1609 // longer block future uploads. | 1608 // longer block future uploads. |
| 1610 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1609 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
| 1611 } | 1610 } |
| 1612 | 1611 |
| 1613 void LayerTreeHostImpl::FinishAllRendering() { | 1612 void LayerTreeHostImpl::FinishAllRendering() { |
| 1614 if (renderer_) | 1613 if (renderer_) |
| 1615 renderer_->Finish(); | 1614 renderer_->Finish(); |
| 1616 } | 1615 } |
| 1617 | 1616 |
| 1618 bool LayerTreeHostImpl::IsContextLost() { | |
| 1619 DCHECK(proxy_->IsImplThread()); | |
| 1620 // To avoid races, rely only on the lost-surface callback. | |
| 1621 // See crbug.com/392891. | |
| 1622 return !have_valid_output_surface_; | |
| 1623 } | |
| 1624 | |
| 1625 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { | 1617 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { |
| 1626 if (use_gpu == use_gpu_rasterization_) | 1618 if (use_gpu == use_gpu_rasterization_) |
| 1627 return; | 1619 return; |
| 1628 | 1620 |
| 1629 use_gpu_rasterization_ = use_gpu; | 1621 use_gpu_rasterization_ = use_gpu; |
| 1630 ReleaseTreeResources(); | 1622 ReleaseTreeResources(); |
| 1631 | 1623 |
| 1632 // Replace existing tile manager with another one that uses appropriate | 1624 // Replace existing tile manager with another one that uses appropriate |
| 1633 // rasterizer. | 1625 // rasterizer. |
| 1634 if (tile_manager_) { | 1626 if (tile_manager_) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1687 return; | 1679 return; |
| 1688 | 1680 |
| 1689 if (top_controls_manager_) | 1681 if (top_controls_manager_) |
| 1690 container_layer->SetBoundsDelta( | 1682 container_layer->SetBoundsDelta( |
| 1691 gfx::Vector2dF(0, | 1683 gfx::Vector2dF(0, |
| 1692 top_controls_layout_height_ - | 1684 top_controls_layout_height_ - |
| 1693 top_controls_manager_->content_top_offset())); | 1685 top_controls_manager_->content_top_offset())); |
| 1694 } | 1686 } |
| 1695 | 1687 |
| 1696 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1688 void LayerTreeHostImpl::DidLoseOutputSurface() { |
| 1697 if (!have_valid_output_surface_) | |
| 1698 return; | |
| 1699 have_valid_output_surface_ = false; | |
| 1700 if (resource_provider_) | 1689 if (resource_provider_) |
| 1701 resource_provider_->DidLoseOutputSurface(); | 1690 resource_provider_->DidLoseOutputSurface(); |
| 1702 // TODO(jamesr): The renderer_ check is needed to make some of the | 1691 client_->DidLoseOutputSurfaceOnImplThread(); |
|
enne (OOO)
2014/08/25 17:09:30
Super excited that this TODO can finally go away.
| |
| 1703 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | |
| 1704 // important) in production. We should adjust the test to not need this. | |
| 1705 if (renderer_) | |
| 1706 client_->DidLoseOutputSurfaceOnImplThread(); | |
| 1707 } | 1692 } |
| 1708 | 1693 |
| 1709 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1694 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
| 1710 return !!InnerViewportScrollLayer(); | 1695 return !!InnerViewportScrollLayer(); |
| 1711 } | 1696 } |
| 1712 | 1697 |
| 1713 LayerImpl* LayerTreeHostImpl::RootLayer() const { | 1698 LayerImpl* LayerTreeHostImpl::RootLayer() const { |
| 1714 return active_tree_->root_layer(); | 1699 return active_tree_->root_layer(); |
| 1715 } | 1700 } |
| 1716 | 1701 |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 // Note: order is important here. | 2040 // Note: order is important here. |
| 2056 renderer_.reset(); | 2041 renderer_.reset(); |
| 2057 DestroyTileManager(); | 2042 DestroyTileManager(); |
| 2058 resource_provider_.reset(); | 2043 resource_provider_.reset(); |
| 2059 output_surface_.reset(); | 2044 output_surface_.reset(); |
| 2060 | 2045 |
| 2061 if (!output_surface->BindToClient(this)) | 2046 if (!output_surface->BindToClient(this)) |
| 2062 return false; | 2047 return false; |
| 2063 | 2048 |
| 2064 output_surface_ = output_surface.Pass(); | 2049 output_surface_ = output_surface.Pass(); |
| 2065 have_valid_output_surface_ = true; | |
| 2066 resource_provider_ = | 2050 resource_provider_ = |
| 2067 ResourceProvider::Create(output_surface_.get(), | 2051 ResourceProvider::Create(output_surface_.get(), |
| 2068 shared_bitmap_manager_, | 2052 shared_bitmap_manager_, |
| 2069 settings_.highp_threshold_min, | 2053 settings_.highp_threshold_min, |
| 2070 settings_.use_rgba_4444_textures, | 2054 settings_.use_rgba_4444_textures, |
| 2071 settings_.texture_id_allocation_chunk_size, | 2055 settings_.texture_id_allocation_chunk_size, |
| 2072 settings_.use_distance_field_text); | 2056 settings_.use_distance_field_text); |
| 2073 | 2057 |
| 2074 if (output_surface_->capabilities().deferred_gl_initialization) | 2058 if (output_surface_->capabilities().deferred_gl_initialization) |
| 2075 EnforceZeroBudget(true); | 2059 EnforceZeroBudget(true); |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3348 } | 3332 } |
| 3349 | 3333 |
| 3350 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3334 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3351 std::vector<PictureLayerImpl*>::iterator it = | 3335 std::vector<PictureLayerImpl*>::iterator it = |
| 3352 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3336 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3353 DCHECK(it != picture_layers_.end()); | 3337 DCHECK(it != picture_layers_.end()); |
| 3354 picture_layers_.erase(it); | 3338 picture_layers_.erase(it); |
| 3355 } | 3339 } |
| 3356 | 3340 |
| 3357 } // namespace cc | 3341 } // namespace cc |
| OLD | NEW |