| Index: components/mus/public/cpp/lib/gles2_context.cc
|
| diff --git a/components/mus/public/cpp/lib/gles2_context.cc b/components/mus/public/cpp/lib/gles2_context.cc
|
| index c71f0ec6a650979d1c6945c9bb22820f03731381..656b589acc50d8255fa0c180201d9c0c1bf34d20 100644
|
| --- a/components/mus/public/cpp/lib/gles2_context.cc
|
| +++ b/components/mus/public/cpp/lib/gles2_context.cc
|
| @@ -9,31 +9,77 @@
|
|
|
| #include <utility>
|
|
|
| +#include "components/mus/public/cpp/gpu_service.h"
|
| +#include "components/mus/public/cpp/lib/command_buffer_client_impl.h"
|
| #include "gpu/command_buffer/client/gles2_cmd_helper.h"
|
| -#include "gpu/command_buffer/client/gles2_implementation.h"
|
| #include "gpu/command_buffer/client/shared_memory_limits.h"
|
| #include "gpu/command_buffer/client/transfer_buffer.h"
|
| +#include "gpu/ipc/client/command_buffer_proxy_impl.h"
|
| #include "mojo/public/cpp/system/core.h"
|
| +#include "url/gurl.h"
|
|
|
| namespace mus {
|
|
|
| -GLES2Context::GLES2Context(const std::vector<int32_t>& attribs,
|
| - mojo::ScopedMessagePipeHandle command_buffer_handle)
|
| - : command_buffer_(attribs, std::move(command_buffer_handle)) {}
|
| +GLES2Context::GLES2Context(
|
| + const std::vector<int32_t>& attribs,
|
| + mojo::ScopedMessagePipeHandle command_buffer_handle) {
|
| + // TODO(penghuang): Use type gpu::gles2::ContextCreationAttribHelper for
|
| + // attribs.
|
| + if (!mus::GpuService::UseChromeGpuCommandBuffer()) {
|
| + command_buffer_client_impl_.reset(
|
| + new CommandBufferClientImpl(attribs, std::move(command_buffer_handle)));
|
| + } else {
|
| + // For using chrome gpu command buffer, the command_buffer_handle is not
|
| + // used.
|
| + DCHECK(!command_buffer_handle.is_valid());
|
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
|
| + GpuService::GetInstance()->gpu_channel_host();
|
| + gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget;
|
| + // TODO(penghuang): support shared group.
|
| + gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr;
|
| + gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT;
|
| + gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL;
|
| + gfx::GpuPreference gpu_preference = gfx::PreferIntegratedGpu;
|
| + gpu::gles2::ContextCreationAttribHelper attributes;
|
| + // TODO(penghuang): figure a useful active_url.
|
| + GURL active_url;
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
| + base::ThreadTaskRunnerHandle::Get();
|
| + if (attributes.Parse(attribs)) {
|
| + command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create(
|
| + std::move(gpu_channel_host), surface_handle, gfx::Size(),
|
| + shared_command_buffer, stream_id, stream_priority, attributes,
|
| + active_url, gpu_preference, std::move(task_runner));
|
| + } else {
|
| + DLOG(WARNING) << "Parse attribs failed!";
|
| + }
|
| + }
|
| +}
|
|
|
| GLES2Context::~GLES2Context() {}
|
|
|
| bool GLES2Context::Initialize() {
|
| - if (!command_buffer_.Initialize())
|
| - return false;
|
| + gpu::CommandBuffer* command_buffer = nullptr;
|
| + gpu::GpuControl* gpu_control = nullptr;
|
| + if (!mus::GpuService::UseChromeGpuCommandBuffer()) {
|
| + if (!command_buffer_client_impl_->Initialize())
|
| + return false;
|
| + command_buffer = command_buffer_client_impl_.get();
|
| + gpu_control = command_buffer_client_impl_.get();
|
| + } else {
|
| + if (!command_buffer_proxy_impl_)
|
| + return false;
|
| + command_buffer = command_buffer_proxy_impl_.get();
|
| + gpu_control = command_buffer_proxy_impl_.get();
|
| + }
|
|
|
| constexpr gpu::SharedMemoryLimits default_limits;
|
| - gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(&command_buffer_));
|
| + gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer));
|
| if (!gles2_helper_->Initialize(default_limits.command_buffer_size))
|
| return false;
|
| gles2_helper_->SetAutomaticFlushes(false);
|
| transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get()));
|
| - gpu::Capabilities capabilities = command_buffer_.GetCapabilities();
|
| + gpu::Capabilities capabilities = gpu_control->GetCapabilities();
|
| bool bind_generates_resource =
|
| !!capabilities.bind_generates_resource_chromium;
|
| // TODO(piman): Some contexts (such as compositor) want this to be true, so
|
| @@ -43,7 +89,7 @@ bool GLES2Context::Initialize() {
|
| implementation_.reset(new gpu::gles2::GLES2Implementation(
|
| gles2_helper_.get(), NULL, transfer_buffer_.get(),
|
| bind_generates_resource, lose_context_when_out_of_memory,
|
| - support_client_side_arrays, &command_buffer_));
|
| + support_client_side_arrays, gpu_control));
|
| if (!implementation_->Initialize(default_limits.start_transfer_buffer_size,
|
| default_limits.min_transfer_buffer_size,
|
| default_limits.max_transfer_buffer_size,
|
|
|