OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/feature_list.h" | 13 #include "base/feature_list.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/memory/singleton.h" | 17 #include "base/memory/singleton.h" |
18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
23 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
24 #include "base/trace_event/trace_event_synthetic_delay.h" | 24 #include "base/trace_event/trace_event_synthetic_delay.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "cc/base/switches.h" | 26 #include "cc/base/switches.h" |
27 #include "cc/debug/benchmark_instrumentation.h" | 27 #include "cc/debug/benchmark_instrumentation.h" |
28 #include "cc/output/output_surface.h" | 28 #include "cc/output/output_surface.h" |
| 29 #include "cc/output/vulkan_in_process_context_provider.h" |
29 #include "cc/scheduler/begin_frame_source.h" | 30 #include "cc/scheduler/begin_frame_source.h" |
30 #include "cc/trees/layer_tree_host.h" | 31 #include "cc/trees/layer_tree_host.h" |
31 #include "components/scheduler/renderer/render_widget_scheduling_state.h" | 32 #include "components/scheduler/renderer/render_widget_scheduling_state.h" |
32 #include "components/scheduler/renderer/renderer_scheduler.h" | 33 #include "components/scheduler/renderer/renderer_scheduler.h" |
33 #include "content/common/content_switches_internal.h" | 34 #include "content/common/content_switches_internal.h" |
34 #include "content/common/gpu/client/context_provider_command_buffer.h" | 35 #include "content/common/gpu/client/context_provider_command_buffer.h" |
35 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 36 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
36 #include "content/common/gpu_process_launch_causes.h" | 37 #include "content/common/gpu_process_launch_causes.h" |
37 #include "content/common/input/synthetic_gesture_packet.h" | 38 #include "content/common/input/synthetic_gesture_packet.h" |
38 #include "content/common/input/web_input_event_traits.h" | 39 #include "content/common/input/web_input_event_traits.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 #include "ipc/ipc_channel_posix.h" | 101 #include "ipc/ipc_channel_posix.h" |
101 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 102 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
102 #include "third_party/skia/include/core/SkPixelRef.h" | 103 #include "third_party/skia/include/core/SkPixelRef.h" |
103 #endif // defined(OS_POSIX) | 104 #endif // defined(OS_POSIX) |
104 | 105 |
105 #if defined(MOJO_SHELL_CLIENT) | 106 #if defined(MOJO_SHELL_CLIENT) |
106 #include "content/public/common/mojo_shell_connection.h" | 107 #include "content/public/common/mojo_shell_connection.h" |
107 #include "content/renderer/mus/render_widget_mus_connection.h" | 108 #include "content/renderer/mus/render_widget_mus_connection.h" |
108 #endif | 109 #endif |
109 | 110 |
110 #if defined(ENABLE_VULKAN) | |
111 #include "cc/output/vulkan_in_process_context_provider.h" | |
112 #endif | |
113 | |
114 #include "third_party/WebKit/public/web/WebWidget.h" | 111 #include "third_party/WebKit/public/web/WebWidget.h" |
115 | 112 |
116 using blink::WebCompositionUnderline; | 113 using blink::WebCompositionUnderline; |
117 using blink::WebCursorInfo; | 114 using blink::WebCursorInfo; |
118 using blink::WebDeviceEmulationParams; | 115 using blink::WebDeviceEmulationParams; |
119 using blink::WebGestureEvent; | 116 using blink::WebGestureEvent; |
120 using blink::WebInputEvent; | 117 using blink::WebInputEvent; |
121 using blink::WebInputEventResult; | 118 using blink::WebInputEventResult; |
122 using blink::WebKeyboardEvent; | 119 using blink::WebKeyboardEvent; |
123 using blink::WebMouseEvent; | 120 using blink::WebMouseEvent; |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 if (!gpu_channel_host) { | 754 if (!gpu_channel_host) { |
758 // Cause the compositor to wait and try again. | 755 // Cause the compositor to wait and try again. |
759 return nullptr; | 756 return nullptr; |
760 } | 757 } |
761 // We may get a valid channel, but with a software renderer. In that case, | 758 // We may get a valid channel, but with a software renderer. In that case, |
762 // disable GPU compositing. | 759 // disable GPU compositing. |
763 if (gpu_channel_host->gpu_info().software_rendering) | 760 if (gpu_channel_host->gpu_info().software_rendering) |
764 use_software = true; | 761 use_software = true; |
765 } | 762 } |
766 | 763 |
767 #if defined(ENABLE_VULKAN) | |
768 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; | 764 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider; |
769 #endif | |
770 scoped_refptr<ContextProviderCommandBuffer> context_provider; | 765 scoped_refptr<ContextProviderCommandBuffer> context_provider; |
771 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; | 766 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider; |
772 if (!use_software) { | 767 if (!use_software) { |
773 #if defined(ENABLE_VULKAN) | 768 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
774 vulkan_context_provider = cc::VulkanInProcessContextProvider::Create(); | 769 vulkan_context_provider = cc::VulkanInProcessContextProvider::Create(); |
775 if (vulkan_context_provider) { | 770 if (vulkan_context_provider) { |
776 uint32_t output_surface_id = next_output_surface_id_++; | 771 uint32_t output_surface_id = next_output_surface_id_++; |
777 return base::WrapUnique(new DelegatedCompositorOutputSurface( | 772 return base::WrapUnique(new DelegatedCompositorOutputSurface( |
778 routing_id(), output_surface_id, context_provider, | 773 routing_id(), output_surface_id, context_provider, |
779 worker_context_provider, vulkan_context_provider, | 774 worker_context_provider, vulkan_context_provider, |
780 frame_swap_message_queue_)); | 775 frame_swap_message_queue_)); |
| 776 } |
781 } | 777 } |
782 #endif | |
783 | 778 |
784 gpu::SharedMemoryLimits limits; | 779 gpu::SharedMemoryLimits limits; |
785 // The renderer compositor context doesn't do a lot of stuff, so we don't | 780 // The renderer compositor context doesn't do a lot of stuff, so we don't |
786 // expect it to need a lot of space for commands or transfer. Raster and | 781 // expect it to need a lot of space for commands or transfer. Raster and |
787 // uploads happen on the worker context instead. | 782 // uploads happen on the worker context instead. |
788 limits.command_buffer_size = 64 * 1024; | 783 limits.command_buffer_size = 64 * 1024; |
789 limits.start_transfer_buffer_size = 64 * 1024; | 784 limits.start_transfer_buffer_size = 64 * 1024; |
790 limits.min_transfer_buffer_size = 64 * 1024; | 785 limits.min_transfer_buffer_size = 64 * 1024; |
791 | 786 |
792 context_provider = new ContextProviderCommandBuffer( | 787 context_provider = new ContextProviderCommandBuffer( |
(...skipping 23 matching lines...) Expand all Loading... |
816 uint32_t output_surface_id = next_output_surface_id_++; | 811 uint32_t output_surface_id = next_output_surface_id_++; |
817 // Composite-to-mailbox is currently used for layout tests in order to cause | 812 // Composite-to-mailbox is currently used for layout tests in order to cause |
818 // them to draw inside in the renderer to do the readback there. This should | 813 // them to draw inside in the renderer to do the readback there. This should |
819 // no longer be the case when crbug.com/311404 is fixed. | 814 // no longer be the case when crbug.com/311404 is fixed. |
820 if (!RenderThreadImpl::current() || | 815 if (!RenderThreadImpl::current() || |
821 !RenderThreadImpl::current()->layout_test_mode()) { | 816 !RenderThreadImpl::current()->layout_test_mode()) { |
822 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); | 817 DCHECK(compositor_deps_->GetCompositorImplThreadTaskRunner()); |
823 return base::WrapUnique(new DelegatedCompositorOutputSurface( | 818 return base::WrapUnique(new DelegatedCompositorOutputSurface( |
824 routing_id(), output_surface_id, std::move(context_provider), | 819 routing_id(), output_surface_id, std::move(context_provider), |
825 std::move(worker_context_provider), | 820 std::move(worker_context_provider), |
826 #if defined(ENABLE_VULKAN) | |
827 vulkan_context_provider, | 821 vulkan_context_provider, |
828 #endif | |
829 frame_swap_message_queue_)); | 822 frame_swap_message_queue_)); |
830 } | 823 } |
831 | 824 |
832 if (!context_provider) { | 825 if (!context_provider) { |
833 std::unique_ptr<cc::SoftwareOutputDevice> software_device( | 826 std::unique_ptr<cc::SoftwareOutputDevice> software_device( |
834 new cc::SoftwareOutputDevice()); | 827 new cc::SoftwareOutputDevice()); |
835 | 828 |
836 return base::WrapUnique(new CompositorOutputSurface( | 829 return base::WrapUnique(new CompositorOutputSurface( |
837 routing_id(), output_surface_id, nullptr, nullptr, | 830 routing_id(), output_surface_id, nullptr, nullptr, nullptr, |
838 #if defined(ENABLE_VULKAN) | |
839 nullptr, | |
840 #endif | |
841 std::move(software_device), frame_swap_message_queue_, true)); | 831 std::move(software_device), frame_swap_message_queue_, true)); |
842 } | 832 } |
843 | 833 |
844 return base::WrapUnique(new MailboxOutputSurface( | 834 return base::WrapUnique(new MailboxOutputSurface( |
845 routing_id(), output_surface_id, std::move(context_provider), | 835 routing_id(), output_surface_id, std::move(context_provider), |
846 std::move(worker_context_provider), frame_swap_message_queue_, | 836 std::move(worker_context_provider), frame_swap_message_queue_, |
847 cc::RGBA_8888)); | 837 cc::RGBA_8888)); |
848 } | 838 } |
849 | 839 |
850 std::unique_ptr<cc::BeginFrameSource> | 840 std::unique_ptr<cc::BeginFrameSource> |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 } | 2110 } |
2121 | 2111 |
2122 float RenderWidget::GetOriginalDeviceScaleFactor() const { | 2112 float RenderWidget::GetOriginalDeviceScaleFactor() const { |
2123 return | 2113 return |
2124 screen_metrics_emulator_ ? | 2114 screen_metrics_emulator_ ? |
2125 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : | 2115 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : |
2126 device_scale_factor_; | 2116 device_scale_factor_; |
2127 } | 2117 } |
2128 | 2118 |
2129 } // namespace content | 2119 } // namespace content |
OLD | NEW |