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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); | 440 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); |
441 for (size_t i = 0; i < pieces.size(); ++i) { | 441 for (size_t i = 0; i < pieces.size(); ++i) { |
442 unsigned number = 0; | 442 unsigned number = 0; |
443 bool succeed = base::StringToUint(pieces[i], &number); | 443 bool succeed = base::StringToUint(pieces[i], &number); |
444 DCHECK(succeed); | 444 DCHECK(succeed); |
445 vector->push_back(number); | 445 vector->push_back(number); |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenContext( | 449 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenContext( |
450 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 450 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { |
451 bool share_resources) { | |
452 DCHECK(gpu_channel_host); | 451 DCHECK(gpu_channel_host); |
453 // This is used to create a few different offscreen contexts: | 452 // This is used to create a few different offscreen contexts: |
454 // - The shared main thread context (offscreen) used by blink for canvas. | 453 // - The shared main thread context (offscreen) used by blink for canvas. |
455 // - The worker context (offscreen) used for GPU raster and video decoding. | 454 // - The worker context (offscreen) used for GPU raster and video decoding. |
456 // This is for an offscreen context, so the default framebuffer doesn't need | 455 // This is for an offscreen context, so the default framebuffer doesn't need |
457 // alpha, depth, stencil, antialiasing. | 456 // alpha, depth, stencil, antialiasing. |
458 gpu::gles2::ContextCreationAttribHelper attributes; | 457 gpu::gles2::ContextCreationAttribHelper attributes; |
459 attributes.alpha_size = -1; | 458 attributes.alpha_size = -1; |
460 attributes.depth_size = 0; | 459 attributes.depth_size = 0; |
461 attributes.stencil_size = 0; | 460 attributes.stencil_size = 0; |
462 attributes.samples = 0; | 461 attributes.samples = 0; |
463 attributes.sample_buffers = 0; | 462 attributes.sample_buffers = 0; |
464 attributes.bind_generates_resource = false; | 463 attributes.bind_generates_resource = false; |
465 attributes.lose_context_when_out_of_memory = true; | 464 attributes.lose_context_when_out_of_memory = true; |
466 constexpr bool automatic_flushes = false; | 465 constexpr bool automatic_flushes = false; |
467 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 466 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
468 gpu::kNullSurfaceHandle, | 467 gpu::kNullSurfaceHandle, |
469 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 468 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
470 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, | 469 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, |
471 share_resources, automatic_flushes, nullptr)); | 470 automatic_flushes)); |
472 } | 471 } |
473 | 472 |
474 } // namespace | 473 } // namespace |
475 | 474 |
476 // For measuring memory usage after each task. Behind a command line flag. | 475 // For measuring memory usage after each task. Behind a command line flag. |
477 class MemoryObserver : public base::MessageLoop::TaskObserver { | 476 class MemoryObserver : public base::MessageLoop::TaskObserver { |
478 public: | 477 public: |
479 MemoryObserver() {} | 478 MemoryObserver() {} |
480 ~MemoryObserver() override {} | 479 ~MemoryObserver() override {} |
481 | 480 |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( | 1475 gpu_factories_.push_back(RendererGpuVideoAcceleratorFactories::Create( |
1477 gpu_channel_host.get(), base::ThreadTaskRunnerHandle::Get(), | 1476 gpu_channel_host.get(), base::ThreadTaskRunnerHandle::Get(), |
1478 media_task_runner, shared_context_provider, | 1477 media_task_runner, shared_context_provider, |
1479 enable_gpu_memory_buffer_video_frames, image_texture_targets, | 1478 enable_gpu_memory_buffer_video_frames, image_texture_targets, |
1480 enable_video_accelerator)); | 1479 enable_video_accelerator)); |
1481 return gpu_factories_.back(); | 1480 return gpu_factories_.back(); |
1482 } | 1481 } |
1483 return nullptr; | 1482 return nullptr; |
1484 } | 1483 } |
1485 | 1484 |
1486 scoped_refptr<cc_blink::ContextProviderWebContext> | 1485 scoped_refptr<ContextProviderCommandBuffer> |
1487 RenderThreadImpl::SharedMainThreadContextProvider() { | 1486 RenderThreadImpl::SharedMainThreadContextProvider() { |
1488 DCHECK(IsMainThread()); | 1487 DCHECK(IsMainThread()); |
1489 if (shared_main_thread_contexts_ && | 1488 if (shared_main_thread_contexts_ && |
1490 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == | 1489 shared_main_thread_contexts_->ContextGL()->GetGraphicsResetStatusKHR() == |
1491 GL_NO_ERROR) | 1490 GL_NO_ERROR) |
1492 return shared_main_thread_contexts_; | 1491 return shared_main_thread_contexts_; |
1493 | 1492 |
1494 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1493 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
1495 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1494 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
1496 if (!gpu_channel_host) { | 1495 if (!gpu_channel_host) { |
1497 shared_main_thread_contexts_ = nullptr; | 1496 shared_main_thread_contexts_ = nullptr; |
1498 return nullptr; | 1497 return nullptr; |
1499 } | 1498 } |
1500 | 1499 |
1501 constexpr bool share_resources = false; | |
1502 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( | 1500 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( |
1503 CreateOffscreenContext(std::move(gpu_channel_host), share_resources), | 1501 CreateOffscreenContext(std::move(gpu_channel_host)), |
1504 gpu::SharedMemoryLimits(), RENDERER_MAINTHREAD_CONTEXT); | 1502 gpu::SharedMemoryLimits(), nullptr, RENDERER_MAINTHREAD_CONTEXT); |
1505 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 1503 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
1506 shared_main_thread_contexts_ = nullptr; | 1504 shared_main_thread_contexts_ = nullptr; |
1507 return shared_main_thread_contexts_; | 1505 return shared_main_thread_contexts_; |
1508 } | 1506 } |
1509 | 1507 |
1510 #if defined(OS_ANDROID) | 1508 #if defined(OS_ANDROID) |
1511 | 1509 |
1512 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1510 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
1513 DCHECK(IsMainThread()); | 1511 DCHECK(IsMainThread()); |
1514 if (!stream_texture_factory_.get() || | 1512 if (!stream_texture_factory_.get() || |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 return shared_worker_context_provider_; | 2001 return shared_worker_context_provider_; |
2004 } | 2002 } |
2005 | 2003 |
2006 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 2004 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
2007 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 2005 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
2008 if (!gpu_channel_host) { | 2006 if (!gpu_channel_host) { |
2009 shared_worker_context_provider_ = nullptr; | 2007 shared_worker_context_provider_ = nullptr; |
2010 return shared_worker_context_provider_; | 2008 return shared_worker_context_provider_; |
2011 } | 2009 } |
2012 | 2010 |
2013 constexpr bool share_resources = true; | |
2014 shared_worker_context_provider_ = new ContextProviderCommandBuffer( | 2011 shared_worker_context_provider_ = new ContextProviderCommandBuffer( |
2015 CreateOffscreenContext(std::move(gpu_channel_host), share_resources), | 2012 CreateOffscreenContext(std::move(gpu_channel_host)), |
2016 gpu::SharedMemoryLimits(), RENDER_WORKER_CONTEXT); | 2013 gpu::SharedMemoryLimits(), nullptr, RENDER_WORKER_CONTEXT); |
2017 if (!shared_worker_context_provider_->BindToCurrentThread()) | 2014 if (!shared_worker_context_provider_->BindToCurrentThread()) |
2018 shared_worker_context_provider_ = nullptr; | 2015 shared_worker_context_provider_ = nullptr; |
2019 if (shared_worker_context_provider_) | 2016 if (shared_worker_context_provider_) |
2020 shared_worker_context_provider_->SetupLock(); | 2017 shared_worker_context_provider_->SetupLock(); |
2021 return shared_worker_context_provider_; | 2018 return shared_worker_context_provider_; |
2022 } | 2019 } |
2023 | 2020 |
2024 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 2021 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
2025 blink_platform_impl_->sampleGamepads(*data); | 2022 blink_platform_impl_->sampleGamepads(*data); |
2026 } | 2023 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 } | 2102 } |
2106 | 2103 |
2107 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2104 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
2108 size_t erased = | 2105 size_t erased = |
2109 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2106 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
2110 routing_id_); | 2107 routing_id_); |
2111 DCHECK_EQ(1u, erased); | 2108 DCHECK_EQ(1u, erased); |
2112 } | 2109 } |
2113 | 2110 |
2114 } // namespace content | 2111 } // namespace content |
OLD | NEW |