| 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); |
| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 layer->SetClipChildren(clip_children); | 1341 layer->SetClipChildren(clip_children); |
| 1331 } else { | 1342 } else { |
| 1332 layer->SetClipChildren(nullptr); | 1343 layer->SetClipChildren(nullptr); |
| 1333 } | 1344 } |
| 1334 | 1345 |
| 1335 // When a scroll offset animation is interrupted the new scroll position on | 1346 // 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 | 1347 // 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 | 1348 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1338 // instead of trying to undo that scrolling later. | 1349 // instead of trying to undo that scrolling later. |
| 1339 if (ScrollOffsetAnimationWasInterrupted()) | 1350 if (ScrollOffsetAnimationWasInterrupted()) |
| 1340 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); | 1351 layer_tree_host() |
| 1341 else | 1352 ->property_trees() |
| 1342 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 1353 ->scroll_tree.synced_scroll_offset(layer->id()) |
| 1354 ->set_clobber_active_value(); |
| 1343 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 1355 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 1344 | 1356 |
| 1345 { | 1357 { |
| 1346 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); | 1358 TRACE_EVENT0("cc", "Layer::PushPropertiesTo::CopyOutputRequests"); |
| 1347 // Wrap the copy_requests_ in a PostTask to the main thread. | 1359 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 1348 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; | 1360 std::vector<scoped_ptr<CopyOutputRequest>> main_thread_copy_requests; |
| 1349 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { | 1361 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) { |
| 1350 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1362 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1351 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1363 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1352 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); | 1364 scoped_ptr<CopyOutputRequest> original_request = std::move(*it); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 this, layer_tree_host_->property_trees()->transform_tree); | 2088 this, layer_tree_host_->property_trees()->transform_tree); |
| 2077 } | 2089 } |
| 2078 | 2090 |
| 2079 gfx::Transform Layer::screen_space_transform() const { | 2091 gfx::Transform Layer::screen_space_transform() const { |
| 2080 DCHECK_NE(transform_tree_index_, -1); | 2092 DCHECK_NE(transform_tree_index_, -1); |
| 2081 return ScreenSpaceTransformFromPropertyTrees( | 2093 return ScreenSpaceTransformFromPropertyTrees( |
| 2082 this, layer_tree_host_->property_trees()->transform_tree); | 2094 this, layer_tree_host_->property_trees()->transform_tree); |
| 2083 } | 2095 } |
| 2084 | 2096 |
| 2085 } // namespace cc | 2097 } // namespace cc |
| OLD | NEW |