OLD | NEW |
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_impl.h" | 5 #include "cc/trees/layer_tree_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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); | 237 gfx::ScrollOffset current_offset = scroll_layer->CurrentScrollOffset(); |
238 if (IsViewportLayerId(scroll_layer_id)) { | 238 if (IsViewportLayerId(scroll_layer_id)) { |
239 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); | 239 current_offset += InnerViewportScrollLayer()->CurrentScrollOffset(); |
240 if (OuterViewportContainerLayer()) | 240 if (OuterViewportContainerLayer()) |
241 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); | 241 clip_size.SetToMin(OuterViewportContainerLayer()->BoundsForScrolling()); |
242 clip_size.Scale(1 / current_page_scale_factor()); | 242 clip_size.Scale(1 / current_page_scale_factor()); |
243 } | 243 } |
244 | 244 |
245 bool scrollbar_needs_animation = false; | 245 bool scrollbar_needs_animation = false; |
246 bool clip_layer_size_did_change = false; | |
247 bool scroll_layer_size_did_change = false; | 246 bool scroll_layer_size_did_change = false; |
248 bool y_offset_did_change = false; | 247 bool y_offset_did_change = false; |
249 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { | 248 for (ScrollbarLayerImplBase* scrollbar : ScrollbarsFor(scroll_layer_id)) { |
250 if (scrollbar->orientation() == HORIZONTAL) { | 249 if (scrollbar->orientation() == HORIZONTAL) { |
251 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); | 250 scrollbar_needs_animation |= scrollbar->SetCurrentPos(current_offset.x()); |
252 clip_layer_size_did_change |= | 251 scrollbar_needs_animation |= |
253 scrollbar->SetClipLayerLength(clip_size.width()); | 252 scrollbar->SetClipLayerLength(clip_size.width()); |
254 scroll_layer_size_did_change |= | 253 scrollbar_needs_animation |= scroll_layer_size_did_change |= |
255 scrollbar->SetScrollLayerLength(scroll_size.width()); | 254 scrollbar->SetScrollLayerLength(scroll_size.width()); |
256 } else { | 255 } else { |
257 scrollbar_needs_animation |= y_offset_did_change |= | 256 scrollbar_needs_animation |= y_offset_did_change |= |
258 scrollbar->SetCurrentPos(current_offset.y()); | 257 scrollbar->SetCurrentPos(current_offset.y()); |
259 clip_layer_size_did_change |= | 258 scrollbar_needs_animation |= |
260 scrollbar->SetClipLayerLength(clip_size.height()); | 259 scrollbar->SetClipLayerLength(clip_size.height()); |
261 scroll_layer_size_did_change |= | 260 scrollbar_needs_animation |= scroll_layer_size_did_change |= |
262 scrollbar->SetScrollLayerLength(scroll_size.height()); | 261 scrollbar->SetScrollLayerLength(scroll_size.height()); |
263 } | 262 } |
264 scrollbar_needs_animation |= | 263 scrollbar_needs_animation |= |
265 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); | 264 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); |
266 } | 265 } |
267 | 266 |
268 scrollbar_needs_animation |= | |
269 (clip_layer_size_did_change || scroll_layer_size_did_change); | |
270 | |
271 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) | 267 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) |
272 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), | 268 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), |
273 current_offset.y()); | 269 current_offset.y()); |
274 | 270 |
275 if (scrollbar_needs_animation) { | 271 if (scrollbar_needs_animation) { |
276 ScrollbarAnimationController* controller = | 272 ScrollbarAnimationController* controller = |
277 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 273 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
278 scroll_layer_id); | 274 scroll_layer_id); |
279 if (!controller) | 275 if (controller) |
280 return; | 276 controller->DidScrollUpdate(scroll_layer_size_did_change); |
281 | |
282 if (clip_layer_size_did_change || scroll_layer_size_did_change) { | |
283 controller->DidResize(); | |
284 } else { | |
285 controller->DidScrollUpdate(); | |
286 } | |
287 } | 277 } |
288 } | 278 } |
289 | 279 |
290 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { | 280 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { |
291 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); | 281 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); |
292 } | 282 } |
293 | 283 |
294 bool LayerTreeImpl::LayerListIsEmpty() const { | 284 bool LayerTreeImpl::LayerListIsEmpty() const { |
295 return layer_list_.empty(); | 285 return layer_list_.empty(); |
296 } | 286 } |
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 | 2155 |
2166 void LayerTreeImpl::ResetAllChangeTracking() { | 2156 void LayerTreeImpl::ResetAllChangeTracking() { |
2167 layers_that_should_push_properties_.clear(); | 2157 layers_that_should_push_properties_.clear(); |
2168 // Iterate over all layers, including masks. | 2158 // Iterate over all layers, including masks. |
2169 for (auto& layer : *layers_) | 2159 for (auto& layer : *layers_) |
2170 layer->ResetChangeTracking(); | 2160 layer->ResetChangeTracking(); |
2171 property_trees_.ResetAllChangeTracking(); | 2161 property_trees_.ResetAllChangeTracking(); |
2172 } | 2162 } |
2173 | 2163 |
2174 } // namespace cc | 2164 } // namespace cc |
OLD | NEW |