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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 zero_budget_(false), | 250 zero_budget_(false), |
251 device_scale_factor_(1.f), | 251 device_scale_factor_(1.f), |
252 overhang_ui_resource_id_(0), | 252 overhang_ui_resource_id_(0), |
253 overdraw_bottom_height_(0.f), | 253 overdraw_bottom_height_(0.f), |
254 resourceless_software_draw_(false), | 254 resourceless_software_draw_(false), |
255 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), | 255 begin_impl_frame_interval_(BeginFrameArgs::DefaultInterval()), |
256 animation_registrar_(AnimationRegistrar::Create()), | 256 animation_registrar_(AnimationRegistrar::Create()), |
257 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 257 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
258 micro_benchmark_controller_(this), | 258 micro_benchmark_controller_(this), |
259 need_to_update_visible_tiles_before_draw_(false), | 259 need_to_update_visible_tiles_before_draw_(false), |
260 have_valid_output_surface_(false), | |
261 shared_bitmap_manager_(manager), | 260 shared_bitmap_manager_(manager), |
262 id_(id), | 261 id_(id), |
263 transfer_buffer_memory_limit_(0u) { | 262 transfer_buffer_memory_limit_(0u) { |
264 DCHECK(proxy_->IsImplThread()); | 263 DCHECK(proxy_->IsImplThread()); |
265 DidVisibilityChange(this, visible_); | 264 DidVisibilityChange(this, visible_); |
266 animation_registrar_->set_supports_scroll_animations( | 265 animation_registrar_->set_supports_scroll_animations( |
267 proxy_->SupportsImplScrolling()); | 266 proxy_->SupportsImplScrolling()); |
268 | 267 |
269 SetDebugState(settings.initial_debug_state); | 268 SetDebugState(settings.initial_debug_state); |
270 | 269 |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 // Once all layers have been drawn, pending texture uploads should no | 1608 // Once all layers have been drawn, pending texture uploads should no |
1610 // longer block future uploads. | 1609 // longer block future uploads. |
1611 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1610 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
1612 } | 1611 } |
1613 | 1612 |
1614 void LayerTreeHostImpl::FinishAllRendering() { | 1613 void LayerTreeHostImpl::FinishAllRendering() { |
1615 if (renderer_) | 1614 if (renderer_) |
1616 renderer_->Finish(); | 1615 renderer_->Finish(); |
1617 } | 1616 } |
1618 | 1617 |
1619 bool LayerTreeHostImpl::IsContextLost() { | |
1620 DCHECK(proxy_->IsImplThread()); | |
1621 // To avoid races, rely only on the lost-surface callback. | |
1622 // See crbug.com/392891. | |
1623 return !have_valid_output_surface_; | |
1624 } | |
1625 | |
1626 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { | 1618 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { |
1627 if (use_gpu == use_gpu_rasterization_) | 1619 if (use_gpu == use_gpu_rasterization_) |
1628 return; | 1620 return; |
1629 | 1621 |
1630 use_gpu_rasterization_ = use_gpu; | 1622 use_gpu_rasterization_ = use_gpu; |
1631 ReleaseTreeResources(); | 1623 ReleaseTreeResources(); |
1632 | 1624 |
1633 // Replace existing tile manager with another one that uses appropriate | 1625 // Replace existing tile manager with another one that uses appropriate |
1634 // rasterizer. | 1626 // rasterizer. |
1635 if (tile_manager_) { | 1627 if (tile_manager_) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 } | 1710 } |
1719 | 1711 |
1720 float LayerTreeHostImpl::VerticalAdjust() const { | 1712 float LayerTreeHostImpl::VerticalAdjust() const { |
1721 if (!active_tree_->InnerViewportContainerLayer()) | 1713 if (!active_tree_->InnerViewportContainerLayer()) |
1722 return 0; | 1714 return 0; |
1723 | 1715 |
1724 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); | 1716 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); |
1725 } | 1717 } |
1726 | 1718 |
1727 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1719 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1728 if (!have_valid_output_surface_) | |
1729 return; | |
1730 have_valid_output_surface_ = false; | |
1731 if (resource_provider_) | 1720 if (resource_provider_) |
1732 resource_provider_->DidLoseOutputSurface(); | 1721 resource_provider_->DidLoseOutputSurface(); |
1733 // TODO(jamesr): The renderer_ check is needed to make some of the | 1722 // TODO(jamesr): The renderer_ check is needed to make some of the |
1734 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1723 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1735 // important) in production. We should adjust the test to not need this. | 1724 // important) in production. We should adjust the test to not need this. |
1736 if (renderer_) | 1725 if (renderer_) |
1737 client_->DidLoseOutputSurfaceOnImplThread(); | 1726 client_->DidLoseOutputSurfaceOnImplThread(); |
1738 } | 1727 } |
1739 | 1728 |
1740 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1729 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 // Note: order is important here. | 2080 // Note: order is important here. |
2092 renderer_.reset(); | 2081 renderer_.reset(); |
2093 DestroyTileManager(); | 2082 DestroyTileManager(); |
2094 resource_provider_.reset(); | 2083 resource_provider_.reset(); |
2095 output_surface_.reset(); | 2084 output_surface_.reset(); |
2096 | 2085 |
2097 if (!output_surface->BindToClient(this)) | 2086 if (!output_surface->BindToClient(this)) |
2098 return false; | 2087 return false; |
2099 | 2088 |
2100 output_surface_ = output_surface.Pass(); | 2089 output_surface_ = output_surface.Pass(); |
2101 have_valid_output_surface_ = true; | |
2102 resource_provider_ = | 2090 resource_provider_ = |
2103 ResourceProvider::Create(output_surface_.get(), | 2091 ResourceProvider::Create(output_surface_.get(), |
2104 shared_bitmap_manager_, | 2092 shared_bitmap_manager_, |
2105 settings_.highp_threshold_min, | 2093 settings_.highp_threshold_min, |
2106 settings_.use_rgba_4444_textures, | 2094 settings_.use_rgba_4444_textures, |
2107 settings_.texture_id_allocation_chunk_size, | 2095 settings_.texture_id_allocation_chunk_size, |
2108 settings_.use_distance_field_text); | 2096 settings_.use_distance_field_text); |
2109 | 2097 |
2110 if (output_surface_->capabilities().deferred_gl_initialization) | 2098 if (output_surface_->capabilities().deferred_gl_initialization) |
2111 EnforceZeroBudget(true); | 2099 EnforceZeroBudget(true); |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 } | 3400 } |
3413 | 3401 |
3414 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3402 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3415 std::vector<PictureLayerImpl*>::iterator it = | 3403 std::vector<PictureLayerImpl*>::iterator it = |
3416 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3404 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3417 DCHECK(it != picture_layers_.end()); | 3405 DCHECK(it != picture_layers_.end()); |
3418 picture_layers_.erase(it); | 3406 picture_layers_.erase(it); |
3419 } | 3407 } |
3420 | 3408 |
3421 } // namespace cc | 3409 } // namespace cc |
OLD | NEW |