| 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()->scroll_tree.SetScrollOffset( |
| 933 id(), scroll_offset); |
| 934 |
| 926 if (TransformNode* transform_node = | 935 if (TransformNode* transform_node = |
| 927 layer_tree_host_->property_trees()->transform_tree.Node( | 936 layer_tree_host_->property_trees()->transform_tree.Node( |
| 928 transform_tree_index())) { | 937 transform_tree_index())) { |
| 929 if (transform_node->owner_id == id()) { | 938 if (transform_node->owner_id == id()) { |
| 930 transform_node->data.scroll_offset = CurrentScrollOffset(); | 939 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 931 transform_node->data.needs_local_transform_update = true; | 940 transform_node->data.needs_local_transform_update = true; |
| 932 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 941 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 933 needs_rebuild = false; | 942 needs_rebuild = false; |
| 934 } | 943 } |
| 935 } | 944 } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 layer->SetClipChildren(clip_children); | 1339 layer->SetClipChildren(clip_children); |
| 1331 } else { | 1340 } else { |
| 1332 layer->SetClipChildren(nullptr); | 1341 layer->SetClipChildren(nullptr); |
| 1333 } | 1342 } |
| 1334 | 1343 |
| 1335 // When a scroll offset animation is interrupted the new scroll position on | 1344 // 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 | 1345 // 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 | 1346 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1338 // instead of trying to undo that scrolling later. | 1347 // instead of trying to undo that scrolling later. |
| 1339 if (ScrollOffsetAnimationWasInterrupted()) | 1348 if (ScrollOffsetAnimationWasInterrupted()) |
| 1340 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1349 layer_tree_host() |
| 1341 else | 1350 ->property_trees() |
| 1342 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1351 ->scroll_tree.synced_scroll_offset(layer->id()) |
| 1352 ->set_clobber_active_value(); |
| 1343 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1353 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1344 | 1354 |
| 1345 { | 1355 { |
| 1346 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | 1356 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1347 // Wrap the copy_requests_ in a PostTask to the main thread. | 1357 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1348 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1358 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1349 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1359 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1350 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1360 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1351 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1361 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1352 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1362 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 } | 1703 } |
| 1694 | 1704 |
| 1695 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1705 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); |
| 1696 scroll_compensation_adjustment_ = | 1706 scroll_compensation_adjustment_ = |
| 1697 ProtoToVector2dF(base.scroll_compensation_adjustment()); | 1707 ProtoToVector2dF(base.scroll_compensation_adjustment()); |
| 1698 | 1708 |
| 1699 update_rect_.Union(ProtoToRect(base.update_rect())); | 1709 update_rect_.Union(ProtoToRect(base.update_rect())); |
| 1700 } | 1710 } |
| 1701 | 1711 |
| 1702 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1712 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1703 return LayerImpl::Create(tree_impl, layer_id_, | 1713 return LayerImpl::Create(tree_impl, layer_id_); |
| 1704 new LayerImpl::SyncedScrollOffset); | |
| 1705 } | 1714 } |
| 1706 | 1715 |
| 1707 bool Layer::DrawsContent() const { | 1716 bool Layer::DrawsContent() const { |
| 1708 return draws_content_; | 1717 return draws_content_; |
| 1709 } | 1718 } |
| 1710 | 1719 |
| 1711 bool Layer::HasDrawableContent() const { | 1720 bool Layer::HasDrawableContent() const { |
| 1712 return is_drawable_; | 1721 return is_drawable_; |
| 1713 } | 1722 } |
| 1714 | 1723 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 this, layer_tree_host_->property_trees()->transform_tree); | 2085 this, layer_tree_host_->property_trees()->transform_tree); |
| 2077 } | 2086 } |
| 2078 | 2087 |
| 2079 gfx::Transform Layer::screen_space_transform() const { | 2088 gfx::Transform Layer::screen_space_transform() const { |
| 2080 DCHECK_NE(transform_tree_index_, -1); | 2089 DCHECK_NE(transform_tree_index_, -1); |
| 2081 return ScreenSpaceTransformFromPropertyTrees( | 2090 return ScreenSpaceTransformFromPropertyTrees( |
| 2082 this, layer_tree_host_->property_trees()->transform_tree); | 2091 this, layer_tree_host_->property_trees()->transform_tree); |
| 2083 } | 2092 } |
| 2084 | 2093 |
| 2085 } // namespace cc | 2094 } // namespace cc |
| OLD | NEW |