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 <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "cc/blink/web_layer_impl.h" | 24 #include "cc/blink/web_layer_impl.h" |
25 #include "cc/debug/layer_tree_debug_state.h" | 25 #include "cc/debug/layer_tree_debug_state.h" |
26 #include "cc/debug/micro_benchmark.h" | 26 #include "cc/debug/micro_benchmark.h" |
27 #include "cc/input/layer_selection_bound.h" | 27 #include "cc/input/layer_selection_bound.h" |
28 #include "cc/layers/layer.h" | 28 #include "cc/layers/layer.h" |
29 #include "cc/output/begin_frame_args.h" | 29 #include "cc/output/begin_frame_args.h" |
30 #include "cc/output/copy_output_request.h" | 30 #include "cc/output/copy_output_request.h" |
31 #include "cc/output/copy_output_result.h" | 31 #include "cc/output/copy_output_result.h" |
32 #include "cc/output/latency_info_swap_promise.h" | 32 #include "cc/output/latency_info_swap_promise.h" |
33 #include "cc/output/swap_promise.h" | 33 #include "cc/output/swap_promise.h" |
| 34 #include "cc/proto/compositor_message.pb.h" |
34 #include "cc/resources/single_release_callback.h" | 35 #include "cc/resources/single_release_callback.h" |
35 #include "cc/scheduler/begin_frame_source.h" | 36 #include "cc/scheduler/begin_frame_source.h" |
36 #include "cc/trees/latency_info_swap_promise_monitor.h" | 37 #include "cc/trees/latency_info_swap_promise_monitor.h" |
37 #include "cc/trees/layer_tree_host.h" | 38 #include "cc/trees/layer_tree_host.h" |
| 39 #include "cc/trees/remote_proto_channel.h" |
38 #include "components/scheduler/renderer/renderer_scheduler.h" | 40 #include "components/scheduler/renderer/renderer_scheduler.h" |
39 #include "content/common/content_switches_internal.h" | 41 #include "content/common/content_switches_internal.h" |
40 #include "content/common/gpu/client/context_provider_command_buffer.h" | 42 #include "content/common/gpu/client/context_provider_command_buffer.h" |
41 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
42 #include "content/renderer/input/input_handler_manager.h" | 44 #include "content/renderer/input/input_handler_manager.h" |
43 #include "gpu/command_buffer/client/gles2_interface.h" | 45 #include "gpu/command_buffer/client/gles2_interface.h" |
44 #include "gpu/command_buffer/service/gpu_switches.h" | 46 #include "gpu/command_buffer/service/gpu_switches.h" |
45 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" | 47 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac
k.h" |
46 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" | 48 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h" |
47 #include "third_party/WebKit/public/platform/WebSize.h" | 49 #include "third_party/WebKit/public/platform/WebSize.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 210 } |
209 | 211 |
210 RenderWidgetCompositor::RenderWidgetCompositor( | 212 RenderWidgetCompositor::RenderWidgetCompositor( |
211 RenderWidget* widget, | 213 RenderWidget* widget, |
212 CompositorDependencies* compositor_deps) | 214 CompositorDependencies* compositor_deps) |
213 : num_failed_recreate_attempts_(0), | 215 : num_failed_recreate_attempts_(0), |
214 widget_(widget), | 216 widget_(widget), |
215 compositor_deps_(compositor_deps), | 217 compositor_deps_(compositor_deps), |
216 never_visible_(false), | 218 never_visible_(false), |
217 layout_and_paint_async_callback_(nullptr), | 219 layout_and_paint_async_callback_(nullptr), |
| 220 remote_proto_channel_receiver_(nullptr), |
218 weak_factory_(this) { | 221 weak_factory_(this) { |
219 } | 222 } |
220 | 223 |
221 void RenderWidgetCompositor::Initialize() { | 224 void RenderWidgetCompositor::Initialize() { |
222 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 225 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
223 | 226 |
224 cc::LayerTreeSettings settings; | 227 cc::LayerTreeSettings settings; |
225 | 228 |
226 // For web contents, layer transforms should scale up the contents of layers | 229 // For web contents, layer transforms should scale up the contents of layers |
227 // to keep content always crisp when possible. | 230 // to keep content always crisp when possible. |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 } | 964 } |
962 | 965 |
963 void RenderWidgetCompositor::DidPostSwapBuffers() { | 966 void RenderWidgetCompositor::DidPostSwapBuffers() { |
964 widget_->OnSwapBuffersPosted(); | 967 widget_->OnSwapBuffersPosted(); |
965 } | 968 } |
966 | 969 |
967 void RenderWidgetCompositor::DidAbortSwapBuffers() { | 970 void RenderWidgetCompositor::DidAbortSwapBuffers() { |
968 widget_->OnSwapBuffersAborted(); | 971 widget_->OnSwapBuffersAborted(); |
969 } | 972 } |
970 | 973 |
| 974 void RenderWidgetCompositor::SetReceiver(Receiver* receiver) { |
| 975 remote_proto_channel_receiver_ = receiver; |
| 976 } |
| 977 |
| 978 void RenderWidgetCompositor::SendCompositorProto( |
| 979 const cc::proto::CompositorMessage& proto) { |
| 980 std::vector<char> serialized(proto.ByteSize()); |
| 981 proto.SerializeToArray(serialized.data(), serialized.size()); |
| 982 widget_->SendCompositorProto(serialized); |
| 983 } |
| 984 |
971 void RenderWidgetCompositor::RecordFrameTimingEvents( | 985 void RenderWidgetCompositor::RecordFrameTimingEvents( |
972 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, | 986 scoped_ptr<cc::FrameTimingTracker::CompositeTimingSet> composite_events, |
973 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 987 scoped_ptr<cc::FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
974 for (const auto& composite_event : *composite_events ) { | 988 for (const auto& composite_event : *composite_events ) { |
975 int64_t frameId = composite_event.first; | 989 int64_t frameId = composite_event.first; |
976 const std::vector<cc::FrameTimingTracker::CompositeTimingEvent>& events = | 990 const std::vector<cc::FrameTimingTracker::CompositeTimingEvent>& events = |
977 composite_event.second; | 991 composite_event.second; |
978 std::vector<blink::WebFrameTimingEvent> webEvents; | 992 std::vector<blink::WebFrameTimingEvent> webEvents; |
979 for (size_t i = 0; i < events.size(); ++i) { | 993 for (size_t i = 0; i < events.size(); ++i) { |
980 webEvents.push_back(blink::WebFrameTimingEvent( | 994 webEvents.push_back(blink::WebFrameTimingEvent( |
(...skipping 17 matching lines...) Expand all Loading... |
998 widget_->webwidget()->recordFrameTimingEvent( | 1012 widget_->webwidget()->recordFrameTimingEvent( |
999 blink::WebWidget::RenderEvent, frameId, webEvents); | 1013 blink::WebWidget::RenderEvent, frameId, webEvents); |
1000 } | 1014 } |
1001 } | 1015 } |
1002 | 1016 |
1003 void RenderWidgetCompositor::SetSurfaceIdNamespace( | 1017 void RenderWidgetCompositor::SetSurfaceIdNamespace( |
1004 uint32_t surface_id_namespace) { | 1018 uint32_t surface_id_namespace) { |
1005 layer_tree_host_->set_surface_id_namespace(surface_id_namespace); | 1019 layer_tree_host_->set_surface_id_namespace(surface_id_namespace); |
1006 } | 1020 } |
1007 | 1021 |
| 1022 void RenderWidgetCompositor::OnHandleCompositorProto( |
| 1023 const std::vector<char>& proto) { |
| 1024 if (!remote_proto_channel_receiver_) |
| 1025 return; |
| 1026 |
| 1027 cc::proto::CompositorMessage deserialized; |
| 1028 if (!deserialized.ParseFromArray(proto.data(), proto.size())) { |
| 1029 LOG(ERROR) << "Unable to parse compositor proto."; |
| 1030 return; |
| 1031 } |
| 1032 |
| 1033 remote_proto_channel_receiver_->OnProtoReceived(deserialized); |
| 1034 } |
| 1035 |
1008 cc::ManagedMemoryPolicy RenderWidgetCompositor::GetGpuMemoryPolicy( | 1036 cc::ManagedMemoryPolicy RenderWidgetCompositor::GetGpuMemoryPolicy( |
1009 const cc::ManagedMemoryPolicy& policy) { | 1037 const cc::ManagedMemoryPolicy& policy) { |
1010 cc::ManagedMemoryPolicy actual = policy; | 1038 cc::ManagedMemoryPolicy actual = policy; |
1011 actual.bytes_limit_when_visible = 0; | 1039 actual.bytes_limit_when_visible = 0; |
1012 | 1040 |
1013 // If the value was overridden on the command line, use the specified value. | 1041 // If the value was overridden on the command line, use the specified value. |
1014 static bool client_hard_limit_bytes_overridden = | 1042 static bool client_hard_limit_bytes_overridden = |
1015 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1043 base::CommandLine::ForCurrentProcess()->HasSwitch( |
1016 switches::kForceGpuMemAvailableMb); | 1044 switches::kForceGpuMemAvailableMb); |
1017 if (client_hard_limit_bytes_overridden) { | 1045 if (client_hard_limit_bytes_overridden) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 #endif | 1112 #endif |
1085 return actual; | 1113 return actual; |
1086 } | 1114 } |
1087 | 1115 |
1088 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1116 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
1089 float device_scale) { | 1117 float device_scale) { |
1090 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); | 1118 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); |
1091 } | 1119 } |
1092 | 1120 |
1093 } // namespace content | 1121 } // namespace content |
OLD | NEW |