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

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

Issue 95763002: cc: Support animating scroll offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "cc/animation/animation.h" 13 #include "cc/animation/animation.h"
14 #include "cc/animation/animation_events.h" 14 #include "cc/animation/animation_events.h"
15 #include "cc/animation/keyframed_animation_curve.h"
15 #include "cc/animation/layer_animation_controller.h" 16 #include "cc/animation/layer_animation_controller.h"
16 #include "cc/layers/layer_client.h" 17 #include "cc/layers/layer_client.h"
17 #include "cc/layers/layer_impl.h" 18 #include "cc/layers/layer_impl.h"
18 #include "cc/output/copy_output_request.h" 19 #include "cc/output/copy_output_request.h"
19 #include "cc/output/copy_output_result.h" 20 #include "cc/output/copy_output_result.h"
20 #include "cc/trees/layer_tree_host.h" 21 #include "cc/trees/layer_tree_host.h"
21 #include "cc/trees/layer_tree_impl.h" 22 #include "cc/trees/layer_tree_impl.h"
22 #include "third_party/skia/include/core/SkImageFilter.h" 23 #include "third_party/skia/include/core/SkImageFilter.h"
23 #include "ui/gfx/rect_conversions.h" 24 #include "ui/gfx/rect_conversions.h"
24 25
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 replica_layer_(NULL), 66 replica_layer_(NULL),
66 raster_scale_(0.f), 67 raster_scale_(0.f),
67 client_(NULL) { 68 client_(NULL) {
68 if (layer_id_ < 0) { 69 if (layer_id_ < 0) {
69 s_next_layer_id = 1; 70 s_next_layer_id = 1;
70 layer_id_ = s_next_layer_id++; 71 layer_id_ = s_next_layer_id++;
71 } 72 }
72 73
73 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); 74 layer_animation_controller_ = LayerAnimationController::Create(layer_id_);
74 layer_animation_controller_->AddValueObserver(this); 75 layer_animation_controller_->AddValueObserver(this);
76 layer_animation_controller_->set_value_provider(this);
75 } 77 }
76 78
77 Layer::~Layer() { 79 Layer::~Layer() {
78 // Our parent should be holding a reference to us so there should be no 80 // Our parent should be holding a reference to us so there should be no
79 // way for us to be destroyed while we still have a parent. 81 // way for us to be destroyed while we still have a parent.
80 DCHECK(!parent()); 82 DCHECK(!parent());
81 // Similarly we shouldn't have a layer tree host since it also keeps a 83 // Similarly we shouldn't have a layer tree host since it also keeps a
82 // reference to us. 84 // reference to us.
83 DCHECK(!layer_tree_host()); 85 DCHECK(!layer_tree_host());
84 86
85 layer_animation_controller_->RemoveValueObserver(this); 87 layer_animation_controller_->RemoveValueObserver(this);
88 layer_animation_controller_->remove_value_provider(this);
86 89
87 // Remove the parent reference from all children and dependents. 90 // Remove the parent reference from all children and dependents.
88 RemoveAllChildren(); 91 RemoveAllChildren();
89 if (mask_layer_.get()) { 92 if (mask_layer_.get()) {
90 DCHECK_EQ(this, mask_layer_->parent()); 93 DCHECK_EQ(this, mask_layer_->parent());
91 mask_layer_->RemoveFromParent(); 94 mask_layer_->RemoveFromParent();
92 } 95 }
93 if (replica_layer_.get()) { 96 if (replica_layer_.get()) {
94 DCHECK_EQ(this, replica_layer_->parent()); 97 DCHECK_EQ(this, replica_layer_->parent());
95 replica_layer_->RemoveFromParent(); 98 replica_layer_->RemoveFromParent();
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 void Layer::CreateRenderSurface() { 1044 void Layer::CreateRenderSurface() {
1042 DCHECK(!draw_properties_.render_surface); 1045 DCHECK(!draw_properties_.render_surface);
1043 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this)); 1046 draw_properties_.render_surface = make_scoped_ptr(new RenderSurface(this));
1044 draw_properties_.render_target = this; 1047 draw_properties_.render_target = this;
1045 } 1048 }
1046 1049
1047 void Layer::ClearRenderSurface() { 1050 void Layer::ClearRenderSurface() {
1048 draw_properties_.render_surface.reset(); 1051 draw_properties_.render_surface.reset();
1049 } 1052 }
1050 1053
1054 gfx::Vector2dF Layer::ScrollOffsetForAnimation() const {
1055 return TotalScrollOffset();
1056 }
1057
1051 // On<Property>Animated is called due to an ongoing accelerated animation. 1058 // On<Property>Animated is called due to an ongoing accelerated animation.
1052 // Since this animation is also being run on the compositor thread, there 1059 // Since this animation is also being run on the compositor thread, there
1053 // is no need to request a commit to push this value over, so the value is 1060 // is no need to request a commit to push this value over, so the value is
1054 // set directly rather than by calling Set<Property>. 1061 // set directly rather than by calling Set<Property>.
1055 void Layer::OnFilterAnimated(const FilterOperations& filters) { 1062 void Layer::OnFilterAnimated(const FilterOperations& filters) {
1056 filters_ = filters; 1063 filters_ = filters;
1057 } 1064 }
1058 1065
1059 void Layer::OnOpacityAnimated(float opacity) { 1066 void Layer::OnOpacityAnimated(float opacity) {
1060 opacity_ = opacity; 1067 opacity_ = opacity;
1061 } 1068 }
1062 1069
1063 void Layer::OnTransformAnimated(const gfx::Transform& transform) { 1070 void Layer::OnTransformAnimated(const gfx::Transform& transform) {
1064 transform_ = transform; 1071 transform_ = transform;
1065 } 1072 }
1066 1073
1074 void Layer::OnScrollOffsetAnimated(gfx::Vector2dF scroll_offset) {
1075 // Do nothing. Scroll deltas will be sent from the compositor thread back
1076 // to the main thread in the same manner as during non-animated
1077 // compositor-driven scrolling.
ajuma 2013/11/28 22:33:36 SingleThreadProxy doesn't send back scroll deltas.
Ian Vollick 2013/11/29 15:29:29 Re 2), we could use scroll to on the main frame, t
ajuma 2013/11/29 21:18:41 Ah, I missed that usesCompositedScrolling doesn't
1078 }
1079
1067 void Layer::OnAnimationWaitingForDeletion() { 1080 void Layer::OnAnimationWaitingForDeletion() {
1068 // Animations are only deleted during PushProperties. 1081 // Animations are only deleted during PushProperties.
1069 SetNeedsPushProperties(); 1082 SetNeedsPushProperties();
1070 } 1083 }
1071 1084
1072 bool Layer::IsActive() const { 1085 bool Layer::IsActive() const {
1073 return true; 1086 return true;
1074 } 1087 }
1075 1088
1076 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { 1089 bool Layer::AddAnimation(scoped_ptr <Animation> animation) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 clip_parent_->RemoveClipChild(this); 1171 clip_parent_->RemoveClipChild(this);
1159 1172
1160 clip_parent_ = NULL; 1173 clip_parent_ = NULL;
1161 } 1174 }
1162 1175
1163 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { 1176 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) {
1164 benchmark->RunOnLayer(this); 1177 benchmark->RunOnLayer(this);
1165 } 1178 }
1166 1179
1167 } // namespace cc 1180 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698