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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 resourceless_software_draw_(false), | 233 resourceless_software_draw_(false), |
234 animation_host_(std::move(animation_host)), | 234 animation_host_(std::move(animation_host)), |
235 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 235 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
236 micro_benchmark_controller_(this), | 236 micro_benchmark_controller_(this), |
237 shared_bitmap_manager_(shared_bitmap_manager), | 237 shared_bitmap_manager_(shared_bitmap_manager), |
238 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 238 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
239 task_graph_runner_(task_graph_runner), | 239 task_graph_runner_(task_graph_runner), |
240 id_(id), | 240 id_(id), |
241 requires_high_res_to_draw_(false), | 241 requires_high_res_to_draw_(false), |
242 is_likely_to_require_a_draw_(false), | 242 is_likely_to_require_a_draw_(false), |
243 has_valid_compositor_frame_sink_(false), | |
243 mutator_(nullptr) { | 244 mutator_(nullptr) { |
244 DCHECK(animation_host_); | 245 DCHECK(animation_host_); |
245 animation_host_->SetMutatorHostClient(this); | 246 animation_host_->SetMutatorHostClient(this); |
246 | 247 |
247 DCHECK(task_runner_provider_->IsImplThread()); | 248 DCHECK(task_runner_provider_->IsImplThread()); |
248 DidVisibilityChange(this, visible_); | 249 DidVisibilityChange(this, visible_); |
249 | 250 |
250 SetDebugState(settings.initial_debug_state); | 251 SetDebugState(settings.initial_debug_state); |
251 | 252 |
252 // LTHI always has an active tree. | 253 // LTHI always has an active tree. |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1918 | 1919 |
1919 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { | 1920 void LayerTreeHostImpl::SynchronouslyInitializeAllTiles() { |
1920 // Only valid for the single-threaded non-scheduled/synchronous case | 1921 // Only valid for the single-threaded non-scheduled/synchronous case |
1921 // using the zero copy raster worker pool. | 1922 // using the zero copy raster worker pool. |
1922 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); | 1923 single_thread_synchronous_task_graph_runner_->RunUntilIdle(); |
1923 } | 1924 } |
1924 | 1925 |
1925 void LayerTreeHostImpl::DidLoseCompositorFrameSink() { | 1926 void LayerTreeHostImpl::DidLoseCompositorFrameSink() { |
1926 if (resource_provider_) | 1927 if (resource_provider_) |
1927 resource_provider_->DidLoseContextProvider(); | 1928 resource_provider_->DidLoseContextProvider(); |
1929 has_valid_compositor_frame_sink_ = false; | |
1928 client_->DidLoseCompositorFrameSinkOnImplThread(); | 1930 client_->DidLoseCompositorFrameSinkOnImplThread(); |
1929 } | 1931 } |
1930 | 1932 |
1931 bool LayerTreeHostImpl::HaveRootScrollLayer() const { | 1933 bool LayerTreeHostImpl::HaveRootScrollLayer() const { |
1932 return !!InnerViewportScrollLayer(); | 1934 return !!InnerViewportScrollLayer(); |
1933 } | 1935 } |
1934 | 1936 |
1935 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { | 1937 LayerImpl* LayerTreeHostImpl::InnerViewportScrollLayer() const { |
1936 return active_tree_->InnerViewportScrollLayer(); | 1938 return active_tree_->InnerViewportScrollLayer(); |
1937 } | 1939 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2250 tile_manager_.FinishTasksAndCleanUp(); | 2252 tile_manager_.FinishTasksAndCleanUp(); |
2251 resource_pool_ = nullptr; | 2253 resource_pool_ = nullptr; |
2252 tile_task_manager_ = nullptr; | 2254 tile_task_manager_ = nullptr; |
2253 single_thread_synchronous_task_graph_runner_ = nullptr; | 2255 single_thread_synchronous_task_graph_runner_ = nullptr; |
2254 image_decode_controller_ = nullptr; | 2256 image_decode_controller_ = nullptr; |
2255 } | 2257 } |
2256 | 2258 |
2257 void LayerTreeHostImpl::ReleaseCompositorFrameSink() { | 2259 void LayerTreeHostImpl::ReleaseCompositorFrameSink() { |
2258 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseCompositorFrameSink"); | 2260 TRACE_EVENT0("cc", "LayerTreeHostImpl::ReleaseCompositorFrameSink"); |
2259 | 2261 |
2260 if (!compositor_frame_sink_) | 2262 if (!compositor_frame_sink_) { |
2263 DCHECK(!has_valid_compositor_frame_sink_); | |
2261 return; | 2264 return; |
2265 } | |
2266 | |
2267 has_valid_compositor_frame_sink_ = false; | |
2262 | 2268 |
2263 // Since we will create a new resource provider, we cannot continue to use | 2269 // Since we will create a new resource provider, we cannot continue to use |
2264 // the old resources (i.e. render_surfaces and texture IDs). Clear them | 2270 // the old resources (i.e. render_surfaces and texture IDs). Clear them |
2265 // before we destroy the old resource provider. | 2271 // before we destroy the old resource provider. |
2266 ReleaseTreeResources(); | 2272 ReleaseTreeResources(); |
2267 | 2273 |
2268 // Note: ui resource cleanup uses the |resource_provider_|. | 2274 // Note: ui resource cleanup uses the |resource_provider_|. |
2269 CleanUpTileManagerAndUIResources(); | 2275 CleanUpTileManagerAndUIResources(); |
2270 resource_provider_ = nullptr; | 2276 resource_provider_ = nullptr; |
2271 | 2277 |
(...skipping 23 matching lines...) Expand all Loading... | |
2295 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); | 2301 TRACE_EVENT0("cc", "LayerTreeHostImpl::InitializeRenderer"); |
2296 | 2302 |
2297 ReleaseCompositorFrameSink(); | 2303 ReleaseCompositorFrameSink(); |
2298 if (!compositor_frame_sink->BindToClient(this)) { | 2304 if (!compositor_frame_sink->BindToClient(this)) { |
2299 // Avoid recreating tree resources because we might not have enough | 2305 // Avoid recreating tree resources because we might not have enough |
2300 // information to do this yet (eg. we don't have a TileManager at this | 2306 // information to do this yet (eg. we don't have a TileManager at this |
2301 // point). | 2307 // point). |
2302 return false; | 2308 return false; |
2303 } | 2309 } |
2304 | 2310 |
2311 has_valid_compositor_frame_sink_ = true; | |
danakj
2016/09/23 21:24:10
nit: put this right beside the assignment to compo
no sievers
2016/09/23 21:27:31
Done.
| |
2305 // When using software compositing, change to the limits specified for it. | 2312 // When using software compositing, change to the limits specified for it. |
2306 // Since this is a one way trip, we don't need to worry about going back to | 2313 // Since this is a one way trip, we don't need to worry about going back to |
2307 // GPU compositing. | 2314 // GPU compositing. |
2308 if (!compositor_frame_sink->context_provider()) | 2315 if (!compositor_frame_sink->context_provider()) |
2309 SetMemoryPolicy(settings_.software_memory_policy); | 2316 SetMemoryPolicy(settings_.software_memory_policy); |
2310 | 2317 |
2311 compositor_frame_sink_ = compositor_frame_sink; | 2318 compositor_frame_sink_ = compositor_frame_sink; |
2312 resource_provider_ = base::MakeUnique<ResourceProvider>( | 2319 resource_provider_ = base::MakeUnique<ResourceProvider>( |
2313 compositor_frame_sink_->context_provider(), shared_bitmap_manager_, | 2320 compositor_frame_sink_->context_provider(), shared_bitmap_manager_, |
2314 gpu_memory_buffer_manager_, | 2321 gpu_memory_buffer_manager_, |
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3694 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, | 3701 void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, |
3695 const UIResourceBitmap& bitmap) { | 3702 const UIResourceBitmap& bitmap) { |
3696 DCHECK_GT(uid, 0); | 3703 DCHECK_GT(uid, 0); |
3697 | 3704 |
3698 // Allow for multiple creation requests with the same UIResourceId. The | 3705 // Allow for multiple creation requests with the same UIResourceId. The |
3699 // previous resource is simply deleted. | 3706 // previous resource is simply deleted. |
3700 ResourceId id = ResourceIdForUIResource(uid); | 3707 ResourceId id = ResourceIdForUIResource(uid); |
3701 if (id) | 3708 if (id) |
3702 DeleteUIResource(uid); | 3709 DeleteUIResource(uid); |
3703 | 3710 |
3711 if (!has_valid_compositor_frame_sink_) { | |
3712 evicted_ui_resources_.insert(uid); | |
3713 return; | |
3714 } | |
3715 | |
3704 ResourceFormat format = resource_provider_->best_texture_format(); | 3716 ResourceFormat format = resource_provider_->best_texture_format(); |
3705 switch (bitmap.GetFormat()) { | 3717 switch (bitmap.GetFormat()) { |
3706 case UIResourceBitmap::RGBA8: | 3718 case UIResourceBitmap::RGBA8: |
3707 break; | 3719 break; |
3708 case UIResourceBitmap::ALPHA_8: | 3720 case UIResourceBitmap::ALPHA_8: |
3709 format = ALPHA_8; | 3721 format = ALPHA_8; |
3710 break; | 3722 break; |
3711 case UIResourceBitmap::ETC1: | 3723 case UIResourceBitmap::ETC1: |
3712 format = ETC1; | 3724 format = ETC1; |
3713 break; | 3725 break; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3779 data.opaque = bitmap.GetOpaque(); | 3791 data.opaque = bitmap.GetOpaque(); |
3780 ui_resource_map_[uid] = data; | 3792 ui_resource_map_[uid] = data; |
3781 | 3793 |
3782 resource_provider_->GenerateSyncTokenForResource(id); | 3794 resource_provider_->GenerateSyncTokenForResource(id); |
3783 MarkUIResourceNotEvicted(uid); | 3795 MarkUIResourceNotEvicted(uid); |
3784 } | 3796 } |
3785 | 3797 |
3786 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 3798 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
3787 ResourceId id = ResourceIdForUIResource(uid); | 3799 ResourceId id = ResourceIdForUIResource(uid); |
3788 if (id) { | 3800 if (id) { |
3789 resource_provider_->DeleteResource(id); | 3801 if (has_valid_compositor_frame_sink_) |
3802 resource_provider_->DeleteResource(id); | |
3790 ui_resource_map_.erase(uid); | 3803 ui_resource_map_.erase(uid); |
3791 } | 3804 } |
3792 MarkUIResourceNotEvicted(uid); | 3805 MarkUIResourceNotEvicted(uid); |
3793 } | 3806 } |
3794 | 3807 |
3795 void LayerTreeHostImpl::ClearUIResources() { | 3808 void LayerTreeHostImpl::ClearUIResources() { |
3796 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 3809 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
3797 iter != ui_resource_map_.end(); ++iter) { | 3810 iter != ui_resource_map_.end(); ++iter) { |
3798 evicted_ui_resources_.insert(iter->first); | 3811 evicted_ui_resources_.insert(iter->first); |
3799 resource_provider_->DeleteResource(iter->second.resource_id); | 3812 resource_provider_->DeleteResource(iter->second.resource_id); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4190 if (is_visible) { | 4203 if (is_visible) { |
4191 worker_context_visibility_ = | 4204 worker_context_visibility_ = |
4192 worker_context->CacheController()->ClientBecameVisible(); | 4205 worker_context->CacheController()->ClientBecameVisible(); |
4193 } else { | 4206 } else { |
4194 worker_context->CacheController()->ClientBecameNotVisible( | 4207 worker_context->CacheController()->ClientBecameNotVisible( |
4195 std::move(worker_context_visibility_)); | 4208 std::move(worker_context_visibility_)); |
4196 } | 4209 } |
4197 } | 4210 } |
4198 | 4211 |
4199 } // namespace cc | 4212 } // namespace cc |
OLD | NEW |