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