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_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 #endif | 1816 #endif |
1817 | 1817 |
1818 uint32_t output_surface_id = g_next_output_surface_id++; | 1818 uint32_t output_surface_id = g_next_output_surface_id++; |
1819 | 1819 |
1820 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1820 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
1821 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1821 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
1822 cc::VulkanInProcessContextProvider::Create(); | 1822 cc::VulkanInProcessContextProvider::Create(); |
1823 if (vulkan_context_provider) { | 1823 if (vulkan_context_provider) { |
1824 DCHECK(!layout_test_mode()); | 1824 DCHECK(!layout_test_mode()); |
1825 return base::WrapUnique(new CompositorOutputSurface( | 1825 return base::WrapUnique(new CompositorOutputSurface( |
1826 routing_id, output_surface_id, vulkan_context_provider, | 1826 routing_id, output_surface_id, std::move(vulkan_context_provider), |
1827 frame_swap_message_queue)); | 1827 std::move(frame_swap_message_queue))); |
1828 } | 1828 } |
1829 } | 1829 } |
1830 | 1830 |
1831 // Create a gpu process channel and verify we want to use GPU compositing | 1831 // Create a gpu process channel and verify we want to use GPU compositing |
1832 // before creating any context providers. | 1832 // before creating any context providers. |
1833 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 1833 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
1834 if (!use_software) { | 1834 if (!use_software) { |
1835 gpu_channel_host = EstablishGpuChannelSync( | 1835 gpu_channel_host = EstablishGpuChannelSync( |
1836 CAUSE_FOR_GPU_LAUNCH_RENDERER_VERIFY_GPU_COMPOSITING); | 1836 CAUSE_FOR_GPU_LAUNCH_RENDERER_VERIFY_GPU_COMPOSITING); |
1837 if (!gpu_channel_host) { | 1837 if (!gpu_channel_host) { |
1838 // Cause the compositor to wait and try again. | 1838 // Cause the compositor to wait and try again. |
1839 return nullptr; | 1839 return nullptr; |
1840 } | 1840 } |
1841 // We may get a valid channel, but with a software renderer. In that case, | 1841 // We may get a valid channel, but with a software renderer. In that case, |
1842 // disable GPU compositing. | 1842 // disable GPU compositing. |
1843 if (gpu_channel_host->gpu_info().software_rendering) | 1843 if (gpu_channel_host->gpu_info().software_rendering) |
1844 use_software = true; | 1844 use_software = true; |
1845 } | 1845 } |
1846 | 1846 |
1847 if (use_software) { | 1847 if (use_software) { |
1848 DCHECK(!layout_test_mode()); | 1848 DCHECK(!layout_test_mode()); |
1849 return base::WrapUnique( | 1849 return base::WrapUnique(new CompositorOutputSurface( |
1850 new CompositorOutputSurface(routing_id, output_surface_id, nullptr, | 1850 routing_id, output_surface_id, nullptr, nullptr, |
1851 nullptr, frame_swap_message_queue)); | 1851 std::move(frame_swap_message_queue))); |
1852 } | 1852 } |
1853 | 1853 |
1854 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = | 1854 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = |
1855 SharedCompositorWorkerContextProvider(); | 1855 SharedCompositorWorkerContextProvider(); |
1856 if (!worker_context_provider) { | 1856 if (!worker_context_provider) { |
1857 // Cause the compositor to wait and try again. | 1857 // Cause the compositor to wait and try again. |
1858 return nullptr; | 1858 return nullptr; |
1859 } | 1859 } |
1860 | 1860 |
1861 // The renderer compositor context doesn't do a lot of stuff, so we don't | 1861 // The renderer compositor context doesn't do a lot of stuff, so we don't |
(...skipping 16 matching lines...) Expand all Loading... |
1878 constexpr bool support_locking = false; | 1878 constexpr bool support_locking = false; |
1879 | 1879 |
1880 // The compositor context shares resources with the worker context unless | 1880 // The compositor context shares resources with the worker context unless |
1881 // the worker is async. | 1881 // the worker is async. |
1882 ContextProviderCommandBuffer* share_context = worker_context_provider.get(); | 1882 ContextProviderCommandBuffer* share_context = worker_context_provider.get(); |
1883 if (IsAsyncWorkerContextEnabled()) | 1883 if (IsAsyncWorkerContextEnabled()) |
1884 share_context = nullptr; | 1884 share_context = nullptr; |
1885 | 1885 |
1886 scoped_refptr<ContextProviderCommandBuffer> context_provider( | 1886 scoped_refptr<ContextProviderCommandBuffer> context_provider( |
1887 new ContextProviderCommandBuffer( | 1887 new ContextProviderCommandBuffer( |
1888 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 1888 gpu_channel_host, gpu::GPU_STREAM_DEFAULT, |
1889 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, | 1889 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, |
1890 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, | 1890 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, |
1891 attributes, share_context, | 1891 attributes, share_context, |
1892 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); | 1892 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); |
1893 | 1893 |
1894 // Composite-to-mailbox is currently used for layout tests in order to cause | |
1895 // them to draw inside in the renderer to do the readback there. This should | |
1896 // no longer be the case when crbug.com/311404 is fixed. | |
1897 if (layout_test_deps_) { | 1894 if (layout_test_deps_) { |
1898 return layout_test_deps_->CreateOutputSurface( | 1895 return layout_test_deps_->CreateOutputSurface( |
1899 output_surface_id, std::move(context_provider), | 1896 std::move(gpu_channel_host), std::move(context_provider), |
1900 std::move(worker_context_provider)); | 1897 std::move(worker_context_provider), this); |
1901 } | 1898 } |
1902 | 1899 |
1903 #if defined(OS_ANDROID) | 1900 #if defined(OS_ANDROID) |
1904 if (sync_compositor_message_filter_) { | 1901 if (sync_compositor_message_filter_) { |
1905 return base::WrapUnique(new SynchronousCompositorOutputSurface( | 1902 return base::WrapUnique(new SynchronousCompositorOutputSurface( |
1906 context_provider, worker_context_provider, routing_id, | 1903 std::move(context_provider), std::move(worker_context_provider), |
1907 output_surface_id, sync_compositor_message_filter_.get(), | 1904 routing_id, output_surface_id, sync_compositor_message_filter_.get(), |
1908 frame_swap_message_queue)); | 1905 std::move(frame_swap_message_queue))); |
1909 } | 1906 } |
1910 #endif | 1907 #endif |
1911 | 1908 |
1912 return base::WrapUnique(new CompositorOutputSurface( | 1909 return base::WrapUnique(new CompositorOutputSurface( |
1913 routing_id, output_surface_id, std::move(context_provider), | 1910 routing_id, output_surface_id, std::move(context_provider), |
1914 std::move(worker_context_provider), frame_swap_message_queue)); | 1911 std::move(worker_context_provider), std::move(frame_swap_message_queue))); |
1915 } | 1912 } |
1916 | 1913 |
1917 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1914 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
1918 blink::WebMediaStreamCenterClient* client) { | 1915 blink::WebMediaStreamCenterClient* client) { |
1919 #if defined(ENABLE_WEBRTC) | 1916 #if defined(ENABLE_WEBRTC) |
1920 if (!media_stream_center_) { | 1917 if (!media_stream_center_) { |
1921 media_stream_center_ = GetContentClient()->renderer() | 1918 media_stream_center_ = GetContentClient()->renderer() |
1922 ->OverrideCreateWebMediaStreamCenter(client); | 1919 ->OverrideCreateWebMediaStreamCenter(client); |
1923 if (!media_stream_center_) { | 1920 if (!media_stream_center_) { |
1924 std::unique_ptr<MediaStreamCenter> media_stream_center( | 1921 std::unique_ptr<MediaStreamCenter> media_stream_center( |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2209 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
2213 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2210 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
2214 | 2211 |
2215 blink::mainThreadIsolate()->MemoryPressureNotification( | 2212 blink::mainThreadIsolate()->MemoryPressureNotification( |
2216 v8_memory_pressure_level); | 2213 v8_memory_pressure_level); |
2217 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2214 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
2218 v8_memory_pressure_level); | 2215 v8_memory_pressure_level); |
2219 } | 2216 } |
2220 | 2217 |
2221 } // namespace content | 2218 } // namespace content |
OLD | NEW |