OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 656 |
657 void RenderWidgetCompositor::SetNeedsCommit() { | 657 void RenderWidgetCompositor::SetNeedsCommit() { |
658 layer_tree_host_->SetNeedsCommit(); | 658 layer_tree_host_->SetNeedsCommit(); |
659 } | 659 } |
660 | 660 |
661 void RenderWidgetCompositor::NotifyInputThrottledUntilCommit() { | 661 void RenderWidgetCompositor::NotifyInputThrottledUntilCommit() { |
662 layer_tree_host_->NotifyInputThrottledUntilCommit(); | 662 layer_tree_host_->NotifyInputThrottledUntilCommit(); |
663 } | 663 } |
664 | 664 |
665 const cc::Layer* RenderWidgetCompositor::GetRootLayer() const { | 665 const cc::Layer* RenderWidgetCompositor::GetRootLayer() const { |
666 return layer_tree_host_->root_layer(); | 666 return layer_tree_host_->GetLayerTree()->root_layer(); |
667 } | 667 } |
668 | 668 |
669 int RenderWidgetCompositor::ScheduleMicroBenchmark( | 669 int RenderWidgetCompositor::ScheduleMicroBenchmark( |
670 const std::string& name, | 670 const std::string& name, |
671 std::unique_ptr<base::Value> value, | 671 std::unique_ptr<base::Value> value, |
672 const base::Callback<void(std::unique_ptr<base::Value>)>& callback) { | 672 const base::Callback<void(std::unique_ptr<base::Value>)>& callback) { |
673 return layer_tree_host_->ScheduleMicroBenchmark(name, std::move(value), | 673 return layer_tree_host_->ScheduleMicroBenchmark(name, std::move(value), |
674 callback); | 674 callback); |
675 } | 675 } |
676 | 676 |
677 bool RenderWidgetCompositor::SendMessageToMicroBenchmark( | 677 bool RenderWidgetCompositor::SendMessageToMicroBenchmark( |
678 int id, | 678 int id, |
679 std::unique_ptr<base::Value> value) { | 679 std::unique_ptr<base::Value> value) { |
680 return layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(value)); | 680 return layer_tree_host_->SendMessageToMicroBenchmark(id, std::move(value)); |
681 } | 681 } |
682 | 682 |
683 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { | 683 void RenderWidgetCompositor::setRootLayer(const blink::WebLayer& layer) { |
684 layer_tree_host_->SetRootLayer( | 684 layer_tree_host_->GetLayerTree()->SetRootLayer( |
685 static_cast<const cc_blink::WebLayerImpl*>(&layer)->layer()); | 685 static_cast<const cc_blink::WebLayerImpl*>(&layer)->layer()); |
686 } | 686 } |
687 | 687 |
688 void RenderWidgetCompositor::clearRootLayer() { | 688 void RenderWidgetCompositor::clearRootLayer() { |
689 layer_tree_host_->SetRootLayer(scoped_refptr<cc::Layer>()); | 689 layer_tree_host_->GetLayerTree()->SetRootLayer(scoped_refptr<cc::Layer>()); |
690 } | 690 } |
691 | 691 |
692 void RenderWidgetCompositor::attachCompositorAnimationTimeline( | 692 void RenderWidgetCompositor::attachCompositorAnimationTimeline( |
693 cc::AnimationTimeline* compositor_timeline) { | 693 cc::AnimationTimeline* compositor_timeline) { |
694 DCHECK(layer_tree_host_->animation_host()); | 694 DCHECK(layer_tree_host_->animation_host()); |
695 layer_tree_host_->animation_host()->AddAnimationTimeline(compositor_timeline); | 695 layer_tree_host_->animation_host()->AddAnimationTimeline(compositor_timeline); |
696 } | 696 } |
697 | 697 |
698 void RenderWidgetCompositor::detachCompositorAnimationTimeline( | 698 void RenderWidgetCompositor::detachCompositorAnimationTimeline( |
699 cc::AnimationTimeline* compositor_timeline) { | 699 cc::AnimationTimeline* compositor_timeline) { |
700 DCHECK(layer_tree_host_->animation_host()); | 700 DCHECK(layer_tree_host_->animation_host()); |
701 layer_tree_host_->animation_host()->RemoveAnimationTimeline( | 701 layer_tree_host_->animation_host()->RemoveAnimationTimeline( |
702 compositor_timeline); | 702 compositor_timeline); |
703 } | 703 } |
704 | 704 |
705 void RenderWidgetCompositor::setViewportSize( | 705 void RenderWidgetCompositor::setViewportSize( |
706 const WebSize& device_viewport_size) { | 706 const WebSize& device_viewport_size) { |
707 layer_tree_host_->SetViewportSize(device_viewport_size); | 707 layer_tree_host_->GetLayerTree()->SetViewportSize(device_viewport_size); |
708 } | 708 } |
709 | 709 |
710 WebFloatPoint RenderWidgetCompositor::adjustEventPointForPinchZoom( | 710 WebFloatPoint RenderWidgetCompositor::adjustEventPointForPinchZoom( |
711 const WebFloatPoint& point) const { | 711 const WebFloatPoint& point) const { |
712 return point; | 712 return point; |
713 } | 713 } |
714 | 714 |
715 void RenderWidgetCompositor::setDeviceScaleFactor(float device_scale) { | 715 void RenderWidgetCompositor::setDeviceScaleFactor(float device_scale) { |
716 layer_tree_host_->SetDeviceScaleFactor(device_scale); | 716 layer_tree_host_->GetLayerTree()->SetDeviceScaleFactor(device_scale); |
717 } | 717 } |
718 | 718 |
719 void RenderWidgetCompositor::setBackgroundColor(blink::WebColor color) { | 719 void RenderWidgetCompositor::setBackgroundColor(blink::WebColor color) { |
720 layer_tree_host_->set_background_color(color); | 720 layer_tree_host_->GetLayerTree()->set_background_color(color); |
721 } | 721 } |
722 | 722 |
723 void RenderWidgetCompositor::setHasTransparentBackground(bool transparent) { | 723 void RenderWidgetCompositor::setHasTransparentBackground(bool transparent) { |
724 layer_tree_host_->set_has_transparent_background(transparent); | 724 layer_tree_host_->GetLayerTree()->set_has_transparent_background(transparent); |
725 } | 725 } |
726 | 726 |
727 void RenderWidgetCompositor::setVisible(bool visible) { | 727 void RenderWidgetCompositor::setVisible(bool visible) { |
728 if (never_visible_) | 728 if (never_visible_) |
729 return; | 729 return; |
730 | 730 |
731 layer_tree_host_->SetVisible(visible); | 731 layer_tree_host_->SetVisible(visible); |
732 } | 732 } |
733 | 733 |
734 void RenderWidgetCompositor::setPageScaleFactorAndLimits( | 734 void RenderWidgetCompositor::setPageScaleFactorAndLimits( |
735 float page_scale_factor, float minimum, float maximum) { | 735 float page_scale_factor, float minimum, float maximum) { |
736 layer_tree_host_->SetPageScaleFactorAndLimits( | 736 layer_tree_host_->GetLayerTree()->SetPageScaleFactorAndLimits( |
737 page_scale_factor, minimum, maximum); | 737 page_scale_factor, minimum, maximum); |
738 } | 738 } |
739 | 739 |
740 void RenderWidgetCompositor::startPageScaleAnimation( | 740 void RenderWidgetCompositor::startPageScaleAnimation( |
741 const blink::WebPoint& destination, | 741 const blink::WebPoint& destination, |
742 bool use_anchor, | 742 bool use_anchor, |
743 float new_page_scale, | 743 float new_page_scale, |
744 double duration_sec) { | 744 double duration_sec) { |
745 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( | 745 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( |
746 duration_sec * base::Time::kMicrosecondsPerSecond); | 746 duration_sec * base::Time::kMicrosecondsPerSecond); |
747 layer_tree_host_->StartPageScaleAnimation( | 747 layer_tree_host_->GetLayerTree()->StartPageScaleAnimation( |
748 gfx::Vector2d(destination.x, destination.y), | 748 gfx::Vector2d(destination.x, destination.y), use_anchor, new_page_scale, |
749 use_anchor, | |
750 new_page_scale, | |
751 duration); | 749 duration); |
752 } | 750 } |
753 | 751 |
754 bool RenderWidgetCompositor::hasPendingPageScaleAnimation() const { | 752 bool RenderWidgetCompositor::hasPendingPageScaleAnimation() const { |
755 return layer_tree_host_->HasPendingPageScaleAnimation(); | 753 return layer_tree_host_->GetLayerTree()->HasPendingPageScaleAnimation(); |
756 } | 754 } |
757 | 755 |
758 void RenderWidgetCompositor::heuristicsForGpuRasterizationUpdated( | 756 void RenderWidgetCompositor::heuristicsForGpuRasterizationUpdated( |
759 bool matches_heuristics) { | 757 bool matches_heuristics) { |
760 layer_tree_host_->SetHasGpuRasterizationTrigger(matches_heuristics); | 758 layer_tree_host_->SetHasGpuRasterizationTrigger(matches_heuristics); |
761 } | 759 } |
762 | 760 |
763 void RenderWidgetCompositor::setNeedsAnimate() { | 761 void RenderWidgetCompositor::setNeedsAnimate() { |
764 layer_tree_host_->SetNeedsAnimate(); | 762 layer_tree_host_->SetNeedsAnimate(); |
765 layer_tree_host_->SetNeedsUpdateLayers(); | 763 layer_tree_host_->SetNeedsUpdateLayers(); |
766 } | 764 } |
767 | 765 |
768 void RenderWidgetCompositor::setNeedsBeginFrame() { | 766 void RenderWidgetCompositor::setNeedsBeginFrame() { |
769 layer_tree_host_->SetNeedsAnimate(); | 767 layer_tree_host_->SetNeedsAnimate(); |
770 } | 768 } |
771 | 769 |
772 void RenderWidgetCompositor::setNeedsCompositorUpdate() { | 770 void RenderWidgetCompositor::setNeedsCompositorUpdate() { |
773 layer_tree_host_->SetNeedsUpdateLayers(); | 771 layer_tree_host_->SetNeedsUpdateLayers(); |
774 } | 772 } |
775 | 773 |
776 void RenderWidgetCompositor::didStopFlinging() { | 774 void RenderWidgetCompositor::didStopFlinging() { |
777 layer_tree_host_->DidStopFlinging(); | 775 layer_tree_host_->DidStopFlinging(); |
778 } | 776 } |
779 | 777 |
780 void RenderWidgetCompositor::registerViewportLayers( | 778 void RenderWidgetCompositor::registerViewportLayers( |
781 const blink::WebLayer* overscrollElasticityLayer, | 779 const blink::WebLayer* overscrollElasticityLayer, |
782 const blink::WebLayer* pageScaleLayer, | 780 const blink::WebLayer* pageScaleLayer, |
783 const blink::WebLayer* innerViewportScrollLayer, | 781 const blink::WebLayer* innerViewportScrollLayer, |
784 const blink::WebLayer* outerViewportScrollLayer) { | 782 const blink::WebLayer* outerViewportScrollLayer) { |
785 layer_tree_host_->RegisterViewportLayers( | 783 layer_tree_host_->GetLayerTree()->RegisterViewportLayers( |
786 // TODO(bokan): This check can probably be removed now, but it looks | 784 // TODO(bokan): This check can probably be removed now, but it looks |
787 // like overscroll elasticity may still be NULL until VisualViewport | 785 // like overscroll elasticity may still be NULL until VisualViewport |
788 // registers its layers. | 786 // registers its layers. |
789 // The scroll elasticity layer will only exist when using pinch virtual | 787 // The scroll elasticity layer will only exist when using pinch virtual |
790 // viewports. | 788 // viewports. |
791 overscrollElasticityLayer | 789 overscrollElasticityLayer |
792 ? static_cast<const cc_blink::WebLayerImpl*>( | 790 ? static_cast<const cc_blink::WebLayerImpl*>( |
793 overscrollElasticityLayer)->layer() | 791 overscrollElasticityLayer) |
| 792 ->layer() |
794 : NULL, | 793 : NULL, |
795 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), | 794 static_cast<const cc_blink::WebLayerImpl*>(pageScaleLayer)->layer(), |
796 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer) | 795 static_cast<const cc_blink::WebLayerImpl*>(innerViewportScrollLayer) |
797 ->layer(), | 796 ->layer(), |
798 // TODO(bokan): This check can probably be removed now, but it looks | 797 // TODO(bokan): This check can probably be removed now, but it looks |
799 // like overscroll elasticity may still be NULL until VisualViewport | 798 // like overscroll elasticity may still be NULL until VisualViewport |
800 // registers its layers. | 799 // registers its layers. |
801 // The outer viewport layer will only exist when using pinch virtual | 800 // The outer viewport layer will only exist when using pinch virtual |
802 // viewports. | 801 // viewports. |
803 outerViewportScrollLayer | 802 outerViewportScrollLayer |
804 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer) | 803 ? static_cast<const cc_blink::WebLayerImpl*>(outerViewportScrollLayer) |
805 ->layer() | 804 ->layer() |
806 : NULL); | 805 : NULL); |
807 } | 806 } |
808 | 807 |
809 void RenderWidgetCompositor::clearViewportLayers() { | 808 void RenderWidgetCompositor::clearViewportLayers() { |
810 layer_tree_host_->RegisterViewportLayers( | 809 layer_tree_host_->GetLayerTree()->RegisterViewportLayers( |
811 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>(), | 810 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>(), |
812 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>()); | 811 scoped_refptr<cc::Layer>(), scoped_refptr<cc::Layer>()); |
813 } | 812 } |
814 | 813 |
815 void RenderWidgetCompositor::registerSelection( | 814 void RenderWidgetCompositor::registerSelection( |
816 const blink::WebSelection& selection) { | 815 const blink::WebSelection& selection) { |
817 layer_tree_host_->RegisterSelection(ConvertWebSelection(selection)); | 816 layer_tree_host_->GetLayerTree()->RegisterSelection( |
| 817 ConvertWebSelection(selection)); |
818 } | 818 } |
819 | 819 |
820 void RenderWidgetCompositor::clearSelection() { | 820 void RenderWidgetCompositor::clearSelection() { |
821 cc::LayerSelection empty_selection; | 821 cc::LayerSelection empty_selection; |
822 layer_tree_host_->RegisterSelection(empty_selection); | 822 layer_tree_host_->GetLayerTree()->RegisterSelection(empty_selection); |
823 } | 823 } |
824 | 824 |
825 void RenderWidgetCompositor::setMutatorClient( | 825 void RenderWidgetCompositor::setMutatorClient( |
826 std::unique_ptr<blink::WebCompositorMutatorClient> client) { | 826 std::unique_ptr<blink::WebCompositorMutatorClient> client) { |
827 TRACE_EVENT0("compositor-worker", "RenderWidgetCompositor::setMutatorClient"); | 827 TRACE_EVENT0("compositor-worker", "RenderWidgetCompositor::setMutatorClient"); |
828 layer_tree_host_->SetLayerTreeMutator(std::move(client)); | 828 layer_tree_host_->SetLayerTreeMutator(std::move(client)); |
829 } | 829 } |
830 | 830 |
831 static_assert(static_cast<cc::EventListenerClass>( | 831 static_assert(static_cast<cc::EventListenerClass>( |
832 blink::WebEventListenerClass::TouchStartOrMove) == | 832 blink::WebEventListenerClass::TouchStartOrMove) == |
(...skipping 17 matching lines...) Expand all Loading... |
850 cc::EventListenerProperties::kBlocking, | 850 cc::EventListenerProperties::kBlocking, |
851 "EventListener and WebEventListener enums must match"); | 851 "EventListener and WebEventListener enums must match"); |
852 static_assert(static_cast<cc::EventListenerProperties>( | 852 static_assert(static_cast<cc::EventListenerProperties>( |
853 blink::WebEventListenerProperties::BlockingAndPassive) == | 853 blink::WebEventListenerProperties::BlockingAndPassive) == |
854 cc::EventListenerProperties::kBlockingAndPassive, | 854 cc::EventListenerProperties::kBlockingAndPassive, |
855 "EventListener and WebEventListener enums must match"); | 855 "EventListener and WebEventListener enums must match"); |
856 | 856 |
857 void RenderWidgetCompositor::setEventListenerProperties( | 857 void RenderWidgetCompositor::setEventListenerProperties( |
858 blink::WebEventListenerClass eventClass, | 858 blink::WebEventListenerClass eventClass, |
859 blink::WebEventListenerProperties properties) { | 859 blink::WebEventListenerProperties properties) { |
860 layer_tree_host_->SetEventListenerProperties( | 860 layer_tree_host_->GetLayerTree()->SetEventListenerProperties( |
861 static_cast<cc::EventListenerClass>(eventClass), | 861 static_cast<cc::EventListenerClass>(eventClass), |
862 static_cast<cc::EventListenerProperties>(properties)); | 862 static_cast<cc::EventListenerProperties>(properties)); |
863 } | 863 } |
864 | 864 |
865 blink::WebEventListenerProperties | 865 blink::WebEventListenerProperties |
866 RenderWidgetCompositor::eventListenerProperties( | 866 RenderWidgetCompositor::eventListenerProperties( |
867 blink::WebEventListenerClass event_class) const { | 867 blink::WebEventListenerClass event_class) const { |
868 return static_cast<blink::WebEventListenerProperties>( | 868 return static_cast<blink::WebEventListenerProperties>( |
869 layer_tree_host_->event_listener_properties( | 869 layer_tree_host_->GetLayerTree()->event_listener_properties( |
870 static_cast<cc::EventListenerClass>(event_class))); | 870 static_cast<cc::EventListenerClass>(event_class))); |
871 } | 871 } |
872 | 872 |
873 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { | 873 void RenderWidgetCompositor::setHaveScrollEventHandlers(bool has_handlers) { |
874 layer_tree_host_->SetHaveScrollEventHandlers(has_handlers); | 874 layer_tree_host_->GetLayerTree()->SetHaveScrollEventHandlers(has_handlers); |
875 } | 875 } |
876 | 876 |
877 bool RenderWidgetCompositor::haveScrollEventHandlers() const { | 877 bool RenderWidgetCompositor::haveScrollEventHandlers() const { |
878 return layer_tree_host_->have_scroll_event_handlers(); | 878 return layer_tree_host_->GetLayerTree()->have_scroll_event_handlers(); |
879 } | 879 } |
880 | 880 |
881 void CompositeAndReadbackAsyncCallback( | 881 void CompositeAndReadbackAsyncCallback( |
882 blink::WebCompositeAndReadbackAsyncCallback* callback, | 882 blink::WebCompositeAndReadbackAsyncCallback* callback, |
883 std::unique_ptr<cc::CopyOutputResult> result) { | 883 std::unique_ptr<cc::CopyOutputResult> result) { |
884 if (result->HasBitmap()) { | 884 if (result->HasBitmap()) { |
885 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); | 885 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); |
886 callback->didCompositeAndReadback(*result_bitmap); | 886 callback->didCompositeAndReadback(*result_bitmap); |
887 } else { | 887 } else { |
888 callback->didCompositeAndReadback(SkBitmap()); | 888 callback->didCompositeAndReadback(SkBitmap()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 void RenderWidgetCompositor::updateTopControlsState( | 996 void RenderWidgetCompositor::updateTopControlsState( |
997 WebTopControlsState constraints, | 997 WebTopControlsState constraints, |
998 WebTopControlsState current, | 998 WebTopControlsState current, |
999 bool animate) { | 999 bool animate) { |
1000 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), | 1000 layer_tree_host_->UpdateTopControlsState(ConvertTopControlsState(constraints), |
1001 ConvertTopControlsState(current), | 1001 ConvertTopControlsState(current), |
1002 animate); | 1002 animate); |
1003 } | 1003 } |
1004 | 1004 |
1005 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { | 1005 void RenderWidgetCompositor::setTopControlsHeight(float height, bool shrink) { |
1006 layer_tree_host_->SetTopControlsHeight(height, shrink); | 1006 layer_tree_host_->GetLayerTree()->SetTopControlsHeight(height, shrink); |
1007 } | 1007 } |
1008 | 1008 |
1009 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { | 1009 void RenderWidgetCompositor::setTopControlsShownRatio(float ratio) { |
1010 layer_tree_host_->SetTopControlsShownRatio(ratio); | 1010 layer_tree_host_->GetLayerTree()->SetTopControlsShownRatio(ratio); |
1011 } | 1011 } |
1012 | 1012 |
1013 void RenderWidgetCompositor::WillBeginMainFrame() { | 1013 void RenderWidgetCompositor::WillBeginMainFrame() { |
1014 delegate_->WillBeginCompositorFrame(); | 1014 delegate_->WillBeginCompositorFrame(); |
1015 } | 1015 } |
1016 | 1016 |
1017 void RenderWidgetCompositor::DidBeginMainFrame() { | 1017 void RenderWidgetCompositor::DidBeginMainFrame() { |
1018 } | 1018 } |
1019 | 1019 |
1020 void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 1020 void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { | 1142 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { |
1143 LOG(ERROR) << "Unable to parse compositor proto."; | 1143 LOG(ERROR) << "Unable to parse compositor proto."; |
1144 return; | 1144 return; |
1145 } | 1145 } |
1146 | 1146 |
1147 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); | 1147 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); |
1148 } | 1148 } |
1149 | 1149 |
1150 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1150 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
1151 float device_scale) { | 1151 float device_scale) { |
1152 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); | 1152 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
1153 } | 1153 } |
1154 | 1154 |
1155 } // namespace content | 1155 } // namespace content |
OLD | NEW |