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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2758343002: cc: Use Element Id to Record Animation Changes (Closed)
Patch Set: fix for test Created 3 years, 9 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/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "cc/scheduler/delay_based_time_source.h" 65 #include "cc/scheduler/delay_based_time_source.h"
66 #include "cc/tiles/eviction_tile_priority_queue.h" 66 #include "cc/tiles/eviction_tile_priority_queue.h"
67 #include "cc/tiles/frame_viewer_instrumentation.h" 67 #include "cc/tiles/frame_viewer_instrumentation.h"
68 #include "cc/tiles/gpu_image_decode_cache.h" 68 #include "cc/tiles/gpu_image_decode_cache.h"
69 #include "cc/tiles/picture_layer_tiling.h" 69 #include "cc/tiles/picture_layer_tiling.h"
70 #include "cc/tiles/raster_tile_priority_queue.h" 70 #include "cc/tiles/raster_tile_priority_queue.h"
71 #include "cc/tiles/software_image_decode_cache.h" 71 #include "cc/tiles/software_image_decode_cache.h"
72 #include "cc/trees/damage_tracker.h" 72 #include "cc/trees/damage_tracker.h"
73 #include "cc/trees/debug_rect_history.h" 73 #include "cc/trees/debug_rect_history.h"
74 #include "cc/trees/draw_property_utils.h" 74 #include "cc/trees/draw_property_utils.h"
75 #include "cc/trees/effect_node.h"
75 #include "cc/trees/frame_rate_counter.h" 76 #include "cc/trees/frame_rate_counter.h"
76 #include "cc/trees/latency_info_swap_promise_monitor.h" 77 #include "cc/trees/latency_info_swap_promise_monitor.h"
77 #include "cc/trees/layer_tree_host_common.h" 78 #include "cc/trees/layer_tree_host_common.h"
78 #include "cc/trees/layer_tree_impl.h" 79 #include "cc/trees/layer_tree_impl.h"
79 #include "cc/trees/mutator_host.h" 80 #include "cc/trees/mutator_host.h"
80 #include "cc/trees/scroll_node.h" 81 #include "cc/trees/scroll_node.h"
81 #include "cc/trees/single_thread_proxy.h" 82 #include "cc/trees/single_thread_proxy.h"
83 #include "cc/trees/transform_node.h"
82 #include "cc/trees/tree_synchronizer.h" 84 #include "cc/trees/tree_synchronizer.h"
83 #include "gpu/GLES2/gl2extchromium.h" 85 #include "gpu/GLES2/gl2extchromium.h"
84 #include "gpu/command_buffer/client/context_support.h" 86 #include "gpu/command_buffer/client/context_support.h"
85 #include "gpu/command_buffer/client/gles2_interface.h" 87 #include "gpu/command_buffer/client/gles2_interface.h"
86 #include "ui/gfx/geometry/point_conversions.h" 88 #include "ui/gfx/geometry/point_conversions.h"
87 #include "ui/gfx/geometry/rect_conversions.h" 89 #include "ui/gfx/geometry/rect_conversions.h"
88 #include "ui/gfx/geometry/scroll_offset.h" 90 #include "ui/gfx/geometry/scroll_offset.h"
89 #include "ui/gfx/geometry/size_conversions.h" 91 #include "ui/gfx/geometry/size_conversions.h"
90 #include "ui/gfx/geometry/vector2d_conversions.h" 92 #include "ui/gfx/geometry/vector2d_conversions.h"
91 93
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 // damage status by pushing the damage status from active tree property 2036 // damage status by pushing the damage status from active tree property
2035 // trees to pending tree property trees or by moving it onto the layers. 2037 // trees to pending tree property trees or by moving it onto the layers.
2036 if (active_tree_->property_trees()->changed) { 2038 if (active_tree_->property_trees()->changed) {
2037 if (pending_tree_->property_trees()->sequence_number == 2039 if (pending_tree_->property_trees()->sequence_number ==
2038 active_tree_->property_trees()->sequence_number) 2040 active_tree_->property_trees()->sequence_number)
2039 active_tree_->property_trees()->PushChangeTrackingTo( 2041 active_tree_->property_trees()->PushChangeTrackingTo(
2040 pending_tree_->property_trees()); 2042 pending_tree_->property_trees());
2041 else 2043 else
2042 active_tree_->MoveChangeTrackingToLayers(); 2044 active_tree_->MoveChangeTrackingToLayers();
2043 } 2045 }
2046 TreeSynchronizer::PushLayerProperties(pending_tree(), active_tree());
2044 active_tree_->property_trees()->PushOpacityIfNeeded( 2047 active_tree_->property_trees()->PushOpacityIfNeeded(
2045 pending_tree_->property_trees()); 2048 pending_tree_->property_trees());
2046 2049
2047 TreeSynchronizer::PushLayerProperties(pending_tree(), active_tree());
2048 pending_tree_->PushPropertiesTo(active_tree_.get()); 2050 pending_tree_->PushPropertiesTo(active_tree_.get());
2049 if (!pending_tree_->LayerListIsEmpty()) 2051 if (!pending_tree_->LayerListIsEmpty())
2050 pending_tree_->property_trees()->ResetAllChangeTracking(); 2052 pending_tree_->property_trees()->ResetAllChangeTracking();
2051 2053
2052 // Now that we've synced everything from the pending tree to the active 2054 // Now that we've synced everything from the pending tree to the active
2053 // tree, rename the pending tree the recycle tree so we can reuse it on the 2055 // tree, rename the pending tree the recycle tree so we can reuse it on the
2054 // next sync. 2056 // next sync.
2055 DCHECK(!recycle_tree_); 2057 DCHECK(!recycle_tree_);
2056 pending_tree_.swap(recycle_tree_); 2058 pending_tree_.swap(recycle_tree_);
2057 2059
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
4113 SetTreeLayerScrollOffsetMutated(element_id, pending_tree(), scroll_offset); 4115 SetTreeLayerScrollOffsetMutated(element_id, pending_tree(), scroll_offset);
4114 SetTreeLayerScrollOffsetMutated(element_id, recycle_tree(), scroll_offset); 4116 SetTreeLayerScrollOffsetMutated(element_id, recycle_tree(), scroll_offset);
4115 } 4117 }
4116 } 4118 }
4117 4119
4118 void LayerTreeHostImpl::ElementIsAnimatingChanged( 4120 void LayerTreeHostImpl::ElementIsAnimatingChanged(
4119 ElementId element_id, 4121 ElementId element_id,
4120 ElementListType list_type, 4122 ElementListType list_type,
4121 const PropertyAnimationState& mask, 4123 const PropertyAnimationState& mask,
4122 const PropertyAnimationState& state) { 4124 const PropertyAnimationState& state) {
4125 // TODO(weiliangc): Most of the code is duplicated with LayerTeeHost version
4126 // of function. Should try to share code.
4123 LayerTreeImpl* tree = 4127 LayerTreeImpl* tree =
4124 list_type == ElementListType::ACTIVE ? active_tree() : pending_tree(); 4128 list_type == ElementListType::ACTIVE ? active_tree() : pending_tree();
4125 if (!tree) 4129 if (!tree)
4126 return; 4130 return;
4127 LayerImpl* layer = tree->LayerByElementId(element_id); 4131 PropertyTrees* property_trees = tree->property_trees();
4128 if (layer) 4132
4129 layer->OnIsAnimatingChanged(mask, state); 4133 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
4134 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
4135 if (!mask.currently_running[property] &&
4136 !mask.potentially_animating[property])
4137 continue;
4138
4139 switch (property) {
4140 case TargetProperty::TRANSFORM:
4141 if (TransformNode* transform_node =
4142 property_trees->transform_tree.FindNodeFromElementId(
4143 element_id)) {
4144 if (mask.currently_running[property])
4145 transform_node->is_currently_animating =
4146 state.currently_running[property];
4147 if (mask.potentially_animating[property]) {
4148 transform_node->has_potential_animation =
4149 state.potentially_animating[property];
4150 transform_node->has_only_translation_animations =
4151 mutator_host()->HasOnlyTranslationTransforms(element_id,
4152 list_type);
4153 property_trees->transform_tree.set_needs_update(true);
4154 tree->set_needs_update_draw_properties();
4155 // TODO(crbug.com/702777):
4156 // was_ever_ready_since_last_transform_animation should not live on
4157 // layers.
4158 if (LayerImpl* layer = tree->LayerByElementId(element_id)) {
4159 layer->set_was_ever_ready_since_last_transform_animation(false);
4160 }
4161 }
4162 }
4163 break;
4164 case TargetProperty::OPACITY:
4165 if (EffectNode* effect_node =
4166 property_trees->effect_tree.FindNodeFromElementId(element_id)) {
4167 if (mask.currently_running[property])
4168 effect_node->is_currently_animating_opacity =
4169 state.currently_running[property];
4170 if (mask.potentially_animating[property]) {
4171 effect_node->has_potential_opacity_animation =
4172 state.potentially_animating[property];
4173 property_trees->effect_tree.set_needs_update(true);
4174 }
4175 }
4176 break;
4177 case TargetProperty::FILTER:
4178 if (EffectNode* effect_node =
4179 property_trees->effect_tree.FindNodeFromElementId(element_id)) {
4180 if (mask.currently_running[property])
4181 effect_node->is_currently_animating_filter =
4182 state.currently_running[property];
4183 if (mask.potentially_animating[property])
4184 effect_node->has_potential_filter_animation =
4185 state.potentially_animating[property];
4186 // Filter animation changes only the node, and the subtree does not
4187 // care. There is no need to request update on property trees here.
4188 }
4189 break;
4190 default:
4191 break;
4192 }
4193 }
4130 } 4194 }
4131 4195
4132 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { 4196 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() {
4133 // TODO(majidvp): We should pass in the original starting scroll position here 4197 // TODO(majidvp): We should pass in the original starting scroll position here
4134 ScrollStateData scroll_state_data; 4198 ScrollStateData scroll_state_data;
4135 ScrollState scroll_state(scroll_state_data); 4199 ScrollState scroll_state(scroll_state_data);
4136 ScrollEnd(&scroll_state); 4200 ScrollEnd(&scroll_state);
4137 } 4201 }
4138 4202
4139 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( 4203 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4186 worker_context_visibility_ = 4250 worker_context_visibility_ =
4187 worker_context->CacheController()->ClientBecameVisible(); 4251 worker_context->CacheController()->ClientBecameVisible();
4188 } else { 4252 } else {
4189 worker_context->CacheController()->ClientBecameNotVisible( 4253 worker_context->CacheController()->ClientBecameNotVisible(
4190 std::move(worker_context_visibility_)); 4254 std::move(worker_context_visibility_));
4191 } 4255 }
4192 } 4256 }
4193 } 4257 }
4194 4258
4195 } // namespace cc 4259 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698