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 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 #endif | 1821 #endif |
1822 | 1822 |
1823 uint32_t output_surface_id = g_next_output_surface_id++; | 1823 uint32_t output_surface_id = g_next_output_surface_id++; |
1824 | 1824 |
1825 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1825 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
1826 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1826 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
1827 cc::VulkanInProcessContextProvider::Create(); | 1827 cc::VulkanInProcessContextProvider::Create(); |
1828 if (vulkan_context_provider) { | 1828 if (vulkan_context_provider) { |
1829 DCHECK(!layout_test_mode()); | 1829 DCHECK(!layout_test_mode()); |
1830 return base::WrapUnique(new CompositorOutputSurface( | 1830 return base::WrapUnique(new CompositorOutputSurface( |
1831 routing_id, output_surface_id, vulkan_context_provider, | 1831 routing_id, output_surface_id, std::move(vulkan_context_provider), |
1832 frame_swap_message_queue)); | 1832 std::move(frame_swap_message_queue))); |
1833 } | 1833 } |
1834 } | 1834 } |
1835 | 1835 |
1836 // Create a gpu process channel and verify we want to use GPU compositing | 1836 // Create a gpu process channel and verify we want to use GPU compositing |
1837 // before creating any context providers. | 1837 // before creating any context providers. |
1838 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; | 1838 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; |
1839 if (!use_software) { | 1839 if (!use_software) { |
1840 gpu_channel_host = EstablishGpuChannelSync( | 1840 gpu_channel_host = EstablishGpuChannelSync( |
1841 CAUSE_FOR_GPU_LAUNCH_RENDERER_VERIFY_GPU_COMPOSITING); | 1841 CAUSE_FOR_GPU_LAUNCH_RENDERER_VERIFY_GPU_COMPOSITING); |
1842 if (!gpu_channel_host) { | 1842 if (!gpu_channel_host) { |
1843 // Cause the compositor to wait and try again. | 1843 // Cause the compositor to wait and try again. |
1844 return nullptr; | 1844 return nullptr; |
1845 } | 1845 } |
1846 // We may get a valid channel, but with a software renderer. In that case, | 1846 // We may get a valid channel, but with a software renderer. In that case, |
1847 // disable GPU compositing. | 1847 // disable GPU compositing. |
1848 if (gpu_channel_host->gpu_info().software_rendering) | 1848 if (gpu_channel_host->gpu_info().software_rendering) |
1849 use_software = true; | 1849 use_software = true; |
1850 } | 1850 } |
1851 | 1851 |
1852 if (use_software) { | 1852 if (use_software) { |
1853 DCHECK(!layout_test_mode()); | 1853 DCHECK(!layout_test_mode()); |
1854 return base::WrapUnique( | 1854 return base::WrapUnique(new CompositorOutputSurface( |
1855 new CompositorOutputSurface(routing_id, output_surface_id, nullptr, | 1855 routing_id, output_surface_id, nullptr, nullptr, |
1856 nullptr, frame_swap_message_queue)); | 1856 std::move(frame_swap_message_queue))); |
1857 } | 1857 } |
1858 | 1858 |
1859 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = | 1859 scoped_refptr<ContextProviderCommandBuffer> worker_context_provider = |
1860 SharedCompositorWorkerContextProvider(); | 1860 SharedCompositorWorkerContextProvider(); |
1861 if (!worker_context_provider) { | 1861 if (!worker_context_provider) { |
1862 // Cause the compositor to wait and try again. | 1862 // Cause the compositor to wait and try again. |
1863 return nullptr; | 1863 return nullptr; |
1864 } | 1864 } |
1865 | 1865 |
1866 // The renderer compositor context doesn't do a lot of stuff, so we don't | 1866 // The renderer compositor context doesn't do a lot of stuff, so we don't |
(...skipping 16 matching lines...) Expand all Loading... |
1883 constexpr bool support_locking = false; | 1883 constexpr bool support_locking = false; |
1884 | 1884 |
1885 // The compositor context shares resources with the worker context unless | 1885 // The compositor context shares resources with the worker context unless |
1886 // the worker is async. | 1886 // the worker is async. |
1887 ContextProviderCommandBuffer* share_context = worker_context_provider.get(); | 1887 ContextProviderCommandBuffer* share_context = worker_context_provider.get(); |
1888 if (IsAsyncWorkerContextEnabled()) | 1888 if (IsAsyncWorkerContextEnabled()) |
1889 share_context = nullptr; | 1889 share_context = nullptr; |
1890 | 1890 |
1891 scoped_refptr<ContextProviderCommandBuffer> context_provider( | 1891 scoped_refptr<ContextProviderCommandBuffer> context_provider( |
1892 new ContextProviderCommandBuffer( | 1892 new ContextProviderCommandBuffer( |
1893 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT, | 1893 gpu_channel_host, gpu::GPU_STREAM_DEFAULT, |
1894 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, | 1894 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, |
1895 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, | 1895 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, |
1896 attributes, share_context, | 1896 attributes, share_context, |
1897 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); | 1897 command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); |
1898 | 1898 |
1899 // Composite-to-mailbox is currently used for layout tests in order to cause | |
1900 // them to draw inside in the renderer to do the readback there. This should | |
1901 // no longer be the case when crbug.com/311404 is fixed. | |
1902 if (layout_test_deps_) { | 1899 if (layout_test_deps_) { |
1903 return layout_test_deps_->CreateOutputSurface( | 1900 return layout_test_deps_->CreateOutputSurface( |
1904 output_surface_id, std::move(context_provider), | 1901 std::move(gpu_channel_host), std::move(context_provider), |
1905 std::move(worker_context_provider)); | 1902 std::move(worker_context_provider), this); |
1906 } | 1903 } |
1907 | 1904 |
1908 #if defined(OS_ANDROID) | 1905 #if defined(OS_ANDROID) |
1909 if (sync_compositor_message_filter_) { | 1906 if (sync_compositor_message_filter_) { |
1910 return base::WrapUnique(new SynchronousCompositorOutputSurface( | 1907 return base::WrapUnique(new SynchronousCompositorOutputSurface( |
1911 context_provider, worker_context_provider, routing_id, | 1908 std::move(context_provider), std::move(worker_context_provider), |
1912 output_surface_id, sync_compositor_message_filter_.get(), | 1909 routing_id, output_surface_id, sync_compositor_message_filter_.get(), |
1913 frame_swap_message_queue)); | 1910 std::move(frame_swap_message_queue))); |
1914 } | 1911 } |
1915 #endif | 1912 #endif |
1916 | 1913 |
1917 return base::WrapUnique(new CompositorOutputSurface( | 1914 return base::WrapUnique(new CompositorOutputSurface( |
1918 routing_id, output_surface_id, std::move(context_provider), | 1915 routing_id, output_surface_id, std::move(context_provider), |
1919 std::move(worker_context_provider), frame_swap_message_queue)); | 1916 std::move(worker_context_provider), std::move(frame_swap_message_queue))); |
1920 } | 1917 } |
1921 | 1918 |
1922 std::unique_ptr<cc::BeginFrameSource> | 1919 std::unique_ptr<cc::BeginFrameSource> |
1923 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1920 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
1924 return base::WrapUnique(new CompositorExternalBeginFrameSource( | 1921 return base::WrapUnique(new CompositorExternalBeginFrameSource( |
1925 compositor_message_filter_.get(), sync_message_filter(), routing_id)); | 1922 compositor_message_filter_.get(), sync_message_filter(), routing_id)); |
1926 } | 1923 } |
1927 | 1924 |
1928 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( | 1925 blink::WebMediaStreamCenter* RenderThreadImpl::CreateMediaStreamCenter( |
1929 blink::WebMediaStreamCenterClient* client) { | 1926 blink::WebMediaStreamCenterClient* client) { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2222 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
2226 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2223 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
2227 | 2224 |
2228 blink::mainThreadIsolate()->MemoryPressureNotification( | 2225 blink::mainThreadIsolate()->MemoryPressureNotification( |
2229 v8_memory_pressure_level); | 2226 v8_memory_pressure_level); |
2230 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2227 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
2231 v8_memory_pressure_level); | 2228 v8_memory_pressure_level); |
2232 } | 2229 } |
2233 | 2230 |
2234 } // namespace content | 2231 } // namespace content |
OLD | NEW |