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 #if DCHECK_IS_ON | 260 have_output_surface_(false), |
danakj
2014/08/06 18:56:43
nit: have_valid_output_surface_ or something along
dneto
2014/08/06 20:20:35
Done. Yeah, I thought about using "valid" in the
| |
261 did_lose_called_(false), | |
262 #endif | |
263 shared_bitmap_manager_(manager), | 261 shared_bitmap_manager_(manager), |
264 id_(id), | 262 id_(id), |
265 transfer_buffer_memory_limit_(0u) { | 263 transfer_buffer_memory_limit_(0u) { |
266 DCHECK(proxy_->IsImplThread()); | 264 DCHECK(proxy_->IsImplThread()); |
267 DidVisibilityChange(this, visible_); | 265 DidVisibilityChange(this, visible_); |
268 animation_registrar_->set_supports_scroll_animations( | 266 animation_registrar_->set_supports_scroll_animations( |
269 proxy_->SupportsImplScrolling()); | 267 proxy_->SupportsImplScrolling()); |
270 | 268 |
271 SetDebugState(settings.initial_debug_state); | 269 SetDebugState(settings.initial_debug_state); |
272 | 270 |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1608 resource_provider_->MarkPendingUploadsAsNonBlocking(); | 1606 resource_provider_->MarkPendingUploadsAsNonBlocking(); |
1609 } | 1607 } |
1610 | 1608 |
1611 void LayerTreeHostImpl::FinishAllRendering() { | 1609 void LayerTreeHostImpl::FinishAllRendering() { |
1612 if (renderer_) | 1610 if (renderer_) |
1613 renderer_->Finish(); | 1611 renderer_->Finish(); |
1614 } | 1612 } |
1615 | 1613 |
1616 bool LayerTreeHostImpl::IsContextLost() { | 1614 bool LayerTreeHostImpl::IsContextLost() { |
1617 DCHECK(proxy_->IsImplThread()); | 1615 DCHECK(proxy_->IsImplThread()); |
1618 return renderer_ && renderer_->IsContextLost(); | 1616 // To avoid races, rely only on the lost-surface callback. |
1617 // See crbug.com/392891. | |
1618 return !have_output_surface_; | |
1619 } | 1619 } |
1620 | 1620 |
1621 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { | 1621 void LayerTreeHostImpl::SetUseGpuRasterization(bool use_gpu) { |
1622 if (use_gpu == use_gpu_rasterization_) | 1622 if (use_gpu == use_gpu_rasterization_) |
1623 return; | 1623 return; |
1624 | 1624 |
1625 use_gpu_rasterization_ = use_gpu; | 1625 use_gpu_rasterization_ = use_gpu; |
1626 ReleaseTreeResources(); | 1626 ReleaseTreeResources(); |
1627 | 1627 |
1628 // Replace existing tile manager with another one that uses appropriate | 1628 // Replace existing tile manager with another one that uses appropriate |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1713 } | 1713 } |
1714 | 1714 |
1715 float LayerTreeHostImpl::VerticalAdjust() const { | 1715 float LayerTreeHostImpl::VerticalAdjust() const { |
1716 if (!active_tree_->InnerViewportContainerLayer()) | 1716 if (!active_tree_->InnerViewportContainerLayer()) |
1717 return 0; | 1717 return 0; |
1718 | 1718 |
1719 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); | 1719 return active_tree_->InnerViewportContainerLayer()->BoundsDelta().y(); |
1720 } | 1720 } |
1721 | 1721 |
1722 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1722 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1723 if (!have_output_surface_) | |
1724 return; | |
1723 if (resource_provider_) | 1725 if (resource_provider_) |
1724 resource_provider_->DidLoseOutputSurface(); | 1726 resource_provider_->DidLoseOutputSurface(); |
1725 // TODO(jamesr): The renderer_ check is needed to make some of the | 1727 // TODO(jamesr): The renderer_ check is needed to make some of the |
1726 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1728 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1727 // important) in production. We should adjust the test to not need this. | 1729 // important) in production. We should adjust the test to not need this. |
1728 if (renderer_) | 1730 if (renderer_) |
1729 client_->DidLoseOutputSurfaceOnImplThread(); | 1731 client_->DidLoseOutputSurfaceOnImplThread(); |
danakj
2014/08/06 18:56:44
This will call over to ThreadProxy::DidLoseOutputS
danakj
2014/08/06 18:57:10
Sorry ignore this I saw you removed that call.
dneto
2014/08/06 20:20:35
Acknowledged.
dneto
2014/08/06 20:20:35
Acknowledged.
Also, for clarity I've moved the set
| |
1730 #if DCHECK_IS_ON | 1732 have_output_surface_ = false; |
1731 did_lose_called_ = true; | |
1732 #endif | |
1733 } | 1733 } |
1734 | 1734 |
1735 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1735 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1736 return !!InnerViewportScrollLayer(); | 1736 return !!InnerViewportScrollLayer(); |
1737 } | 1737 } |
1738 | 1738 |
1739 LayerImpl* LayerTreeHostImpl::RootLayer() const { | 1739 LayerImpl* LayerTreeHostImpl::RootLayer() const { |
1740 return active_tree_->root_layer(); | 1740 return active_tree_->root_layer(); |
1741 } | 1741 } |
1742 | 1742 |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2070 resource_provider_->use_sync_query(); | 2070 resource_provider_->use_sync_query(); |
2071 } | 2071 } |
2072 | 2072 |
2073 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { | 2073 void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { |
2074 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); | 2074 SetManagedMemoryPolicy(cached_managed_memory_policy_, zero_budget); |
2075 } | 2075 } |
2076 | 2076 |
2077 bool LayerTreeHostImpl::InitializeRenderer( | 2077 bool LayerTreeHostImpl::InitializeRenderer( |
2078 scoped_ptr<OutputSurface> output_surface) { | 2078 scoped_ptr<OutputSurface> output_surface) { |
2079 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2079 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
2080 #if DCHECK_IS_ON | |
2081 DCHECK(!renderer_ || did_lose_called_); | |
2082 #endif | |
2083 | 2080 |
2084 // Since we will create a new resource provider, we cannot continue to use | 2081 // Since we will create a new resource provider, we cannot continue to use |
2085 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2082 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
2086 // before we destroy the old resource provider. | 2083 // before we destroy the old resource provider. |
2087 ReleaseTreeResources(); | 2084 ReleaseTreeResources(); |
2088 | 2085 |
2089 // Note: order is important here. | 2086 // Note: order is important here. |
2090 renderer_.reset(); | 2087 renderer_.reset(); |
2091 DestroyTileManager(); | 2088 DestroyTileManager(); |
2092 resource_provider_.reset(); | 2089 resource_provider_.reset(); |
2093 output_surface_.reset(); | 2090 output_surface_.reset(); |
2094 | 2091 |
2095 if (!output_surface->BindToClient(this)) | 2092 if (!output_surface->BindToClient(this)) |
2096 return false; | 2093 return false; |
2097 | 2094 |
2098 output_surface_ = output_surface.Pass(); | 2095 output_surface_ = output_surface.Pass(); |
2096 have_output_surface_ = true; | |
2099 resource_provider_ = | 2097 resource_provider_ = |
2100 ResourceProvider::Create(output_surface_.get(), | 2098 ResourceProvider::Create(output_surface_.get(), |
2101 shared_bitmap_manager_, | 2099 shared_bitmap_manager_, |
2102 settings_.highp_threshold_min, | 2100 settings_.highp_threshold_min, |
2103 settings_.use_rgba_4444_textures, | 2101 settings_.use_rgba_4444_textures, |
2104 settings_.texture_id_allocation_chunk_size, | 2102 settings_.texture_id_allocation_chunk_size, |
2105 settings_.use_distance_field_text); | 2103 settings_.use_distance_field_text); |
2106 | 2104 |
2107 if (output_surface_->capabilities().deferred_gl_initialization) | 2105 if (output_surface_->capabilities().deferred_gl_initialization) |
2108 EnforceZeroBudget(true); | 2106 EnforceZeroBudget(true); |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3371 } | 3369 } |
3372 | 3370 |
3373 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3371 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3374 std::vector<PictureLayerImpl*>::iterator it = | 3372 std::vector<PictureLayerImpl*>::iterator it = |
3375 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3373 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3376 DCHECK(it != picture_layers_.end()); | 3374 DCHECK(it != picture_layers_.end()); |
3377 picture_layers_.erase(it); | 3375 picture_layers_.erase(it); |
3378 } | 3376 } |
3379 | 3377 |
3380 } // namespace cc | 3378 } // namespace cc |
OLD | NEW |