| 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool LayerTreeHost::CommitRequested() const { | 537 bool LayerTreeHost::CommitRequested() const { |
| 538 return proxy_->CommitRequested(); | 538 return proxy_->CommitRequested(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 bool LayerTreeHost::BeginMainFrameRequested() const { | 541 bool LayerTreeHost::BeginMainFrameRequested() const { |
| 542 return proxy_->BeginMainFrameRequested(); | 542 return proxy_->BeginMainFrameRequested(); |
| 543 } | 543 } |
| 544 | 544 |
| 545 | |
| 546 void LayerTreeHost::SetNextCommitWaitsForActivation() { | 545 void LayerTreeHost::SetNextCommitWaitsForActivation() { |
| 547 proxy_->SetNextCommitWaitsForActivation(); | 546 proxy_->SetNextCommitWaitsForActivation(); |
| 548 } | 547 } |
| 549 | 548 |
| 550 void LayerTreeHost::SetNextCommitForcesRedraw() { | 549 void LayerTreeHost::SetNextCommitForcesRedraw() { |
| 551 next_commit_forces_redraw_ = true; | 550 next_commit_forces_redraw_ = true; |
| 552 proxy_->SetNeedsUpdateLayers(); | 551 proxy_->SetNeedsUpdateLayers(); |
| 553 } | 552 } |
| 554 | 553 |
| 555 void LayerTreeHost::SetAnimationEvents( | 554 void LayerTreeHost::SetAnimationEvents( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 debug_state_.RecordRenderingStats()); | 596 debug_state_.RecordRenderingStats()); |
| 598 | 597 |
| 599 SetNeedsCommit(); | 598 SetNeedsCommit(); |
| 600 } | 599 } |
| 601 | 600 |
| 602 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { | 601 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { |
| 603 if (has_trigger == has_gpu_rasterization_trigger_) | 602 if (has_trigger == has_gpu_rasterization_trigger_) |
| 604 return; | 603 return; |
| 605 | 604 |
| 606 has_gpu_rasterization_trigger_ = has_trigger; | 605 has_gpu_rasterization_trigger_ = has_trigger; |
| 607 TRACE_EVENT_INSTANT1("cc", | 606 TRACE_EVENT_INSTANT1("cc", "LayerTreeHost::SetHasGpuRasterizationTrigger", |
| 608 "LayerTreeHost::SetHasGpuRasterizationTrigger", | 607 TRACE_EVENT_SCOPE_THREAD, "has_trigger", |
| 609 TRACE_EVENT_SCOPE_THREAD, | |
| 610 "has_trigger", | |
| 611 has_gpu_rasterization_trigger_); | 608 has_gpu_rasterization_trigger_); |
| 612 } | 609 } |
| 613 | 610 |
| 614 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { | 611 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { |
| 615 if (device_viewport_size == device_viewport_size_) | 612 if (device_viewport_size == device_viewport_size_) |
| 616 return; | 613 return; |
| 617 | 614 |
| 618 device_viewport_size_ = device_viewport_size; | 615 device_viewport_size_ = device_viewport_size; |
| 619 | 616 |
| 620 SetPropertyTreesNeedRebuild(); | 617 SetPropertyTreesNeedRebuild(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 667 } |
| 671 | 668 |
| 672 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { | 669 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { |
| 673 proxy_->SetThrottleFrameProduction(throttle); | 670 proxy_->SetThrottleFrameProduction(throttle); |
| 674 } | 671 } |
| 675 | 672 |
| 676 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d& target_offset, | 673 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d& target_offset, |
| 677 bool use_anchor, | 674 bool use_anchor, |
| 678 float scale, | 675 float scale, |
| 679 base::TimeDelta duration) { | 676 base::TimeDelta duration) { |
| 680 pending_page_scale_animation_.reset( | 677 pending_page_scale_animation_.reset(new PendingPageScaleAnimation( |
| 681 new PendingPageScaleAnimation( | 678 target_offset, use_anchor, scale, duration)); |
| 682 target_offset, | |
| 683 use_anchor, | |
| 684 scale, | |
| 685 duration)); | |
| 686 | 679 |
| 687 SetNeedsCommit(); | 680 SetNeedsCommit(); |
| 688 } | 681 } |
| 689 | 682 |
| 690 void LayerTreeHost::NotifyInputThrottledUntilCommit() { | 683 void LayerTreeHost::NotifyInputThrottledUntilCommit() { |
| 691 proxy_->NotifyInputThrottledUntilCommit(); | 684 proxy_->NotifyInputThrottledUntilCommit(); |
| 692 } | 685 } |
| 693 | 686 |
| 694 void LayerTreeHost::LayoutAndUpdateLayers() { | 687 void LayerTreeHost::LayoutAndUpdateLayers() { |
| 695 DCHECK(IsSingleThreaded()); | 688 DCHECK(IsSingleThreaded()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 837 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
| 845 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( | 838 Layer* layer = LayerTreeHostCommon::FindLayerInSubtree( |
| 846 root_layer_.get(), info->scrolls[i].layer_id); | 839 root_layer_.get(), info->scrolls[i].layer_id); |
| 847 if (!layer) | 840 if (!layer) |
| 848 continue; | 841 continue; |
| 849 if (layer == outer_viewport_scroll_layer_.get()) { | 842 if (layer == outer_viewport_scroll_layer_.get()) { |
| 850 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta; | 843 outer_viewport_scroll_delta += info->scrolls[i].scroll_delta; |
| 851 } else if (layer == inner_viewport_scroll_layer_.get()) { | 844 } else if (layer == inner_viewport_scroll_layer_.get()) { |
| 852 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta; | 845 inner_viewport_scroll_delta += info->scrolls[i].scroll_delta; |
| 853 } else { | 846 } else { |
| 854 layer->SetScrollOffsetFromImplSide( | 847 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( |
| 855 gfx::ScrollOffsetWithDelta(layer->scroll_offset(), | 848 layer->scroll_offset(), info->scrolls[i].scroll_delta)); |
| 856 info->scrolls[i].scroll_delta)); | |
| 857 } | 849 } |
| 858 SetNeedsUpdateLayers(); | 850 SetNeedsUpdateLayers(); |
| 859 } | 851 } |
| 860 } | 852 } |
| 861 | 853 |
| 862 if (!inner_viewport_scroll_delta.IsZero() || | 854 if (!inner_viewport_scroll_delta.IsZero() || |
| 863 !outer_viewport_scroll_delta.IsZero() || info->page_scale_delta != 1.f || | 855 !outer_viewport_scroll_delta.IsZero() || info->page_scale_delta != 1.f || |
| 864 !info->elastic_overscroll_delta.IsZero() || info->top_controls_delta) { | 856 !info->elastic_overscroll_delta.IsZero() || info->top_controls_delta) { |
| 865 // Preemptively apply the scroll offset and scale delta here before sending | 857 // Preemptively apply the scroll offset and scale delta here before sending |
| 866 // it to the client. If the client comes back and sets it to the same | 858 // it to the client. If the client comes back and sets it to the same |
| (...skipping 17 matching lines...) Expand all Loading... |
| 884 // TODO(ccameron): pass the elastic overscroll here so that input events | 876 // TODO(ccameron): pass the elastic overscroll here so that input events |
| 885 // may be translated appropriately. | 877 // may be translated appropriately. |
| 886 client_->ApplyViewportDeltas( | 878 client_->ApplyViewportDeltas( |
| 887 inner_viewport_scroll_delta, outer_viewport_scroll_delta, | 879 inner_viewport_scroll_delta, outer_viewport_scroll_delta, |
| 888 info->elastic_overscroll_delta, info->page_scale_delta, | 880 info->elastic_overscroll_delta, info->page_scale_delta, |
| 889 info->top_controls_delta); | 881 info->top_controls_delta); |
| 890 SetNeedsUpdateLayers(); | 882 SetNeedsUpdateLayers(); |
| 891 } | 883 } |
| 892 } | 884 } |
| 893 | 885 |
| 886 void LayerTreeHost::ApplyMutations(LayerTreeMutationMap* mutations) { |
| 887 if (mutations) { |
| 888 TRACE_EVENT0("compositor-worker", "LayerTreeHost::ApplyMutations"); |
| 889 client_->ApplyMutations(*mutations); |
| 890 } |
| 891 } |
| 892 |
| 894 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { | 893 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { |
| 895 if (device_scale_factor == device_scale_factor_) | 894 if (device_scale_factor == device_scale_factor_) |
| 896 return; | 895 return; |
| 897 device_scale_factor_ = device_scale_factor; | 896 device_scale_factor_ = device_scale_factor; |
| 898 | 897 |
| 899 property_trees_.needs_rebuild = true; | 898 property_trees_.needs_rebuild = true; |
| 900 SetNeedsCommit(); | 899 SetNeedsCommit(); |
| 901 } | 900 } |
| 902 | 901 |
| 903 void LayerTreeHost::SetPaintedDeviceScaleFactor( | 902 void LayerTreeHost::SetPaintedDeviceScaleFactor( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 if (iter == ui_resource_client_map_.end()) | 959 if (iter == ui_resource_client_map_.end()) |
| 961 return; | 960 return; |
| 962 | 961 |
| 963 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_DELETE, uid); | 962 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_DELETE, uid); |
| 964 ui_resource_request_queue_.push_back(request); | 963 ui_resource_request_queue_.push_back(request); |
| 965 ui_resource_client_map_.erase(iter); | 964 ui_resource_client_map_.erase(iter); |
| 966 } | 965 } |
| 967 | 966 |
| 968 void LayerTreeHost::RecreateUIResources() { | 967 void LayerTreeHost::RecreateUIResources() { |
| 969 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); | 968 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); |
| 970 iter != ui_resource_client_map_.end(); | 969 iter != ui_resource_client_map_.end(); ++iter) { |
| 971 ++iter) { | |
| 972 UIResourceId uid = iter->first; | 970 UIResourceId uid = iter->first; |
| 973 const UIResourceClientData& data = iter->second; | 971 const UIResourceClientData& data = iter->second; |
| 974 bool resource_lost = true; | 972 bool resource_lost = true; |
| 975 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_CREATE, uid, | 973 UIResourceRequest request(UIResourceRequest::UI_RESOURCE_CREATE, uid, |
| 976 data.client->GetBitmap(uid, resource_lost)); | 974 data.client->GetBitmap(uid, resource_lost)); |
| 977 ui_resource_request_queue_.push_back(request); | 975 ui_resource_request_queue_.push_back(request); |
| 978 } | 976 } |
| 979 } | 977 } |
| 980 | 978 |
| 981 // Returns the size of a resource given its id. | 979 // Returns the size of a resource given its id. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 proxy_->SetAuthoritativeVSyncInterval(interval); | 1073 proxy_->SetAuthoritativeVSyncInterval(interval); |
| 1076 } | 1074 } |
| 1077 | 1075 |
| 1078 void LayerTreeHost::RecordFrameTimingEvents( | 1076 void LayerTreeHost::RecordFrameTimingEvents( |
| 1079 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1077 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 1080 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1078 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
| 1081 client_->RecordFrameTimingEvents(std::move(composite_events), | 1079 client_->RecordFrameTimingEvents(std::move(composite_events), |
| 1082 std::move(main_frame_events)); | 1080 std::move(main_frame_events)); |
| 1083 } | 1081 } |
| 1084 | 1082 |
| 1083 void LayerTreeHost::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
| 1084 TRACE_EVENT0("compositor-worker", "LayerTreeHost::SetLayerTreeMutator"); |
| 1085 proxy_->SetMutator(mutator); |
| 1086 } |
| 1087 |
| 1085 Layer* LayerTreeHost::LayerById(int id) const { | 1088 Layer* LayerTreeHost::LayerById(int id) const { |
| 1086 LayerIdMap::const_iterator iter = layer_id_map_.find(id); | 1089 LayerIdMap::const_iterator iter = layer_id_map_.find(id); |
| 1087 return iter != layer_id_map_.end() ? iter->second : NULL; | 1090 return iter != layer_id_map_.end() ? iter->second : NULL; |
| 1088 } | 1091 } |
| 1089 | 1092 |
| 1090 void LayerTreeHost::RegisterLayer(Layer* layer) { | 1093 void LayerTreeHost::RegisterLayer(Layer* layer) { |
| 1091 DCHECK(!LayerById(layer->id())); | 1094 DCHECK(!LayerById(layer->id())); |
| 1092 DCHECK(!in_paint_layer_contents_); | 1095 DCHECK(!in_paint_layer_contents_); |
| 1093 layer_id_map_[layer->id()] = layer; | 1096 layer_id_map_[layer->id()] = layer; |
| 1094 if (animation_host_) | 1097 if (animation_host_) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 return compositor_mode_ == CompositorMode::SingleThreaded; | 1273 return compositor_mode_ == CompositorMode::SingleThreaded; |
| 1271 } | 1274 } |
| 1272 | 1275 |
| 1273 bool LayerTreeHost::IsThreaded() const { | 1276 bool LayerTreeHost::IsThreaded() const { |
| 1274 DCHECK(compositor_mode_ != CompositorMode::Threaded || | 1277 DCHECK(compositor_mode_ != CompositorMode::Threaded || |
| 1275 task_runner_provider_->HasImplThread()); | 1278 task_runner_provider_->HasImplThread()); |
| 1276 return compositor_mode_ == CompositorMode::Threaded; | 1279 return compositor_mode_ == CompositorMode::Threaded; |
| 1277 } | 1280 } |
| 1278 | 1281 |
| 1279 } // namespace cc | 1282 } // namespace cc |
| OLD | NEW |