Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Side by Side Diff: cc/layers/layer.cc

Issue 864003002: cc: Make LayerAnimationController keep state for clearing scroll delta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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),
75 background_color_(0), 74 background_color_(0),
76 opacity_(1.f), 75 opacity_(1.f),
77 blend_mode_(SkXfermode::kSrcOver_Mode), 76 blend_mode_(SkXfermode::kSrcOver_Mode),
78 scroll_parent_(nullptr), 77 scroll_parent_(nullptr),
79 clip_parent_(nullptr), 78 clip_parent_(nullptr),
80 replica_layer_(nullptr), 79 replica_layer_(nullptr),
81 raster_scale_(0.f), 80 raster_scale_(0.f),
82 client_(nullptr) { 81 client_(nullptr) {
83 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); 82 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
84 layer_animation_controller_->AddValueObserver(this); 83 layer_animation_controller_->AddValueObserver(this);
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 layer->SetClipChildren(clip_children); 963 layer->SetClipChildren(clip_children);
965 } else { 964 } else {
966 layer->SetClipChildren(nullptr); 965 layer->SetClipChildren(nullptr);
967 } 966 }
968 967
969 // Adjust the scroll delta to be just the scrolls that have happened since 968 // Adjust the scroll delta to be just the scrolls that have happened since
970 // the BeginMainFrame was sent. This happens for impl-side painting 969 // the BeginMainFrame was sent. This happens for impl-side painting
971 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. 970 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk.
972 if (layer->layer_tree_impl()->settings().impl_side_painting) { 971 if (layer->layer_tree_impl()->settings().impl_side_painting) {
973 layer->SetScrollOffset(scroll_offset_); 972 layer->SetScrollOffset(scroll_offset_);
974 if (clear_impl_scroll_delta_)
975 layer->ClearScrollDeltaAtActivation();
976 } else { 973 } else {
977 if (clear_impl_scroll_delta_) { 974 if (layer_animation_controller_
975 ->scroll_offset_animation_was_interrupted()) {
978 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF()); 976 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF());
979 } else { 977 } else {
980 layer->SetScrollOffsetAndDelta( 978 layer->SetScrollOffsetAndDelta(
981 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); 979 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta());
982 } 980 }
983 layer->SetSentScrollDelta(gfx::Vector2dF()); 981 layer->SetSentScrollDelta(gfx::Vector2dF());
984 } 982 }
985 clear_impl_scroll_delta_ = false;
986 983
987 // Wrap the copy_requests_ in a PostTask to the main thread. 984 // Wrap the copy_requests_ in a PostTask to the main thread.
988 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; 985 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests;
989 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); 986 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin();
990 it != copy_requests_.end(); 987 it != copy_requests_.end();
991 ++it) { 988 ++it) {
992 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = 989 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner =
993 layer_tree_host()->proxy()->MainThreadTaskRunner(); 990 layer_tree_host()->proxy()->MainThreadTaskRunner();
994 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); 991 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it);
995 const CopyOutputRequest& original_request_ref = *original_request; 992 const CopyOutputRequest& original_request_ref = *original_request;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 // Do nothing. Scroll deltas will be sent from the compositor thread back 1142 // Do nothing. Scroll deltas will be sent from the compositor thread back
1146 // to the main thread in the same manner as during non-animated 1143 // to the main thread in the same manner as during non-animated
1147 // compositor-driven scrolling. 1144 // compositor-driven scrolling.
1148 } 1145 }
1149 1146
1150 void Layer::OnAnimationWaitingForDeletion() { 1147 void Layer::OnAnimationWaitingForDeletion() {
1151 // Animations are only deleted during PushProperties. 1148 // Animations are only deleted during PushProperties.
1152 SetNeedsPushProperties(); 1149 SetNeedsPushProperties();
1153 } 1150 }
1154 1151
1155 void Layer::OnScrollOffsetAnimationRemoved() {
1156 clear_impl_scroll_delta_ = true;
1157 }
1158
1159 bool Layer::IsActive() const { 1152 bool Layer::IsActive() const {
1160 return true; 1153 return true;
1161 } 1154 }
1162 1155
1163 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { 1156 bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
1164 if (!layer_animation_controller_->animation_registrar()) 1157 if (!layer_animation_controller_->animation_registrar())
1165 return false; 1158 return false;
1166 1159
1167 if (animation->target_property() == Animation::ScrollOffset && 1160 if (animation->target_property() == Animation::ScrollOffset &&
1168 !layer_animation_controller_->animation_registrar() 1161 !layer_animation_controller_->animation_registrar()
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 const TransformNode* node = tree.Node(transform_tree_index()); 1281 const TransformNode* node = tree.Node(transform_tree_index());
1289 gfx::Transform ssxform; 1282 gfx::Transform ssxform;
1290 tree.ComputeTransform(node->id, node->data.target_id, &ssxform); 1283 tree.ComputeTransform(node->id, node->data.target_id, &ssxform);
1291 xform.ConcatTransform(ssxform); 1284 xform.ConcatTransform(ssxform);
1292 } 1285 }
1293 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); 1286 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y());
1294 return xform; 1287 return xform;
1295 } 1288 }
1296 1289
1297 } // namespace cc 1290 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.h ('k') | cc/layers/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698