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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 66 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
67 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, | 67 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(client, |
68 settings)); | 68 settings)); |
69 if (!layer_tree_host->Initialize(impl_task_runner)) | 69 if (!layer_tree_host->Initialize(impl_task_runner)) |
70 return scoped_ptr<LayerTreeHost>(); | 70 return scoped_ptr<LayerTreeHost>(); |
71 return layer_tree_host.Pass(); | 71 return layer_tree_host.Pass(); |
72 } | 72 } |
73 | 73 |
74 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, | 74 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, |
75 const LayerTreeSettings& settings) | 75 const LayerTreeSettings& settings) |
76 : animating_(false), | 76 : ui_resource_id_(1), |
77 animating_(false), | |
77 needs_full_tree_sync_(true), | 78 needs_full_tree_sync_(true), |
78 needs_filter_context_(false), | 79 needs_filter_context_(false), |
79 client_(client), | 80 client_(client), |
80 commit_number_(0), | 81 commit_number_(0), |
81 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 82 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
82 output_surface_can_be_initialized_(true), | 83 output_surface_can_be_initialized_(true), |
83 output_surface_lost_(true), | 84 output_surface_lost_(true), |
84 num_failed_recreate_attempts_(0), | 85 num_failed_recreate_attempts_(0), |
85 settings_(settings), | 86 settings_(settings), |
86 debug_state_(settings.initial_debug_state), | 87 debug_state_(settings.initial_debug_state), |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 TRACE_EVENT0("cc", "LayerTreeHost::CommitTo"); | 242 TRACE_EVENT0("cc", "LayerTreeHost::CommitTo"); |
242 } | 243 } |
243 | 244 |
244 // This function commits the LayerTreeHost to an impl tree. When modifying | 245 // This function commits the LayerTreeHost to an impl tree. When modifying |
245 // this function, keep in mind that the function *runs* on the impl thread! Any | 246 // this function, keep in mind that the function *runs* on the impl thread! Any |
246 // code that is logically a main thread operation, e.g. deletion of a Layer, | 247 // code that is logically a main thread operation, e.g. deletion of a Layer, |
247 // should be delayed until the LayerTreeHost::CommitComplete, which will run | 248 // should be delayed until the LayerTreeHost::CommitComplete, which will run |
248 // after the commit, but on the main thread. | 249 // after the commit, but on the main thread. |
249 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { | 250 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
250 DCHECK(proxy_->IsImplThread()); | 251 DCHECK(proxy_->IsImplThread()); |
251 | |
252 // If there are linked evicted backings, these backings' resources may be put | 252 // If there are linked evicted backings, these backings' resources may be put |
253 // into the impl tree, so we can't draw yet. Determine this before clearing | 253 // into the impl tree, so we can't draw yet. Determine this before clearing |
254 // all evicted backings. | 254 // all evicted backings. |
255 bool new_impl_tree_has_no_evicted_resources = false; | 255 bool new_impl_tree_has_no_evicted_resources = false; |
256 if (contents_texture_manager_) { | 256 if (contents_texture_manager_) { |
257 new_impl_tree_has_no_evicted_resources = | 257 new_impl_tree_has_no_evicted_resources = |
258 !contents_texture_manager_->LinkedEvictedBackingsExist(); | 258 !contents_texture_manager_->LinkedEvictedBackingsExist(); |
259 | 259 |
260 // If the memory limit has been increased since this now-finishing | 260 // If the memory limit has been increased since this now-finishing |
261 // commit began, and the extra now-available memory would have been used, | 261 // commit began, and the extra now-available memory would have been used, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 if (pending_page_scale_animation_) { | 342 if (pending_page_scale_animation_) { |
343 host_impl->StartPageScaleAnimation( | 343 host_impl->StartPageScaleAnimation( |
344 pending_page_scale_animation_->target_offset, | 344 pending_page_scale_animation_->target_offset, |
345 pending_page_scale_animation_->use_anchor, | 345 pending_page_scale_animation_->use_anchor, |
346 pending_page_scale_animation_->scale, | 346 pending_page_scale_animation_->scale, |
347 base::TimeTicks::Now(), | 347 base::TimeTicks::Now(), |
348 pending_page_scale_animation_->duration); | 348 pending_page_scale_animation_->duration); |
349 pending_page_scale_animation_.reset(); | 349 pending_page_scale_animation_.reset(); |
350 } | 350 } |
351 | 351 |
352 if (!ui_resource_request_queue_.empty()) { | |
353 if (settings_.impl_side_painting) { | |
354 host_impl->set_ui_resource_request_queue(ui_resource_request_queue_); | |
355 ui_resource_request_queue_.clear(); | |
356 } else { | |
357 while (ui_resource_request_queue_.size() > 0) { | |
enne (OOO)
2013/07/22 23:09:15
Can you share this commit-time queue-processing fu
powei
2013/07/24 02:28:29
Done.
| |
358 UIResourceRequest req = ui_resource_request_queue_.front(); | |
359 ui_resource_request_queue_.pop_front(); | |
360 switch (req.type) { | |
361 case UIResourceCreate: | |
362 host_impl->CreateUIResource(req.id, req.bitmap); | |
363 break; | |
364 case UIResourceDelete: | |
365 host_impl->DeleteUIResource(req.id); | |
366 break; | |
367 } | |
368 } | |
369 } | |
370 } | |
371 | |
352 DCHECK(!sync_tree->ViewportSizeInvalid()); | 372 DCHECK(!sync_tree->ViewportSizeInvalid()); |
353 | 373 |
354 if (new_impl_tree_has_no_evicted_resources) { | 374 if (new_impl_tree_has_no_evicted_resources) { |
355 if (sync_tree->ContentsTexturesPurged()) | 375 if (sync_tree->ContentsTexturesPurged()) |
356 sync_tree->ResetContentsTexturesPurged(); | 376 sync_tree->ResetContentsTexturesPurged(); |
357 } | 377 } |
358 | 378 |
359 if (!settings_.impl_side_painting) { | 379 if (!settings_.impl_side_painting) { |
360 // If we're not in impl-side painting, the tree is immediately | 380 // If we're not in impl-side painting, the tree is immediately |
361 // considered active. | 381 // considered active. |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1048 (*iter).second->Animate(monotonic_time); | 1068 (*iter).second->Animate(monotonic_time); |
1049 bool start_ready_animations = true; | 1069 bool start_ready_animations = true; |
1050 (*iter).second->UpdateState(start_ready_animations, NULL); | 1070 (*iter).second->UpdateState(start_ready_animations, NULL); |
1051 } | 1071 } |
1052 } | 1072 } |
1053 | 1073 |
1054 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1074 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1055 return proxy_->CapturePicture(); | 1075 return proxy_->CapturePicture(); |
1056 } | 1076 } |
1057 | 1077 |
1078 | |
1079 UIResourceId | |
1080 LayerTreeHost::CreateUIResource(const UIResourceCallback& bitmap_cb) { | |
1081 UIResourceRequest request; | |
1082 request.type = UIResourceCreate; | |
1083 request.id = ui_resource_id_++; | |
1084 // The boolean parameter indicates this retrieval is not due to a | |
enne (OOO)
2013/07/22 23:09:15
style nit: Rather than a comment, just say "bool r
powei
2013/07/24 02:28:29
Done.
| |
1085 // resource lost. | |
1086 request.bitmap = bitmap_cb.Run(false); | |
1087 ui_resource_request_queue_.push_back(request); | |
1088 ui_resource_client_map_[request.id] = bitmap_cb; | |
enne (OOO)
2013/07/22 23:09:15
Can you DCHECK that this doesn't exist in the map
powei
2013/07/24 02:28:29
Done.
| |
1089 return request.id; | |
1090 } | |
1091 | |
1092 // Deletes a UI resource. May safely be called more than once. | |
1093 void LayerTreeHost::DeleteUIResource(UIResourceId uid) { | |
1094 if (ui_resource_client_map_.find(uid) != ui_resource_client_map_.end()) { | |
1095 UIResourceRequest request; | |
1096 request.type = UIResourceDelete; | |
1097 request.id = uid; | |
1098 ui_resource_request_queue_.push_back(request); | |
1099 ui_resource_client_map_.erase(uid); | |
1100 } | |
1101 } | |
1102 | |
1103 void LayerTreeHost::UIResourceLost(UIResourceId id) { | |
1104 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(id); | |
1105 if (iter != ui_resource_client_map_.end()) { | |
1106 UIResourceRequest request; | |
1107 request.type = UIResourceCreate; | |
1108 request.id = id; | |
1109 request.bitmap = iter->second.Run(true); | |
aelias_OOO_until_Jul13
2013/07/23 00:06:48
I think that if this callback is a destroyed weak_
powei
2013/07/24 02:28:29
I don't know if a weak_ptr can be passed with the
| |
1110 ui_resource_request_queue_.push_back(request); | |
1111 } | |
1112 } | |
1113 | |
1114 | |
1058 } // namespace cc | 1115 } // namespace cc |
OLD | NEW |