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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 | 562 |
563 bool LayerTreeHost::CommitRequested() const { | 563 bool LayerTreeHost::CommitRequested() const { |
564 return proxy_->CommitRequested(); | 564 return proxy_->CommitRequested(); |
565 } | 565 } |
566 | 566 |
567 bool LayerTreeHost::BeginMainFrameRequested() const { | 567 bool LayerTreeHost::BeginMainFrameRequested() const { |
568 return proxy_->BeginMainFrameRequested(); | 568 return proxy_->BeginMainFrameRequested(); |
569 } | 569 } |
570 | 570 |
571 | |
572 void LayerTreeHost::SetNextCommitWaitsForActivation() { | 571 void LayerTreeHost::SetNextCommitWaitsForActivation() { |
573 proxy_->SetNextCommitWaitsForActivation(); | 572 proxy_->SetNextCommitWaitsForActivation(); |
574 } | 573 } |
575 | 574 |
576 void LayerTreeHost::SetNextCommitForcesRedraw() { | 575 void LayerTreeHost::SetNextCommitForcesRedraw() { |
577 next_commit_forces_redraw_ = true; | 576 next_commit_forces_redraw_ = true; |
578 proxy_->SetNeedsUpdateLayers(); | 577 proxy_->SetNeedsUpdateLayers(); |
579 } | 578 } |
580 | 579 |
581 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEvents> events) { | 580 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEvents> events) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 debug_state_.RecordRenderingStats()); | 621 debug_state_.RecordRenderingStats()); |
623 | 622 |
624 SetNeedsCommit(); | 623 SetNeedsCommit(); |
625 } | 624 } |
626 | 625 |
627 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { | 626 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { |
628 if (has_trigger == has_gpu_rasterization_trigger_) | 627 if (has_trigger == has_gpu_rasterization_trigger_) |
629 return; | 628 return; |
630 | 629 |
631 has_gpu_rasterization_trigger_ = has_trigger; | 630 has_gpu_rasterization_trigger_ = has_trigger; |
632 TRACE_EVENT_INSTANT1("cc", | 631 TRACE_EVENT_INSTANT1("cc", "LayerTreeHost::SetHasGpuRasterizationTrigger", |
633 "LayerTreeHost::SetHasGpuRasterizationTrigger", | 632 TRACE_EVENT_SCOPE_THREAD, "has_trigger", |
634 TRACE_EVENT_SCOPE_THREAD, | |
635 "has_trigger", | |
636 has_gpu_rasterization_trigger_); | 633 has_gpu_rasterization_trigger_); |
637 } | 634 } |
638 | 635 |
639 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { | 636 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { |
640 if (device_viewport_size == device_viewport_size_) | 637 if (device_viewport_size == device_viewport_size_) |
641 return; | 638 return; |
642 | 639 |
643 device_viewport_size_ = device_viewport_size; | 640 device_viewport_size_ = device_viewport_size; |
644 | 641 |
645 SetPropertyTreesNeedRebuild(); | 642 SetPropertyTreesNeedRebuild(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 } | 692 } |
696 | 693 |
697 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { | 694 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { |
698 proxy_->SetThrottleFrameProduction(throttle); | 695 proxy_->SetThrottleFrameProduction(throttle); |
699 } | 696 } |
700 | 697 |
701 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d& target_offset, | 698 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d& target_offset, |
702 bool use_anchor, | 699 bool use_anchor, |
703 float scale, | 700 float scale, |
704 base::TimeDelta duration) { | 701 base::TimeDelta duration) { |
705 pending_page_scale_animation_.reset( | 702 pending_page_scale_animation_.reset(new PendingPageScaleAnimation( |
706 new PendingPageScaleAnimation( | 703 target_offset, use_anchor, scale, duration)); |
707 target_offset, | |
708 use_anchor, | |
709 scale, | |
710 duration)); | |
711 | 704 |
712 SetNeedsCommit(); | 705 SetNeedsCommit(); |
713 } | 706 } |
714 | 707 |
715 void LayerTreeHost::NotifyInputThrottledUntilCommit() { | 708 void LayerTreeHost::NotifyInputThrottledUntilCommit() { |
716 proxy_->NotifyInputThrottledUntilCommit(); | 709 proxy_->NotifyInputThrottledUntilCommit(); |
717 } | 710 } |
718 | 711 |
719 void LayerTreeHost::LayoutAndUpdateLayers() { | 712 void LayerTreeHost::LayoutAndUpdateLayers() { |
720 DCHECK(IsSingleThreaded()); | 713 DCHECK(IsSingleThreaded()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 862 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
870 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( | 863 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( |
871 root_layer_.get(), info->scrolls[i].layer_id); | 864 root_layer_.get(), info->scrolls[i].layer_id); |
872 if (!layer) | 865 if (!layer) |
873 continue; | 866 continue; |
874 if (layer == outer_viewport_scroll_layer_.get()) { | 867 if (layer == outer_viewport_scroll_layer_.get()) { |
875 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta; | 868 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta; |
876 } else if (layer == inner_viewport_scroll_layer_.get()) { | 869 } else if (layer == inner_viewport_scroll_layer_.get()) { |
877 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta; | 870 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta; |
878 } else { | 871 } else { |
879 layer->SetScrollOffsetFromImplSide( | 872 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( |
880 gfx::ScrollOffsetWithDelta(layer->scroll_offset(), | 873 layer->scroll_offset(), info->scrolls[i].scroll_delta)); |
881 info->scrolls[i].scroll_delta)); | |
882 } | 874 } |
883 SetNeedsUpdateLayers(); | 875 SetNeedsUpdateLayers(); |
884 } | 876 } |
885 } | 877 } |
886 | 878 |
887 if (!inner_viewport_scroll_delta.IsZero() || | 879 if (!inner_viewport_scroll_delta.IsZero() || |
888 !outer_viewport_scroll_delta.IsZero() || info->page_scale_delta != 1.f || | 880 !outer_viewport_scroll_delta.IsZero() || info->page_scale_delta != 1.f || |
889 !info->elastic_overscroll_delta.IsZero() || info->top_controls_delta) { | 881 !info->elastic_overscroll_delta.IsZero() || info->top_controls_delta) { |
890 // Preemptively apply the scroll offset and scale delta here before sending | 882 // Preemptively apply the scroll offset and scale delta here before sending |
891 // it to the client. If the client comes back and sets it to the same | 883 // it to the client. If the client comes back and sets it to the same |
(...skipping 17 matching lines...) Expand all Loading... |
909 // TODO(ccameron): pass the elastic overscroll here so that input events | 901 // TODO(ccameron): pass the elastic overscroll here so that input events |
910 // may be translated appropriately. | 902 // may be translated appropriately. |
911 client_->ApplyViewportDeltas( | 903 client_->ApplyViewportDeltas( |
912 inner_viewport_scroll_delta, outer_viewport_scroll_delta, | 904 inner_viewport_scroll_delta, outer_viewport_scroll_delta, |
913 info->elastic_overscroll_delta, info->page_scale_delta, | 905 info->elastic_overscroll_delta, info->page_scale_delta, |
914 info->top_controls_delta); | 906 info->top_controls_delta); |
915 SetNeedsUpdateLayers(); | 907 SetNeedsUpdateLayers(); |
916 } | 908 } |
917 } | 909 } |
918 | 910 |
| 911 void LayerTreeHost::ApplyMutations(LayerTreeMutations* mutations) { |
| 912 if (mutations) { |
| 913 TRACE_EVENT0("compositor-worker", "LayerTreeHost::ApplyMutations"); |
| 914 client_->ApplyMutations(*mutations); |
| 915 } |
| 916 } |
| 917 |
919 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { | 918 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { |
920 if (device_scale_factor == device_scale_factor_) | 919 if (device_scale_factor == device_scale_factor_) |
921 return; | 920 return; |
922 device_scale_factor_ = device_scale_factor; | 921 device_scale_factor_ = device_scale_factor; |
923 | 922 |
924 property_trees_.needs_rebuild = true; | 923 property_trees_.needs_rebuild = true; |
925 SetNeedsCommit(); | 924 SetNeedsCommit(); |
926 } | 925 } |
927 | 926 |
928 void LayerTreeHost::SetPaintedDeviceScaleFactor( | 927 void LayerTreeHost::SetPaintedDeviceScaleFactor( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 if (iter == ui_resource_client_map_.end()) | 986 if (iter == ui_resource_client_map_.end()) |
988 return; | 987 return; |
989 | 988 |
990 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_DELETE, uid); | 989 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_DELETE, uid); |
991 ui_resource_request_queue_.push_back(request); | 990 ui_resource_request_queue_.push_back(request); |
992 ui_resource_client_map_.erase(iter); | 991 ui_resource_client_map_.erase(iter); |
993 } | 992 } |
994 | 993 |
995 void LayerTreeHost::RecreateUIResources() { | 994 void LayerTreeHost::RecreateUIResources() { |
996 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); | 995 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); |
997 iter != ui_resource_client_map_.end(); | 996 iter != ui_resource_client_map_.end(); ++iter) { |
998 ++iter) { | |
999 UIResourceId uid = iter->first; | 997 UIResourceId uid = iter->first; |
1000 const UIResourceClientData& data = iter->second; | 998 const UIResourceClientData& data = iter->second; |
1001 bool resource_lost = true; | 999 bool resource_lost = true; |
1002 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_CREATE, uid, | 1000 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_CREATE, uid, |
1003 data.client->GetBitmap(uid, resource_lost)); | 1001 data.client->GetBitmap(uid, resource_lost)); |
1004 ui_resource_request_queue_.push_back(request); | 1002 ui_resource_request_queue_.push_back(request); |
1005 } | 1003 } |
1006 } | 1004 } |
1007 | 1005 |
1008 // Returns the size of a resource given its id. | 1006 // Returns the size of a resource given its id. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 proxy_->SetAuthoritativeVSyncInterval(interval); | 1100 proxy_->SetAuthoritativeVSyncInterval(interval); |
1103 } | 1101 } |
1104 | 1102 |
1105 void LayerTreeHost::RecordFrameTimingEvents( | 1103 void LayerTreeHost::RecordFrameTimingEvents( |
1106 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1104 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
1107 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1105 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
1108 client_->RecordFrameTimingEvents(std::move(composite_events), | 1106 client_->RecordFrameTimingEvents(std::move(composite_events), |
1109 std::move(main_frame_events)); | 1107 std::move(main_frame_events)); |
1110 } | 1108 } |
1111 | 1109 |
| 1110 void LayerTreeHost::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
| 1111 TRACE_EVENT0("compositor-worker", "LayerTreeHost::SetLayerTreeMutator"); |
| 1112 proxy_->SetMutator(mutator); |
| 1113 } |
| 1114 |
1112 Layer* LayerTreeHost::LayerById(int id) const { | 1115 Layer* LayerTreeHost::LayerById(int id) const { |
1113 LayerIdMap::const_iterator iter = layer_id_map_.find(id); | 1116 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
1114 return iter != layer_id_map_.end() ? iter->second : NULL; | 1117 return iter != layer_id_map_.end() ? iter->second : NULL; |
1115 } | 1118 } |
1116 | 1119 |
1117 void LayerTreeHost::RegisterLayer(Layer* layer) { | 1120 void LayerTreeHost::RegisterLayer(Layer* layer) { |
1118 DCHECK(!LayerById(layer->id())); | 1121 DCHECK(!LayerById(layer->id())); |
1119 DCHECK(!in_paint_layer_contents_); | 1122 DCHECK(!in_paint_layer_contents_); |
1120 layer_id_map_[layer->id()] = layer; | 1123 layer_id_map_[layer->id()] = layer; |
1121 if (animation_host_) | 1124 if (animation_host_) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 | 1439 |
1437 // It is required to create new PropertyTrees before deserializing it. | 1440 // It is required to create new PropertyTrees before deserializing it. |
1438 property_trees_ = PropertyTrees(); | 1441 property_trees_ = PropertyTrees(); |
1439 property_trees_.FromProtobuf(proto.property_trees()); | 1442 property_trees_.FromProtobuf(proto.property_trees()); |
1440 | 1443 |
1441 surface_id_namespace_ = proto.surface_id_namespace(); | 1444 surface_id_namespace_ = proto.surface_id_namespace(); |
1442 next_surface_sequence_ = proto.next_surface_sequence(); | 1445 next_surface_sequence_ = proto.next_surface_sequence(); |
1443 } | 1446 } |
1444 | 1447 |
1445 } // namespace cc | 1448 } // namespace cc |
OLD | NEW |