| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 393 str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 394 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); | 394 DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1); |
| 395 for (size_t i = 0; i < pieces.size(); ++i) { | 395 for (size_t i = 0; i < pieces.size(); ++i) { |
| 396 unsigned number = 0; | 396 unsigned number = 0; |
| 397 bool succeed = base::StringToUint(pieces[i], &number); | 397 bool succeed = base::StringToUint(pieces[i], &number); |
| 398 DCHECK(succeed); | 398 DCHECK(succeed); |
| 399 vector->push_back(number); | 399 vector->push_back(number); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> CreateOffscreenContext( | 403 scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( |
| 404 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { | 404 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 405 command_buffer_metrics::ContextType type) { |
| 405 DCHECK(gpu_channel_host); | 406 DCHECK(gpu_channel_host); |
| 406 // This is used to create a few different offscreen contexts: | 407 // This is used to create a few different offscreen contexts: |
| 407 // - The shared main thread context (offscreen) used by blink for canvas. | 408 // - The shared main thread context (offscreen) used by blink for canvas. |
| 408 // - The worker context (offscreen) used for GPU raster and video decoding. | 409 // - The worker context (offscreen) used for GPU raster and video decoding. |
| 409 // This is for an offscreen context, so the default framebuffer doesn't need | 410 // This is for an offscreen context, so the default framebuffer doesn't need |
| 410 // alpha, depth, stencil, antialiasing. | 411 // alpha, depth, stencil, antialiasing. |
| 411 gpu::gles2::ContextCreationAttribHelper attributes; | 412 gpu::gles2::ContextCreationAttribHelper attributes; |
| 412 attributes.alpha_size = -1; | 413 attributes.alpha_size = -1; |
| 413 attributes.depth_size = 0; | 414 attributes.depth_size = 0; |
| 414 attributes.stencil_size = 0; | 415 attributes.stencil_size = 0; |
| 415 attributes.samples = 0; | 416 attributes.samples = 0; |
| 416 attributes.sample_buffers = 0; | 417 attributes.sample_buffers = 0; |
| 417 attributes.bind_generates_resource = false; | 418 attributes.bind_generates_resource = false; |
| 418 attributes.lose_context_when_out_of_memory = true; | 419 attributes.lose_context_when_out_of_memory = true; |
| 419 constexpr bool automatic_flushes = false; | 420 constexpr bool automatic_flushes = false; |
| 420 return base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( | 421 return make_scoped_refptr(new ContextProviderCommandBuffer( |
| 421 gpu::kNullSurfaceHandle, | 422 base::WrapUnique(new WebGraphicsContext3DCommandBufferImpl( |
| 422 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext3d"), | 423 gpu::kNullSurfaceHandle, |
| 423 std::move(gpu_channel_host), attributes, gfx::PreferIntegratedGpu, | 424 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
| 424 automatic_flushes)); | 425 std::move(gpu_channel_host), gfx::PreferIntegratedGpu, |
| 426 automatic_flushes)), |
| 427 gpu::SharedMemoryLimits(), attributes, nullptr, type)); |
| 425 } | 428 } |
| 426 | 429 |
| 427 } // namespace | 430 } // namespace |
| 428 | 431 |
| 429 // 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. |
| 430 class MemoryObserver : public base::MessageLoop::TaskObserver { | 433 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 431 public: | 434 public: |
| 432 MemoryObserver() {} | 435 MemoryObserver() {} |
| 433 ~MemoryObserver() override {} | 436 ~MemoryObserver() override {} |
| 434 | 437 |
| (...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 GL_NO_ERROR) | 1439 GL_NO_ERROR) |
| 1437 return shared_main_thread_contexts_; | 1440 return shared_main_thread_contexts_; |
| 1438 | 1441 |
| 1439 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1442 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 1440 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1443 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 1441 if (!gpu_channel_host) { | 1444 if (!gpu_channel_host) { |
| 1442 shared_main_thread_contexts_ = nullptr; | 1445 shared_main_thread_contexts_ = nullptr; |
| 1443 return nullptr; | 1446 return nullptr; |
| 1444 } | 1447 } |
| 1445 | 1448 |
| 1446 shared_main_thread_contexts_ = new ContextProviderCommandBuffer( | 1449 shared_main_thread_contexts_ = CreateOffscreenContext( |
| 1447 CreateOffscreenContext(std::move(gpu_channel_host)), | 1450 std::move(gpu_channel_host), |
| 1448 gpu::SharedMemoryLimits(), nullptr, RENDERER_MAINTHREAD_CONTEXT); | 1451 command_buffer_metrics::RENDERER_MAINTHREAD_CONTEXT); |
| 1449 if (!shared_main_thread_contexts_->BindToCurrentThread()) | 1452 if (!shared_main_thread_contexts_->BindToCurrentThread()) |
| 1450 shared_main_thread_contexts_ = nullptr; | 1453 shared_main_thread_contexts_ = nullptr; |
| 1451 return shared_main_thread_contexts_; | 1454 return shared_main_thread_contexts_; |
| 1452 } | 1455 } |
| 1453 | 1456 |
| 1454 #if defined(OS_ANDROID) | 1457 #if defined(OS_ANDROID) |
| 1455 | 1458 |
| 1456 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1459 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
| 1457 DCHECK(IsMainThread()); | 1460 DCHECK(IsMainThread()); |
| 1458 if (!stream_texture_factory_.get() || | 1461 if (!stream_texture_factory_.get() || |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 return shared_worker_context_provider_; | 1938 return shared_worker_context_provider_; |
| 1936 } | 1939 } |
| 1937 | 1940 |
| 1938 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( | 1941 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(EstablishGpuChannelSync( |
| 1939 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); | 1942 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)); |
| 1940 if (!gpu_channel_host) { | 1943 if (!gpu_channel_host) { |
| 1941 shared_worker_context_provider_ = nullptr; | 1944 shared_worker_context_provider_ = nullptr; |
| 1942 return shared_worker_context_provider_; | 1945 return shared_worker_context_provider_; |
| 1943 } | 1946 } |
| 1944 | 1947 |
| 1945 shared_worker_context_provider_ = new ContextProviderCommandBuffer( | 1948 shared_worker_context_provider_ = |
| 1946 CreateOffscreenContext(std::move(gpu_channel_host)), | 1949 CreateOffscreenContext(std::move(gpu_channel_host), |
| 1947 gpu::SharedMemoryLimits(), nullptr, RENDER_WORKER_CONTEXT); | 1950 command_buffer_metrics::RENDER_WORKER_CONTEXT); |
| 1948 if (!shared_worker_context_provider_->BindToCurrentThread()) | 1951 if (!shared_worker_context_provider_->BindToCurrentThread()) |
| 1949 shared_worker_context_provider_ = nullptr; | 1952 shared_worker_context_provider_ = nullptr; |
| 1950 if (shared_worker_context_provider_) | 1953 if (shared_worker_context_provider_) |
| 1951 shared_worker_context_provider_->SetupLock(); | 1954 shared_worker_context_provider_->SetupLock(); |
| 1952 return shared_worker_context_provider_; | 1955 return shared_worker_context_provider_; |
| 1953 } | 1956 } |
| 1954 | 1957 |
| 1955 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 1958 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
| 1956 blink_platform_impl_->sampleGamepads(*data); | 1959 blink_platform_impl_->sampleGamepads(*data); |
| 1957 } | 1960 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2036 } | 2039 } |
| 2037 | 2040 |
| 2038 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2041 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2039 size_t erased = | 2042 size_t erased = |
| 2040 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2043 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2041 routing_id_); | 2044 routing_id_); |
| 2042 DCHECK_EQ(1u, erased); | 2045 DCHECK_EQ(1u, erased); |
| 2043 } | 2046 } |
| 2044 | 2047 |
| 2045 } // namespace content | 2048 } // namespace content |
| OLD | NEW |