OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (void* source = request->source()) { | 415 if (void* source = request->source()) { |
416 auto it = std::find_if(copy_requests_.begin(), copy_requests_.end(), | 416 auto it = std::find_if(copy_requests_.begin(), copy_requests_.end(), |
417 [source](const scoped_ptr<CopyOutputRequest>& x) { | 417 [source](const scoped_ptr<CopyOutputRequest>& x) { |
418 return x->source() == source; | 418 return x->source() == source; |
419 }); | 419 }); |
420 if (it != copy_requests_.end()) | 420 if (it != copy_requests_.end()) |
421 copy_requests_.erase(it); | 421 copy_requests_.erase(it); |
422 } | 422 } |
423 if (request->IsEmpty()) | 423 if (request->IsEmpty()) |
424 return; | 424 return; |
425 copy_requests_.push_back(request.Pass()); | 425 copy_requests_.push_back(std::move(request)); |
426 if (had_no_copy_requests) { | 426 if (had_no_copy_requests) { |
427 UpdateNumCopyRequestsForSubtree(1); | 427 UpdateNumCopyRequestsForSubtree(1); |
428 } | 428 } |
429 SetNeedsCommit(); | 429 SetNeedsCommit(); |
430 } | 430 } |
431 | 431 |
432 void Layer::UpdateNumCopyRequestsForSubtree(int delta) { | 432 void Layer::UpdateNumCopyRequestsForSubtree(int delta) { |
433 if (!delta) | 433 if (!delta) |
434 return; | 434 return; |
435 for (Layer* layer = this; layer; layer = layer->parent()) { | 435 for (Layer* layer = this; layer; layer = layer->parent()) { |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 1154 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
1155 DCHECK(IsPropertyChangeAllowed()); | 1155 DCHECK(IsPropertyChangeAllowed()); |
1156 if (position_constraint_ == constraint) | 1156 if (position_constraint_ == constraint) |
1157 return; | 1157 return; |
1158 position_constraint_ = constraint; | 1158 position_constraint_ = constraint; |
1159 SetNeedsCommit(); | 1159 SetNeedsCommit(); |
1160 } | 1160 } |
1161 | 1161 |
1162 static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request, | 1162 static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request, |
1163 scoped_ptr<CopyOutputResult> result) { | 1163 scoped_ptr<CopyOutputResult> result) { |
1164 request->SendResult(result.Pass()); | 1164 request->SendResult(std::move(result)); |
1165 } | 1165 } |
1166 | 1166 |
1167 static void PostCopyCallbackToMainThread( | 1167 static void PostCopyCallbackToMainThread( |
1168 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1168 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
1169 scoped_ptr<CopyOutputRequest> request, | 1169 scoped_ptr<CopyOutputRequest> request, |
1170 scoped_ptr<CopyOutputResult> result) { | 1170 scoped_ptr<CopyOutputResult> result) { |
1171 main_thread_task_runner->PostTask(FROM_HERE, | 1171 main_thread_task_runner->PostTask(FROM_HERE, |
1172 base::Bind(&RunCopyCallbackOnMainThread, | 1172 base::Bind(&RunCopyCallbackOnMainThread, |
1173 base::Passed(&request), | 1173 base::Passed(&request), |
1174 base::Passed(&result))); | 1174 base::Passed(&result))); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1302 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
1303 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1303 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
1304 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1304 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
1305 const CopyOutputRequest& original_request_ref = *original_request; | 1305 const CopyOutputRequest& original_request_ref = *original_request; |
1306 scoped_ptr<CopyOutputRequest> main_thread_request = | 1306 scoped_ptr<CopyOutputRequest> main_thread_request = |
1307 CopyOutputRequest::CreateRelayRequest( | 1307 CopyOutputRequest::CreateRelayRequest( |
1308 original_request_ref, | 1308 original_request_ref, |
1309 base::Bind(&PostCopyCallbackToMainThread, | 1309 base::Bind(&PostCopyCallbackToMainThread, |
1310 main_thread_task_runner, | 1310 main_thread_task_runner, |
1311 base::Passed(&original_request))); | 1311 base::Passed(&original_request))); |
1312 main_thread_copy_requests.push_back(main_thread_request.Pass()); | 1312 main_thread_copy_requests.push_back(std::move(main_thread_request)); |
1313 } | 1313 } |
1314 if (!copy_requests_.empty() && layer_tree_host_) | 1314 if (!copy_requests_.empty() && layer_tree_host_) |
1315 layer_tree_host_->property_trees()->needs_rebuild = true; | 1315 layer_tree_host_->property_trees()->needs_rebuild = true; |
1316 if (had_copy_requests) | 1316 if (had_copy_requests) |
1317 UpdateNumCopyRequestsForSubtree(-1); | 1317 UpdateNumCopyRequestsForSubtree(-1); |
1318 | 1318 |
1319 copy_requests_.clear(); | 1319 copy_requests_.clear(); |
1320 layer->PassCopyRequests(&main_thread_copy_requests); | 1320 layer->PassCopyRequests(&main_thread_copy_requests); |
1321 | 1321 |
1322 // If the main thread commits multiple times before the impl thread actually | 1322 // If the main thread commits multiple times before the impl thread actually |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 if (!layer_animation_controller_->animation_registrar()) | 1652 if (!layer_animation_controller_->animation_registrar()) |
1653 return false; | 1653 return false; |
1654 | 1654 |
1655 if (animation->target_property() == Animation::SCROLL_OFFSET && | 1655 if (animation->target_property() == Animation::SCROLL_OFFSET && |
1656 !layer_animation_controller_->animation_registrar() | 1656 !layer_animation_controller_->animation_registrar() |
1657 ->supports_scroll_animations()) | 1657 ->supports_scroll_animations()) |
1658 return false; | 1658 return false; |
1659 | 1659 |
1660 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", | 1660 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", |
1661 !layer_tree_host_); | 1661 !layer_tree_host_); |
1662 layer_animation_controller_->AddAnimation(animation.Pass()); | 1662 layer_animation_controller_->AddAnimation(std::move(animation)); |
1663 SetNeedsCommit(); | 1663 SetNeedsCommit(); |
1664 return true; | 1664 return true; |
1665 } | 1665 } |
1666 | 1666 |
1667 void Layer::PauseAnimation(int animation_id, double time_offset) { | 1667 void Layer::PauseAnimation(int animation_id, double time_offset) { |
1668 DCHECK(layer_animation_controller_); | 1668 DCHECK(layer_animation_controller_); |
1669 layer_animation_controller_->PauseAnimation( | 1669 layer_animation_controller_->PauseAnimation( |
1670 animation_id, base::TimeDelta::FromSecondsD(time_offset)); | 1670 animation_id, base::TimeDelta::FromSecondsD(time_offset)); |
1671 SetNeedsCommit(); | 1671 SetNeedsCommit(); |
1672 } | 1672 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 this, layer_tree_host_->property_trees()->transform_tree); | 1825 this, layer_tree_host_->property_trees()->transform_tree); |
1826 } | 1826 } |
1827 | 1827 |
1828 gfx::Transform Layer::screen_space_transform() const { | 1828 gfx::Transform Layer::screen_space_transform() const { |
1829 DCHECK_NE(transform_tree_index_, -1); | 1829 DCHECK_NE(transform_tree_index_, -1); |
1830 return ScreenSpaceTransformFromPropertyTrees( | 1830 return ScreenSpaceTransformFromPropertyTrees( |
1831 this, layer_tree_host_->property_trees()->transform_tree); | 1831 this, layer_tree_host_->property_trees()->transform_tree); |
1832 } | 1832 } |
1833 | 1833 |
1834 } // namespace cc | 1834 } // namespace cc |
OLD | NEW |