OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "cc/base/math_util.h" | 12 #include "cc/base/math_util.h" |
13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
15 #include "cc/output/copy_output_request.h" | 15 #include "cc/output/copy_output_request.h" |
| 16 #include "cc/trees/clip_node.h" |
16 #include "cc/trees/draw_property_utils.h" | 17 #include "cc/trees/draw_property_utils.h" |
| 18 #include "cc/trees/effect_node.h" |
17 #include "cc/trees/layer_tree_host.h" | 19 #include "cc/trees/layer_tree_host.h" |
18 #include "cc/trees/layer_tree_impl.h" | 20 #include "cc/trees/layer_tree_impl.h" |
| 21 #include "cc/trees/scroll_node.h" |
| 22 #include "cc/trees/transform_node.h" |
19 #include "ui/gfx/geometry/point_f.h" | 23 #include "ui/gfx/geometry/point_f.h" |
20 #include "ui/gfx/geometry/vector2d_conversions.h" | 24 #include "ui/gfx/geometry/vector2d_conversions.h" |
21 | 25 |
22 namespace cc { | 26 namespace cc { |
23 | 27 |
24 class LayerTreeHost; | 28 class LayerTreeHost; |
25 | 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 static const int kInvalidPropertyTreeNodeId = -1; | 32 static const int kInvalidPropertyTreeNodeId = -1; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 LayerType* layer, | 277 LayerType* layer, |
274 bool created_render_surface, | 278 bool created_render_surface, |
275 bool created_transform_node, | 279 bool created_transform_node, |
276 DataForRecursion<LayerType>* data_for_children) { | 280 DataForRecursion<LayerType>* data_for_children) { |
277 ClipNode* parent = GetClipParent(data_from_ancestor, layer); | 281 ClipNode* parent = GetClipParent(data_from_ancestor, layer); |
278 int parent_id = parent->id; | 282 int parent_id = parent->id; |
279 | 283 |
280 bool is_root = !Parent(layer); | 284 bool is_root = !Parent(layer); |
281 | 285 |
282 // Whether we have an ancestor clip that we might need to apply. | 286 // Whether we have an ancestor clip that we might need to apply. |
283 bool ancestor_clips_subtree = is_root || parent->data.layers_are_clipped; | 287 bool ancestor_clips_subtree = is_root || parent->layers_are_clipped; |
284 | 288 |
285 bool layers_are_clipped = false; | 289 bool layers_are_clipped = false; |
286 bool has_unclipped_surface = false; | 290 bool has_unclipped_surface = false; |
287 | 291 |
288 if (created_render_surface) { | 292 if (created_render_surface) { |
289 // Clips can usually be applied to a surface's descendants simply by | 293 // Clips can usually be applied to a surface's descendants simply by |
290 // clipping the surface (or applied implicitly by the surface's bounds). | 294 // clipping the surface (or applied implicitly by the surface's bounds). |
291 // However, if the surface has unclipped descendants (layers that aren't | 295 // However, if the surface has unclipped descendants (layers that aren't |
292 // affected by the ancestor clip), we cannot clip the surface itself, and | 296 // affected by the ancestor clip), we cannot clip the surface itself, and |
293 // must instead apply clips to the clipped descendants. | 297 // must instead apply clips to the clipped descendants. |
294 if (ancestor_clips_subtree && NumUnclippedDescendants(layer) > 0) { | 298 if (ancestor_clips_subtree && NumUnclippedDescendants(layer) > 0) { |
295 layers_are_clipped = true; | 299 layers_are_clipped = true; |
296 } else if (!ancestor_clips_subtree) { | 300 } else if (!ancestor_clips_subtree) { |
297 // When there are no ancestor clips that need to be applied to a render | 301 // When there are no ancestor clips that need to be applied to a render |
298 // surface, we reset clipping state. The surface might contribute a clip | 302 // surface, we reset clipping state. The surface might contribute a clip |
299 // of its own, but clips from ancestor nodes don't need to be considered | 303 // of its own, but clips from ancestor nodes don't need to be considered |
300 // when computing clip rects or visibility. | 304 // when computing clip rects or visibility. |
301 has_unclipped_surface = true; | 305 has_unclipped_surface = true; |
302 DCHECK(!parent->data.applies_local_clip); | 306 DCHECK(!parent->applies_local_clip); |
303 } | 307 } |
304 // A surface with unclipped descendants cannot be clipped by its ancestor | 308 // A surface with unclipped descendants cannot be clipped by its ancestor |
305 // clip at draw time since the unclipped descendants aren't affected by the | 309 // clip at draw time since the unclipped descendants aren't affected by the |
306 // ancestor clip. | 310 // ancestor clip. |
307 data_for_children->target_is_clipped = | 311 data_for_children->target_is_clipped = |
308 ancestor_clips_subtree && !NumUnclippedDescendants(layer); | 312 ancestor_clips_subtree && !NumUnclippedDescendants(layer); |
309 } else { | 313 } else { |
310 // Without a new render surface, layer clipping state from ancestors needs | 314 // Without a new render surface, layer clipping state from ancestors needs |
311 // to continue to propagate. | 315 // to continue to propagate. |
312 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; | 316 data_for_children->target_is_clipped = data_from_ancestor.target_is_clipped; |
313 layers_are_clipped = ancestor_clips_subtree; | 317 layers_are_clipped = ancestor_clips_subtree; |
314 } | 318 } |
315 | 319 |
316 bool layer_clips_subtree = LayerClipsSubtree(layer); | 320 bool layer_clips_subtree = LayerClipsSubtree(layer); |
317 if (layer_clips_subtree) | 321 if (layer_clips_subtree) |
318 layers_are_clipped = true; | 322 layers_are_clipped = true; |
319 | 323 |
320 // Without surfaces, all non-viewport clips have to be applied using layer | 324 // Without surfaces, all non-viewport clips have to be applied using layer |
321 // clipping. | 325 // clipping. |
322 bool layers_are_clipped_when_surfaces_disabled = | 326 bool layers_are_clipped_when_surfaces_disabled = |
323 layer_clips_subtree || | 327 layer_clips_subtree || parent->layers_are_clipped_when_surfaces_disabled; |
324 parent->data.layers_are_clipped_when_surfaces_disabled; | |
325 | 328 |
326 // Render surface's clip is needed during hit testing. So, we need to create | 329 // Render surface's clip is needed during hit testing. So, we need to create |
327 // a clip node for every render surface. | 330 // a clip node for every render surface. |
328 bool requires_node = layer_clips_subtree || created_render_surface; | 331 bool requires_node = layer_clips_subtree || created_render_surface; |
329 | 332 |
330 if (!requires_node) { | 333 if (!requires_node) { |
331 data_for_children->clip_tree_parent = parent_id; | 334 data_for_children->clip_tree_parent = parent_id; |
332 DCHECK_EQ(layers_are_clipped, parent->data.layers_are_clipped); | 335 DCHECK_EQ(layers_are_clipped, parent->layers_are_clipped); |
333 DCHECK_EQ(layers_are_clipped_when_surfaces_disabled, | 336 DCHECK_EQ(layers_are_clipped_when_surfaces_disabled, |
334 parent->data.layers_are_clipped_when_surfaces_disabled); | 337 parent->layers_are_clipped_when_surfaces_disabled); |
335 } else { | 338 } else { |
336 LayerType* transform_parent = data_for_children->transform_tree_parent; | 339 LayerType* transform_parent = data_for_children->transform_tree_parent; |
337 if (PositionConstraint(layer).is_fixed_position() && | 340 if (PositionConstraint(layer).is_fixed_position() && |
338 !created_transform_node) { | 341 !created_transform_node) { |
339 transform_parent = data_for_children->transform_fixed_parent; | 342 transform_parent = data_for_children->transform_fixed_parent; |
340 } | 343 } |
341 ClipNode node; | 344 ClipNode node; |
342 node.data.clip = | 345 node.clip = gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), |
343 gfx::RectF(gfx::PointF() + layer->offset_to_transform_parent(), | 346 gfx::SizeF(layer->bounds())); |
344 gfx::SizeF(layer->bounds())); | 347 node.transform_id = transform_parent->transform_tree_index(); |
345 node.data.transform_id = transform_parent->transform_tree_index(); | 348 node.target_id = data_for_children->property_trees->effect_tree |
346 node.data.target_id = data_for_children->property_trees->effect_tree | 349 .Node(data_for_children->render_target) |
347 .Node(data_for_children->render_target) | 350 ->transform_id; |
348 ->data.transform_id; | |
349 node.owner_id = layer->id(); | 351 node.owner_id = layer->id(); |
350 | 352 |
351 if (ancestor_clips_subtree || layer_clips_subtree) { | 353 if (ancestor_clips_subtree || layer_clips_subtree) { |
352 // Surfaces reset the rect used for layer clipping. At other nodes, layer | 354 // Surfaces reset the rect used for layer clipping. At other nodes, layer |
353 // clipping state from ancestors must continue to get propagated. | 355 // clipping state from ancestors must continue to get propagated. |
354 node.data.layer_clipping_uses_only_local_clip = | 356 node.layer_clipping_uses_only_local_clip = |
355 (created_render_surface && NumUnclippedDescendants(layer) == 0) || | 357 (created_render_surface && NumUnclippedDescendants(layer) == 0) || |
356 !ancestor_clips_subtree; | 358 !ancestor_clips_subtree; |
357 } else { | 359 } else { |
358 // Otherwise, we're either unclipped, or exist only in order to apply our | 360 // Otherwise, we're either unclipped, or exist only in order to apply our |
359 // parent's clips in our space. | 361 // parent's clips in our space. |
360 node.data.layer_clipping_uses_only_local_clip = false; | 362 node.layer_clipping_uses_only_local_clip = false; |
361 } | 363 } |
362 | 364 |
363 node.data.applies_local_clip = layer_clips_subtree; | 365 node.applies_local_clip = layer_clips_subtree; |
364 node.data.resets_clip = has_unclipped_surface; | 366 node.resets_clip = has_unclipped_surface; |
365 node.data.target_is_clipped = data_for_children->target_is_clipped; | 367 node.target_is_clipped = data_for_children->target_is_clipped; |
366 node.data.layers_are_clipped = layers_are_clipped; | 368 node.layers_are_clipped = layers_are_clipped; |
367 node.data.layers_are_clipped_when_surfaces_disabled = | 369 node.layers_are_clipped_when_surfaces_disabled = |
368 layers_are_clipped_when_surfaces_disabled; | 370 layers_are_clipped_when_surfaces_disabled; |
369 | 371 |
370 data_for_children->clip_tree_parent = | 372 data_for_children->clip_tree_parent = |
371 data_for_children->property_trees->clip_tree.Insert(node, parent_id); | 373 data_for_children->property_trees->clip_tree.Insert(node, parent_id); |
372 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = | 374 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = |
373 data_for_children->clip_tree_parent; | 375 data_for_children->clip_tree_parent; |
374 } | 376 } |
375 | 377 |
376 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 378 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
377 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the | 379 // TODO(awoloszyn): Right now when we hit a node with a replica, we reset the |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 523 |
522 data_for_children->property_trees->transform_tree.Insert(TransformNode(), | 524 data_for_children->property_trees->transform_tree.Insert(TransformNode(), |
523 parent_index); | 525 parent_index); |
524 | 526 |
525 TransformNode* node = | 527 TransformNode* node = |
526 data_for_children->property_trees->transform_tree.back(); | 528 data_for_children->property_trees->transform_tree.back(); |
527 layer->SetTransformTreeIndex(node->id); | 529 layer->SetTransformTreeIndex(node->id); |
528 data_for_children->property_trees->transform_id_to_index_map[layer->id()] = | 530 data_for_children->property_trees->transform_id_to_index_map[layer->id()] = |
529 node->id; | 531 node->id; |
530 | 532 |
531 node->data.scrolls = is_scrollable; | 533 node->scrolls = is_scrollable; |
532 node->data.flattens_inherited_transform = data_for_children->should_flatten; | 534 node->flattens_inherited_transform = data_for_children->should_flatten; |
533 | 535 |
534 node->data.sorting_context_id = layer->sorting_context_id(); | 536 node->sorting_context_id = layer->sorting_context_id(); |
535 | 537 |
536 if (layer == data_from_ancestor.page_scale_layer) | 538 if (layer == data_from_ancestor.page_scale_layer) |
537 data_for_children->in_subtree_of_page_scale_layer = true; | 539 data_for_children->in_subtree_of_page_scale_layer = true; |
538 node->data.in_subtree_of_page_scale_layer = | 540 node->in_subtree_of_page_scale_layer = |
539 data_for_children->in_subtree_of_page_scale_layer; | 541 data_for_children->in_subtree_of_page_scale_layer; |
540 | 542 |
541 // Surfaces inherently flatten transforms. | 543 // Surfaces inherently flatten transforms. |
542 data_for_children->should_flatten = | 544 data_for_children->should_flatten = |
543 ShouldFlattenTransform(layer) || has_surface; | 545 ShouldFlattenTransform(layer) || has_surface; |
544 DCHECK_GT(data_from_ancestor.property_trees->effect_tree.size(), 0u); | 546 DCHECK_GT(data_from_ancestor.property_trees->effect_tree.size(), 0u); |
545 | 547 |
546 data_for_children->property_trees->transform_tree.SetTargetId( | 548 data_for_children->property_trees->transform_tree.SetTargetId( |
547 node->id, data_for_children->property_trees->effect_tree | 549 node->id, data_for_children->property_trees->effect_tree |
548 .Node(data_from_ancestor.render_target) | 550 .Node(data_from_ancestor.render_target) |
549 ->data.transform_id); | 551 ->transform_id); |
550 data_for_children->property_trees->transform_tree.SetContentTargetId( | 552 data_for_children->property_trees->transform_tree.SetContentTargetId( |
551 node->id, data_for_children->property_trees->effect_tree | 553 node->id, data_for_children->property_trees->effect_tree |
552 .Node(data_for_children->render_target) | 554 .Node(data_for_children->render_target) |
553 ->data.transform_id); | 555 ->transform_id); |
554 DCHECK_NE( | 556 DCHECK_NE( |
555 data_for_children->property_trees->transform_tree.TargetId(node->id), | 557 data_for_children->property_trees->transform_tree.TargetId(node->id), |
556 kInvalidPropertyTreeNodeId); | 558 kInvalidPropertyTreeNodeId); |
557 | 559 |
558 node->data.has_potential_animation = has_potentially_animated_transform; | 560 node->has_potential_animation = has_potentially_animated_transform; |
559 node->data.is_currently_animating = layer->TransformIsAnimating(); | 561 node->is_currently_animating = layer->TransformIsAnimating(); |
560 if (has_potentially_animated_transform) { | 562 if (has_potentially_animated_transform) { |
561 node->data.has_only_translation_animations = | 563 node->has_only_translation_animations = |
562 layer->HasOnlyTranslationTransforms(); | 564 layer->HasOnlyTranslationTransforms(); |
563 } | 565 } |
564 | 566 |
565 float post_local_scale_factor = 1.0f; | 567 float post_local_scale_factor = 1.0f; |
566 if (is_root) | 568 if (is_root) |
567 post_local_scale_factor = | 569 post_local_scale_factor = |
568 data_for_children->property_trees->transform_tree.device_scale_factor(); | 570 data_for_children->property_trees->transform_tree.device_scale_factor(); |
569 | 571 |
570 if (is_page_scale_layer) { | 572 if (is_page_scale_layer) { |
571 post_local_scale_factor *= data_from_ancestor.page_scale_factor; | 573 post_local_scale_factor *= data_from_ancestor.page_scale_factor; |
572 data_for_children->property_trees->transform_tree.set_page_scale_factor( | 574 data_for_children->property_trees->transform_tree.set_page_scale_factor( |
573 data_from_ancestor.page_scale_factor); | 575 data_from_ancestor.page_scale_factor); |
574 } | 576 } |
575 | 577 |
576 if (has_surface && !is_root) | 578 if (has_surface && !is_root) |
577 node->data.needs_sublayer_scale = true; | 579 node->needs_sublayer_scale = true; |
578 | 580 |
579 node->data.source_node_id = source_index; | 581 node->source_node_id = source_index; |
580 node->data.post_local_scale_factor = post_local_scale_factor; | 582 node->post_local_scale_factor = post_local_scale_factor; |
581 if (is_root) { | 583 if (is_root) { |
582 data_for_children->property_trees->transform_tree.SetDeviceTransform( | 584 data_for_children->property_trees->transform_tree.SetDeviceTransform( |
583 *data_from_ancestor.device_transform, layer->position()); | 585 *data_from_ancestor.device_transform, layer->position()); |
584 data_for_children->property_trees->transform_tree | 586 data_for_children->property_trees->transform_tree |
585 .SetDeviceTransformScaleFactor(*data_from_ancestor.device_transform); | 587 .SetDeviceTransformScaleFactor(*data_from_ancestor.device_transform); |
586 } else { | 588 } else { |
587 node->data.source_offset = source_offset; | 589 node->source_offset = source_offset; |
588 node->data.update_post_local_transform(layer->position(), | 590 node->update_post_local_transform(layer->position(), |
589 TransformOrigin(layer)); | 591 TransformOrigin(layer)); |
590 } | 592 } |
591 | 593 |
592 if (is_overscroll_elasticity_layer) { | 594 if (is_overscroll_elasticity_layer) { |
593 DCHECK(!is_scrollable); | 595 DCHECK(!is_scrollable); |
594 node->data.scroll_offset = | 596 node->scroll_offset = |
595 gfx::ScrollOffset(data_from_ancestor.elastic_overscroll); | 597 gfx::ScrollOffset(data_from_ancestor.elastic_overscroll); |
596 } else if (!ScrollParent(layer)) { | 598 } else if (!ScrollParent(layer)) { |
597 node->data.scroll_offset = layer->CurrentScrollOffset(); | 599 node->scroll_offset = layer->CurrentScrollOffset(); |
598 } | 600 } |
599 | 601 |
600 if (is_fixed) { | 602 if (is_fixed) { |
601 if (data_from_ancestor.affected_by_inner_viewport_bounds_delta) { | 603 if (data_from_ancestor.affected_by_inner_viewport_bounds_delta) { |
602 node->data.affected_by_inner_viewport_bounds_delta_x = | 604 node->affected_by_inner_viewport_bounds_delta_x = |
603 PositionConstraint(layer).is_fixed_to_right_edge(); | 605 PositionConstraint(layer).is_fixed_to_right_edge(); |
604 node->data.affected_by_inner_viewport_bounds_delta_y = | 606 node->affected_by_inner_viewport_bounds_delta_y = |
605 PositionConstraint(layer).is_fixed_to_bottom_edge(); | 607 PositionConstraint(layer).is_fixed_to_bottom_edge(); |
606 if (node->data.affected_by_inner_viewport_bounds_delta_x || | 608 if (node->affected_by_inner_viewport_bounds_delta_x || |
607 node->data.affected_by_inner_viewport_bounds_delta_y) { | 609 node->affected_by_inner_viewport_bounds_delta_y) { |
608 data_for_children->property_trees->transform_tree | 610 data_for_children->property_trees->transform_tree |
609 .AddNodeAffectedByInnerViewportBoundsDelta(node->id); | 611 .AddNodeAffectedByInnerViewportBoundsDelta(node->id); |
610 } | 612 } |
611 } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) { | 613 } else if (data_from_ancestor.affected_by_outer_viewport_bounds_delta) { |
612 node->data.affected_by_outer_viewport_bounds_delta_x = | 614 node->affected_by_outer_viewport_bounds_delta_x = |
613 PositionConstraint(layer).is_fixed_to_right_edge(); | 615 PositionConstraint(layer).is_fixed_to_right_edge(); |
614 node->data.affected_by_outer_viewport_bounds_delta_y = | 616 node->affected_by_outer_viewport_bounds_delta_y = |
615 PositionConstraint(layer).is_fixed_to_bottom_edge(); | 617 PositionConstraint(layer).is_fixed_to_bottom_edge(); |
616 if (node->data.affected_by_outer_viewport_bounds_delta_x || | 618 if (node->affected_by_outer_viewport_bounds_delta_x || |
617 node->data.affected_by_outer_viewport_bounds_delta_y) { | 619 node->affected_by_outer_viewport_bounds_delta_y) { |
618 data_for_children->property_trees->transform_tree | 620 data_for_children->property_trees->transform_tree |
619 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); | 621 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); |
620 } | 622 } |
621 } | 623 } |
622 } | 624 } |
623 | 625 |
624 node->data.local = layer->transform(); | 626 node->local = layer->transform(); |
625 node->data.update_pre_local_transform(TransformOrigin(layer)); | 627 node->update_pre_local_transform(TransformOrigin(layer)); |
626 | 628 |
627 node->data.needs_local_transform_update = true; | 629 node->needs_local_transform_update = true; |
628 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); | 630 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); |
629 | 631 |
630 layer->set_offset_to_transform_parent(gfx::Vector2dF()); | 632 layer->set_offset_to_transform_parent(gfx::Vector2dF()); |
631 | 633 |
632 // Flattening (if needed) will be handled by |node|. | 634 // Flattening (if needed) will be handled by |node|. |
633 layer->set_should_flatten_transform_from_property_tree(false); | 635 layer->set_should_flatten_transform_from_property_tree(false); |
634 | 636 |
635 data_for_children->scroll_snap += node->data.scroll_snap; | 637 data_for_children->scroll_snap += node->scroll_snap; |
636 | 638 |
637 node->owner_id = layer->id(); | 639 node->owner_id = layer->id(); |
638 | 640 |
639 return true; | 641 return true; |
640 } | 642 } |
641 | 643 |
642 static inline bool HasPotentialOpacityAnimation(Layer* layer) { | 644 static inline bool HasPotentialOpacityAnimation(Layer* layer) { |
643 return layer->HasPotentiallyRunningOpacityAnimation() || | 645 return layer->HasPotentiallyRunningOpacityAnimation() || |
644 layer->OpacityCanAnimateOnImplThread(); | 646 layer->OpacityCanAnimateOnImplThread(); |
645 } | 647 } |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 return false; | 888 return false; |
887 } | 889 } |
888 | 890 |
889 EffectNode node; | 891 EffectNode node; |
890 node.owner_id = layer->id(); | 892 node.owner_id = layer->id(); |
891 if (AlwaysUseActiveTreeOpacity(layer)) { | 893 if (AlwaysUseActiveTreeOpacity(layer)) { |
892 data_for_children->property_trees->always_use_active_tree_opacity_effect_ids | 894 data_for_children->property_trees->always_use_active_tree_opacity_effect_ids |
893 .push_back(node.owner_id); | 895 .push_back(node.owner_id); |
894 } | 896 } |
895 | 897 |
896 node.data.opacity = Opacity(layer); | 898 node.opacity = Opacity(layer); |
897 node.data.has_render_surface = should_create_render_surface; | 899 node.has_render_surface = should_create_render_surface; |
898 node.data.has_copy_request = HasCopyRequest(layer); | 900 node.has_copy_request = HasCopyRequest(layer); |
899 node.data.background_filters = BackgroundFilters(layer); | 901 node.background_filters = BackgroundFilters(layer); |
900 node.data.has_potential_opacity_animation = has_potential_opacity_animation; | 902 node.has_potential_opacity_animation = has_potential_opacity_animation; |
901 node.data.double_sided = DoubleSided(layer); | 903 node.double_sided = DoubleSided(layer); |
902 node.data.subtree_hidden = HideLayerAndSubtree(layer); | 904 node.subtree_hidden = HideLayerAndSubtree(layer); |
903 node.data.is_currently_animating_opacity = layer->OpacityIsAnimating(); | 905 node.is_currently_animating_opacity = layer->OpacityIsAnimating(); |
904 | 906 |
905 EffectTree& effect_tree = data_for_children->property_trees->effect_tree; | 907 EffectTree& effect_tree = data_for_children->property_trees->effect_tree; |
906 if (MaskLayer(layer)) { | 908 if (MaskLayer(layer)) { |
907 node.data.mask_layer_id = MaskLayer(layer)->id(); | 909 node.mask_layer_id = MaskLayer(layer)->id(); |
908 effect_tree.AddMaskOrReplicaLayerId(node.data.mask_layer_id); | 910 effect_tree.AddMaskOrReplicaLayerId(node.mask_layer_id); |
909 } | 911 } |
910 if (ReplicaLayer(layer)) { | 912 if (ReplicaLayer(layer)) { |
911 node.data.replica_layer_id = ReplicaLayer(layer)->id(); | 913 node.replica_layer_id = ReplicaLayer(layer)->id(); |
912 effect_tree.AddMaskOrReplicaLayerId(node.data.replica_layer_id); | 914 effect_tree.AddMaskOrReplicaLayerId(node.replica_layer_id); |
913 if (MaskLayer(ReplicaLayer(layer))) { | 915 if (MaskLayer(ReplicaLayer(layer))) { |
914 node.data.replica_mask_layer_id = MaskLayer(ReplicaLayer(layer))->id(); | 916 node.replica_mask_layer_id = MaskLayer(ReplicaLayer(layer))->id(); |
915 effect_tree.AddMaskOrReplicaLayerId(node.data.replica_mask_layer_id); | 917 effect_tree.AddMaskOrReplicaLayerId(node.replica_mask_layer_id); |
916 } | 918 } |
917 } | 919 } |
918 | 920 |
919 if (!is_root) { | 921 if (!is_root) { |
920 // The effect node's transform id is used only when we create a render | 922 // The effect node's transform id is used only when we create a render |
921 // surface. So, we can leave the default value when we don't create a render | 923 // surface. So, we can leave the default value when we don't create a render |
922 // surface. | 924 // surface. |
923 if (should_create_render_surface) { | 925 if (should_create_render_surface) { |
924 // In this case, we will create a transform node, so it's safe to use the | 926 // In this case, we will create a transform node, so it's safe to use the |
925 // next available id from the transform tree as this effect node's | 927 // next available id from the transform tree as this effect node's |
926 // transform id. | 928 // transform id. |
927 node.data.transform_id = | 929 node.transform_id = |
928 data_from_ancestor.property_trees->transform_tree.next_available_id(); | 930 data_from_ancestor.property_trees->transform_tree.next_available_id(); |
929 node.data.has_unclipped_descendants = | 931 node.has_unclipped_descendants = (NumUnclippedDescendants(layer) != 0); |
930 (NumUnclippedDescendants(layer) != 0); | |
931 } | 932 } |
932 node.data.clip_id = data_from_ancestor.clip_tree_parent; | 933 node.clip_id = data_from_ancestor.clip_tree_parent; |
933 } else { | 934 } else { |
934 // Root render surface acts the unbounded and untransformed to draw content | 935 // Root render surface acts the unbounded and untransformed to draw content |
935 // into. Transform node created from root layer (includes device scale | 936 // into. Transform node created from root layer (includes device scale |
936 // factor) and clip node created from root layer (include viewports) applies | 937 // factor) and clip node created from root layer (include viewports) applies |
937 // to root render surface's content, but not root render surface itself. | 938 // to root render surface's content, but not root render surface itself. |
938 node.data.transform_id = kRootPropertyTreeNodeId; | 939 node.transform_id = kRootPropertyTreeNodeId; |
939 node.data.clip_id = kViewportClipTreeNodeId; | 940 node.clip_id = kViewportClipTreeNodeId; |
940 } | 941 } |
941 data_for_children->effect_tree_parent = effect_tree.Insert(node, parent_id); | 942 data_for_children->effect_tree_parent = effect_tree.Insert(node, parent_id); |
942 int node_id = data_for_children->effect_tree_parent; | 943 int node_id = data_for_children->effect_tree_parent; |
943 layer->SetEffectTreeIndex(node_id); | 944 layer->SetEffectTreeIndex(node_id); |
944 data_for_children->property_trees->effect_id_to_index_map[layer->id()] = | 945 data_for_children->property_trees->effect_id_to_index_map[layer->id()] = |
945 data_for_children->effect_tree_parent; | 946 data_for_children->effect_tree_parent; |
946 | 947 |
947 std::vector<std::unique_ptr<CopyOutputRequest>> layer_copy_requests; | 948 std::vector<std::unique_ptr<CopyOutputRequest>> layer_copy_requests; |
948 TakeCopyRequests(layer, &layer_copy_requests); | 949 TakeCopyRequests(layer, &layer_copy_requests); |
949 for (auto& it : layer_copy_requests) { | 950 for (auto& it : layer_copy_requests) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 MainThreadScrollingReason::kNotScrollingOnMain && | 985 MainThreadScrollingReason::kNotScrollingOnMain && |
985 (has_different_main_thread_scrolling_reasons || | 986 (has_different_main_thread_scrolling_reasons || |
986 data_from_ancestor | 987 data_from_ancestor |
987 .scroll_tree_parent_created_by_uninheritable_criteria)); | 988 .scroll_tree_parent_created_by_uninheritable_criteria)); |
988 | 989 |
989 if (!requires_node) { | 990 if (!requires_node) { |
990 data_for_children->scroll_tree_parent = parent_id; | 991 data_for_children->scroll_tree_parent = parent_id; |
991 } else { | 992 } else { |
992 ScrollNode node; | 993 ScrollNode node; |
993 node.owner_id = layer->id(); | 994 node.owner_id = layer->id(); |
994 node.data.scrollable = scrollable; | 995 node.scrollable = scrollable; |
995 node.data.main_thread_scrolling_reasons = main_thread_scrolling_reasons; | 996 node.main_thread_scrolling_reasons = main_thread_scrolling_reasons; |
996 node.data.contains_non_fast_scrollable_region = | 997 node.contains_non_fast_scrollable_region = |
997 contains_non_fast_scrollable_region; | 998 contains_non_fast_scrollable_region; |
998 gfx::Size clip_bounds; | 999 gfx::Size clip_bounds; |
999 if (layer->scroll_clip_layer()) { | 1000 if (layer->scroll_clip_layer()) { |
1000 clip_bounds = layer->scroll_clip_layer()->bounds(); | 1001 clip_bounds = layer->scroll_clip_layer()->bounds(); |
1001 DCHECK(layer->scroll_clip_layer()->transform_tree_index() != | 1002 DCHECK(layer->scroll_clip_layer()->transform_tree_index() != |
1002 kInvalidPropertyTreeNodeId); | 1003 kInvalidPropertyTreeNodeId); |
1003 node.data.max_scroll_offset_affected_by_page_scale = | 1004 node.max_scroll_offset_affected_by_page_scale = |
1004 !data_from_ancestor.property_trees->transform_tree | 1005 !data_from_ancestor.property_trees->transform_tree |
1005 .Node(layer->scroll_clip_layer()->transform_tree_index()) | 1006 .Node(layer->scroll_clip_layer()->transform_tree_index()) |
1006 ->data.in_subtree_of_page_scale_layer && | 1007 ->in_subtree_of_page_scale_layer && |
1007 data_from_ancestor.in_subtree_of_page_scale_layer; | 1008 data_from_ancestor.in_subtree_of_page_scale_layer; |
1008 } | 1009 } |
1009 | 1010 |
1010 node.data.scroll_clip_layer_bounds = clip_bounds; | 1011 node.scroll_clip_layer_bounds = clip_bounds; |
1011 node.data.is_inner_viewport_scroll_layer = | 1012 node.is_inner_viewport_scroll_layer = |
1012 layer == data_from_ancestor.inner_viewport_scroll_layer; | 1013 layer == data_from_ancestor.inner_viewport_scroll_layer; |
1013 node.data.is_outer_viewport_scroll_layer = | 1014 node.is_outer_viewport_scroll_layer = |
1014 layer == data_from_ancestor.outer_viewport_scroll_layer; | 1015 layer == data_from_ancestor.outer_viewport_scroll_layer; |
1015 | 1016 |
1016 node.data.bounds = layer->bounds(); | 1017 node.bounds = layer->bounds(); |
1017 node.data.offset_to_transform_parent = layer->offset_to_transform_parent(); | 1018 node.offset_to_transform_parent = layer->offset_to_transform_parent(); |
1018 node.data.should_flatten = | 1019 node.should_flatten = layer->should_flatten_transform_from_property_tree(); |
1019 layer->should_flatten_transform_from_property_tree(); | 1020 node.user_scrollable_horizontal = layer->user_scrollable_horizontal(); |
1020 node.data.user_scrollable_horizontal = layer->user_scrollable_horizontal(); | 1021 node.user_scrollable_vertical = layer->user_scrollable_vertical(); |
1021 node.data.user_scrollable_vertical = layer->user_scrollable_vertical(); | 1022 node.element_id = layer->element_id(); |
1022 node.data.element_id = layer->element_id(); | 1023 node.transform_id = |
1023 node.data.transform_id = | |
1024 data_for_children->transform_tree_parent->transform_tree_index(); | 1024 data_for_children->transform_tree_parent->transform_tree_index(); |
1025 | 1025 |
1026 data_for_children->scroll_tree_parent = | 1026 data_for_children->scroll_tree_parent = |
1027 data_for_children->property_trees->scroll_tree.Insert(node, parent_id); | 1027 data_for_children->property_trees->scroll_tree.Insert(node, parent_id); |
1028 data_for_children->main_thread_scrolling_reasons = | 1028 data_for_children->main_thread_scrolling_reasons = |
1029 node.data.main_thread_scrolling_reasons; | 1029 node.main_thread_scrolling_reasons; |
1030 data_for_children->scroll_tree_parent_created_by_uninheritable_criteria = | 1030 data_for_children->scroll_tree_parent_created_by_uninheritable_criteria = |
1031 scroll_node_uninheritable_criteria; | 1031 scroll_node_uninheritable_criteria; |
1032 data_for_children->property_trees->scroll_id_to_index_map[layer->id()] = | 1032 data_for_children->property_trees->scroll_id_to_index_map[layer->id()] = |
1033 data_for_children->scroll_tree_parent; | 1033 data_for_children->scroll_tree_parent; |
1034 | 1034 |
1035 if (node.data.scrollable) { | 1035 if (node.scrollable) { |
1036 data_for_children->property_trees->scroll_tree.SetBaseScrollOffset( | 1036 data_for_children->property_trees->scroll_tree.SetBaseScrollOffset( |
1037 layer->id(), layer->CurrentScrollOffset()); | 1037 layer->id(), layer->CurrentScrollOffset()); |
1038 } | 1038 } |
1039 } | 1039 } |
1040 | 1040 |
1041 layer->SetScrollTreeIndex(data_for_children->scroll_tree_parent); | 1041 layer->SetScrollTreeIndex(data_for_children->scroll_tree_parent); |
1042 } | 1042 } |
1043 | 1043 |
1044 template <typename LayerType> | 1044 template <typename LayerType> |
1045 void SetBackfaceVisibilityTransform(LayerType* layer, | 1045 void SetBackfaceVisibilityTransform(LayerType* layer, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); | 1175 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); |
1176 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); | 1176 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); |
1177 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); | 1177 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); |
1178 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); | 1178 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); |
1179 } | 1179 } |
1180 | 1180 |
1181 EffectNode* effect_node = data_for_children.property_trees->effect_tree.Node( | 1181 EffectNode* effect_node = data_for_children.property_trees->effect_tree.Node( |
1182 data_for_children.effect_tree_parent); | 1182 data_for_children.effect_tree_parent); |
1183 | 1183 |
1184 if (effect_node->owner_id == layer->id()) { | 1184 if (effect_node->owner_id == layer->id()) { |
1185 if (effect_node->data.has_copy_request) | 1185 if (effect_node->has_copy_request) |
1186 data_to_parent->num_copy_requests_in_subtree++; | 1186 data_to_parent->num_copy_requests_in_subtree++; |
1187 effect_node->data.num_copy_requests_in_subtree = | 1187 effect_node->num_copy_requests_in_subtree = |
1188 data_to_parent->num_copy_requests_in_subtree; | 1188 data_to_parent->num_copy_requests_in_subtree; |
1189 } | 1189 } |
1190 } | 1190 } |
1191 | 1191 |
1192 } // namespace | 1192 } // namespace |
1193 | 1193 |
1194 void CC_EXPORT | 1194 void CC_EXPORT |
1195 PropertyTreeBuilder::PreCalculateMetaInformation(Layer* root_layer) { | 1195 PropertyTreeBuilder::PreCalculateMetaInformation(Layer* root_layer) { |
1196 PreCalculateMetaInformationRecursiveData recursive_data; | 1196 PreCalculateMetaInformationRecursiveData recursive_data; |
1197 PreCalculateMetaInformationInternal(root_layer, &recursive_data); | 1197 PreCalculateMetaInformationInternal(root_layer, &recursive_data); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 device_scale_factor); | 1283 device_scale_factor); |
1284 data_for_recursion.safe_opaque_background_color = color; | 1284 data_for_recursion.safe_opaque_background_color = color; |
1285 data_for_recursion.property_trees->transform_id_to_index_map.clear(); | 1285 data_for_recursion.property_trees->transform_id_to_index_map.clear(); |
1286 data_for_recursion.property_trees->effect_id_to_index_map.clear(); | 1286 data_for_recursion.property_trees->effect_id_to_index_map.clear(); |
1287 data_for_recursion.property_trees->clip_id_to_index_map.clear(); | 1287 data_for_recursion.property_trees->clip_id_to_index_map.clear(); |
1288 data_for_recursion.property_trees->scroll_id_to_index_map.clear(); | 1288 data_for_recursion.property_trees->scroll_id_to_index_map.clear(); |
1289 data_for_recursion.property_trees->always_use_active_tree_opacity_effect_ids | 1289 data_for_recursion.property_trees->always_use_active_tree_opacity_effect_ids |
1290 .clear(); | 1290 .clear(); |
1291 | 1291 |
1292 ClipNode root_clip; | 1292 ClipNode root_clip; |
1293 root_clip.data.resets_clip = true; | 1293 root_clip.resets_clip = true; |
1294 root_clip.data.applies_local_clip = true; | 1294 root_clip.applies_local_clip = true; |
1295 root_clip.data.clip = gfx::RectF(viewport); | 1295 root_clip.clip = gfx::RectF(viewport); |
1296 root_clip.data.transform_id = kRootPropertyTreeNodeId; | 1296 root_clip.transform_id = kRootPropertyTreeNodeId; |
1297 data_for_recursion.clip_tree_parent = | 1297 data_for_recursion.clip_tree_parent = |
1298 data_for_recursion.property_trees->clip_tree.Insert( | 1298 data_for_recursion.property_trees->clip_tree.Insert( |
1299 root_clip, kRootPropertyTreeNodeId); | 1299 root_clip, kRootPropertyTreeNodeId); |
1300 | 1300 |
1301 DataForRecursionFromChild<LayerType> data_from_child; | 1301 DataForRecursionFromChild<LayerType> data_from_child; |
1302 BuildPropertyTreesInternal(root_layer, data_for_recursion, &data_from_child); | 1302 BuildPropertyTreesInternal(root_layer, data_for_recursion, &data_from_child); |
1303 property_trees->needs_rebuild = false; | 1303 property_trees->needs_rebuild = false; |
1304 | 1304 |
1305 // The transform tree is kept up to date as it is built, but the | 1305 // The transform tree is kept up to date as it is built, but the |
1306 // combined_clips stored in the clip tree and the screen_space_opacity and | 1306 // combined_clips stored in the clip tree and the screen_space_opacity and |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 color = SkColorSetA(color, 255); | 1379 color = SkColorSetA(color, 255); |
1380 BuildPropertyTreesTopLevelInternal( | 1380 BuildPropertyTreesTopLevelInternal( |
1381 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1381 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1382 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1382 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1383 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1383 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1384 device_transform, property_trees, color); | 1384 device_transform, property_trees, color); |
1385 property_trees->ResetCachedData(); | 1385 property_trees->ResetCachedData(); |
1386 } | 1386 } |
1387 | 1387 |
1388 } // namespace cc | 1388 } // namespace cc |
OLD | NEW |