| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 layer->SetClipChildren(clip_children); | 1340 layer->SetClipChildren(clip_children); |
| 1332 } else { | 1341 } else { |
| 1333 layer->SetClipChildren(nullptr); | 1342 layer->SetClipChildren(nullptr); |
| 1334 } | 1343 } |
| 1335 | 1344 |
| 1336 // 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 |
| 1337 // 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 |
| 1338 // 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 |
| 1339 // instead of trying to undo that scrolling later. | 1348 // instead of trying to undo that scrolling later. |
| 1340 if (ScrollOffsetAnimationWasInterrupted()) | 1349 if (ScrollOffsetAnimationWasInterrupted()) |
| 1341 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1350 layer_tree_host() |
| 1342 else | 1351 ->property_trees() |
| 1343 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1352 ->scroll_tree.synced_scroll_offset(layer->id()) |
| 1353 ->set_clobber_active_value(); |
| 1344 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1354 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1345 | 1355 |
| 1346 { | 1356 { |
| 1347 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | 1357 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1348 // Wrap the copy_requests_ in a PostTask to the main thread. | 1358 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1349 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1359 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1350 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1360 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1351 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1361 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1352 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1362 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1353 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1363 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 } | 1706 } |
| 1697 | 1707 |
| 1698 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1708 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); |
| 1699 scroll_compensation_adjustment_ = | 1709 scroll_compensation_adjustment_ = |
| 1700 ProtoToVector2dF(base.scroll_compensation_adjustment()); | 1710 ProtoToVector2dF(base.scroll_compensation_adjustment()); |
| 1701 | 1711 |
| 1702 update_rect_.Union(ProtoToRect(base.update_rect())); | 1712 update_rect_.Union(ProtoToRect(base.update_rect())); |
| 1703 } | 1713 } |
| 1704 | 1714 |
| 1705 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1715 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1706 return LayerImpl::Create(tree_impl, layer_id_, | 1716 return LayerImpl::Create(tree_impl, layer_id_); |
| 1707 new LayerImpl::SyncedScrollOffset); | |
| 1708 } | 1717 } |
| 1709 | 1718 |
| 1710 bool Layer::DrawsContent() const { | 1719 bool Layer::DrawsContent() const { |
| 1711 return draws_content_; | 1720 return draws_content_; |
| 1712 } | 1721 } |
| 1713 | 1722 |
| 1714 bool Layer::HasDrawableContent() const { | 1723 bool Layer::HasDrawableContent() const { |
| 1715 return is_drawable_; | 1724 return is_drawable_; |
| 1716 } | 1725 } |
| 1717 | 1726 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 this, layer_tree_host_->property_trees()->transform_tree); | 2088 this, layer_tree_host_->property_trees()->transform_tree); |
| 2080 } | 2089 } |
| 2081 | 2090 |
| 2082 gfx::Transform Layer::screen_space_transform() const { | 2091 gfx::Transform Layer::screen_space_transform() const { |
| 2083 DCHECK_NE(transform_tree_index_, -1); | 2092 DCHECK_NE(transform_tree_index_, -1); |
| 2084 return ScreenSpaceTransformFromPropertyTrees( | 2093 return ScreenSpaceTransformFromPropertyTrees( |
| 2085 this, layer_tree_host_->property_trees()->transform_tree); | 2094 this, layer_tree_host_->property_trees()->transform_tree); |
| 2086 } | 2095 } |
| 2087 | 2096 |
| 2088 } // namespace cc | 2097 } // namespace cc |
| OLD | NEW |