Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2835403004: Revert "Use MojoCompositorFrameSink in RendererCompositorFrameSink"
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 const int kMaxResourceRequestsPerFlushWhenThrottled = 8; 244 const int kMaxResourceRequestsPerFlushWhenThrottled = 8;
245 #endif 245 #endif
246 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; 246 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.;
247 247
248 // Maximum allocation size allowed for image scaling filters that 248 // Maximum allocation size allowed for image scaling filters that
249 // require pre-scaling. Skia will fallback to a filter that doesn't 249 // require pre-scaling. Skia will fallback to a filter that doesn't
250 // require pre-scaling if the default filter would require an 250 // require pre-scaling if the default filter would require an
251 // allocation that exceeds this limit. 251 // allocation that exceeds this limit.
252 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; 252 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024;
253 253
254 #if defined(OS_ANDROID)
255 // Unique identifier for each output surface created. 254 // Unique identifier for each output surface created.
256 uint32_t g_next_compositor_frame_sink_id = 1; 255 uint32_t g_next_compositor_frame_sink_id = 1;
257 #endif
258 256
259 // An implementation of mojom::RenderMessageFilter which can be mocked out 257 // An implementation of mojom::RenderMessageFilter which can be mocked out
260 // for tests which may indirectly send messages over this interface. 258 // for tests which may indirectly send messages over this interface.
261 mojom::RenderMessageFilter* g_render_message_filter_for_testing; 259 mojom::RenderMessageFilter* g_render_message_filter_for_testing;
262 260
263 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access 261 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
264 // incorrectly from the wrong thread. 262 // incorrectly from the wrong thread.
265 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl>>::DestructorAtExit 263 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl>>::DestructorAtExit
266 lazy_tls = LAZY_INSTANCE_INITIALIZER; 264 lazy_tls = LAZY_INSTANCE_INITIALIZER;
267 265
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 needs_to_record_first_active_paint_ = false; 885 needs_to_record_first_active_paint_ = false;
888 886
889 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); 887 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
890 888
891 // If this renderer doesn't run inside the browser process, enable 889 // If this renderer doesn't run inside the browser process, enable
892 // SequencedWorkerPool. Otherwise, it should already have been enabled. 890 // SequencedWorkerPool. Otherwise, it should already have been enabled.
893 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler 891 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler
894 // redirection experiment concludes https://crbug.com/622400. 892 // redirection experiment concludes https://crbug.com/622400.
895 if (!command_line.HasSwitch(switches::kSingleProcess)) 893 if (!command_line.HasSwitch(switches::kSingleProcess))
896 base::SequencedWorkerPool::EnableForProcess(); 894 base::SequencedWorkerPool::EnableForProcess();
897
898 GetConnector()->BindInterface(mojom::kBrowserServiceName,
899 mojo::MakeRequest(&frame_sink_provider_));
900 } 895 }
901 896
902 RenderThreadImpl::~RenderThreadImpl() { 897 RenderThreadImpl::~RenderThreadImpl() {
903 } 898 }
904 899
905 void RenderThreadImpl::Shutdown() { 900 void RenderThreadImpl::Shutdown() {
906 // In a multi-process mode, we immediately exit the renderer. 901 // In a multi-process mode, we immediately exit the renderer.
907 // Historically we had a graceful shutdown sequence here but it was 902 // Historically we had a graceful shutdown sequence here but it was
908 // 1) a waste of performance and 2) a source of lots of complicated 903 // 1) a waste of performance and 2) a source of lots of complicated
909 // crashes caused by shutdown ordering. Immediate exit eliminates 904 // crashes caused by shutdown ordering. Immediate exit eliminates
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 return; 1852 return;
1858 } 1853 }
1859 RendererWindowTreeClient::Get(routing_id) 1854 RendererWindowTreeClient::Get(routing_id)
1860 ->RequestCompositorFrameSink( 1855 ->RequestCompositorFrameSink(
1861 gpu_->CreateContextProvider(std::move(channel)), 1856 gpu_->CreateContextProvider(std::move(channel)),
1862 GetGpuMemoryBufferManager(), callback); 1857 GetGpuMemoryBufferManager(), callback);
1863 return; 1858 return;
1864 } 1859 }
1865 #endif 1860 #endif
1866 1861
1862 uint32_t compositor_frame_sink_id = g_next_compositor_frame_sink_id++;
1863
1867 if (command_line.HasSwitch(switches::kEnableVulkan)) { 1864 if (command_line.HasSwitch(switches::kEnableVulkan)) {
1868 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = 1865 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider =
1869 cc::VulkanInProcessContextProvider::Create(); 1866 cc::VulkanInProcessContextProvider::Create();
1870 if (vulkan_context_provider) { 1867 if (vulkan_context_provider) {
1871 DCHECK(!layout_test_mode()); 1868 DCHECK(!layout_test_mode());
1872 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1869 callback.Run(base::MakeUnique<RendererCompositorFrameSink>(
1873 routing_id, std::move(synthetic_begin_frame_source), 1870 routing_id, compositor_frame_sink_id,
1871 std::move(synthetic_begin_frame_source),
1874 std::move(vulkan_context_provider), 1872 std::move(vulkan_context_provider),
1875 std::move(frame_swap_message_queue))); 1873 std::move(frame_swap_message_queue)));
1876 return; 1874 return;
1877 } 1875 }
1878 } 1876 }
1879 1877
1880 // Create a gpu process channel and verify we want to use GPU compositing 1878 // Create a gpu process channel and verify we want to use GPU compositing
1881 // before creating any context providers. 1879 // before creating any context providers.
1882 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; 1880 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
1883 if (!use_software) { 1881 if (!use_software) {
1884 gpu_channel_host = EstablishGpuChannelSync(); 1882 gpu_channel_host = EstablishGpuChannelSync();
1885 if (!gpu_channel_host) { 1883 if (!gpu_channel_host) {
1886 // Cause the compositor to wait and try again. 1884 // Cause the compositor to wait and try again.
1887 callback.Run(nullptr); 1885 callback.Run(nullptr);
1888 return; 1886 return;
1889 } 1887 }
1890 // We may get a valid channel, but with a software renderer. In that case, 1888 // We may get a valid channel, but with a software renderer. In that case,
1891 // disable GPU compositing. 1889 // disable GPU compositing.
1892 if (gpu_channel_host->gpu_info().software_rendering) 1890 if (gpu_channel_host->gpu_info().software_rendering)
1893 use_software = true; 1891 use_software = true;
1894 } 1892 }
1895 1893
1896 if (use_software) { 1894 if (use_software) {
1897 DCHECK(!layout_test_mode()); 1895 DCHECK(!layout_test_mode());
1898 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1896 callback.Run(base::MakeUnique<RendererCompositorFrameSink>(
1899 routing_id, std::move(synthetic_begin_frame_source), nullptr, nullptr, 1897 routing_id, compositor_frame_sink_id,
1900 nullptr, shared_bitmap_manager(), std::move(frame_swap_message_queue))); 1898 std::move(synthetic_begin_frame_source), nullptr, nullptr, nullptr,
1899 shared_bitmap_manager(), std::move(frame_swap_message_queue)));
1901 return; 1900 return;
1902 } 1901 }
1903 1902
1904 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider = 1903 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider =
1905 SharedCompositorWorkerContextProvider(); 1904 SharedCompositorWorkerContextProvider();
1906 if (!worker_context_provider) { 1905 if (!worker_context_provider) {
1907 // Cause the compositor to wait and try again. 1906 // Cause the compositor to wait and try again.
1908 callback.Run(nullptr); 1907 callback.Run(nullptr);
1909 return; 1908 return;
1910 } 1909 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 1950
1952 #if defined(OS_ANDROID) 1951 #if defined(OS_ANDROID)
1953 if (sync_compositor_message_filter_) { 1952 if (sync_compositor_message_filter_) {
1954 std::unique_ptr<cc::BeginFrameSource> begin_frame_source = 1953 std::unique_ptr<cc::BeginFrameSource> begin_frame_source =
1955 synthetic_begin_frame_source 1954 synthetic_begin_frame_source
1956 ? std::move(synthetic_begin_frame_source) 1955 ? std::move(synthetic_begin_frame_source)
1957 : CreateExternalBeginFrameSource(routing_id); 1956 : CreateExternalBeginFrameSource(routing_id);
1958 callback.Run(base::MakeUnique<SynchronousCompositorFrameSink>( 1957 callback.Run(base::MakeUnique<SynchronousCompositorFrameSink>(
1959 std::move(context_provider), std::move(worker_context_provider), 1958 std::move(context_provider), std::move(worker_context_provider),
1960 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id, 1959 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id,
1961 g_next_compositor_frame_sink_id++, std::move(begin_frame_source), 1960 compositor_frame_sink_id, std::move(begin_frame_source),
1962 sync_compositor_message_filter_.get(), 1961 sync_compositor_message_filter_.get(),
1963 std::move(frame_swap_message_queue))); 1962 std::move(frame_swap_message_queue)));
1964 return; 1963 return;
1965 } 1964 }
1966 #endif 1965 #endif
1967 callback.Run(base::WrapUnique(new RendererCompositorFrameSink( 1966 callback.Run(base::WrapUnique(new RendererCompositorFrameSink(
1968 routing_id, std::move(synthetic_begin_frame_source), 1967 routing_id, compositor_frame_sink_id,
1969 std::move(context_provider), std::move(worker_context_provider), 1968 std::move(synthetic_begin_frame_source), std::move(context_provider),
1970 GetGpuMemoryBufferManager(), nullptr, 1969 std::move(worker_context_provider), GetGpuMemoryBufferManager(), nullptr,
1971 std::move(frame_swap_message_queue)))); 1970 std::move(frame_swap_message_queue))));
1972 } 1971 }
1973 1972
1974 AssociatedInterfaceRegistry* 1973 AssociatedInterfaceRegistry*
1975 RenderThreadImpl::GetAssociatedInterfaceRegistry() { 1974 RenderThreadImpl::GetAssociatedInterfaceRegistry() {
1976 return &associated_interfaces_; 1975 return &associated_interfaces_;
1977 } 1976 }
1978 1977
1979 std::unique_ptr<cc::SwapPromise> 1978 std::unique_ptr<cc::SwapPromise>
1980 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( 1979 RenderThreadImpl::RequestCopyOfOutputForLayoutTest(
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 } 2413 }
2415 } 2414 }
2416 2415
2417 void RenderThreadImpl::OnRendererInterfaceRequest( 2416 void RenderThreadImpl::OnRendererInterfaceRequest(
2418 mojom::RendererAssociatedRequest request) { 2417 mojom::RendererAssociatedRequest request) {
2419 DCHECK(!renderer_binding_.is_bound()); 2418 DCHECK(!renderer_binding_.is_bound());
2420 renderer_binding_.Bind(std::move(request)); 2419 renderer_binding_.Bind(std::move(request));
2421 } 2420 }
2422 2421
2423 } // namespace content 2422 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698