OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 reset_raster_scale_to_unknown(); | 114 reset_raster_scale_to_unknown(); |
115 } | 115 } |
116 | 116 |
117 if (host && layer_animation_controller_->has_any_animation()) | 117 if (host && layer_animation_controller_->has_any_animation()) |
118 host->SetNeedsCommit(); | 118 host->SetNeedsCommit(); |
119 if (host && | 119 if (host && |
120 (!filters_.IsEmpty() || !background_filters_.IsEmpty() || filter_)) | 120 (!filters_.IsEmpty() || !background_filters_.IsEmpty() || filter_)) |
121 layer_tree_host_->set_needs_filter_context(); | 121 layer_tree_host_->set_needs_filter_context(); |
122 } | 122 } |
123 | 123 |
| 124 void Layer::SetNeedsUpdate() { |
| 125 if (layer_tree_host_ && !ignore_set_needs_commit_) |
| 126 layer_tree_host_->SetNeedsUpdateLayers(); |
| 127 } |
| 128 |
124 void Layer::SetNeedsCommit() { | 129 void Layer::SetNeedsCommit() { |
125 if (!layer_tree_host_) | 130 if (!layer_tree_host_) |
126 return; | 131 return; |
127 | 132 |
128 SetNeedsPushProperties(); | 133 SetNeedsPushProperties(); |
129 | 134 |
130 if (ignore_set_needs_commit_) | 135 if (ignore_set_needs_commit_) |
131 return; | 136 return; |
132 | 137 |
133 layer_tree_host_->SetNeedsCommit(); | 138 layer_tree_host_->SetNeedsCommit(); |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) { | 561 void Layer::SetScrollOffset(gfx::Vector2d scroll_offset) { |
557 DCHECK(IsPropertyChangeAllowed()); | 562 DCHECK(IsPropertyChangeAllowed()); |
558 if (scroll_offset_ == scroll_offset) | 563 if (scroll_offset_ == scroll_offset) |
559 return; | 564 return; |
560 scroll_offset_ = scroll_offset; | 565 scroll_offset_ = scroll_offset; |
561 SetNeedsCommit(); | 566 SetNeedsCommit(); |
562 } | 567 } |
563 | 568 |
564 void Layer::SetScrollOffsetFromImplSide(gfx::Vector2d scroll_offset) { | 569 void Layer::SetScrollOffsetFromImplSide(gfx::Vector2d scroll_offset) { |
565 DCHECK(IsPropertyChangeAllowed()); | 570 DCHECK(IsPropertyChangeAllowed()); |
| 571 // This function only gets called during a begin frame, so there |
| 572 // is no need to call SetNeedsUpdate here. |
566 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 573 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
567 if (scroll_offset_ == scroll_offset) | 574 if (scroll_offset_ == scroll_offset) |
568 return; | 575 return; |
569 scroll_offset_ = scroll_offset; | 576 scroll_offset_ = scroll_offset; |
| 577 SetNeedsPushProperties(); |
570 if (!did_scroll_callback_.is_null()) | 578 if (!did_scroll_callback_.is_null()) |
571 did_scroll_callback_.Run(); | 579 did_scroll_callback_.Run(); |
572 // Note: didScroll() could potentially change the layer structure. | 580 // The callback could potentially change the layer structure: |
573 // "this" may have been destroyed during the process. | 581 // "this" may have been destroyed during the process. |
574 } | 582 } |
575 | 583 |
576 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { | 584 void Layer::SetMaxScrollOffset(gfx::Vector2d max_scroll_offset) { |
577 DCHECK(IsPropertyChangeAllowed()); | 585 DCHECK(IsPropertyChangeAllowed()); |
578 if (max_scroll_offset_ == max_scroll_offset) | 586 if (max_scroll_offset_ == max_scroll_offset) |
579 return; | 587 return; |
580 max_scroll_offset_ = max_scroll_offset; | 588 max_scroll_offset_ = max_scroll_offset; |
581 SetNeedsCommit(); | 589 SetNeedsCommit(); |
582 } | 590 } |
583 | 591 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 void Layer::SetHideLayerAndSubtree(bool hide) { | 664 void Layer::SetHideLayerAndSubtree(bool hide) { |
657 DCHECK(IsPropertyChangeAllowed()); | 665 DCHECK(IsPropertyChangeAllowed()); |
658 if (hide_layer_and_subtree_ == hide) | 666 if (hide_layer_and_subtree_ == hide) |
659 return; | 667 return; |
660 | 668 |
661 hide_layer_and_subtree_ = hide; | 669 hide_layer_and_subtree_ = hide; |
662 SetNeedsCommit(); | 670 SetNeedsCommit(); |
663 } | 671 } |
664 | 672 |
665 void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { | 673 void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { |
| 674 if (!update_rect_.Contains(dirty_rect)) { |
| 675 SetNeedsPushProperties(); |
| 676 } |
| 677 |
666 update_rect_.Union(dirty_rect); | 678 update_rect_.Union(dirty_rect); |
667 needs_display_ = true; | 679 needs_display_ = true; |
668 | 680 |
669 // Simply mark the contents as dirty. For non-root layers, the call to | 681 if (DrawsContent() && !update_rect_.IsEmpty()) { |
670 // SetNeedsCommit will schedule a fresh compositing pass. | 682 SetNeedsUpdate(); |
671 // For the root layer, SetNeedsCommit has no effect. | 683 } |
672 if (DrawsContent() && !update_rect_.IsEmpty()) | |
673 SetNeedsCommit(); | |
674 } | 684 } |
675 | 685 |
676 bool Layer::DescendantIsFixedToContainerLayer() const { | 686 bool Layer::DescendantIsFixedToContainerLayer() const { |
677 for (size_t i = 0; i < children_.size(); ++i) { | 687 for (size_t i = 0; i < children_.size(); ++i) { |
678 if (children_[i]->position_constraint_.is_fixed_position() || | 688 if (children_[i]->position_constraint_.is_fixed_position() || |
679 children_[i]->DescendantIsFixedToContainerLayer()) | 689 children_[i]->DescendantIsFixedToContainerLayer()) |
680 return true; | 690 return true; |
681 } | 691 } |
682 return false; | 692 return false; |
683 } | 693 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 | 958 |
949 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 959 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
950 return layer_tree_host_->rendering_stats_instrumentation(); | 960 return layer_tree_host_->rendering_stats_instrumentation(); |
951 } | 961 } |
952 | 962 |
953 bool Layer::SupportsLCDText() const { | 963 bool Layer::SupportsLCDText() const { |
954 return false; | 964 return false; |
955 } | 965 } |
956 | 966 |
957 } // namespace cc | 967 } // namespace cc |
OLD | NEW |