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

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

Issue 2774373002: Use MojoCompositorFrameSink in RendererCompositorFrameSink (Closed)
Patch Set: Fixed mac 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
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)
254 // Unique identifier for each output surface created. 255 // Unique identifier for each output surface created.
255 uint32_t g_next_compositor_frame_sink_id = 1; 256 uint32_t g_next_compositor_frame_sink_id = 1;
257 #endif
256 258
257 // An implementation of mojom::RenderMessageFilter which can be mocked out 259 // An implementation of mojom::RenderMessageFilter which can be mocked out
258 // for tests which may indirectly send messages over this interface. 260 // for tests which may indirectly send messages over this interface.
259 mojom::RenderMessageFilter* g_render_message_filter_for_testing; 261 mojom::RenderMessageFilter* g_render_message_filter_for_testing;
260 262
261 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access 263 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
262 // incorrectly from the wrong thread. 264 // incorrectly from the wrong thread.
263 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl>>::DestructorAtExit 265 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl>>::DestructorAtExit
264 lazy_tls = LAZY_INSTANCE_INITIALIZER; 266 lazy_tls = LAZY_INSTANCE_INITIALIZER;
265 267
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 needs_to_record_first_active_paint_ = false; 905 needs_to_record_first_active_paint_ = false;
904 906
905 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); 907 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
906 908
907 // If this renderer doesn't run inside the browser process, enable 909 // If this renderer doesn't run inside the browser process, enable
908 // SequencedWorkerPool. Otherwise, it should already have been enabled. 910 // SequencedWorkerPool. Otherwise, it should already have been enabled.
909 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler 911 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler
910 // redirection experiment concludes https://crbug.com/622400. 912 // redirection experiment concludes https://crbug.com/622400.
911 if (!command_line.HasSwitch(switches::kSingleProcess)) 913 if (!command_line.HasSwitch(switches::kSingleProcess))
912 base::SequencedWorkerPool::EnableForProcess(); 914 base::SequencedWorkerPool::EnableForProcess();
915
916 GetConnector()->BindInterface(mojom::kBrowserServiceName,
917 mojo::MakeRequest(&frame_sink_provider_));
913 } 918 }
914 919
915 RenderThreadImpl::~RenderThreadImpl() { 920 RenderThreadImpl::~RenderThreadImpl() {
916 } 921 }
917 922
918 void RenderThreadImpl::Shutdown() { 923 void RenderThreadImpl::Shutdown() {
919 // In a multi-process mode, we immediately exit the renderer. 924 // In a multi-process mode, we immediately exit the renderer.
920 // Historically we had a graceful shutdown sequence here but it was 925 // Historically we had a graceful shutdown sequence here but it was
921 // 1) a waste of performance and 2) a source of lots of complicated 926 // 1) a waste of performance and 2) a source of lots of complicated
922 // crashes caused by shutdown ordering. Immediate exit eliminates 927 // crashes caused by shutdown ordering. Immediate exit eliminates
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 return; 1909 return;
1905 } 1910 }
1906 RendererWindowTreeClient::Get(routing_id) 1911 RendererWindowTreeClient::Get(routing_id)
1907 ->RequestCompositorFrameSink( 1912 ->RequestCompositorFrameSink(
1908 gpu_->CreateContextProvider(std::move(channel)), 1913 gpu_->CreateContextProvider(std::move(channel)),
1909 GetGpuMemoryBufferManager(), callback); 1914 GetGpuMemoryBufferManager(), callback);
1910 return; 1915 return;
1911 } 1916 }
1912 #endif 1917 #endif
1913 1918
1914 uint32_t compositor_frame_sink_id = g_next_compositor_frame_sink_id++;
1915
1916 if (command_line.HasSwitch(switches::kEnableVulkan)) { 1919 if (command_line.HasSwitch(switches::kEnableVulkan)) {
1917 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = 1920 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider =
1918 cc::VulkanInProcessContextProvider::Create(); 1921 cc::VulkanInProcessContextProvider::Create();
1919 if (vulkan_context_provider) { 1922 if (vulkan_context_provider) {
1920 DCHECK(!layout_test_mode()); 1923 DCHECK(!layout_test_mode());
1921 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1924 callback.Run(base::MakeUnique<RendererCompositorFrameSink>(
1922 routing_id, compositor_frame_sink_id, 1925 routing_id, std::move(synthetic_begin_frame_source),
1923 std::move(synthetic_begin_frame_source),
1924 std::move(vulkan_context_provider), 1926 std::move(vulkan_context_provider),
1925 std::move(frame_swap_message_queue))); 1927 std::move(frame_swap_message_queue)));
1926 return; 1928 return;
1927 } 1929 }
1928 } 1930 }
1929 1931
1930 // Create a gpu process channel and verify we want to use GPU compositing 1932 // Create a gpu process channel and verify we want to use GPU compositing
1931 // before creating any context providers. 1933 // before creating any context providers.
1932 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host; 1934 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host;
1933 if (!use_software) { 1935 if (!use_software) {
1934 gpu_channel_host = EstablishGpuChannelSync(); 1936 gpu_channel_host = EstablishGpuChannelSync();
1935 if (!gpu_channel_host) { 1937 if (!gpu_channel_host) {
1936 // Cause the compositor to wait and try again. 1938 // Cause the compositor to wait and try again.
1937 callback.Run(nullptr); 1939 callback.Run(nullptr);
1938 return; 1940 return;
1939 } 1941 }
1940 // We may get a valid channel, but with a software renderer. In that case, 1942 // We may get a valid channel, but with a software renderer. In that case,
1941 // disable GPU compositing. 1943 // disable GPU compositing.
1942 if (gpu_channel_host->gpu_info().software_rendering) 1944 if (gpu_channel_host->gpu_info().software_rendering)
1943 use_software = true; 1945 use_software = true;
1944 } 1946 }
1945 1947
1946 if (use_software) { 1948 if (use_software) {
1947 DCHECK(!layout_test_mode()); 1949 DCHECK(!layout_test_mode());
1948 callback.Run(base::MakeUnique<RendererCompositorFrameSink>( 1950 callback.Run(base::MakeUnique<RendererCompositorFrameSink>(
1949 routing_id, compositor_frame_sink_id, 1951 routing_id, std::move(synthetic_begin_frame_source), nullptr, nullptr,
1950 std::move(synthetic_begin_frame_source), nullptr, nullptr, nullptr, 1952 nullptr, shared_bitmap_manager(), std::move(frame_swap_message_queue)));
1951 shared_bitmap_manager(), std::move(frame_swap_message_queue)));
1952 return; 1953 return;
1953 } 1954 }
1954 1955
1955 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider = 1956 scoped_refptr<ui::ContextProviderCommandBuffer> worker_context_provider =
1956 SharedCompositorWorkerContextProvider(); 1957 SharedCompositorWorkerContextProvider();
1957 if (!worker_context_provider) { 1958 if (!worker_context_provider) {
1958 // Cause the compositor to wait and try again. 1959 // Cause the compositor to wait and try again.
1959 callback.Run(nullptr); 1960 callback.Run(nullptr);
1960 return; 1961 return;
1961 } 1962 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 2003
2003 #if defined(OS_ANDROID) 2004 #if defined(OS_ANDROID)
2004 if (sync_compositor_message_filter_) { 2005 if (sync_compositor_message_filter_) {
2005 std::unique_ptr<cc::BeginFrameSource> begin_frame_source = 2006 std::unique_ptr<cc::BeginFrameSource> begin_frame_source =
2006 synthetic_begin_frame_source 2007 synthetic_begin_frame_source
2007 ? std::move(synthetic_begin_frame_source) 2008 ? std::move(synthetic_begin_frame_source)
2008 : CreateExternalBeginFrameSource(routing_id); 2009 : CreateExternalBeginFrameSource(routing_id);
2009 callback.Run(base::MakeUnique<SynchronousCompositorFrameSink>( 2010 callback.Run(base::MakeUnique<SynchronousCompositorFrameSink>(
2010 std::move(context_provider), std::move(worker_context_provider), 2011 std::move(context_provider), std::move(worker_context_provider),
2011 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id, 2012 GetGpuMemoryBufferManager(), shared_bitmap_manager(), routing_id,
2012 compositor_frame_sink_id, std::move(begin_frame_source), 2013 g_next_compositor_frame_sink_id++, std::move(begin_frame_source),
2013 sync_compositor_message_filter_.get(), 2014 sync_compositor_message_filter_.get(),
2014 std::move(frame_swap_message_queue))); 2015 std::move(frame_swap_message_queue)));
2015 return; 2016 return;
2016 } 2017 }
2017 #endif 2018 #endif
2018 callback.Run(base::WrapUnique(new RendererCompositorFrameSink( 2019 callback.Run(base::WrapUnique(new RendererCompositorFrameSink(
2019 routing_id, compositor_frame_sink_id, 2020 routing_id, std::move(synthetic_begin_frame_source),
2020 std::move(synthetic_begin_frame_source), std::move(context_provider), 2021 std::move(context_provider), std::move(worker_context_provider),
2021 std::move(worker_context_provider), GetGpuMemoryBufferManager(), nullptr, 2022 GetGpuMemoryBufferManager(), nullptr,
2022 std::move(frame_swap_message_queue)))); 2023 std::move(frame_swap_message_queue))));
2023 } 2024 }
2024 2025
2025 AssociatedInterfaceRegistry* 2026 AssociatedInterfaceRegistry*
2026 RenderThreadImpl::GetAssociatedInterfaceRegistry() { 2027 RenderThreadImpl::GetAssociatedInterfaceRegistry() {
2027 return &associated_interfaces_; 2028 return &associated_interfaces_;
2028 } 2029 }
2029 2030
2030 std::unique_ptr<cc::SwapPromise> 2031 std::unique_ptr<cc::SwapPromise>
2031 RenderThreadImpl::RequestCopyOfOutputForLayoutTest( 2032 RenderThreadImpl::RequestCopyOfOutputForLayoutTest(
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 } 2466 }
2466 } 2467 }
2467 2468
2468 void RenderThreadImpl::OnRendererInterfaceRequest( 2469 void RenderThreadImpl::OnRendererInterfaceRequest(
2469 mojom::RendererAssociatedRequest request) { 2470 mojom::RendererAssociatedRequest request) {
2470 DCHECK(!renderer_binding_.is_bound()); 2471 DCHECK(!renderer_binding_.is_bound());
2471 renderer_binding_.Bind(std::move(request)); 2472 renderer_binding_.Bind(std::move(request));
2472 } 2473 }
2473 2474
2474 } // namespace content 2475 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698