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() | |
| 889 ->scroll_tree.synced_scroll_offset(id()) | |
| 890 ->PushFromMainThread(scroll_offset); | |
|
ajuma
2016/03/01 22:54:20
How about adding a SetScrollOffset method to Scrol
sunxd
2016/03/02 17:45:34
Done.
| |
| 891 | |
| 887 if (TransformNode* transform_node = | 892 if (TransformNode* transform_node = |
| 888 layer_tree_host_->property_trees()->transform_tree.Node( | 893 layer_tree_host_->property_trees()->transform_tree.Node( |
| 889 transform_tree_index())) { | 894 transform_tree_index())) { |
| 890 if (transform_node->owner_id == id()) { | 895 if (transform_node->owner_id == id()) { |
| 891 transform_node->data.scroll_offset = CurrentScrollOffset(); | 896 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 892 transform_node->data.needs_local_transform_update = true; | 897 transform_node->data.needs_local_transform_update = true; |
| 893 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 898 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 894 SetNeedsCommitNoRebuild(); | 899 SetNeedsCommitNoRebuild(); |
| 895 return; | 900 return; |
| 896 } | 901 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 916 DCHECK(IsPropertyChangeAllowed()); | 921 DCHECK(IsPropertyChangeAllowed()); |
| 917 // This function only gets called during a BeginMainFrame, so there | 922 // This function only gets called during a BeginMainFrame, so there |
| 918 // is no need to call SetNeedsUpdate here. | 923 // is no need to call SetNeedsUpdate here. |
| 919 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 924 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
| 920 if (scroll_offset_ == scroll_offset) | 925 if (scroll_offset_ == scroll_offset) |
| 921 return; | 926 return; |
| 922 scroll_offset_ = scroll_offset; | 927 scroll_offset_ = scroll_offset; |
| 923 SetNeedsPushProperties(); | 928 SetNeedsPushProperties(); |
| 924 | 929 |
| 925 bool needs_rebuild = true; | 930 bool needs_rebuild = true; |
| 931 | |
| 932 if (scroll_tree_index() != -1 && scrollable()) | |
| 933 layer_tree_host_->property_trees() | |
| 934 ->scroll_tree.synced_scroll_offset(id()) | |
| 935 ->PushFromMainThread(scroll_offset); | |
| 936 | |
| 926 if (TransformNode* transform_node = | 937 if (TransformNode* transform_node = |
| 927 layer_tree_host_->property_trees()->transform_tree.Node( | 938 layer_tree_host_->property_trees()->transform_tree.Node( |
| 928 transform_tree_index())) { | 939 transform_tree_index())) { |
| 929 if (transform_node->owner_id == id()) { | 940 if (transform_node->owner_id == id()) { |
| 930 transform_node->data.scroll_offset = CurrentScrollOffset(); | 941 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 931 transform_node->data.needs_local_transform_update = true; | 942 transform_node->data.needs_local_transform_update = true; |
| 932 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 943 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 933 needs_rebuild = false; | 944 needs_rebuild = false; |
| 934 } | 945 } |
| 935 } | 946 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1332 layer->SetClipChildren(clip_children); | 1343 layer->SetClipChildren(clip_children); |
| 1333 } else { | 1344 } else { |
| 1334 layer->SetClipChildren(nullptr); | 1345 layer->SetClipChildren(nullptr); |
| 1335 } | 1346 } |
| 1336 | 1347 |
| 1337 // When a scroll offset animation is interrupted the new scroll position on | 1348 // When a scroll offset animation is interrupted the new scroll position on |
| 1338 // the pending tree will clobber any impl-side scrolling occuring on the | 1349 // the pending tree will clobber any impl-side scrolling occuring on the |
| 1339 // active tree. To do so, avoid scrolling the pending tree along with it | 1350 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1340 // instead of trying to undo that scrolling later. | 1351 // instead of trying to undo that scrolling later. |
| 1341 if (ScrollOffsetAnimationWasInterrupted()) | 1352 if (ScrollOffsetAnimationWasInterrupted()) |
| 1342 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1353 layer_tree_host() |
| 1343 else | 1354 ->property_trees() |
| 1344 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1355 ->scroll_tree.synced_scroll_offset(layer->id()) |
| 1356 ->set_clobber_active_value(); | |
| 1345 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1357 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1346 | 1358 |
| 1347 { | 1359 { |
| 1348 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | 1360 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1349 // Wrap the copy_requests_ in a PostTask to the main thread. | 1361 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1350 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1362 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1351 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1363 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1352 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1364 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1353 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1365 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1354 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1366 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2078 this, layer_tree_host_->property_trees()->transform_tree); | 2090 this, layer_tree_host_->property_trees()->transform_tree); |
| 2079 } | 2091 } |
| 2080 | 2092 |
| 2081 gfx::Transform Layer::screen_space_transform() const { | 2093 gfx::Transform Layer::screen_space_transform() const { |
| 2082 DCHECK_NE(transform_tree_index_, -1); | 2094 DCHECK_NE(transform_tree_index_, -1); |
| 2083 return ScreenSpaceTransformFromPropertyTrees( | 2095 return ScreenSpaceTransformFromPropertyTrees( |
| 2084 this, layer_tree_host_->property_trees()->transform_tree); | 2096 this, layer_tree_host_->property_trees()->transform_tree); |
| 2085 } | 2097 } |
| 2086 | 2098 |
| 2087 } // namespace cc | 2099 } // namespace cc |
| OLD | NEW |