Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { | 877 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { |
| 878 DCHECK(IsPropertyChangeAllowed()); | 878 DCHECK(IsPropertyChangeAllowed()); |
| 879 | 879 |
| 880 if (scroll_offset_ == scroll_offset) | 880 if (scroll_offset_ == scroll_offset) |
| 881 return; | 881 return; |
| 882 scroll_offset_ = scroll_offset; | 882 scroll_offset_ = scroll_offset; |
| 883 | 883 |
| 884 if (!layer_tree_host_) | 884 if (!layer_tree_host_) |
| 885 return; | 885 return; |
| 886 | 886 |
| 887 if (scroll_tree_index() != -1 && scrollable()) | |
| 888 layer_tree_host_->property_trees()->scroll_tree.SetScrollOffset( | |
| 889 id(), scroll_offset); | |
| 890 | |
| 887 if (TransformNode* transform_node = | 891 if (TransformNode* transform_node = |
| 888 layer_tree_host_->property_trees()->transform_tree.Node( | 892 layer_tree_host_->property_trees()->transform_tree.Node( |
| 889 transform_tree_index())) { | 893 transform_tree_index())) { |
| 890 if (transform_node->owner_id == id()) { | 894 if (transform_node->owner_id == id()) { |
| 891 transform_node->data.scroll_offset = CurrentScrollOffset(); | 895 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 892 transform_node->data.needs_local_transform_update = true; | 896 transform_node->data.needs_local_transform_update = true; |
| 893 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 897 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 894 SetNeedsCommitNoRebuild(); | 898 SetNeedsCommitNoRebuild(); |
| 895 return; | 899 return; |
| 896 } | 900 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 916 DCHECK(IsPropertyChangeAllowed()); | 920 DCHECK(IsPropertyChangeAllowed()); |
| 917 // This function only gets called during a BeginMainFrame, so there | 921 // This function only gets called during a BeginMainFrame, so there |
| 918 // is no need to call SetNeedsUpdate here. | 922 // is no need to call SetNeedsUpdate here. |
| 919 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 923 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
| 920 if (scroll_offset_ == scroll_offset) | 924 if (scroll_offset_ == scroll_offset) |
| 921 return; | 925 return; |
| 922 scroll_offset_ = scroll_offset; | 926 scroll_offset_ = scroll_offset; |
| 923 SetNeedsPushProperties(); | 927 SetNeedsPushProperties(); |
| 924 | 928 |
| 925 bool needs_rebuild = true; | 929 bool needs_rebuild = true; |
| 930 | |
| 931 if (scroll_tree_index() != -1 && scrollable()) | |
| 932 layer_tree_host_->property_trees() | |
| 933 ->scroll_tree.synced_scroll_offset(id()) | |
| 934 ->PushFromMainThread(scroll_offset); | |
|
ajuma
2016/03/02 18:43:09
How about calling ScrollTree::SetScrollOffset here
sunxd
2016/03/02 20:52:55
Done.
| |
| 935 | |
| 926 if (TransformNode* transform_node = | 936 if (TransformNode* transform_node = |
| 927 layer_tree_host_->property_trees()->transform_tree.Node( | 937 layer_tree_host_->property_trees()->transform_tree.Node( |
| 928 transform_tree_index())) { | 938 transform_tree_index())) { |
| 929 if (transform_node->owner_id == id()) { | 939 if (transform_node->owner_id == id()) { |
| 930 transform_node->data.scroll_offset = CurrentScrollOffset(); | 940 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 931 transform_node->data.needs_local_transform_update = true; | 941 transform_node->data.needs_local_transform_update = true; |
| 932 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 942 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 933 needs_rebuild = false; | 943 needs_rebuild = false; |
| 934 } | 944 } |
| 935 } | 945 } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 layer->SetClipChildren(clip_children); | 1340 layer->SetClipChildren(clip_children); |
| 1331 } else { | 1341 } else { |
| 1332 layer->SetClipChildren(nullptr); | 1342 layer->SetClipChildren(nullptr); |
| 1333 } | 1343 } |
| 1334 | 1344 |
| 1335 // When a scroll offset animation is interrupted the new scroll position on | 1345 // When a scroll offset animation is interrupted the new scroll position on |
| 1336 // the pending tree will clobber any impl-side scrolling occuring on the | 1346 // the pending tree will clobber any impl-side scrolling occuring on the |
| 1337 // active tree. To do so, avoid scrolling the pending tree along with it | 1347 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1338 // instead of trying to undo that scrolling later. | 1348 // instead of trying to undo that scrolling later. |
| 1339 if (ScrollOffsetAnimationWasInterrupted()) | 1349 if (ScrollOffsetAnimationWasInterrupted()) |
| 1340 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1350 layer_tree_host() |
| 1341 else | 1351 ->property_trees() |
| 1342 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1352 ->scroll_tree.synced_scroll_offset(layer->id()) |
| 1353 ->set_clobber_active_value(); | |
| 1343 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1354 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1344 | 1355 |
| 1345 { | 1356 { |
| 1346 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | 1357 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1347 // Wrap the copy_requests_ in a PostTask to the main thread. | 1358 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1348 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1359 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1349 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1360 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1350 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1361 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1351 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1362 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1352 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1363 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1693 } | 1704 } |
| 1694 | 1705 |
| 1695 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1706 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); |
| 1696 scroll_compensation_adjustment_ = | 1707 scroll_compensation_adjustment_ = |
| 1697 ProtoToVector2dF(base.scroll_compensation_adjustment()); | 1708 ProtoToVector2dF(base.scroll_compensation_adjustment()); |
| 1698 | 1709 |
| 1699 update_rect_.Union(ProtoToRect(base.update_rect())); | 1710 update_rect_.Union(ProtoToRect(base.update_rect())); |
| 1700 } | 1711 } |
| 1701 | 1712 |
| 1702 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1713 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1703 return LayerImpl::Create(tree_impl, layer_id_, | 1714 return LayerImpl::Create(tree_impl, layer_id_, new SyncedScrollOffset); |
| 1704 new LayerImpl::SyncedScrollOffset); | |
| 1705 } | 1715 } |
| 1706 | 1716 |
| 1707 bool Layer::DrawsContent() const { | 1717 bool Layer::DrawsContent() const { |
| 1708 return draws_content_; | 1718 return draws_content_; |
| 1709 } | 1719 } |
| 1710 | 1720 |
| 1711 bool Layer::HasDrawableContent() const { | 1721 bool Layer::HasDrawableContent() const { |
| 1712 return is_drawable_; | 1722 return is_drawable_; |
| 1713 } | 1723 } |
| 1714 | 1724 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2076 this, layer_tree_host_->property_trees()->transform_tree); | 2086 this, layer_tree_host_->property_trees()->transform_tree); |
| 2077 } | 2087 } |
| 2078 | 2088 |
| 2079 gfx::Transform Layer::screen_space_transform() const { | 2089 gfx::Transform Layer::screen_space_transform() const { |
| 2080 DCHECK_NE(transform_tree_index_, -1); | 2090 DCHECK_NE(transform_tree_index_, -1); |
| 2081 return ScreenSpaceTransformFromPropertyTrees( | 2091 return ScreenSpaceTransformFromPropertyTrees( |
| 2082 this, layer_tree_host_->property_trees()->transform_tree); | 2092 this, layer_tree_host_->property_trees()->transform_tree); |
| 2083 } | 2093 } |
| 2084 | 2094 |
| 2085 } // namespace cc | 2095 } // namespace cc |
| OLD | NEW |