| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 394 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 395 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); | 395 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); |
| 396 for (size_t i = 0; i < pieces.size(); ++i) { | 396 for (size_t i = 0; i < pieces.size(); ++i) { |
| 397 unsigned number = 0; | 397 unsigned number = 0; |
| 398 bool succeed = base::StringToUint(pieces[i], &number); | 398 bool succeed = base::StringToUint(pieces[i], &number); |
| 399 DCHECK(succeed); | 399 DCHECK(succeed); |
| 400 vector->push_back(number); | 400 vector->push_back(number); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenContext( | 404 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( |
| 405 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { | 405 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 406 command_buffer_metrics::ContextType type) { |
| 406 DCHECK(gpu_channel_host); | 407 DCHECK(gpu_channel_host); |
| 407 // This is used to create a few different offscreen contexts: | 408 // This is used to create a few different offscreen contexts: |
| 408 // - The shared main thread context (offscreen) used by blink for canvas. | 409 // - The shared main thread context (offscreen) used by blink for canvas. |
| 409 // - The worker context (offscreen) used for GPU raster and video decoding. | 410 // - The worker context (offscreen) used for GPU raster and video decoding. |
| 410 // This is for an offscreen context, so the default framebuffer doesn't need | 411 // This is for an offscreen context, so the default framebuffer doesn't need |
| 411 // alpha, depth, stencil, antialiasing. | 412 // alpha, depth, stencil, antialiasing. |
| 412 gpu::gles2::ContextCreationAttribHelper attributes; | 413 gpu::gles2::ContextCreationAttribHelper attributes; |
| 413 attributes.alpha_size = -1; | 414 attributes.alpha_size = -1; |
| 414 attributes.depth_size = 0; | 415 attributes.depth_size = 0; |
| 415 attributes.stencil_size = 0; | 416 attributes.stencil_size = 0; |
| 416 attributes.samples = 0; | 417 attributes.samples = 0; |
| 417 attributes.sample_buffers = 0; | 418 attributes.sample_buffers = 0; |
| 418 attributes.bind_generates_resource = false; | 419 attributes.bind_generates_resource = false; |
| 419 attributes.lose_context_when_out_of_memory = true; | 420 attributes.lose_context_when_out_of_memory = true; |
| 420 constexpr bool automatic_flushes = false; | 421 constexpr bool automatic_flushes = false; |
| 421 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 422 return make_scoped_refptr(new ContextProviderCommandBuffer( |
| 422 gpu::kNullSurfaceHandle, | 423 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
| 423 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 424 gpu::kNullSurfaceHandle, |
| 424 gpu_channel_host.get(), attributes, gfx::PreferIntegratedGpu, | 425 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
| 425 automatic_flushes)); | 426 gpu_channel_host.get(), gfx::PreferIntegratedGpu, automatic_flushes)), |
| 427 gpu::SharedMemoryLimits(), attributes, nullptr, type)); |
| 426 } | 428 } |
| 427 | 429 |
| 428 } // namespace | 430 } // namespace |
| 429 | 431 |
| 430 // For measuring memory usage after each task. Behind a command line flag. | 432 // For measuring memory usage after each task. Behind a command line flag. |
| 431 class MemoryObserver : public base::MessageLoop::TaskObserver { | 433 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 432 public: | 434 public: |
| 433 MemoryObserver() {} | 435 MemoryObserver() {} |
| 434 ~MemoryObserver() override {} | 436 ~MemoryObserver() override {} |
| 435 | 437 |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 GL_NO_ERROR) | 1447 GL_NO_ERROR) |
| 1446 return shared_main_thread_contexts_; | 1448 return shared_main_thread_contexts_; |
| 1447 | 1449 |
| 1448 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1450 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 1449 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1451 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 1450 if (!gpu_channel_host) { | 1452 if (!gpu_channel_host) { |
| 1451 shared_main_thread_contexts_ = nullptr; | 1453 shared_main_thread_contexts_ = nullptr; |
| 1452 return nullptr; | 1454 return nullptr; |
| 1453 } | 1455 } |
| 1454 | 1456 |
| 1455 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( | 1457 shared_main_thread_contexts_ = CreateOffscreenContext( |
| 1456 CreateOffscreenContext(std::move(gpu_channel_host)), | 1458 std::move(gpu_channel_host), |
| 1457 gpu::SharedMemoryLimits(), nullptr, RENDERER_MAINTHREAD_CONTEXT); | 1459 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT); |
| 1458 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 1460 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
| 1459 shared_main_thread_contexts_ = nullptr; | 1461 shared_main_thread_contexts_ = nullptr; |
| 1460 return shared_main_thread_contexts_; | 1462 return shared_main_thread_contexts_; |
| 1461 } | 1463 } |
| 1462 | 1464 |
| 1463 #if defined(OS_ANDROID) | 1465 #if defined(OS_ANDROID) |
| 1464 | 1466 |
| 1465 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1467 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
| 1466 DCHECK(IsMainThread()); | 1468 DCHECK(IsMainThread()); |
| 1467 if (!stream_texture_factory_.get() || | 1469 if (!stream_texture_factory_.get() || |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 return shared_worker_context_provider_; | 1949 return shared_worker_context_provider_; |
| 1948 } | 1950 } |
| 1949 | 1951 |
| 1950 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1952 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 1951 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1953 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 1952 if (!gpu_channel_host) { | 1954 if (!gpu_channel_host) { |
| 1953 shared_worker_context_provider_ = nullptr; | 1955 shared_worker_context_provider_ = nullptr; |
| 1954 return shared_worker_context_provider_; | 1956 return shared_worker_context_provider_; |
| 1955 } | 1957 } |
| 1956 | 1958 |
| 1957 shared_worker_context_provider_ = new ContextProviderCommandBuffer( | 1959 shared_worker_context_provider_ = |
| 1958 CreateOffscreenContext(std::move(gpu_channel_host)), | 1960 CreateOffscreenContext(std::move(gpu_channel_host), |
| 1959 gpu::SharedMemoryLimits(), nullptr, RENDER_WORKER_CONTEXT); | 1961 command_buffer_metrics::RENDER_WORKER_CONTEXT); |
| 1960 if (!shared_worker_context_provider_->BindToCurrentThread()) | 1962 if (!shared_worker_context_provider_->BindToCurrentThread()) |
| 1961 shared_worker_context_provider_ = nullptr; | 1963 shared_worker_context_provider_ = nullptr; |
| 1962 if (shared_worker_context_provider_) | 1964 if (shared_worker_context_provider_) |
| 1963 shared_worker_context_provider_->SetupLock(); | 1965 shared_worker_context_provider_->SetupLock(); |
| 1964 return shared_worker_context_provider_; | 1966 return shared_worker_context_provider_; |
| 1965 } | 1967 } |
| 1966 | 1968 |
| 1967 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 1969 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
| 1968 blink_platform_impl_->sampleGamepads(*data); | 1970 blink_platform_impl_->sampleGamepads(*data); |
| 1969 } | 1971 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 } | 2050 } |
| 2049 | 2051 |
| 2050 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2052 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2051 size_t erased = | 2053 size_t erased = |
| 2052 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2054 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2053 routing_id_); | 2055 routing_id_); |
| 2054 DCHECK_EQ(1u, erased); | 2056 DCHECK_EQ(1u, erased); |
| 2055 } | 2057 } |
| 2056 | 2058 |
| 2057 } // namespace content | 2059 } // namespace content |
| OLD | NEW |