Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| 11 #include "base/trace_event/trace_event_argument.h" | 11 #include "base/trace_event/trace_event_argument.h" |
| 12 #include "cc/animation/animation_registrar.h" | 12 #include "cc/animation/animation_registrar.h" |
| 13 #include "cc/animation/scrollbar_animation_controller.h" | 13 #include "cc/animation/scrollbar_animation_controller.h" |
| 14 #include "cc/base/math_util.h" | 14 #include "cc/base/math_util.h" |
| 15 #include "cc/base/simple_enclosed_region.h" | 15 #include "cc/base/simple_enclosed_region.h" |
| 16 #include "cc/debug/debug_colors.h" | 16 #include "cc/debug/debug_colors.h" |
| 17 #include "cc/debug/layer_tree_debug_state.h" | 17 #include "cc/debug/layer_tree_debug_state.h" |
| 18 #include "cc/debug/micro_benchmark_impl.h" | 18 #include "cc/debug/micro_benchmark_impl.h" |
| 19 #include "cc/debug/traced_value.h" | 19 #include "cc/debug/traced_value.h" |
| 20 #include "cc/input/scroll_state.h" | |
| 20 #include "cc/layers/layer_utils.h" | 21 #include "cc/layers/layer_utils.h" |
| 21 #include "cc/layers/painted_scrollbar_layer_impl.h" | 22 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 22 #include "cc/output/copy_output_request.h" | 23 #include "cc/output/copy_output_request.h" |
| 23 #include "cc/quads/debug_border_draw_quad.h" | 24 #include "cc/quads/debug_border_draw_quad.h" |
| 24 #include "cc/quads/render_pass.h" | 25 #include "cc/quads/render_pass.h" |
| 25 #include "cc/trees/layer_tree_host_common.h" | 26 #include "cc/trees/layer_tree_host_common.h" |
| 26 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
| 27 #include "cc/trees/layer_tree_settings.h" | 28 #include "cc/trees/layer_tree_settings.h" |
| 28 #include "cc/trees/proxy.h" | 29 #include "cc/trees/proxy.h" |
| 29 #include "ui/gfx/geometry/box_f.h" | 30 #include "ui/gfx/geometry/box_f.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 SetNeedsPushProperties(); | 191 SetNeedsPushProperties(); |
| 191 } | 192 } |
| 192 | 193 |
| 193 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 194 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
| 194 if (scroll_children_.get() == children) | 195 if (scroll_children_.get() == children) |
| 195 return; | 196 return; |
| 196 scroll_children_.reset(children); | 197 scroll_children_.reset(children); |
| 197 SetNeedsPushProperties(); | 198 SetNeedsPushProperties(); |
| 198 } | 199 } |
| 199 | 200 |
| 201 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { | |
| 202 DCHECK(scroll_state); | |
| 203 if (scroll_state->FullyConsumed()) | |
| 204 return; | |
| 205 | |
| 206 scroll_state->DistributeToScrollChainDescendant(); | |
| 207 | |
| 208 // If the scroll doesn't propagate, and we're currently scrolling | |
| 209 // a layer other than this one, prevent the scroll from | |
| 210 // propagating to this layer. | |
| 211 if (!scroll_state->should_propagate() && | |
| 212 scroll_state->delta_consumed_for_scroll_sequence() && | |
|
Ian Vollick
2015/07/30 19:02:25
Hmm, what if we shouldn't propagate, and the true
tdresser
2015/07/30 20:34:20
delta_consumed_for_scroll_sequence persists for th
| |
| 213 scroll_state->current_native_scrolling_layer() != this) { | |
| 214 return; | |
| 215 } | |
| 216 | |
| 217 ApplyScroll(scroll_state); | |
| 218 } | |
| 219 | |
| 220 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { | |
| 221 DCHECK(scroll_state); | |
| 222 layer_tree_impl()->ApplyScroll(this, scroll_state); | |
| 223 } | |
| 224 | |
| 200 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { | 225 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { |
| 201 if (num_descendants_that_draw_content_ == num_descendants) | 226 if (num_descendants_that_draw_content_ == num_descendants) |
| 202 return; | 227 return; |
| 203 num_descendants_that_draw_content_ = num_descendants; | 228 num_descendants_that_draw_content_ = num_descendants; |
| 204 SetNeedsPushProperties(); | 229 SetNeedsPushProperties(); |
| 205 } | 230 } |
| 206 | 231 |
| 207 void LayerImpl::SetClipParent(LayerImpl* ancestor) { | 232 void LayerImpl::SetClipParent(LayerImpl* ancestor) { |
| 208 if (clip_parent_ == ancestor) | 233 if (clip_parent_ == ancestor) |
| 209 return; | 234 return; |
| (...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1849 } | 1874 } |
| 1850 | 1875 |
| 1851 // TODO(enne): the transform needs to come from property trees instead of | 1876 // TODO(enne): the transform needs to come from property trees instead of |
| 1852 // draw properties. | 1877 // draw properties. |
| 1853 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1878 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
| 1854 draw_properties().target_space_transform, default_scale); | 1879 draw_properties().target_space_transform, default_scale); |
| 1855 return std::max(transform_scales.x(), transform_scales.y()); | 1880 return std::max(transform_scales.x(), transform_scales.y()); |
| 1856 } | 1881 } |
| 1857 | 1882 |
| 1858 } // namespace cc | 1883 } // namespace cc |
| OLD | NEW |