| 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 base::Bind( | 1398 base::Bind( |
| 1399 base::IgnoreResult( | 1399 base::IgnoreResult( |
| 1400 &RendererGpuVideoAcceleratorFactories::CheckContextLost), | 1400 &RendererGpuVideoAcceleratorFactories::CheckContextLost), |
| 1401 base::Unretained(gpu_factories_.back()))); | 1401 base::Unretained(gpu_factories_.back()))); |
| 1402 } | 1402 } |
| 1403 } | 1403 } |
| 1404 } | 1404 } |
| 1405 | 1405 |
| 1406 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1406 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1407 | 1407 |
| 1408 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = |
| 1409 EstablishGpuChannelSync(CAUSE_FOR_GPU_LAUNCH_MEDIA_CONTEXT); |
| 1410 if (!gpu_channel_host) |
| 1411 return nullptr; |
| 1412 scoped_refptr<ContextProviderCommandBuffer> media_context_provider = |
| 1413 CreateOffscreenContext( |
| 1414 gpu_channel_host, command_buffer_metrics::RENDER_WORKER_CONTEXT, |
| 1415 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL); |
| 1416 if (!media_context_provider->BindToCurrentThread()) |
| 1417 return nullptr; |
| 1418 media_context_provider->SetupLock(); |
| 1419 |
| 1408 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = | 1420 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = |
| 1409 GetMediaThreadTaskRunner(); | 1421 GetMediaThreadTaskRunner(); |
| 1410 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = | 1422 const bool enable_video_accelerator = |
| 1411 SharedWorkerContextProvider(); | 1423 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); |
| 1412 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = GetGpuChannel(); | 1424 const bool enable_gpu_memory_buffer_video_frames = |
| 1413 if (shared_context_provider && gpu_channel_host) { | |
| 1414 const bool enable_video_accelerator = | |
| 1415 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); | |
| 1416 const bool enable_gpu_memory_buffer_video_frames = | |
| 1417 #if defined(OS_MACOSX) || defined(OS_LINUX) | 1425 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 1418 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); | 1426 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); |
| 1419 #else | 1427 #else |
| 1420 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); | 1428 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); |
| 1421 #endif | 1429 #endif |
| 1422 std::vector<unsigned> image_texture_targets; | 1430 std::vector<unsigned> image_texture_targets; |
| 1423 std::string video_frame_image_texture_target_string = | 1431 std::string video_frame_image_texture_target_string = |
| 1424 cmd_line->GetSwitchValueASCII(switches::kVideoImageTextureTarget); | 1432 cmd_line->GetSwitchValueASCII(switches::kVideoImageTextureTarget); |
| 1425 StringToUintVector(video_frame_image_texture_target_string, | 1433 StringToUintVector(video_frame_image_texture_target_string, |
| 1426 &image_texture_targets); | 1434 &image_texture_targets); |
| 1427 | 1435 |
| 1428 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( | 1436 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( |
| 1429 std::move(gpu_channel_host), base::ThreadTaskRunnerHandle::Get(), | 1437 std::move(gpu_channel_host), base::ThreadTaskRunnerHandle::Get(), |
| 1430 media_task_runner, shared_context_provider, | 1438 media_task_runner, std::move(media_context_provider), |
| 1431 enable_gpu_memory_buffer_video_frames, image_texture_targets, | 1439 enable_gpu_memory_buffer_video_frames, image_texture_targets, |
| 1432 enable_video_accelerator)); | 1440 enable_video_accelerator)); |
| 1433 return gpu_factories_.back(); | 1441 return gpu_factories_.back(); |
| 1434 } | |
| 1435 return nullptr; | |
| 1436 } | 1442 } |
| 1437 | 1443 |
| 1438 scoped_refptr<ContextProviderCommandBuffer> | 1444 scoped_refptr<ContextProviderCommandBuffer> |
| 1439 RenderThreadImpl::SharedMainThreadContextProvider() { | 1445 RenderThreadImpl::SharedMainThreadContextProvider() { |
| 1440 DCHECK(IsMainThread()); | 1446 DCHECK(IsMainThread()); |
| 1441 if (shared_main_thread_contexts_ && | 1447 if (shared_main_thread_contexts_ && |
| 1442 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == | 1448 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == |
| 1443 GL_NO_ERROR) | 1449 GL_NO_ERROR) |
| 1444 return shared_main_thread_contexts_; | 1450 return shared_main_thread_contexts_; |
| 1445 | 1451 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 #endif | 1942 #endif |
| 1937 } | 1943 } |
| 1938 return media_thread_->task_runner(); | 1944 return media_thread_->task_runner(); |
| 1939 } | 1945 } |
| 1940 | 1946 |
| 1941 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() { | 1947 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() { |
| 1942 return raster_worker_pool_.get(); | 1948 return raster_worker_pool_.get(); |
| 1943 } | 1949 } |
| 1944 | 1950 |
| 1945 scoped_refptr<ContextProviderCommandBuffer> | 1951 scoped_refptr<ContextProviderCommandBuffer> |
| 1946 RenderThreadImpl::SharedWorkerContextProvider() { | 1952 RenderThreadImpl::SharedCompositorWorkerContextProvider() { |
| 1947 DCHECK(IsMainThread()); | 1953 DCHECK(IsMainThread()); |
| 1948 // Try to reuse existing shared worker context provider. | 1954 // Try to reuse existing shared worker context provider. |
| 1949 if (shared_worker_context_provider_) { | 1955 if (shared_worker_context_provider_) { |
| 1950 // Note: If context is lost, delete reference after releasing the lock. | 1956 // Note: If context is lost, delete reference after releasing the lock. |
| 1951 cc::ContextProvider::ScopedContextLock lock( | 1957 cc::ContextProvider::ScopedContextLock lock( |
| 1952 shared_worker_context_provider_.get()); | 1958 shared_worker_context_provider_.get()); |
| 1953 if (shared_worker_context_provider_->ContextGL() | 1959 if (shared_worker_context_provider_->ContextGL() |
| 1954 ->GetGraphicsResetStatusKHR() == GL_NO_ERROR) | 1960 ->GetGraphicsResetStatusKHR() == GL_NO_ERROR) |
| 1955 return shared_worker_context_provider_; | 1961 return shared_worker_context_provider_; |
| 1956 } | 1962 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 } | 2070 } |
| 2065 | 2071 |
| 2066 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2072 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2067 size_t erased = | 2073 size_t erased = |
| 2068 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2074 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2069 routing_id_); | 2075 routing_id_); |
| 2070 DCHECK_EQ(1u, erased); | 2076 DCHECK_EQ(1u, erased); |
| 2071 } | 2077 } |
| 2072 | 2078 |
| 2073 } // namespace content | 2079 } // namespace content |
| OLD | NEW |