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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 // Ignore what the system said and give all clients the same maximum | 582 // Ignore what the system said and give all clients the same maximum |
583 // allocation on desktop platforms. | 583 // allocation on desktop platforms. |
584 actual.bytes_limit_when_visible = 512 * 1024 * 1024; | 584 actual.bytes_limit_when_visible = 512 * 1024 * 1024; |
585 actual.priority_cutoff_when_visible = | 585 actual.priority_cutoff_when_visible = |
586 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; | 586 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
587 #endif | 587 #endif |
588 return actual; | 588 return actual; |
589 } | 589 } |
590 | 590 |
591 void RenderWidgetCompositor::SetNeverVisible() { | 591 void RenderWidgetCompositor::SetNeverVisible() { |
592 DCHECK(!layer_tree_host_->visible()); | 592 DCHECK(!layer_tree_host_->IsVisible()); |
593 never_visible_ = true; | 593 never_visible_ = true; |
594 } | 594 } |
595 | 595 |
596 const base::WeakPtr<cc::InputHandler>& | 596 const base::WeakPtr<cc::InputHandler>& |
597 RenderWidgetCompositor::GetInputHandler() { | 597 RenderWidgetCompositor::GetInputHandler() { |
598 return layer_tree_host_->GetInputHandler(); | 598 return layer_tree_host_->GetInputHandler(); |
599 } | 599 } |
600 | 600 |
601 bool RenderWidgetCompositor::BeginMainFrameRequested() const { | 601 bool RenderWidgetCompositor::BeginMainFrameRequested() const { |
602 return layer_tree_host_->BeginMainFrameRequested(); | 602 return layer_tree_host_->BeginMainFrameRequested(); |
603 } | 603 } |
604 | 604 |
605 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { | 605 void RenderWidgetCompositor::SetNeedsDisplayOnAllLayers() { |
606 layer_tree_host_->GetLayerTree()->SetNeedsDisplayOnAllLayers(); | 606 layer_tree_host_->GetLayerTree()->SetNeedsDisplayOnAllLayers(); |
607 } | 607 } |
608 | 608 |
609 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { | 609 void RenderWidgetCompositor::SetRasterizeOnlyVisibleContent() { |
610 cc::LayerTreeDebugState current = layer_tree_host_->debug_state(); | 610 cc::LayerTreeDebugState current = layer_tree_host_->GetDebugState(); |
611 current.rasterize_only_visible_content = true; | 611 current.rasterize_only_visible_content = true; |
612 layer_tree_host_->SetDebugState(current); | 612 layer_tree_host_->SetDebugState(current); |
613 } | 613 } |
614 | 614 |
615 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { | 615 void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) { |
616 layer_tree_host_->SetNeedsRedrawRect(damage_rect); | 616 layer_tree_host_->SetNeedsRedrawRect(damage_rect); |
617 } | 617 } |
618 | 618 |
619 void RenderWidgetCompositor::SetNeedsForcedRedraw() { | 619 void RenderWidgetCompositor::SetNeedsForcedRedraw() { |
620 layer_tree_host_->SetNextCommitForcesRedraw(); | 620 layer_tree_host_->SetNextCommitForcesRedraw(); |
621 setNeedsAnimate(); | 621 setNeedsAnimate(); |
622 } | 622 } |
623 | 623 |
624 std::unique_ptr<cc::SwapPromiseMonitor> | 624 std::unique_ptr<cc::SwapPromiseMonitor> |
625 RenderWidgetCompositor::CreateLatencyInfoSwapPromiseMonitor( | 625 RenderWidgetCompositor::CreateLatencyInfoSwapPromiseMonitor( |
626 ui::LatencyInfo* latency) { | 626 ui::LatencyInfo* latency) { |
627 return std::unique_ptr<cc::SwapPromiseMonitor>( | 627 return std::unique_ptr<cc::SwapPromiseMonitor>( |
628 new cc::LatencyInfoSwapPromiseMonitor(latency, layer_tree_host_.get(), | 628 new cc::LatencyInfoSwapPromiseMonitor(latency, layer_tree_host_.get(), |
629 NULL)); | 629 NULL)); |
630 } | 630 } |
631 | 631 |
632 void RenderWidgetCompositor::QueueSwapPromise( | 632 void RenderWidgetCompositor::QueueSwapPromise( |
633 std::unique_ptr<cc::SwapPromise> swap_promise) { | 633 std::unique_ptr<cc::SwapPromise> swap_promise) { |
634 layer_tree_host_->QueueSwapPromise(std::move(swap_promise)); | 634 layer_tree_host_->QueueSwapPromise(std::move(swap_promise)); |
635 } | 635 } |
636 | 636 |
637 int RenderWidgetCompositor::GetSourceFrameNumber() const { | 637 int RenderWidgetCompositor::GetSourceFrameNumber() const { |
638 return layer_tree_host_->source_frame_number(); | 638 return layer_tree_host_->SourceFrameNumber(); |
639 } | 639 } |
640 | 640 |
641 void RenderWidgetCompositor::SetNeedsUpdateLayers() { | 641 void RenderWidgetCompositor::SetNeedsUpdateLayers() { |
642 layer_tree_host_->SetNeedsUpdateLayers(); | 642 layer_tree_host_->SetNeedsUpdateLayers(); |
643 } | 643 } |
644 | 644 |
645 void RenderWidgetCompositor::SetNeedsCommit() { | 645 void RenderWidgetCompositor::SetNeedsCommit() { |
646 layer_tree_host_->SetNeedsCommit(); | 646 layer_tree_host_->SetNeedsCommit(); |
647 } | 647 } |
648 | 648 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 if (result->HasBitmap()) { | 875 if (result->HasBitmap()) { |
876 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); | 876 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); |
877 callback->didCompositeAndReadback(*result_bitmap); | 877 callback->didCompositeAndReadback(*result_bitmap); |
878 } else { | 878 } else { |
879 callback->didCompositeAndReadback(SkBitmap()); | 879 callback->didCompositeAndReadback(SkBitmap()); |
880 } | 880 } |
881 } | 881 } |
882 | 882 |
883 bool RenderWidgetCompositor::CompositeIsSynchronous() const { | 883 bool RenderWidgetCompositor::CompositeIsSynchronous() const { |
884 if (!threaded_) { | 884 if (!threaded_) { |
885 DCHECK(!layer_tree_host_->settings().single_thread_proxy_scheduler); | 885 DCHECK(!layer_tree_host_->GetSettings().single_thread_proxy_scheduler); |
886 return true; | 886 return true; |
887 } | 887 } |
888 return false; | 888 return false; |
889 } | 889 } |
890 | 890 |
891 void RenderWidgetCompositor::layoutAndPaintAsync( | 891 void RenderWidgetCompositor::layoutAndPaintAsync( |
892 blink::WebLayoutAndPaintAsyncCallback* callback) { | 892 blink::WebLayoutAndPaintAsyncCallback* callback) { |
893 DCHECK(!layout_and_paint_async_callback_); | 893 DCHECK(!layout_and_paint_async_callback_); |
894 layout_and_paint_async_callback_ = callback; | 894 layout_and_paint_async_callback_ = callback; |
895 | 895 |
(...skipping 16 matching lines...) Expand all Loading... |
912 if (!layout_and_paint_async_callback_) | 912 if (!layout_and_paint_async_callback_) |
913 return; | 913 return; |
914 layout_and_paint_async_callback_->didLayoutAndPaint(); | 914 layout_and_paint_async_callback_->didLayoutAndPaint(); |
915 layout_and_paint_async_callback_ = nullptr; | 915 layout_and_paint_async_callback_ = nullptr; |
916 } | 916 } |
917 | 917 |
918 void RenderWidgetCompositor::compositeAndReadbackAsync( | 918 void RenderWidgetCompositor::compositeAndReadbackAsync( |
919 blink::WebCompositeAndReadbackAsyncCallback* callback) { | 919 blink::WebCompositeAndReadbackAsyncCallback* callback) { |
920 DCHECK(!layout_and_paint_async_callback_); | 920 DCHECK(!layout_and_paint_async_callback_); |
921 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 921 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
922 layer_tree_host_->task_runner_provider()->MainThreadTaskRunner(); | 922 layer_tree_host_->GetTaskRunnerProvider()->MainThreadTaskRunner(); |
923 std::unique_ptr<cc::CopyOutputRequest> request = | 923 std::unique_ptr<cc::CopyOutputRequest> request = |
924 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( | 924 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( |
925 [](blink::WebCompositeAndReadbackAsyncCallback* callback, | 925 [](blink::WebCompositeAndReadbackAsyncCallback* callback, |
926 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 926 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
927 std::unique_ptr<cc::CopyOutputResult> result) { | 927 std::unique_ptr<cc::CopyOutputResult> result) { |
928 task_runner->PostTask(FROM_HERE, | 928 task_runner->PostTask(FROM_HERE, |
929 base::Bind(&CompositeAndReadbackAsyncCallback, | 929 base::Bind(&CompositeAndReadbackAsyncCallback, |
930 callback, base::Passed(&result))); | 930 callback, base::Passed(&result))); |
931 }, | 931 }, |
932 callback, base::Passed(&main_thread_task_runner))); | 932 callback, base::Passed(&main_thread_task_runner))); |
(...skipping 15 matching lines...) Expand all Loading... |
948 void RenderWidgetCompositor::SynchronouslyComposite() { | 948 void RenderWidgetCompositor::SynchronouslyComposite() { |
949 DCHECK(CompositeIsSynchronous()); | 949 DCHECK(CompositeIsSynchronous()); |
950 layer_tree_host_->Composite(base::TimeTicks::Now()); | 950 layer_tree_host_->Composite(base::TimeTicks::Now()); |
951 } | 951 } |
952 | 952 |
953 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 953 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { |
954 layer_tree_host_->SetDeferCommits(defer_commits); | 954 layer_tree_host_->SetDeferCommits(defer_commits); |
955 } | 955 } |
956 | 956 |
957 int RenderWidgetCompositor::layerTreeId() const { | 957 int RenderWidgetCompositor::layerTreeId() const { |
958 return layer_tree_host_->id(); | 958 return layer_tree_host_->GetId(); |
959 } | 959 } |
960 | 960 |
961 void RenderWidgetCompositor::setShowFPSCounter(bool show) { | 961 void RenderWidgetCompositor::setShowFPSCounter(bool show) { |
962 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 962 cc::LayerTreeDebugState debug_state = layer_tree_host_->GetDebugState(); |
963 debug_state.show_fps_counter = show; | 963 debug_state.show_fps_counter = show; |
964 layer_tree_host_->SetDebugState(debug_state); | 964 layer_tree_host_->SetDebugState(debug_state); |
965 } | 965 } |
966 | 966 |
967 void RenderWidgetCompositor::setShowPaintRects(bool show) { | 967 void RenderWidgetCompositor::setShowPaintRects(bool show) { |
968 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 968 cc::LayerTreeDebugState debug_state = layer_tree_host_->GetDebugState(); |
969 debug_state.show_paint_rects = show; | 969 debug_state.show_paint_rects = show; |
970 layer_tree_host_->SetDebugState(debug_state); | 970 layer_tree_host_->SetDebugState(debug_state); |
971 } | 971 } |
972 | 972 |
973 void RenderWidgetCompositor::setShowDebugBorders(bool show) { | 973 void RenderWidgetCompositor::setShowDebugBorders(bool show) { |
974 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 974 cc::LayerTreeDebugState debug_state = layer_tree_host_->GetDebugState(); |
975 debug_state.show_debug_borders = show; | 975 debug_state.show_debug_borders = show; |
976 layer_tree_host_->SetDebugState(debug_state); | 976 layer_tree_host_->SetDebugState(debug_state); |
977 } | 977 } |
978 | 978 |
979 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { | 979 void RenderWidgetCompositor::setShowScrollBottleneckRects(bool show) { |
980 cc::LayerTreeDebugState debug_state = layer_tree_host_->debug_state(); | 980 cc::LayerTreeDebugState debug_state = layer_tree_host_->GetDebugState(); |
981 debug_state.show_touch_event_handler_rects = show; | 981 debug_state.show_touch_event_handler_rects = show; |
982 debug_state.show_wheel_event_handler_rects = show; | 982 debug_state.show_wheel_event_handler_rects = show; |
983 debug_state.show_non_fast_scrollable_rects = show; | 983 debug_state.show_non_fast_scrollable_rects = show; |
984 layer_tree_host_->SetDebugState(debug_state); | 984 layer_tree_host_->SetDebugState(debug_state); |
985 } | 985 } |
986 | 986 |
987 void RenderWidgetCompositor::updateTopControlsState( | 987 void RenderWidgetCompositor::updateTopControlsState( |
988 WebTopControlsState constraints, | 988 WebTopControlsState constraints, |
989 WebTopControlsState current, | 989 WebTopControlsState current, |
990 bool animate) { | 990 bool animate) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 void RenderWidgetCompositor::SendCompositorProto( | 1117 void RenderWidgetCompositor::SendCompositorProto( |
1118 const cc::proto::CompositorMessage& proto) { | 1118 const cc::proto::CompositorMessage& proto) { |
1119 int signed_size = proto.ByteSize(); | 1119 int signed_size = proto.ByteSize(); |
1120 size_t unsigned_size = base::checked_cast<size_t>(signed_size); | 1120 size_t unsigned_size = base::checked_cast<size_t>(signed_size); |
1121 std::vector<uint8_t> serialized(unsigned_size); | 1121 std::vector<uint8_t> serialized(unsigned_size); |
1122 proto.SerializeToArray(serialized.data(), signed_size); | 1122 proto.SerializeToArray(serialized.data(), signed_size); |
1123 delegate_->ForwardCompositorProto(serialized); | 1123 delegate_->ForwardCompositorProto(serialized); |
1124 } | 1124 } |
1125 | 1125 |
1126 void RenderWidgetCompositor::SetSurfaceClientId(uint32_t surface_client_id) { | 1126 void RenderWidgetCompositor::SetSurfaceClientId(uint32_t surface_client_id) { |
1127 layer_tree_host_->set_surface_client_id(surface_client_id); | 1127 layer_tree_host_->SetSurfaceClientId(surface_client_id); |
1128 } | 1128 } |
1129 | 1129 |
1130 void RenderWidgetCompositor::OnHandleCompositorProto( | 1130 void RenderWidgetCompositor::OnHandleCompositorProto( |
1131 const std::vector<uint8_t>& proto) { | 1131 const std::vector<uint8_t>& proto) { |
1132 DCHECK(remote_proto_channel_receiver_); | 1132 DCHECK(remote_proto_channel_receiver_); |
1133 | 1133 |
1134 std::unique_ptr<cc::proto::CompositorMessage> deserialized( | 1134 std::unique_ptr<cc::proto::CompositorMessage> deserialized( |
1135 new cc::proto::CompositorMessage); | 1135 new cc::proto::CompositorMessage); |
1136 int signed_size = base::checked_cast<int>(proto.size()); | 1136 int signed_size = base::checked_cast<int>(proto.size()); |
1137 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { | 1137 if (!deserialized->ParseFromArray(proto.data(), signed_size)) { |
1138 LOG(ERROR) << "Unable to parse compositor proto."; | 1138 LOG(ERROR) << "Unable to parse compositor proto."; |
1139 return; | 1139 return; |
1140 } | 1140 } |
1141 | 1141 |
1142 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); | 1142 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); |
1143 } | 1143 } |
1144 | 1144 |
1145 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1145 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
1146 float device_scale) { | 1146 float device_scale) { |
1147 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1147 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
1148 } | 1148 } |
1149 | 1149 |
1150 } // namespace content | 1150 } // namespace content |
OLD | NEW |