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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "content/child/thread_safe_sender.h" | 68 #include "content/child/thread_safe_sender.h" |
69 #include "content/child/web_database_observer_impl.h" | 69 #include "content/child/web_database_observer_impl.h" |
70 #include "content/child/worker_thread_registry.h" | 70 #include "content/child/worker_thread_registry.h" |
71 #include "content/common/child_process_messages.h" | 71 #include "content/common/child_process_messages.h" |
72 #include "content/common/content_constants_internal.h" | 72 #include "content/common/content_constants_internal.h" |
73 #include "content/common/dom_storage/dom_storage_messages.h" | 73 #include "content/common/dom_storage/dom_storage_messages.h" |
74 #include "content/common/features.h" | 74 #include "content/common/features.h" |
75 #include "content/common/field_trial_recorder.mojom.h" | 75 #include "content/common/field_trial_recorder.mojom.h" |
76 #include "content/common/frame_messages.h" | 76 #include "content/common/frame_messages.h" |
77 #include "content/common/frame_owner_properties.h" | 77 #include "content/common/frame_owner_properties.h" |
| 78 #include "content/common/gpu_stream_constants.h" |
78 #include "content/common/render_process_messages.h" | 79 #include "content/common/render_process_messages.h" |
79 #include "content/common/resource_messages.h" | 80 #include "content/common/resource_messages.h" |
80 #include "content/common/site_isolation_policy.h" | 81 #include "content/common/site_isolation_policy.h" |
81 #include "content/common/view_messages.h" | 82 #include "content/common/view_messages.h" |
82 #include "content/common/worker_messages.h" | 83 #include "content/common/worker_messages.h" |
83 #include "content/public/common/content_constants.h" | 84 #include "content/public/common/content_constants.h" |
84 #include "content/public/common/content_features.h" | 85 #include "content/public/common/content_features.h" |
85 #include "content/public/common/content_paths.h" | 86 #include "content/public/common/content_paths.h" |
86 #include "content/public/common/content_switches.h" | 87 #include "content/public/common/content_switches.h" |
87 #include "content/public/common/renderer_preferences.h" | 88 #include "content/public/common/renderer_preferences.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(source_info), | 360 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(source_info), |
360 std::move(request)); | 361 std::move(request)); |
361 } | 362 } |
362 | 363 |
363 scoped_refptr<ui::ContextProviderCommandBuffer> CreateOffscreenContext( | 364 scoped_refptr<ui::ContextProviderCommandBuffer> CreateOffscreenContext( |
364 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 365 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
365 const gpu::SharedMemoryLimits& limits, | 366 const gpu::SharedMemoryLimits& limits, |
366 bool support_locking, | 367 bool support_locking, |
367 ui::command_buffer_metrics::ContextType type, | 368 ui::command_buffer_metrics::ContextType type, |
368 int32_t stream_id, | 369 int32_t stream_id, |
369 gpu::GpuStreamPriority stream_priority) { | 370 gpu::SchedulingPriority stream_priority) { |
370 DCHECK(gpu_channel_host); | 371 DCHECK(gpu_channel_host); |
371 // This is used to create a few different offscreen contexts: | 372 // This is used to create a few different offscreen contexts: |
372 // - The shared main thread context (offscreen) used by blink for canvas. | 373 // - The shared main thread context (offscreen) used by blink for canvas. |
373 // - The worker context (offscreen) used for GPU raster and video decoding. | 374 // - The worker context (offscreen) used for GPU raster and video decoding. |
374 // This is for an offscreen context, so the default framebuffer doesn't need | 375 // This is for an offscreen context, so the default framebuffer doesn't need |
375 // alpha, depth, stencil, antialiasing. | 376 // alpha, depth, stencil, antialiasing. |
376 gpu::gles2::ContextCreationAttribHelper attributes; | 377 gpu::gles2::ContextCreationAttribHelper attributes; |
377 attributes.alpha_size = -1; | 378 attributes.alpha_size = -1; |
378 attributes.depth_size = 0; | 379 attributes.depth_size = 0; |
379 attributes.stencil_size = 0; | 380 attributes.stencil_size = 0; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 EstablishGpuChannelSync(); | 1390 EstablishGpuChannelSync(); |
1390 if (!gpu_channel_host) | 1391 if (!gpu_channel_host) |
1391 return nullptr; | 1392 return nullptr; |
1392 // This context is only used to create textures and mailbox them, so | 1393 // This context is only used to create textures and mailbox them, so |
1393 // use lower limits than the default. | 1394 // use lower limits than the default. |
1394 gpu::SharedMemoryLimits limits = gpu::SharedMemoryLimits::ForMailboxContext(); | 1395 gpu::SharedMemoryLimits limits = gpu::SharedMemoryLimits::ForMailboxContext(); |
1395 bool support_locking = true; | 1396 bool support_locking = true; |
1396 scoped_refptr<ui::ContextProviderCommandBuffer> media_context_provider = | 1397 scoped_refptr<ui::ContextProviderCommandBuffer> media_context_provider = |
1397 CreateOffscreenContext(gpu_channel_host, limits, support_locking, | 1398 CreateOffscreenContext(gpu_channel_host, limits, support_locking, |
1398 ui::command_buffer_metrics::MEDIA_CONTEXT, | 1399 ui::command_buffer_metrics::MEDIA_CONTEXT, |
1399 gpu::GPU_STREAM_DEFAULT, | 1400 kGpuStreamIdDefault, kGpuStreamPriorityDefault); |
1400 gpu::GpuStreamPriority::NORMAL); | |
1401 if (!media_context_provider->BindToCurrentThread()) | 1401 if (!media_context_provider->BindToCurrentThread()) |
1402 return nullptr; | 1402 return nullptr; |
1403 | 1403 |
1404 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = | 1404 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = |
1405 GetMediaThreadTaskRunner(); | 1405 GetMediaThreadTaskRunner(); |
1406 const bool enable_video_accelerator = | 1406 const bool enable_video_accelerator = |
1407 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); | 1407 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); |
1408 const bool enable_gpu_memory_buffer_video_frames = | 1408 const bool enable_gpu_memory_buffer_video_frames = |
1409 #if defined(OS_MACOSX) || defined(OS_LINUX) | 1409 #if defined(OS_MACOSX) || defined(OS_LINUX) |
1410 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames) && | 1410 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames) && |
(...skipping 29 matching lines...) Expand all Loading... |
1440 EstablishGpuChannelSync()); | 1440 EstablishGpuChannelSync()); |
1441 if (!gpu_channel_host) { | 1441 if (!gpu_channel_host) { |
1442 shared_main_thread_contexts_ = nullptr; | 1442 shared_main_thread_contexts_ = nullptr; |
1443 return nullptr; | 1443 return nullptr; |
1444 } | 1444 } |
1445 | 1445 |
1446 bool support_locking = false; | 1446 bool support_locking = false; |
1447 shared_main_thread_contexts_ = CreateOffscreenContext( | 1447 shared_main_thread_contexts_ = CreateOffscreenContext( |
1448 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, | 1448 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, |
1449 ui::command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT, | 1449 ui::command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT, |
1450 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL); | 1450 kGpuStreamIdDefault, kGpuStreamPriorityDefault); |
1451 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 1451 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
1452 shared_main_thread_contexts_ = nullptr; | 1452 shared_main_thread_contexts_ = nullptr; |
1453 return shared_main_thread_contexts_; | 1453 return shared_main_thread_contexts_; |
1454 } | 1454 } |
1455 | 1455 |
1456 #if defined(OS_ANDROID) | 1456 #if defined(OS_ANDROID) |
1457 | 1457 |
1458 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1458 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
1459 DCHECK(IsMainThread()); | 1459 DCHECK(IsMainThread()); |
1460 if (!stream_texture_factory_.get() || | 1460 if (!stream_texture_factory_.get() || |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 | 1953 |
1954 // The compositor context shares resources with the worker context unless | 1954 // The compositor context shares resources with the worker context unless |
1955 // the worker is async. | 1955 // the worker is async. |
1956 ui::ContextProviderCommandBuffer* share_context = | 1956 ui::ContextProviderCommandBuffer* share_context = |
1957 worker_context_provider.get(); | 1957 worker_context_provider.get(); |
1958 if (IsAsyncWorkerContextEnabled()) | 1958 if (IsAsyncWorkerContextEnabled()) |
1959 share_context = nullptr; | 1959 share_context = nullptr; |
1960 | 1960 |
1961 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider( | 1961 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider( |
1962 new ui::ContextProviderCommandBuffer( | 1962 new ui::ContextProviderCommandBuffer( |
1963 gpu_channel_host, gpu::GPU_STREAM_DEFAULT, | 1963 gpu_channel_host, kGpuStreamIdDefault, kGpuStreamPriorityDefault, |
1964 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, url, | 1964 gpu::kNullSurfaceHandle, url, automatic_flushes, support_locking, |
1965 automatic_flushes, support_locking, limits, attributes, share_context, | 1965 limits, attributes, share_context, |
1966 ui::command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); | 1966 ui::command_buffer_metrics::RENDER_COMPOSITOR_CONTEXT)); |
1967 | 1967 |
1968 if (layout_test_deps_) { | 1968 if (layout_test_deps_) { |
1969 callback.Run(layout_test_deps_->CreateCompositorFrameSink( | 1969 callback.Run(layout_test_deps_->CreateCompositorFrameSink( |
1970 routing_id, std::move(gpu_channel_host), std::move(context_provider), | 1970 routing_id, std::move(gpu_channel_host), std::move(context_provider), |
1971 std::move(worker_context_provider), GetGpuMemoryBufferManager(), this)); | 1971 std::move(worker_context_provider), GetGpuMemoryBufferManager(), this)); |
1972 return; | 1972 return; |
1973 } | 1973 } |
1974 | 1974 |
1975 #if defined(OS_ANDROID) | 1975 #if defined(OS_ANDROID) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 return shared_worker_context_provider_; | 2296 return shared_worker_context_provider_; |
2297 } | 2297 } |
2298 | 2298 |
2299 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( | 2299 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host( |
2300 EstablishGpuChannelSync()); | 2300 EstablishGpuChannelSync()); |
2301 if (!gpu_channel_host) { | 2301 if (!gpu_channel_host) { |
2302 shared_worker_context_provider_ = nullptr; | 2302 shared_worker_context_provider_ = nullptr; |
2303 return shared_worker_context_provider_; | 2303 return shared_worker_context_provider_; |
2304 } | 2304 } |
2305 | 2305 |
2306 int32_t stream_id = gpu::GPU_STREAM_DEFAULT; | 2306 int32_t stream_id = kGpuStreamIdDefault; |
2307 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 2307 gpu::SchedulingPriority stream_priority = kGpuStreamPriorityDefault; |
2308 if (is_async_worker_context_enabled_) { | 2308 if (is_async_worker_context_enabled_) { |
2309 stream_id = gpu_channel_host->GenerateStreamID(); | 2309 stream_id = kGpuStreamIdWorker; |
2310 stream_priority = gpu::GpuStreamPriority::LOW; | 2310 stream_priority = kGpuStreamPriorityWorker; |
2311 } | 2311 } |
2312 | 2312 |
2313 bool support_locking = true; | 2313 bool support_locking = true; |
2314 shared_worker_context_provider_ = CreateOffscreenContext( | 2314 shared_worker_context_provider_ = CreateOffscreenContext( |
2315 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, | 2315 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, |
2316 ui::command_buffer_metrics::RENDER_WORKER_CONTEXT, stream_id, | 2316 ui::command_buffer_metrics::RENDER_WORKER_CONTEXT, stream_id, |
2317 stream_priority); | 2317 stream_priority); |
2318 if (!shared_worker_context_provider_->BindToCurrentThread()) | 2318 if (!shared_worker_context_provider_->BindToCurrentThread()) |
2319 shared_worker_context_provider_ = nullptr; | 2319 shared_worker_context_provider_ = nullptr; |
2320 return shared_worker_context_provider_; | 2320 return shared_worker_context_provider_; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 } | 2441 } |
2442 } | 2442 } |
2443 | 2443 |
2444 void RenderThreadImpl::OnRendererInterfaceRequest( | 2444 void RenderThreadImpl::OnRendererInterfaceRequest( |
2445 mojom::RendererAssociatedRequest request) { | 2445 mojom::RendererAssociatedRequest request) { |
2446 DCHECK(!renderer_binding_.is_bound()); | 2446 DCHECK(!renderer_binding_.is_bound()); |
2447 renderer_binding_.Bind(std::move(request)); | 2447 renderer_binding_.Bind(std::move(request)); |
2448 } | 2448 } |
2449 | 2449 |
2450 } // namespace content | 2450 } // namespace content |
OLD | NEW |