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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 2118993002: Detemplatize cc property nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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/layers/layer.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 12 matching lines...) Expand all
23 #include "cc/debug/layer_tree_debug_state.h" 23 #include "cc/debug/layer_tree_debug_state.h"
24 #include "cc/debug/micro_benchmark_impl.h" 24 #include "cc/debug/micro_benchmark_impl.h"
25 #include "cc/debug/traced_value.h" 25 #include "cc/debug/traced_value.h"
26 #include "cc/input/main_thread_scrolling_reason.h" 26 #include "cc/input/main_thread_scrolling_reason.h"
27 #include "cc/input/scroll_state.h" 27 #include "cc/input/scroll_state.h"
28 #include "cc/layers/layer.h" 28 #include "cc/layers/layer.h"
29 #include "cc/layers/layer_utils.h" 29 #include "cc/layers/layer_utils.h"
30 #include "cc/output/copy_output_request.h" 30 #include "cc/output/copy_output_request.h"
31 #include "cc/quads/debug_border_draw_quad.h" 31 #include "cc/quads/debug_border_draw_quad.h"
32 #include "cc/quads/render_pass.h" 32 #include "cc/quads/render_pass.h"
33 #include "cc/trees/clip_node.h"
33 #include "cc/trees/draw_property_utils.h" 34 #include "cc/trees/draw_property_utils.h"
35 #include "cc/trees/effect_node.h"
34 #include "cc/trees/layer_tree_host_common.h" 36 #include "cc/trees/layer_tree_host_common.h"
35 #include "cc/trees/layer_tree_impl.h" 37 #include "cc/trees/layer_tree_impl.h"
36 #include "cc/trees/layer_tree_settings.h" 38 #include "cc/trees/layer_tree_settings.h"
37 #include "cc/trees/proxy.h" 39 #include "cc/trees/proxy.h"
40 #include "cc/trees/scroll_node.h"
41 #include "cc/trees/transform_node.h"
38 #include "ui/gfx/geometry/box_f.h" 42 #include "ui/gfx/geometry/box_f.h"
39 #include "ui/gfx/geometry/point_conversions.h" 43 #include "ui/gfx/geometry/point_conversions.h"
40 #include "ui/gfx/geometry/quad_f.h" 44 #include "ui/gfx/geometry/quad_f.h"
41 #include "ui/gfx/geometry/rect_conversions.h" 45 #include "ui/gfx/geometry/rect_conversions.h"
42 #include "ui/gfx/geometry/size_conversions.h" 46 #include "ui/gfx/geometry/size_conversions.h"
43 #include "ui/gfx/geometry/vector2d_conversions.h" 47 #include "ui/gfx/geometry/vector2d_conversions.h"
44 48
45 namespace cc { 49 namespace cc {
46 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) 50 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
47 : layer_id_(id), 51 : layer_id_(id),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 layer_property_changed_ = false; 375 layer_property_changed_ = false;
372 needs_push_properties_ = false; 376 needs_push_properties_ = false;
373 update_rect_ = gfx::Rect(); 377 update_rect_ = gfx::Rect();
374 layer_tree_impl()->RemoveLayerShouldPushProperties(this); 378 layer_tree_impl()->RemoveLayerShouldPushProperties(this);
375 } 379 }
376 380
377 bool LayerImpl::IsAffectedByPageScale() const { 381 bool LayerImpl::IsAffectedByPageScale() const {
378 TransformTree& transform_tree = 382 TransformTree& transform_tree =
379 layer_tree_impl()->property_trees()->transform_tree; 383 layer_tree_impl()->property_trees()->transform_tree;
380 return transform_tree.Node(transform_tree_index()) 384 return transform_tree.Node(transform_tree_index())
381 ->data.in_subtree_of_page_scale_layer; 385 ->in_subtree_of_page_scale_layer;
382 } 386 }
383 387
384 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const { 388 gfx::Vector2dF LayerImpl::FixedContainerSizeDelta() const {
385 LayerImpl* scroll_clip_layer = 389 LayerImpl* scroll_clip_layer =
386 layer_tree_impl()->LayerById(scroll_clip_layer_id_); 390 layer_tree_impl()->LayerById(scroll_clip_layer_id_);
387 if (!scroll_clip_layer) 391 if (!scroll_clip_layer)
388 return gfx::Vector2dF(); 392 return gfx::Vector2dF();
389 393
390 return scroll_clip_layer->bounds_delta(); 394 return scroll_clip_layer->bounds_delta();
391 } 395 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 bool LayerImpl::LayerPropertyChanged() const { 441 bool LayerImpl::LayerPropertyChanged() const {
438 if (layer_property_changed_ || 442 if (layer_property_changed_ ||
439 (layer_tree_impl()->property_trees() && 443 (layer_tree_impl()->property_trees() &&
440 layer_tree_impl()->property_trees()->full_tree_damaged)) 444 layer_tree_impl()->property_trees()->full_tree_damaged))
441 return true; 445 return true;
442 if (transform_tree_index() == -1) 446 if (transform_tree_index() == -1)
443 return false; 447 return false;
444 TransformNode* transform_node = 448 TransformNode* transform_node =
445 layer_tree_impl()->property_trees()->transform_tree.Node( 449 layer_tree_impl()->property_trees()->transform_tree.Node(
446 transform_tree_index()); 450 transform_tree_index());
447 if (transform_node && transform_node->data.transform_changed) 451 if (transform_node && transform_node->transform_changed)
448 return true; 452 return true;
449 if (effect_tree_index() == -1) 453 if (effect_tree_index() == -1)
450 return false; 454 return false;
451 EffectNode* effect_node = 455 EffectNode* effect_node =
452 layer_tree_impl()->property_trees()->effect_tree.Node( 456 layer_tree_impl()->property_trees()->effect_tree.Node(
453 effect_tree_index()); 457 effect_tree_index());
454 if (effect_node && effect_node->data.effect_changed) 458 if (effect_node && effect_node->effect_changed)
455 return true; 459 return true;
456 return false; 460 return false;
457 } 461 }
458 462
459 void LayerImpl::NoteLayerPropertyChanged() { 463 void LayerImpl::NoteLayerPropertyChanged() {
460 layer_property_changed_ = true; 464 layer_property_changed_ = true;
461 layer_tree_impl()->set_needs_update_draw_properties(); 465 layer_tree_impl()->set_needs_update_draw_properties();
462 SetNeedsPushProperties(); 466 SetNeedsPushProperties();
463 } 467 }
464 468
(...skipping 18 matching lines...) Expand all
483 damage_rect_.SetRect(0, 0, 0, 0); 487 damage_rect_.SetRect(0, 0, 0, 0);
484 488
485 if (render_surface_) 489 if (render_surface_)
486 render_surface_->ResetPropertyChangedFlag(); 490 render_surface_->ResetPropertyChangedFlag();
487 } 491 }
488 492
489 int LayerImpl::num_copy_requests_in_target_subtree() { 493 int LayerImpl::num_copy_requests_in_target_subtree() {
490 return layer_tree_impl() 494 return layer_tree_impl()
491 ->property_trees() 495 ->property_trees()
492 ->effect_tree.Node(effect_tree_index()) 496 ->effect_tree.Node(effect_tree_index())
493 ->data.num_copy_requests_in_subtree; 497 ->num_copy_requests_in_subtree;
494 } 498 }
495 499
496 void LayerImpl::UpdatePropertyTreeTransform() { 500 void LayerImpl::UpdatePropertyTreeTransform() {
497 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 501 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
498 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 502 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
499 id())) { 503 id())) {
500 // A LayerImpl's own current state is insufficient for determining whether 504 // A LayerImpl's own current state is insufficient for determining whether
501 // it owns a TransformNode, since this depends on the state of the 505 // it owns a TransformNode, since this depends on the state of the
502 // corresponding Layer at the time of the last commit. For example, a 506 // corresponding Layer at the time of the last commit. For example, a
503 // transform animation might have been in progress at the time the last 507 // transform animation might have been in progress at the time the last
504 // commit started, but might have finished since then on the compositor 508 // commit started, but might have finished since then on the compositor
505 // thread. 509 // thread.
506 TransformNode* node = property_trees->transform_tree.Node( 510 TransformNode* node = property_trees->transform_tree.Node(
507 property_trees->transform_id_to_index_map[id()]); 511 property_trees->transform_id_to_index_map[id()]);
508 if (node->data.local != transform_) { 512 if (node->local != transform_) {
509 node->data.local = transform_; 513 node->local = transform_;
510 node->data.needs_local_transform_update = true; 514 node->needs_local_transform_update = true;
511 node->data.transform_changed = true; 515 node->transform_changed = true;
512 property_trees->changed = true; 516 property_trees->changed = true;
513 property_trees->transform_tree.set_needs_update(true); 517 property_trees->transform_tree.set_needs_update(true);
514 // TODO(ajuma): The current criteria for creating clip nodes means that 518 // TODO(ajuma): The current criteria for creating clip nodes means that
515 // property trees may need to be rebuilt when the new transform isn't 519 // property trees may need to be rebuilt when the new transform isn't
516 // axis-aligned wrt the old transform (see Layer::SetTransform). Since 520 // axis-aligned wrt the old transform (see Layer::SetTransform). Since
517 // rebuilding property trees every frame of a transform animation is 521 // rebuilding property trees every frame of a transform animation is
518 // something we should try to avoid, change property tree-building so that 522 // something we should try to avoid, change property tree-building so that
519 // it doesn't depend on axis aliginment. 523 // it doesn't depend on axis aliginment.
520 } 524 }
521 } 525 }
522 } 526 }
523 527
524 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) { 528 void LayerImpl::UpdatePropertyTreeTransformIsAnimated(bool is_animated) {
525 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 529 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
526 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 530 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
527 id())) { 531 id())) {
528 TransformNode* node = property_trees->transform_tree.Node( 532 TransformNode* node = property_trees->transform_tree.Node(
529 property_trees->transform_id_to_index_map[id()]); 533 property_trees->transform_id_to_index_map[id()]);
530 // A LayerImpl's own current state is insufficient for determining whether 534 // A LayerImpl's own current state is insufficient for determining whether
531 // it owns a TransformNode, since this depends on the state of the 535 // it owns a TransformNode, since this depends on the state of the
532 // corresponding Layer at the time of the last commit. For example, if 536 // corresponding Layer at the time of the last commit. For example, if
533 // |is_animated| is false, this might mean a transform animation just ticked 537 // |is_animated| is false, this might mean a transform animation just ticked
534 // past its finish point (so the LayerImpl still owns a TransformNode) or it 538 // past its finish point (so the LayerImpl still owns a TransformNode) or it
535 // might mean that a transform animation was removed during commit or 539 // might mean that a transform animation was removed during commit or
536 // activation (and, in that case, the LayerImpl will no longer own a 540 // activation (and, in that case, the LayerImpl will no longer own a
537 // TransformNode, unless it has non-animation-related reasons for owning a 541 // TransformNode, unless it has non-animation-related reasons for owning a
538 // node). 542 // node).
539 if (node->data.has_potential_animation != is_animated) { 543 if (node->has_potential_animation != is_animated) {
540 node->data.has_potential_animation = is_animated; 544 node->has_potential_animation = is_animated;
541 if (is_animated) { 545 if (is_animated) {
542 node->data.has_only_translation_animations = 546 node->has_only_translation_animations = HasOnlyTranslationTransforms();
543 HasOnlyTranslationTransforms();
544 } else { 547 } else {
545 node->data.has_only_translation_animations = true; 548 node->has_only_translation_animations = true;
546 } 549 }
547 550
548 property_trees->transform_tree.set_needs_update(true); 551 property_trees->transform_tree.set_needs_update(true);
549 layer_tree_impl()->set_needs_update_draw_properties(); 552 layer_tree_impl()->set_needs_update_draw_properties();
550 } 553 }
551 } 554 }
552 } 555 }
553 556
554 void LayerImpl::UpdatePropertyTreeOpacity(float opacity) { 557 void LayerImpl::UpdatePropertyTreeOpacity(float opacity) {
555 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 558 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
556 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) { 559 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) {
557 // A LayerImpl's own current state is insufficient for determining whether 560 // A LayerImpl's own current state is insufficient for determining whether
558 // it owns an OpacityNode, since this depends on the state of the 561 // it owns an OpacityNode, since this depends on the state of the
559 // corresponding Layer at the time of the last commit. For example, an 562 // corresponding Layer at the time of the last commit. For example, an
560 // opacity animation might have been in progress at the time the last commit 563 // opacity animation might have been in progress at the time the last commit
561 // started, but might have finished since then on the compositor thread. 564 // started, but might have finished since then on the compositor thread.
562 EffectNode* node = property_trees->effect_tree.Node( 565 EffectNode* node = property_trees->effect_tree.Node(
563 property_trees->effect_id_to_index_map[id()]); 566 property_trees->effect_id_to_index_map[id()]);
564 if (node->data.opacity == opacity) 567 if (node->opacity == opacity)
565 return; 568 return;
566 node->data.opacity = opacity; 569 node->opacity = opacity;
567 node->data.effect_changed = true; 570 node->effect_changed = true;
568 property_trees->changed = true; 571 property_trees->changed = true;
569 property_trees->effect_tree.set_needs_update(true); 572 property_trees->effect_tree.set_needs_update(true);
570 } 573 }
571 } 574 }
572 575
573 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() { 576 void LayerImpl::UpdatePropertyTreeForScrollingAndAnimationIfNeeded() {
574 if (scrollable()) 577 if (scrollable())
575 UpdatePropertyTreeScrollOffset(); 578 UpdatePropertyTreeScrollOffset();
576 579
577 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) { 580 if (HasAnyAnimationTargetingProperty(TargetProperty::TRANSFORM)) {
578 UpdatePropertyTreeTransformIsAnimated( 581 UpdatePropertyTreeTransformIsAnimated(
579 HasPotentiallyRunningTransformAnimation()); 582 HasPotentiallyRunningTransformAnimation());
580 } 583 }
581 } 584 }
582 585
583 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const { 586 gfx::ScrollOffset LayerImpl::ScrollOffsetForAnimation() const {
584 return CurrentScrollOffset(); 587 return CurrentScrollOffset();
585 } 588 }
586 589
587 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) { 590 void LayerImpl::OnFilterAnimated(const FilterOperations& filters) {
588 if (filters_ != filters) { 591 if (filters_ != filters) {
589 SetFilters(filters); 592 SetFilters(filters);
590 SetNeedsPushProperties(); 593 SetNeedsPushProperties();
591 layer_tree_impl()->set_needs_update_draw_properties(); 594 layer_tree_impl()->set_needs_update_draw_properties();
592 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree; 595 EffectTree& effect_tree = layer_tree_impl()->property_trees()->effect_tree;
593 EffectNode* node = effect_tree.Node(effect_tree_index_); 596 EffectNode* node = effect_tree.Node(effect_tree_index_);
594 DCHECK(layer_tree_impl()->property_trees()->IsInIdToIndexMap( 597 DCHECK(layer_tree_impl()->property_trees()->IsInIdToIndexMap(
595 PropertyTrees::TreeType::EFFECT, id())); 598 PropertyTrees::TreeType::EFFECT, id()));
596 node->data.effect_changed = true; 599 node->effect_changed = true;
597 layer_tree_impl()->property_trees()->changed = true; 600 layer_tree_impl()->property_trees()->changed = true;
598 effect_tree.set_needs_update(true); 601 effect_tree.set_needs_update(true);
599 } 602 }
600 } 603 }
601 604
602 void LayerImpl::OnOpacityAnimated(float opacity) { 605 void LayerImpl::OnOpacityAnimated(float opacity) {
603 UpdatePropertyTreeOpacity(opacity); 606 UpdatePropertyTreeOpacity(opacity);
604 SetNeedsPushProperties(); 607 SetNeedsPushProperties();
605 layer_tree_impl()->set_needs_update_draw_properties(); 608 layer_tree_impl()->set_needs_update_draw_properties();
606 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity); 609 layer_tree_impl()->AddToOpacityAnimationsMap(id(), opacity);
(...skipping 25 matching lines...) Expand all
632 635
633 void LayerImpl::OnTransformIsCurrentlyAnimatingChanged( 636 void LayerImpl::OnTransformIsCurrentlyAnimatingChanged(
634 bool is_currently_animating) { 637 bool is_currently_animating) {
635 DCHECK(layer_tree_impl_); 638 DCHECK(layer_tree_impl_);
636 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 639 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
637 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 640 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
638 id())) 641 id()))
639 return; 642 return;
640 TransformNode* node = property_trees->transform_tree.Node( 643 TransformNode* node = property_trees->transform_tree.Node(
641 property_trees->transform_id_to_index_map[id()]); 644 property_trees->transform_id_to_index_map[id()]);
642 node->data.is_currently_animating = is_currently_animating; 645 node->is_currently_animating = is_currently_animating;
643 } 646 }
644 647
645 void LayerImpl::OnTransformIsPotentiallyAnimatingChanged( 648 void LayerImpl::OnTransformIsPotentiallyAnimatingChanged(
646 bool has_potential_animation) { 649 bool has_potential_animation) {
647 UpdatePropertyTreeTransformIsAnimated(has_potential_animation); 650 UpdatePropertyTreeTransformIsAnimated(has_potential_animation);
648 was_ever_ready_since_last_transform_animation_ = false; 651 was_ever_ready_since_last_transform_animation_ = false;
649 } 652 }
650 653
651 void LayerImpl::OnOpacityIsCurrentlyAnimatingChanged( 654 void LayerImpl::OnOpacityIsCurrentlyAnimatingChanged(
652 bool is_currently_animating) { 655 bool is_currently_animating) {
653 DCHECK(layer_tree_impl_); 656 DCHECK(layer_tree_impl_);
654 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 657 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
655 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 658 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
656 return; 659 return;
657 EffectNode* node = property_trees->effect_tree.Node( 660 EffectNode* node = property_trees->effect_tree.Node(
658 property_trees->effect_id_to_index_map[id()]); 661 property_trees->effect_id_to_index_map[id()]);
659 662
660 node->data.is_currently_animating_opacity = is_currently_animating; 663 node->is_currently_animating_opacity = is_currently_animating;
661 } 664 }
662 665
663 void LayerImpl::OnOpacityIsPotentiallyAnimatingChanged( 666 void LayerImpl::OnOpacityIsPotentiallyAnimatingChanged(
664 bool has_potential_animation) { 667 bool has_potential_animation) {
665 DCHECK(layer_tree_impl_); 668 DCHECK(layer_tree_impl_);
666 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 669 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
667 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 670 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
668 return; 671 return;
669 EffectNode* node = property_trees->effect_tree.Node( 672 EffectNode* node = property_trees->effect_tree.Node(
670 property_trees->effect_id_to_index_map[id()]); 673 property_trees->effect_id_to_index_map[id()]);
671 node->data.has_potential_opacity_animation = has_potential_animation; 674 node->has_potential_opacity_animation = has_potential_animation;
672 property_trees->effect_tree.set_needs_update(true); 675 property_trees->effect_tree.set_needs_update(true);
673 } 676 }
674 677
675 bool LayerImpl::IsActive() const { 678 bool LayerImpl::IsActive() const {
676 return layer_tree_impl_->IsActiveTree(); 679 return layer_tree_impl_->IsActiveTree();
677 } 680 }
678 681
679 gfx::Size LayerImpl::bounds() const { 682 gfx::Size LayerImpl::bounds() const {
680 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_); 683 gfx::Vector2d delta = gfx::ToCeiledVector2d(bounds_delta_);
681 return gfx::Size(bounds_.width() + delta.x(), 684 return gfx::Size(bounds_.width() + delta.x(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta); 717 property_trees->SetInnerViewportScrollBoundsDelta(bounds_delta);
715 718
716 layer_tree_impl()->DidUpdateScrollState(id()); 719 layer_tree_impl()->DidUpdateScrollState(id());
717 720
718 if (masks_to_bounds()) { 721 if (masks_to_bounds()) {
719 // If layer is clipping, then update the clip node using the new bounds. 722 // If layer is clipping, then update the clip node using the new bounds.
720 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index()); 723 ClipNode* clip_node = property_trees->clip_tree.Node(clip_tree_index());
721 if (clip_node) { 724 if (clip_node) {
722 DCHECK(property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::CLIP, 725 DCHECK(property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::CLIP,
723 id())); 726 id()));
724 clip_node->data.clip = gfx::RectF( 727 clip_node->clip = gfx::RectF(gfx::PointF() + offset_to_transform_parent(),
725 gfx::PointF() + offset_to_transform_parent(), gfx::SizeF(bounds())); 728 gfx::SizeF(bounds()));
726 property_trees->clip_tree.set_needs_update(true); 729 property_trees->clip_tree.set_needs_update(true);
727 } 730 }
728 property_trees->full_tree_damaged = true; 731 property_trees->full_tree_damaged = true;
729 layer_tree_impl()->set_needs_update_draw_properties(); 732 layer_tree_impl()->set_needs_update_draw_properties();
730 } else { 733 } else {
731 NoteLayerPropertyChanged(); 734 NoteLayerPropertyChanged();
732 } 735 }
733 } 736 }
734 737
735 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { 738 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 void LayerImpl::SetContentsOpaque(bool opaque) { 787 void LayerImpl::SetContentsOpaque(bool opaque) {
785 contents_opaque_ = opaque; 788 contents_opaque_ = opaque;
786 } 789 }
787 790
788 float LayerImpl::Opacity() const { 791 float LayerImpl::Opacity() const {
789 PropertyTrees* property_trees = layer_tree_impl()->property_trees(); 792 PropertyTrees* property_trees = layer_tree_impl()->property_trees();
790 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id())) 793 if (!property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id()))
791 return 1.f; 794 return 1.f;
792 EffectNode* node = property_trees->effect_tree.Node( 795 EffectNode* node = property_trees->effect_tree.Node(
793 property_trees->effect_id_to_index_map[id()]); 796 property_trees->effect_id_to_index_map[id()]);
794 return node->data.opacity; 797 return node->opacity;
795 } 798 }
796 799
797 bool LayerImpl::OpacityIsAnimating() const { 800 bool LayerImpl::OpacityIsAnimating() const {
798 return layer_tree_impl_->IsAnimatingOpacityProperty(this); 801 return layer_tree_impl_->IsAnimatingOpacityProperty(this);
799 } 802 }
800 803
801 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const { 804 bool LayerImpl::HasPotentiallyRunningOpacityAnimation() const {
802 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this); 805 return layer_tree_impl_->HasPotentiallyRunningOpacityAnimation(this);
803 } 806 }
804 807
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 id()); 920 id());
918 } 921 }
919 922
920 void LayerImpl::UpdatePropertyTreeScrollOffset() { 923 void LayerImpl::UpdatePropertyTreeScrollOffset() {
921 // TODO(enne): in the future, scrolling should update the scroll tree 924 // TODO(enne): in the future, scrolling should update the scroll tree
922 // directly instead of going through layers. 925 // directly instead of going through layers.
923 TransformTree& transform_tree = 926 TransformTree& transform_tree =
924 layer_tree_impl()->property_trees()->transform_tree; 927 layer_tree_impl()->property_trees()->transform_tree;
925 TransformNode* node = transform_tree.Node(transform_tree_index_); 928 TransformNode* node = transform_tree.Node(transform_tree_index_);
926 gfx::ScrollOffset current_offset = CurrentScrollOffset(); 929 gfx::ScrollOffset current_offset = CurrentScrollOffset();
927 if (node->data.scroll_offset != current_offset) { 930 if (node->scroll_offset != current_offset) {
928 node->data.scroll_offset = current_offset; 931 node->scroll_offset = current_offset;
929 node->data.needs_local_transform_update = true; 932 node->needs_local_transform_update = true;
930 transform_tree.set_needs_update(true); 933 transform_tree.set_needs_update(true);
931 } 934 }
932 } 935 }
933 936
934 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const { 937 SimpleEnclosedRegion LayerImpl::VisibleOpaqueRegion() const {
935 if (contents_opaque()) 938 if (contents_opaque())
936 return SimpleEnclosedRegion(visible_layer_rect()); 939 return SimpleEnclosedRegion(visible_layer_rect());
937 return SimpleEnclosedRegion(); 940 return SimpleEnclosedRegion();
938 } 941 }
939 942
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 if (layer_tree_impl()->settings().layers_always_allowed_lcd_text) 1104 if (layer_tree_impl()->settings().layers_always_allowed_lcd_text)
1102 return true; 1105 return true;
1103 if (!layer_tree_impl()->settings().can_use_lcd_text) 1106 if (!layer_tree_impl()->settings().can_use_lcd_text)
1104 return false; 1107 return false;
1105 if (!contents_opaque()) 1108 if (!contents_opaque())
1106 return false; 1109 return false;
1107 1110
1108 if (layer_tree_impl() 1111 if (layer_tree_impl()
1109 ->property_trees() 1112 ->property_trees()
1110 ->effect_tree.Node(effect_tree_index()) 1113 ->effect_tree.Node(effect_tree_index())
1111 ->data.screen_space_opacity != 1.f) 1114 ->screen_space_opacity != 1.f)
1112 return false; 1115 return false;
1113 if (!layer_tree_impl() 1116 if (!layer_tree_impl()
1114 ->property_trees() 1117 ->property_trees()
1115 ->transform_tree.Node(transform_tree_index()) 1118 ->transform_tree.Node(transform_tree_index())
1116 ->data.node_and_ancestors_have_only_integer_translation) 1119 ->node_and_ancestors_have_only_integer_translation)
1117 return false; 1120 return false;
1118 if (static_cast<int>(offset_to_transform_parent().x()) != 1121 if (static_cast<int>(offset_to_transform_parent().x()) !=
1119 offset_to_transform_parent().x()) 1122 offset_to_transform_parent().x())
1120 return false; 1123 return false;
1121 if (static_cast<int>(offset_to_transform_parent().y()) != 1124 if (static_cast<int>(offset_to_transform_parent().y()) !=
1122 offset_to_transform_parent().y()) 1125 offset_to_transform_parent().y())
1123 return false; 1126 return false;
1124 return true; 1127 return true;
1125 } 1128 }
1126 1129
(...skipping 11 matching lines...) Expand all
1138 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale); 1141 scaled_draw_transform.Scale(SK_MScalar1 / scale, SK_MScalar1 / scale);
1139 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale); 1142 gfx::Size scaled_bounds = gfx::ScaleToCeiledSize(bounds(), scale);
1140 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform, 1143 return MathUtil::MapEnclosingClippedRect(scaled_draw_transform,
1141 gfx::Rect(scaled_bounds)); 1144 gfx::Rect(scaled_bounds));
1142 } 1145 }
1143 1146
1144 RenderSurfaceImpl* LayerImpl::render_target() { 1147 RenderSurfaceImpl* LayerImpl::render_target() {
1145 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; 1148 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1146 EffectNode* node = effect_tree.Node(effect_tree_index_); 1149 EffectNode* node = effect_tree.Node(effect_tree_index_);
1147 1150
1148 if (node->data.render_surface) 1151 if (node->render_surface)
1149 return node->data.render_surface; 1152 return node->render_surface;
1150 else 1153 else
1151 return effect_tree.Node(node->data.target_id)->data.render_surface; 1154 return effect_tree.Node(node->target_id)->render_surface;
1152 } 1155 }
1153 1156
1154 const RenderSurfaceImpl* LayerImpl::render_target() const { 1157 const RenderSurfaceImpl* LayerImpl::render_target() const {
1155 const EffectTree& effect_tree = 1158 const EffectTree& effect_tree =
1156 layer_tree_impl_->property_trees()->effect_tree; 1159 layer_tree_impl_->property_trees()->effect_tree;
1157 const EffectNode* node = effect_tree.Node(effect_tree_index_); 1160 const EffectNode* node = effect_tree.Node(effect_tree_index_);
1158 1161
1159 if (node->data.render_surface) 1162 if (node->render_surface)
1160 return node->data.render_surface; 1163 return node->render_surface;
1161 else 1164 else
1162 return effect_tree.Node(node->data.target_id)->data.render_surface; 1165 return effect_tree.Node(node->target_id)->render_surface;
1163 } 1166 }
1164 1167
1165 bool LayerImpl::IsHidden() const { 1168 bool LayerImpl::IsHidden() const {
1166 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; 1169 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1167 EffectNode* node = effect_tree.Node(effect_tree_index_); 1170 EffectNode* node = effect_tree.Node(effect_tree_index_);
1168 return node->data.screen_space_opacity == 0.f; 1171 return node->screen_space_opacity == 0.f;
1169 } 1172 }
1170 1173
1171 bool LayerImpl::InsideReplica() const { 1174 bool LayerImpl::InsideReplica() const {
1172 // There are very few render targets so this should be cheap to do for each 1175 // There are very few render targets so this should be cheap to do for each
1173 // layer instead of something more complicated. 1176 // layer instead of something more complicated.
1174 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree; 1177 EffectTree& effect_tree = layer_tree_impl_->property_trees()->effect_tree;
1175 EffectNode* node = effect_tree.Node(effect_tree_index_); 1178 EffectNode* node = effect_tree.Node(effect_tree_index_);
1176 1179
1177 while (node->id > 0) { 1180 while (node->id > 0) {
1178 if (node->data.replica_layer_id != -1) 1181 if (node->replica_layer_id != -1)
1179 return true; 1182 return true;
1180 node = effect_tree.Node(node->data.target_id); 1183 node = effect_tree.Node(node->target_id);
1181 } 1184 }
1182 1185
1183 return false; 1186 return false;
1184 } 1187 }
1185 1188
1186 float LayerImpl::GetIdealContentsScale() const { 1189 float LayerImpl::GetIdealContentsScale() const {
1187 float page_scale = IsAffectedByPageScale() 1190 float page_scale = IsAffectedByPageScale()
1188 ? layer_tree_impl()->current_page_scale_factor() 1191 ? layer_tree_impl()->current_page_scale_factor()
1189 : 1.f; 1192 : 1.f;
1190 float device_scale = layer_tree_impl()->device_scale_factor(); 1193 float device_scale = layer_tree_impl()->device_scale_factor();
1191 1194
1192 float default_scale = page_scale * device_scale; 1195 float default_scale = page_scale * device_scale;
1193 if (!layer_tree_impl() 1196 if (!layer_tree_impl()
1194 ->settings() 1197 ->settings()
1195 .layer_transforms_should_scale_layer_contents) { 1198 .layer_transforms_should_scale_layer_contents) {
1196 return default_scale; 1199 return default_scale;
1197 } 1200 }
1198 1201
1199 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1202 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1200 ScreenSpaceTransform(), default_scale); 1203 ScreenSpaceTransform(), default_scale);
1201 return std::max(transform_scales.x(), transform_scales.y()); 1204 return std::max(transform_scales.x(), transform_scales.y());
1202 } 1205 }
1203 1206
1204 } // namespace cc 1207 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698