Chromium Code Reviews| 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 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1393 base::Bind( | 1393 base::Bind( |
| 1394 base::IgnoreResult( | 1394 base::IgnoreResult( |
| 1395 &RendererGpuVideoAcceleratorFactories::CheckContextLost), | 1395 &RendererGpuVideoAcceleratorFactories::CheckContextLost), |
| 1396 base::Unretained(gpu_factories_.back()))); | 1396 base::Unretained(gpu_factories_.back()))); |
| 1397 } | 1397 } |
| 1398 } | 1398 } |
| 1399 } | 1399 } |
| 1400 | 1400 |
| 1401 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1401 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 1402 | 1402 |
| 1403 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = | |
| 1404 EstablishGpuChannelSync(CAUSE_FOR_GPU_LAUNCH_MEDIA_CONTEXT); | |
| 1405 if (!gpu_channel_host) | |
| 1406 return nullptr; | |
| 1407 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = | |
| 1408 CreateOffscreenContext(gpu_channel_host, | |
| 1409 command_buffer_metrics::RENDER_WORKER_CONTEXT); | |
| 1410 if (!shared_worker_context_provider_->BindToCurrentThread()) | |
|
piman
2016/05/06 23:38:57
Did you mean shared_context_provider here?
danakj
2016/05/09 17:25:39
I need to rename this, cuz ya I did.
| |
| 1411 return nullptr; | |
| 1412 shared_worker_context_provider_->SetupLock(); | |
| 1413 | |
| 1403 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = | 1414 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner = |
| 1404 GetMediaThreadTaskRunner(); | 1415 GetMediaThreadTaskRunner(); |
| 1405 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = | 1416 const bool enable_video_accelerator = |
| 1406 SharedWorkerContextProvider(); | 1417 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); |
| 1407 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = GetGpuChannel(); | 1418 const bool enable_gpu_memory_buffer_video_frames = |
| 1408 if (shared_context_provider && gpu_channel_host) { | |
| 1409 const bool enable_video_accelerator = | |
| 1410 !cmd_line->HasSwitch(switches::kDisableAcceleratedVideoDecode); | |
| 1411 const bool enable_gpu_memory_buffer_video_frames = | |
| 1412 #if defined(OS_MACOSX) || defined(OS_LINUX) | 1419 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 1413 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); | 1420 !cmd_line->HasSwitch(switches::kDisableGpuMemoryBufferVideoFrames); |
| 1414 #else | 1421 #else |
| 1415 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); | 1422 cmd_line->HasSwitch(switches::kEnableGpuMemoryBufferVideoFrames); |
| 1416 #endif | 1423 #endif |
| 1417 std::vector<unsigned> image_texture_targets; | 1424 std::vector<unsigned> image_texture_targets; |
| 1418 std::string video_frame_image_texture_target_string = | 1425 std::string video_frame_image_texture_target_string = |
| 1419 cmd_line->GetSwitchValueASCII(switches::kVideoImageTextureTarget); | 1426 cmd_line->GetSwitchValueASCII(switches::kVideoImageTextureTarget); |
| 1420 StringToUintVector(video_frame_image_texture_target_string, | 1427 StringToUintVector(video_frame_image_texture_target_string, |
| 1421 &image_texture_targets); | 1428 &image_texture_targets); |
| 1422 | 1429 |
| 1423 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( | 1430 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( |
| 1424 std::move(gpu_channel_host), base::ThreadTaskRunnerHandle::Get(), | 1431 std::move(gpu_channel_host), base::ThreadTaskRunnerHandle::Get(), |
| 1425 media_task_runner, shared_context_provider, | 1432 media_task_runner, std::move(shared_context_provider), |
| 1426 enable_gpu_memory_buffer_video_frames, image_texture_targets, | 1433 enable_gpu_memory_buffer_video_frames, image_texture_targets, |
| 1427 enable_video_accelerator)); | 1434 enable_video_accelerator)); |
| 1428 return gpu_factories_.back(); | 1435 return gpu_factories_.back(); |
| 1429 } | |
| 1430 return nullptr; | |
| 1431 } | 1436 } |
| 1432 | 1437 |
| 1433 scoped_refptr<ContextProviderCommandBuffer> | 1438 scoped_refptr<ContextProviderCommandBuffer> |
| 1434 RenderThreadImpl::SharedMainThreadContextProvider() { | 1439 RenderThreadImpl::SharedMainThreadContextProvider() { |
| 1435 DCHECK(IsMainThread()); | 1440 DCHECK(IsMainThread()); |
| 1436 if (shared_main_thread_contexts_ && | 1441 if (shared_main_thread_contexts_ && |
| 1437 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == | 1442 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == |
| 1438 GL_NO_ERROR) | 1443 GL_NO_ERROR) |
| 1439 return shared_main_thread_contexts_; | 1444 return shared_main_thread_contexts_; |
| 1440 | 1445 |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1926 #endif | 1931 #endif |
| 1927 } | 1932 } |
| 1928 return media_thread_->task_runner(); | 1933 return media_thread_->task_runner(); |
| 1929 } | 1934 } |
| 1930 | 1935 |
| 1931 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() { | 1936 base::TaskRunner* RenderThreadImpl::GetWorkerTaskRunner() { |
| 1932 return raster_worker_pool_.get(); | 1937 return raster_worker_pool_.get(); |
| 1933 } | 1938 } |
| 1934 | 1939 |
| 1935 scoped_refptr<ContextProviderCommandBuffer> | 1940 scoped_refptr<ContextProviderCommandBuffer> |
| 1936 RenderThreadImpl::SharedWorkerContextProvider() { | 1941 RenderThreadImpl::SharedCompositorWorkerContextProvider() { |
| 1937 DCHECK(IsMainThread()); | 1942 DCHECK(IsMainThread()); |
| 1938 // Try to reuse existing shared worker context provider. | 1943 // Try to reuse existing shared worker context provider. |
| 1939 if (shared_worker_context_provider_) { | 1944 if (shared_worker_context_provider_) { |
| 1940 // Note: If context is lost, delete reference after releasing the lock. | 1945 // Note: If context is lost, delete reference after releasing the lock. |
| 1941 cc::ContextProvider::ScopedContextLock lock( | 1946 cc::ContextProvider::ScopedContextLock lock( |
| 1942 shared_worker_context_provider_.get()); | 1947 shared_worker_context_provider_.get()); |
| 1943 if (shared_worker_context_provider_->ContextGL() | 1948 if (shared_worker_context_provider_->ContextGL() |
| 1944 ->GetGraphicsResetStatusKHR() == GL_NO_ERROR) | 1949 ->GetGraphicsResetStatusKHR() == GL_NO_ERROR) |
| 1945 return shared_worker_context_provider_; | 1950 return shared_worker_context_provider_; |
| 1946 } | 1951 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 } | 2051 } |
| 2047 | 2052 |
| 2048 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2053 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2049 size_t erased = | 2054 size_t erased = |
| 2050 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2055 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2051 routing_id_); | 2056 routing_id_); |
| 2052 DCHECK_EQ(1u, erased); | 2057 DCHECK_EQ(1u, erased); |
| 2053 } | 2058 } |
| 2054 | 2059 |
| 2055 } // namespace content | 2060 } // namespace content |
| OLD | NEW |