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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 hide_layer_and_subtree_(false), | 64 hide_layer_and_subtree_(false), |
65 masks_to_bounds_(false), | 65 masks_to_bounds_(false), |
66 contents_opaque_(false), | 66 contents_opaque_(false), |
67 double_sided_(true), | 67 double_sided_(true), |
68 should_flatten_transform_(true), | 68 should_flatten_transform_(true), |
69 use_parent_backface_visibility_(false), | 69 use_parent_backface_visibility_(false), |
70 draw_checkerboard_for_missing_tiles_(false), | 70 draw_checkerboard_for_missing_tiles_(false), |
71 force_render_surface_(false), | 71 force_render_surface_(false), |
72 transform_is_invertible_(true), | 72 transform_is_invertible_(true), |
73 has_render_surface_(false), | 73 has_render_surface_(false), |
| 74 clear_impl_scroll_delta_(false), |
74 background_color_(0), | 75 background_color_(0), |
75 opacity_(1.f), | 76 opacity_(1.f), |
76 blend_mode_(SkXfermode::kSrcOver_Mode), | 77 blend_mode_(SkXfermode::kSrcOver_Mode), |
77 scroll_parent_(nullptr), | 78 scroll_parent_(nullptr), |
78 clip_parent_(nullptr), | 79 clip_parent_(nullptr), |
79 replica_layer_(nullptr), | 80 replica_layer_(nullptr), |
80 raster_scale_(0.f), | 81 raster_scale_(0.f), |
81 client_(nullptr) { | 82 client_(nullptr) { |
82 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 83 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
83 layer_animation_controller_->AddValueObserver(this); | 84 layer_animation_controller_->AddValueObserver(this); |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 layer->SetClipChildren(clip_children); | 964 layer->SetClipChildren(clip_children); |
964 } else { | 965 } else { |
965 layer->SetClipChildren(nullptr); | 966 layer->SetClipChildren(nullptr); |
966 } | 967 } |
967 | 968 |
968 // Adjust the scroll delta to be just the scrolls that have happened since | 969 // Adjust the scroll delta to be just the scrolls that have happened since |
969 // the BeginMainFrame was sent. This happens for impl-side painting | 970 // the BeginMainFrame was sent. This happens for impl-side painting |
970 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. | 971 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. |
971 if (layer->layer_tree_impl()->settings().impl_side_painting) { | 972 if (layer->layer_tree_impl()->settings().impl_side_painting) { |
972 layer->SetScrollOffset(scroll_offset_); | 973 layer->SetScrollOffset(scroll_offset_); |
| 974 if (clear_impl_scroll_delta_) |
| 975 layer->ClearScrollDeltaAtActivation(); |
973 } else { | 976 } else { |
974 layer->SetScrollOffsetAndDelta( | 977 if (clear_impl_scroll_delta_) { |
975 scroll_offset_, | 978 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF()); |
976 layer->ScrollDelta() - layer->sent_scroll_delta()); | 979 } else { |
| 980 layer->SetScrollOffsetAndDelta( |
| 981 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
| 982 } |
977 layer->SetSentScrollDelta(gfx::Vector2dF()); | 983 layer->SetSentScrollDelta(gfx::Vector2dF()); |
978 } | 984 } |
| 985 clear_impl_scroll_delta_ = false; |
979 | 986 |
980 // Wrap the copy_requests_ in a PostTask to the main thread. | 987 // Wrap the copy_requests_ in a PostTask to the main thread. |
981 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; | 988 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; |
982 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); | 989 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); |
983 it != copy_requests_.end(); | 990 it != copy_requests_.end(); |
984 ++it) { | 991 ++it) { |
985 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 992 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
986 layer_tree_host()->proxy()->MainThreadTaskRunner(); | 993 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
987 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); | 994 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); |
988 const CopyOutputRequest& original_request_ref = *original_request; | 995 const CopyOutputRequest& original_request_ref = *original_request; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 // Do nothing. Scroll deltas will be sent from the compositor thread back | 1145 // Do nothing. Scroll deltas will be sent from the compositor thread back |
1139 // to the main thread in the same manner as during non-animated | 1146 // to the main thread in the same manner as during non-animated |
1140 // compositor-driven scrolling. | 1147 // compositor-driven scrolling. |
1141 } | 1148 } |
1142 | 1149 |
1143 void Layer::OnAnimationWaitingForDeletion() { | 1150 void Layer::OnAnimationWaitingForDeletion() { |
1144 // Animations are only deleted during PushProperties. | 1151 // Animations are only deleted during PushProperties. |
1145 SetNeedsPushProperties(); | 1152 SetNeedsPushProperties(); |
1146 } | 1153 } |
1147 | 1154 |
| 1155 void Layer::OnScrollOffsetAnimationRemoved() { |
| 1156 clear_impl_scroll_delta_ = true; |
| 1157 } |
| 1158 |
1148 bool Layer::IsActive() const { | 1159 bool Layer::IsActive() const { |
1149 return true; | 1160 return true; |
1150 } | 1161 } |
1151 | 1162 |
1152 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { | 1163 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { |
1153 if (!layer_animation_controller_->animation_registrar()) | 1164 if (!layer_animation_controller_->animation_registrar()) |
1154 return false; | 1165 return false; |
1155 | 1166 |
1156 if (animation->target_property() == Animation::ScrollOffset && | 1167 if (animation->target_property() == Animation::ScrollOffset && |
1157 !layer_animation_controller_->animation_registrar() | 1168 !layer_animation_controller_->animation_registrar() |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 const TransformNode* node = tree.Node(transform_tree_index()); | 1288 const TransformNode* node = tree.Node(transform_tree_index()); |
1278 gfx::Transform ssxform; | 1289 gfx::Transform ssxform; |
1279 tree.ComputeTransform(node->id, node->data.target_id, &ssxform); | 1290 tree.ComputeTransform(node->id, node->data.target_id, &ssxform); |
1280 xform.ConcatTransform(ssxform); | 1291 xform.ConcatTransform(ssxform); |
1281 } | 1292 } |
1282 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | 1293 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); |
1283 return xform; | 1294 return xform; |
1284 } | 1295 } |
1285 | 1296 |
1286 } // namespace cc | 1297 } // namespace cc |
OLD | NEW |