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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 SetNeedsPushProperties(); | 190 SetNeedsPushProperties(); |
190 } | 191 } |
191 | 192 |
192 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 193 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
193 if (scroll_children_.get() == children) | 194 if (scroll_children_.get() == children) |
194 return; | 195 return; |
195 scroll_children_.reset(children); | 196 scroll_children_.reset(children); |
196 SetNeedsPushProperties(); | 197 SetNeedsPushProperties(); |
197 } | 198 } |
198 | 199 |
| 200 void LayerImpl::DistributeScroll(ScrollState* scroll_state) { |
| 201 DCHECK(scroll_state); |
| 202 if (scroll_state->FullyConsumed()) |
| 203 return; |
| 204 |
| 205 scroll_state->DistributeToScrollChainDescendant(); |
| 206 |
| 207 // If the scroll doesn't propagate, and we're currently scrolling |
| 208 // a layer other than this one, prevent the scroll from |
| 209 // propagating to this layer. |
| 210 if (!scroll_state->should_propagate() && |
| 211 scroll_state->delta_consumed_for_scroll_sequence() && |
| 212 scroll_state->current_native_scrolling_layer() != this) { |
| 213 return; |
| 214 } |
| 215 |
| 216 ApplyScroll(scroll_state); |
| 217 } |
| 218 |
| 219 void LayerImpl::ApplyScroll(ScrollState* scroll_state) { |
| 220 DCHECK(scroll_state); |
| 221 layer_tree_impl()->ApplyScroll(this, scroll_state); |
| 222 } |
| 223 |
199 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { | 224 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { |
200 if (num_descendants_that_draw_content_ == num_descendants) | 225 if (num_descendants_that_draw_content_ == num_descendants) |
201 return; | 226 return; |
202 num_descendants_that_draw_content_ = num_descendants; | 227 num_descendants_that_draw_content_ = num_descendants; |
203 SetNeedsPushProperties(); | 228 SetNeedsPushProperties(); |
204 } | 229 } |
205 | 230 |
206 void LayerImpl::SetClipParent(LayerImpl* ancestor) { | 231 void LayerImpl::SetClipParent(LayerImpl* ancestor) { |
207 if (clip_parent_ == ancestor) | 232 if (clip_parent_ == ancestor) |
208 return; | 233 return; |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 } | 1833 } |
1809 | 1834 |
1810 // TODO(enne): the transform needs to come from property trees instead of | 1835 // TODO(enne): the transform needs to come from property trees instead of |
1811 // draw properties. | 1836 // draw properties. |
1812 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( | 1837 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( |
1813 draw_properties().target_space_transform, default_scale); | 1838 draw_properties().target_space_transform, default_scale); |
1814 return std::max(transform_scales.x(), transform_scales.y()); | 1839 return std::max(transform_scales.x(), transform_scales.y()); |
1815 } | 1840 } |
1816 | 1841 |
1817 } // namespace cc | 1842 } // namespace cc |
OLD | NEW |