| 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) { |
| 451 DCHECK(gpu_channel_host); | 452 DCHECK(gpu_channel_host); |
| 452 // This is used to create a few different offscreen contexts: | 453 // This is used to create a few different offscreen contexts: |
| 453 // - The shared main thread context (offscreen) used by blink for canvas. | 454 // - The shared main thread context (offscreen) used by blink for canvas. |
| 454 // - The worker context (offscreen) used for GPU raster and video decoding. | 455 // - The worker context (offscreen) used for GPU raster and video decoding. |
| 455 // This is for an offscreen context, so the default framebuffer doesn't need | 456 // This is for an offscreen context, so the default framebuffer doesn't need |
| 456 // alpha, depth, stencil, antialiasing. | 457 // alpha, depth, stencil, antialiasing. |
| 457 gpu::gles2::ContextCreationAttribHelper attributes; | 458 gpu::gles2::ContextCreationAttribHelper attributes; |
| 458 attributes.alpha_size = -1; | 459 attributes.alpha_size = -1; |
| 459 attributes.depth_size = 0; | 460 attributes.depth_size = 0; |
| 460 attributes.stencil_size = 0; | 461 attributes.stencil_size = 0; |
| 461 attributes.samples = 0; | 462 attributes.samples = 0; |
| 462 attributes.sample_buffers = 0; | 463 attributes.sample_buffers = 0; |
| 463 attributes.bind_generates_resource = false; | 464 attributes.bind_generates_resource = false; |
| 464 attributes.lose_context_when_out_of_memory = true; | 465 attributes.lose_context_when_out_of_memory = true; |
| 465 bool share_resources = true; | 466 constexpr bool automatic_flushes = false; |
| 466 bool automatic_flushes = false; | |
| 467 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 467 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
| 468 gpu::kNullSurfaceHandle, | 468 gpu::kNullSurfaceHandle, |
| 469 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 469 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), |
| 470 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, | 470 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, |
| 471 share_resources, automatic_flushes, nullptr)); | 471 share_resources, automatic_flushes, nullptr)); |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace | 474 } // namespace |
| 475 | 475 |
| 476 // For measuring memory usage after each task. Behind a command line flag. | 476 // For measuring memory usage after each task. Behind a command line flag. |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 GL_NO_ERROR) | 1499 GL_NO_ERROR) |
| 1500 return shared_main_thread_contexts_; | 1500 return shared_main_thread_contexts_; |
| 1501 | 1501 |
| 1502 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1502 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 1503 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1503 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 1504 if (!gpu_channel_host) { | 1504 if (!gpu_channel_host) { |
| 1505 shared_main_thread_contexts_ = nullptr; | 1505 shared_main_thread_contexts_ = nullptr; |
| 1506 return nullptr; | 1506 return nullptr; |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 constexpr bool share_resources = false; |
| 1509 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( | 1510 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( |
| 1510 CreateOffscreenContext(std::move(gpu_channel_host)), | 1511 CreateOffscreenContext(std::move(gpu_channel_host), share_resources), |
| 1511 gpu::SharedMemoryLimits(), RENDERER_MAINTHREAD_CONTEXT); | 1512 gpu::SharedMemoryLimits(), RENDERER_MAINTHREAD_CONTEXT); |
| 1512 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 1513 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
| 1513 shared_main_thread_contexts_ = nullptr; | 1514 shared_main_thread_contexts_ = nullptr; |
| 1514 return shared_main_thread_contexts_; | 1515 return shared_main_thread_contexts_; |
| 1515 } | 1516 } |
| 1516 | 1517 |
| 1517 #if defined(OS_ANDROID) | 1518 #if defined(OS_ANDROID) |
| 1518 | 1519 |
| 1519 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1520 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
| 1520 DCHECK(IsMainThread()); | 1521 DCHECK(IsMainThread()); |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 return shared_worker_context_provider_; | 2015 return shared_worker_context_provider_; |
| 2015 } | 2016 } |
| 2016 | 2017 |
| 2017 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 2018 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 2018 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 2019 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 2019 if (!gpu_channel_host) { | 2020 if (!gpu_channel_host) { |
| 2020 shared_worker_context_provider_ = nullptr; | 2021 shared_worker_context_provider_ = nullptr; |
| 2021 return shared_worker_context_provider_; | 2022 return shared_worker_context_provider_; |
| 2022 } | 2023 } |
| 2023 | 2024 |
| 2025 constexpr bool share_resources = true; |
| 2024 shared_worker_context_provider_ = new ContextProviderCommandBuffer( | 2026 shared_worker_context_provider_ = new ContextProviderCommandBuffer( |
| 2025 CreateOffscreenContext(std::move(gpu_channel_host)), | 2027 CreateOffscreenContext(std::move(gpu_channel_host), share_resources), |
| 2026 gpu::SharedMemoryLimits(), RENDER_WORKER_CONTEXT); | 2028 gpu::SharedMemoryLimits(), RENDER_WORKER_CONTEXT); |
| 2027 if (!shared_worker_context_provider_->BindToCurrentThread()) | 2029 if (!shared_worker_context_provider_->BindToCurrentThread()) |
| 2028 shared_worker_context_provider_ = nullptr; | 2030 shared_worker_context_provider_ = nullptr; |
| 2029 if (shared_worker_context_provider_) | 2031 if (shared_worker_context_provider_) |
| 2030 shared_worker_context_provider_->SetupLock(); | 2032 shared_worker_context_provider_->SetupLock(); |
| 2031 return shared_worker_context_provider_; | 2033 return shared_worker_context_provider_; |
| 2032 } | 2034 } |
| 2033 | 2035 |
| 2034 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 2036 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
| 2035 blink_platform_impl_->sampleGamepads(*data); | 2037 blink_platform_impl_->sampleGamepads(*data); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2115 } | 2117 } |
| 2116 | 2118 |
| 2117 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2119 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2118 size_t erased = | 2120 size_t erased = |
| 2119 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2121 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2120 routing_id_); | 2122 routing_id_); |
| 2121 DCHECK_EQ(1u, erased); | 2123 DCHECK_EQ(1u, erased); |
| 2122 } | 2124 } |
| 2123 | 2125 |
| 2124 } // namespace content | 2126 } // namespace content |
| OLD | NEW |