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

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

Issue 2840433002: Move LayerImpl's bounds_delta to property trees (Closed)
Patch Set: Document ViewportBoundsDelta better Created 3 years, 8 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_impl.h ('k') | no next file » | 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_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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 scrollbar->SetScrollLayerLength(scroll_size.width()); 255 scrollbar->SetScrollLayerLength(scroll_size.width());
256 } else { 256 } else {
257 scrollbar_needs_animation |= y_offset_did_change |= 257 scrollbar_needs_animation |= y_offset_did_change |=
258 scrollbar->SetCurrentPos(current_offset.y()); 258 scrollbar->SetCurrentPos(current_offset.y());
259 clip_layer_size_did_change |= 259 clip_layer_size_did_change |=
260 scrollbar->SetClipLayerLength(clip_size.height()); 260 scrollbar->SetClipLayerLength(clip_size.height());
261 scroll_layer_size_did_change |= 261 scroll_layer_size_did_change |=
262 scrollbar->SetScrollLayerLength(scroll_size.height()); 262 scrollbar->SetScrollLayerLength(scroll_size.height());
263 } 263 }
264 scrollbar_needs_animation |= 264 scrollbar_needs_animation |=
265 scrollbar->SetVerticalAdjust(clip_layer->bounds_delta().y()); 265 scrollbar->SetVerticalAdjust(clip_layer->ViewportBoundsDelta().y());
266 } 266 }
267 267
268 scrollbar_needs_animation |= 268 scrollbar_needs_animation |=
269 (clip_layer_size_did_change || scroll_layer_size_did_change); 269 (clip_layer_size_did_change || scroll_layer_size_did_change);
270 270
271 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id)) 271 if (y_offset_did_change && IsViewportLayerId(scroll_layer_id))
272 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(), 272 TRACE_COUNTER_ID1("cc", "scroll_offset_y", scroll_layer->id(),
273 current_offset.y()); 273 current_offset.y());
274 274
275 if (scrollbar_needs_animation) { 275 if (scrollbar_needs_animation) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() { 379 std::unique_ptr<OwnedLayerImplList> LayerTreeImpl::DetachLayers() {
380 root_layer_for_testing_ = nullptr; 380 root_layer_for_testing_ = nullptr;
381 layer_list_.clear(); 381 layer_list_.clear();
382 render_surface_layer_list_.clear(); 382 render_surface_layer_list_.clear();
383 set_needs_update_draw_properties(); 383 set_needs_update_draw_properties();
384 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_); 384 std::unique_ptr<OwnedLayerImplList> ret = std::move(layers_);
385 layers_.reset(new OwnedLayerImplList); 385 layers_.reset(new OwnedLayerImplList);
386 return ret; 386 return ret;
387 } 387 }
388 388
389 static void UpdateClipTreeForBoundsDeltaOnLayer(LayerImpl* layer,
390 ClipTree* clip_tree) {
391 if (layer && layer->masks_to_bounds()) {
392 ClipNode* clip_node = clip_tree->Node(layer->clip_tree_index());
393 if (clip_node) {
394 DCHECK_EQ(layer->id(), clip_node->owning_layer_id);
395 gfx::SizeF bounds = gfx::SizeF(layer->bounds());
396 if (clip_node->clip.size() != bounds) {
397 clip_node->clip.set_size(bounds);
398 clip_tree->set_needs_update(true);
399 }
400 }
401 }
402 }
403
404 void LayerTreeImpl::SetPropertyTrees(PropertyTrees* property_trees) { 389 void LayerTreeImpl::SetPropertyTrees(PropertyTrees* property_trees) {
405 std::vector<std::unique_ptr<RenderSurfaceImpl>> old_render_surfaces; 390 std::vector<std::unique_ptr<RenderSurfaceImpl>> old_render_surfaces;
406 property_trees_.effect_tree.TakeRenderSurfaces(&old_render_surfaces); 391 property_trees_.effect_tree.TakeRenderSurfaces(&old_render_surfaces);
407 property_trees_ = *property_trees; 392 property_trees_ = *property_trees;
408 bool render_surfaces_changed = 393 bool render_surfaces_changed =
409 property_trees_.effect_tree.CreateOrReuseRenderSurfaces( 394 property_trees_.effect_tree.CreateOrReuseRenderSurfaces(
410 &old_render_surfaces, this); 395 &old_render_surfaces, this);
411 if (render_surfaces_changed) 396 if (render_surfaces_changed)
412 set_needs_update_draw_properties(); 397 set_needs_update_draw_properties();
413 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree); 398 property_trees->effect_tree.PushCopyRequestsTo(&property_trees_.effect_tree);
414 property_trees_.is_main_thread = false; 399 property_trees_.is_main_thread = false;
415 property_trees_.is_active = IsActiveTree(); 400 property_trees_.is_active = IsActiveTree();
416 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); 401 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false);
417 // The value of some effect node properties (like is_drawn) depends on 402 // The value of some effect node properties (like is_drawn) depends on
418 // whether we are on the active tree or not. So, we need to update the 403 // whether we are on the active tree or not. So, we need to update the
419 // effect tree. 404 // effect tree.
420 if (IsActiveTree()) 405 if (IsActiveTree())
421 property_trees_.effect_tree.set_needs_update(true); 406 property_trees_.effect_tree.set_needs_update(true);
422 } 407 }
423 408
424 void LayerTreeImpl::UpdatePropertyTreesForBoundsDelta() {
425 DCHECK(IsActiveTree());
426 LayerImpl* inner_container = InnerViewportContainerLayer();
427 LayerImpl* outer_container = OuterViewportContainerLayer();
428 LayerImpl* inner_scroll = InnerViewportScrollLayer();
429
430 UpdateClipTreeForBoundsDeltaOnLayer(inner_container,
431 &property_trees_.clip_tree);
432 UpdateClipTreeForBoundsDeltaOnLayer(InnerViewportScrollLayer(),
433 &property_trees_.clip_tree);
434 UpdateClipTreeForBoundsDeltaOnLayer(outer_container,
435 &property_trees_.clip_tree);
436
437 if (inner_container)
438 property_trees_.SetInnerViewportContainerBoundsDelta(
439 inner_container->bounds_delta());
440 if (outer_container)
441 property_trees_.SetOuterViewportContainerBoundsDelta(
442 outer_container->bounds_delta());
443 if (inner_scroll)
444 property_trees_.SetInnerViewportScrollBoundsDelta(
445 inner_scroll->bounds_delta());
446 }
447
448 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) { 409 void LayerTreeImpl::PushPropertiesTo(LayerTreeImpl* target_tree) {
449 // The request queue should have been processed and does not require a push. 410 // The request queue should have been processed and does not require a push.
450 DCHECK_EQ(ui_resource_request_queue_.size(), 0u); 411 DCHECK_EQ(ui_resource_request_queue_.size(), 0u);
451 412
452 // To maintain the current scrolling node we need to use element ids which 413 // To maintain the current scrolling node we need to use element ids which
453 // are stable across the property tree update in SetPropertyTrees. 414 // are stable across the property tree update in SetPropertyTrees.
454 ElementId scrolling_element_id; 415 ElementId scrolling_element_id;
455 if (ScrollNode* scrolling_node = target_tree->CurrentlyScrollingNode()) 416 if (ScrollNode* scrolling_node = target_tree->CurrentlyScrollingNode())
456 scrolling_element_id = scrolling_node->element_id; 417 scrolling_element_id = scrolling_node->element_id;
457 418
458 target_tree->SetPropertyTrees(&property_trees_); 419 target_tree->SetPropertyTrees(&property_trees_);
459 420
460 ScrollNode* scrolling_node = nullptr; 421 ScrollNode* scrolling_node = nullptr;
461 if (scrolling_element_id) { 422 if (scrolling_element_id) {
462 auto& scroll_tree = target_tree->property_trees()->scroll_tree; 423 auto& scroll_tree = target_tree->property_trees()->scroll_tree;
463 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id); 424 scrolling_node = scroll_tree.FindNodeFromElementId(scrolling_element_id);
464 } 425 }
465 target_tree->SetCurrentlyScrollingNode(scrolling_node); 426 target_tree->SetCurrentlyScrollingNode(scrolling_node);
466 427
467 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree( 428 target_tree->property_trees()->scroll_tree.PushScrollUpdatesFromPendingTree(
468 &property_trees_, target_tree); 429 &property_trees_, target_tree);
469 430
470 // This needs to be called early so that we don't clamp with incorrect max
471 // offsets when UpdateViewportContainerSizes is called from e.g.
472 // PushBrowserControls
473 target_tree->UpdatePropertyTreesForBoundsDelta();
474
475 if (next_activation_forces_redraw_) { 431 if (next_activation_forces_redraw_) {
476 target_tree->ForceRedrawNextActivation(); 432 target_tree->ForceRedrawNextActivation();
477 next_activation_forces_redraw_ = false; 433 next_activation_forces_redraw_ = false;
478 } 434 }
479 435
480 target_tree->PassSwapPromises(std::move(swap_promise_list_)); 436 target_tree->PassSwapPromises(std::move(swap_promise_list_));
481 swap_promise_list_.clear(); 437 swap_promise_list_.clear();
482 438
483 target_tree->set_browser_controls_shrink_blink_size( 439 target_tree->set_browser_controls_shrink_blink_size(
484 browser_controls_shrink_blink_size_); 440 browser_controls_shrink_blink_size_);
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2134
2179 void LayerTreeImpl::ResetAllChangeTracking() { 2135 void LayerTreeImpl::ResetAllChangeTracking() {
2180 layers_that_should_push_properties_.clear(); 2136 layers_that_should_push_properties_.clear();
2181 // Iterate over all layers, including masks. 2137 // Iterate over all layers, including masks.
2182 for (auto& layer : *layers_) 2138 for (auto& layer : *layers_)
2183 layer->ResetChangeTracking(); 2139 layer->ResetChangeTracking();
2184 property_trees_.ResetAllChangeTracking(); 2140 property_trees_.ResetAllChangeTracking();
2185 } 2141 }
2186 2142
2187 } // namespace cc 2143 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698