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_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <stack> | 8 #include <stack> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 "LayerTreeHost::SetNeedsCommit::cancel prepaint", | 502 "LayerTreeHost::SetNeedsCommit::cancel prepaint", |
503 TRACE_EVENT_SCOPE_THREAD); | 503 TRACE_EVENT_SCOPE_THREAD); |
504 prepaint_callback_.Cancel(); | 504 prepaint_callback_.Cancel(); |
505 } | 505 } |
506 proxy_->SetNeedsCommit(); | 506 proxy_->SetNeedsCommit(); |
507 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 507 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
508 } | 508 } |
509 | 509 |
510 void LayerTreeHost::SetNeedsFullTreeSync() { | 510 void LayerTreeHost::SetNeedsFullTreeSync() { |
511 needs_full_tree_sync_ = true; | 511 needs_full_tree_sync_ = true; |
| 512 |
| 513 property_trees_.needs_rebuild = true; |
512 SetNeedsCommit(); | 514 SetNeedsCommit(); |
513 } | 515 } |
514 | 516 |
515 void LayerTreeHost::SetNeedsRedraw() { | 517 void LayerTreeHost::SetNeedsRedraw() { |
516 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_)); | 518 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_)); |
517 } | 519 } |
518 | 520 |
519 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 521 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
520 proxy_->SetNeedsRedraw(damage_rect); | 522 proxy_->SetNeedsRedraw(damage_rect); |
521 } | 523 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 "has_trigger", | 621 "has_trigger", |
620 has_gpu_rasterization_trigger_); | 622 has_gpu_rasterization_trigger_); |
621 } | 623 } |
622 | 624 |
623 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { | 625 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { |
624 if (device_viewport_size == device_viewport_size_) | 626 if (device_viewport_size == device_viewport_size_) |
625 return; | 627 return; |
626 | 628 |
627 device_viewport_size_ = device_viewport_size; | 629 device_viewport_size_ = device_viewport_size; |
628 | 630 |
| 631 property_trees_.needs_rebuild = true; |
629 SetNeedsCommit(); | 632 SetNeedsCommit(); |
630 } | 633 } |
631 | 634 |
632 void LayerTreeHost::SetTopControlsHeight(float height, bool shrink) { | 635 void LayerTreeHost::SetTopControlsHeight(float height, bool shrink) { |
633 if (top_controls_height_ == height && | 636 if (top_controls_height_ == height && |
634 top_controls_shrink_blink_size_ == shrink) | 637 top_controls_shrink_blink_size_ == shrink) |
635 return; | 638 return; |
636 | 639 |
637 top_controls_height_ = height; | 640 top_controls_height_ = height; |
638 top_controls_shrink_blink_size_ = shrink; | 641 top_controls_shrink_blink_size_ = shrink; |
639 SetNeedsCommit(); | 642 SetNeedsCommit(); |
640 } | 643 } |
641 | 644 |
642 void LayerTreeHost::SetTopControlsShownRatio(float ratio) { | 645 void LayerTreeHost::SetTopControlsShownRatio(float ratio) { |
643 if (top_controls_shown_ratio_ == ratio) | 646 if (top_controls_shown_ratio_ == ratio) |
644 return; | 647 return; |
645 | 648 |
646 top_controls_shown_ratio_ = ratio; | 649 top_controls_shown_ratio_ = ratio; |
647 SetNeedsCommit(); | 650 SetNeedsCommit(); |
648 } | 651 } |
649 | 652 |
650 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { | 653 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { |
651 DCHECK(CommitRequested()); | 654 DCHECK(CommitRequested()); |
| 655 if (page_scale_delta == 1.f) |
| 656 return; |
652 page_scale_factor_ *= page_scale_delta; | 657 page_scale_factor_ *= page_scale_delta; |
| 658 property_trees_.needs_rebuild = true; |
653 } | 659 } |
654 | 660 |
655 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor, | 661 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor, |
656 float min_page_scale_factor, | 662 float min_page_scale_factor, |
657 float max_page_scale_factor) { | 663 float max_page_scale_factor) { |
658 if (page_scale_factor == page_scale_factor_ && | 664 if (page_scale_factor == page_scale_factor_ && |
659 min_page_scale_factor == min_page_scale_factor_ && | 665 min_page_scale_factor == min_page_scale_factor_ && |
660 max_page_scale_factor == max_page_scale_factor_) | 666 max_page_scale_factor == max_page_scale_factor_) |
661 return; | 667 return; |
662 | 668 |
663 page_scale_factor_ = page_scale_factor; | 669 page_scale_factor_ = page_scale_factor; |
664 min_page_scale_factor_ = min_page_scale_factor; | 670 min_page_scale_factor_ = min_page_scale_factor; |
665 max_page_scale_factor_ = max_page_scale_factor; | 671 max_page_scale_factor_ = max_page_scale_factor; |
| 672 property_trees_.needs_rebuild = true; |
666 SetNeedsCommit(); | 673 SetNeedsCommit(); |
667 } | 674 } |
668 | 675 |
669 void LayerTreeHost::SetVisible(bool visible) { | 676 void LayerTreeHost::SetVisible(bool visible) { |
670 if (visible_ == visible) | 677 if (visible_ == visible) |
671 return; | 678 return; |
672 visible_ = visible; | 679 visible_ = visible; |
673 if (!visible) | 680 if (!visible) |
674 ReduceMemoryUsage(); | 681 ReduceMemoryUsage(); |
675 proxy_->SetVisible(visible); | 682 proxy_->SetVisible(visible); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 hud_layer_->PrepareForCalculateDrawProperties( | 796 hud_layer_->PrepareForCalculateDrawProperties( |
790 device_viewport_size(), device_scale_factor_); | 797 device_viewport_size(), device_scale_factor_); |
791 } | 798 } |
792 | 799 |
793 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps"); | 800 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps"); |
794 bool can_render_to_separate_surface = true; | 801 bool can_render_to_separate_surface = true; |
795 // TODO(vmpstr): Passing 0 as the current render surface layer list id means | 802 // TODO(vmpstr): Passing 0 as the current render surface layer list id means |
796 // that we won't be able to detect if a layer is part of |update_list|. | 803 // that we won't be able to detect if a layer is part of |update_list|. |
797 // Change this if this information is required. | 804 // Change this if this information is required. |
798 int render_surface_layer_list_id = 0; | 805 int render_surface_layer_list_id = 0; |
799 PropertyTrees property_trees; | |
800 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs( | 806 LayerTreeHostCommon::CalcDrawPropsMainInputs inputs( |
801 root_layer, device_viewport_size(), gfx::Transform(), | 807 root_layer, device_viewport_size(), gfx::Transform(), |
802 device_scale_factor_, page_scale_factor_, page_scale_layer, | 808 device_scale_factor_, page_scale_factor_, page_scale_layer, |
803 elastic_overscroll_, overscroll_elasticity_layer_.get(), | 809 elastic_overscroll_, overscroll_elasticity_layer_.get(), |
804 GetRendererCapabilities().max_texture_size, settings_.can_use_lcd_text, | 810 GetRendererCapabilities().max_texture_size, settings_.can_use_lcd_text, |
805 settings_.layers_always_allowed_lcd_text, | 811 settings_.layers_always_allowed_lcd_text, |
806 can_render_to_separate_surface, | 812 can_render_to_separate_surface, |
807 settings_.layer_transforms_should_scale_layer_contents, | 813 settings_.layer_transforms_should_scale_layer_contents, |
808 settings_.verify_property_trees, &update_list, | 814 settings_.verify_property_trees, &update_list, |
809 render_surface_layer_list_id, &property_trees); | 815 render_surface_layer_list_id, &property_trees_); |
810 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 816 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
811 } | 817 } |
812 | 818 |
813 // Reset partial texture update requests. | 819 // Reset partial texture update requests. |
814 partial_texture_update_requests_ = 0; | 820 partial_texture_update_requests_ = 0; |
815 | 821 |
816 bool did_paint_content = false; | 822 bool did_paint_content = false; |
817 bool need_more_updates = false; | 823 bool need_more_updates = false; |
818 PaintLayerContents( | 824 PaintLayerContents( |
819 update_list, queue, &did_paint_content, &need_more_updates); | 825 update_list, queue, &did_paint_content, &need_more_updates); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 | 1118 |
1113 partial_texture_update_requests_++; | 1119 partial_texture_update_requests_++; |
1114 return true; | 1120 return true; |
1115 } | 1121 } |
1116 | 1122 |
1117 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { | 1123 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { |
1118 if (device_scale_factor == device_scale_factor_) | 1124 if (device_scale_factor == device_scale_factor_) |
1119 return; | 1125 return; |
1120 device_scale_factor_ = device_scale_factor; | 1126 device_scale_factor_ = device_scale_factor; |
1121 | 1127 |
| 1128 property_trees_.needs_rebuild = true; |
1122 SetNeedsCommit(); | 1129 SetNeedsCommit(); |
1123 } | 1130 } |
1124 | 1131 |
1125 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 1132 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
1126 TopControlsState current, | 1133 TopControlsState current, |
1127 bool animate) { | 1134 bool animate) { |
1128 // Top controls are only used in threaded mode. | 1135 // Top controls are only used in threaded mode. |
1129 proxy_->ImplThreadTaskRunner()->PostTask( | 1136 proxy_->ImplThreadTaskRunner()->PostTask( |
1130 FROM_HERE, | 1137 FROM_HERE, |
1131 base::Bind(&TopControlsManager::UpdateTopControlsState, | 1138 base::Bind(&TopControlsManager::UpdateTopControlsState, |
1132 top_controls_manager_weak_ptr_, | 1139 top_controls_manager_weak_ptr_, |
1133 constraints, | 1140 constraints, |
1134 current, | 1141 current, |
1135 animate)); | 1142 animate)); |
1136 } | 1143 } |
1137 | 1144 |
1138 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1145 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
1139 if (!settings_.accelerated_animation_enabled) | 1146 if (!settings_.accelerated_animation_enabled) |
1140 return; | 1147 return; |
1141 | 1148 |
1142 if (animation_registrar_->AnimateLayers(monotonic_time)) | 1149 AnimationEventsVector events; |
1143 animation_registrar_->UpdateAnimationState(true, NULL); | 1150 if (animation_registrar_->AnimateLayers(monotonic_time)) { |
| 1151 animation_registrar_->UpdateAnimationState(true, &events); |
| 1152 if (!events.empty()) |
| 1153 property_trees_.needs_rebuild = true; |
| 1154 } |
1144 } | 1155 } |
1145 | 1156 |
1146 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 1157 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
1147 DCHECK(client); | 1158 DCHECK(client); |
1148 | 1159 |
1149 UIResourceId next_id = next_ui_resource_id_++; | 1160 UIResourceId next_id = next_ui_resource_id_++; |
1150 DCHECK(ui_resource_client_map_.find(next_id) == | 1161 DCHECK(ui_resource_client_map_.find(next_id) == |
1151 ui_resource_client_map_.end()); | 1162 ui_resource_client_map_.end()); |
1152 | 1163 |
1153 bool resource_lost = false; | 1164 bool resource_lost = false; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 const BeginFrameArgs& args) const { | 1284 const BeginFrameArgs& args) const { |
1274 client_->SendBeginFramesToChildren(args); | 1285 client_->SendBeginFramesToChildren(args); |
1275 } | 1286 } |
1276 | 1287 |
1277 void LayerTreeHost::SetAuthoritativeVSyncInterval( | 1288 void LayerTreeHost::SetAuthoritativeVSyncInterval( |
1278 const base::TimeDelta& interval) { | 1289 const base::TimeDelta& interval) { |
1279 proxy_->SetAuthoritativeVSyncInterval(interval); | 1290 proxy_->SetAuthoritativeVSyncInterval(interval); |
1280 } | 1291 } |
1281 | 1292 |
1282 } // namespace cc | 1293 } // namespace cc |
OLD | NEW |