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 <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; | |
| 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 MarkUIResourceNotEvicted(uid); | |
|
danakj
2016/09/20 01:17:34
I think you wanna mark evicted (instead of *not ev
no sievers
2016/09/20 22:20:35
Doh, thanks.. done!
| |
| 3712 if (!has_valid_compositor_frame_sink_) | |
| 3713 return; | |
| 3714 | |
| 3704 ResourceFormat format = resource_provider_->best_texture_format(); | 3715 ResourceFormat format = resource_provider_->best_texture_format(); |
| 3705 switch (bitmap.GetFormat()) { | 3716 switch (bitmap.GetFormat()) { |
| 3706 case UIResourceBitmap::RGBA8: | 3717 case UIResourceBitmap::RGBA8: |
| 3707 break; | 3718 break; |
| 3708 case UIResourceBitmap::ALPHA_8: | 3719 case UIResourceBitmap::ALPHA_8: |
| 3709 format = ALPHA_8; | 3720 format = ALPHA_8; |
| 3710 break; | 3721 break; |
| 3711 case UIResourceBitmap::ETC1: | 3722 case UIResourceBitmap::ETC1: |
| 3712 format = ETC1; | 3723 format = ETC1; |
| 3713 break; | 3724 break; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3773 auto* pixels = static_cast<uint8_t*>(scaled_bitmap.getPixels()); | 3784 auto* pixels = static_cast<uint8_t*>(scaled_bitmap.getPixels()); |
| 3774 resource_provider_->CopyToResource(id, pixels, upload_size); | 3785 resource_provider_->CopyToResource(id, pixels, upload_size); |
| 3775 } | 3786 } |
| 3776 | 3787 |
| 3777 UIResourceData data; | 3788 UIResourceData data; |
| 3778 data.resource_id = id; | 3789 data.resource_id = id; |
| 3779 data.opaque = bitmap.GetOpaque(); | 3790 data.opaque = bitmap.GetOpaque(); |
| 3780 ui_resource_map_[uid] = data; | 3791 ui_resource_map_[uid] = data; |
| 3781 | 3792 |
| 3782 resource_provider_->GenerateSyncTokenForResource(id); | 3793 resource_provider_->GenerateSyncTokenForResource(id); |
| 3783 MarkUIResourceNotEvicted(uid); | |
| 3784 } | 3794 } |
| 3785 | 3795 |
| 3786 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | 3796 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 3787 ResourceId id = ResourceIdForUIResource(uid); | 3797 ResourceId id = ResourceIdForUIResource(uid); |
| 3788 if (id) { | 3798 if (id) { |
| 3789 resource_provider_->DeleteResource(id); | 3799 if (has_valid_compositor_frame_sink_) |
| 3800 resource_provider_->DeleteResource(id); | |
| 3790 ui_resource_map_.erase(uid); | 3801 ui_resource_map_.erase(uid); |
| 3791 } | 3802 } |
| 3792 MarkUIResourceNotEvicted(uid); | 3803 MarkUIResourceNotEvicted(uid); |
| 3793 } | 3804 } |
| 3794 | 3805 |
| 3795 void LayerTreeHostImpl::ClearUIResources() { | 3806 void LayerTreeHostImpl::ClearUIResources() { |
| 3796 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); | 3807 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); |
| 3797 iter != ui_resource_map_.end(); ++iter) { | 3808 iter != ui_resource_map_.end(); ++iter) { |
| 3798 evicted_ui_resources_.insert(iter->first); | 3809 evicted_ui_resources_.insert(iter->first); |
| 3799 resource_provider_->DeleteResource(iter->second.resource_id); | 3810 resource_provider_->DeleteResource(iter->second.resource_id); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4190 if (is_visible) { | 4201 if (is_visible) { |
| 4191 worker_context_visibility_ = | 4202 worker_context_visibility_ = |
| 4192 worker_context->CacheController()->ClientBecameVisible(); | 4203 worker_context->CacheController()->ClientBecameVisible(); |
| 4193 } else { | 4204 } else { |
| 4194 worker_context->CacheController()->ClientBecameNotVisible( | 4205 worker_context->CacheController()->ClientBecameNotVisible( |
| 4195 std::move(worker_context_visibility_)); | 4206 std::move(worker_context_visibility_)); |
| 4196 } | 4207 } |
| 4197 } | 4208 } |
| 4198 | 4209 |
| 4199 } // namespace cc | 4210 } // namespace cc |
| OLD | NEW |