Commit 7948bc43 authored by penghuang's avatar penghuang Committed by Commit bot

Use mus::MojoGpuMemoryBufferManager in mus::GpuService.

BUG=586390

Review-Url: https://codereview.chromium.org/2020293003
Cr-Commit-Position: refs/heads/master@{#398130}
parent b765188e
......@@ -13,8 +13,18 @@ component("mus_common") {
"event_param_traits.cc",
"event_param_traits.h",
"event_param_traits_macros.h",
"gpu_memory_buffer_impl.cc",
"gpu_memory_buffer_impl.h",
"gpu_service.cc",
"gpu_service.h",
"gpu_type_converters.cc",
"gpu_type_converters.h",
"mojo_buffer_backing.cc",
"mojo_buffer_backing.h",
"mojo_gpu_memory_buffer.cc",
"mojo_gpu_memory_buffer.h",
"mojo_gpu_memory_buffer_manager.cc",
"mojo_gpu_memory_buffer_manager.h",
"mus_common_export.h",
"switches.cc",
"switches.h",
......@@ -27,10 +37,13 @@ component("mus_common") {
deps = [
"//components/mus/public/interfaces",
"//gpu/command_buffer/client",
"//gpu/config",
"//gpu/ipc/client",
"//gpu/ipc/common:command_buffer_traits",
"//ipc:ipc",
"//mojo/public/c/system:for_component",
"//services/shell/public/cpp",
"//ui/events:events",
"//ui/gfx/ipc/geometry",
]
......
include_rules = [
"+gpu/config",
"+gpu/command_buffer",
"+gpu/ipc/client",
"+gpu/ipc/common",
]
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/gles2/gpu_memory_buffer_impl.h"
#include "components/mus/common/gpu_memory_buffer_impl.h"
namespace mus {
......
......@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_GLES2_GPU_MEMORY_BUFFER_IMPL_H_
#define COMPONENTS_MUS_GLES2_GPU_MEMORY_BUFFER_IMPL_H_
#ifndef COMPONENTS_MUS_COMMON_GPU_MEMORY_BUFFER_IMPL_H_
#define COMPONENTS_MUS_COMMON_GPU_MEMORY_BUFFER_IMPL_H_
#include <memory>
#include "base/callback.h"
#include "base/macros.h"
#include "components/mus/common/mus_common_export.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
......@@ -20,7 +21,7 @@
namespace mus {
// Provides common implementation of a GPU memory buffer.
class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
class MUS_COMMON_EXPORT GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
public:
~GpuMemoryBufferImpl() override;
......@@ -57,4 +58,4 @@ class GpuMemoryBufferImpl : public gfx::GpuMemoryBuffer {
} // namespace mus
#endif // COMPONENTS_MUS_GLES2_GPU_MEMORY_BUFFER_IMPL_H_
#endif // COMPONENTS_MUS_COMMON_GPU_MEMORY_BUFFER_IMPL_H_
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/public/cpp/lib/gpu_service.h"
#include "components/mus/common/gpu_service.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "components/mus/common/gpu_type_converters.h"
#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/common/switches.h"
#include "components/mus/public/cpp/lib/gpu_memory_buffer_manager_mus.h"
#include "components/mus/public/interfaces/gpu_service.mojom.h"
#include "services/shell/public/cpp/connector.h"
......@@ -32,7 +32,7 @@ GpuService::GpuService()
: main_message_loop_(base::MessageLoop::current()),
shutdown_event_(false, false),
io_thread_("GPUIOThread"),
gpu_memory_buffer_manager_(new mus::GpuMemoryBufferManagerMus) {
gpu_memory_buffer_manager_(new MojoGpuMemoryBufferManager) {
base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
thread_options.priority = base::ThreadPriority::NORMAL;
CHECK(io_thread_.StartWithOptions(thread_options));
......@@ -54,6 +54,7 @@ GpuService* GpuService::GetInstance() {
scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannel(
shell::Connector* connector) {
base::AutoLock auto_lock(lock_);
if (gpu_channel_ && gpu_channel_->IsLost()) {
gpu_channel_->DestroyChannel();
gpu_channel_ = nullptr;
......
......@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_H_
#define COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_SERVICE_H_
#ifndef COMPONENTS_MUS_COMMON_GPU_SERVICE_H_
#define COMPONENTS_MUS_COMMON_GPU_SERVICE_H_
#include <stdint.h>
#include <vector>
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "components/mus/common/mus_common_export.h"
#include "gpu/ipc/client/gpu_channel_host.h"
namespace shell {
......@@ -19,9 +21,9 @@ class Connector;
namespace mus {
class GpuMemoryBufferManagerMus;
class MojoGpuMemoryBufferManager;
class GpuService : public gpu::GpuChannelHostFactory {
class MUS_COMMON_EXPORT GpuService : public gpu::GpuChannelHostFactory {
public:
scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannel(
shell::Connector* connector);
......@@ -44,7 +46,10 @@ class GpuService : public gpu::GpuChannelHostFactory {
base::MessageLoop* main_message_loop_;
base::WaitableEvent shutdown_event_;
base::Thread io_thread_;
std::unique_ptr<GpuMemoryBufferManagerMus> gpu_memory_buffer_manager_;
std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
// Lock for |gpu_channel_|.
base::Lock lock_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
DISALLOW_COPY_AND_ASSIGN(GpuService);
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/gles2/mojo_buffer_backing.h"
#include "components/mus/common/mojo_buffer_backing.h"
#include "base/logging.h"
......
......@@ -2,20 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_GLES2_MOJO_BUFFER_BACKING_H_
#define COMPONENTS_MUS_GLES2_MOJO_BUFFER_BACKING_H_
#ifndef COMPONENTS_MUS_COMMON_MOJO_BUFFER_BACKING_H_
#define COMPONENTS_MUS_COMMON_MOJO_BUFFER_BACKING_H_
#include <stddef.h>
#include <memory>
#include "base/macros.h"
#include "components/mus/common/mus_common_export.h"
#include "gpu/command_buffer/common/buffer.h"
#include "mojo/public/cpp/system/core.h"
namespace mus {
class MojoBufferBacking : public gpu::BufferBacking {
class MUS_COMMON_EXPORT MojoBufferBacking : public gpu::BufferBacking {
public:
MojoBufferBacking(mojo::ScopedSharedBufferHandle handle,
void* memory,
......@@ -39,4 +40,4 @@ class MojoBufferBacking : public gpu::BufferBacking {
} // namespace mus
#endif // COMPONENTS_MUS_GLES2_MOJO_BUFFER_BACKING_H_
#endif // COMPONENTS_MUS_COMMON_MOJO_BUFFER_BACKING_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/gles2/mojo_gpu_memory_buffer.h"
#include "components/mus/common/mojo_gpu_memory_buffer.h"
#include <stdint.h>
......
......@@ -2,21 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_H_
#define COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_H_
#ifndef COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_H_
#define COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_H_
#include <stddef.h>
#include <memory>
#include "base/macros.h"
#include "components/mus/gles2/gpu_memory_buffer_impl.h"
#include "components/mus/common/gpu_memory_buffer_impl.h"
#include "components/mus/common/mus_common_export.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
namespace mus {
class MojoGpuMemoryBufferImpl : public mus::GpuMemoryBufferImpl {
class MUS_COMMON_EXPORT MojoGpuMemoryBufferImpl
: public mus::GpuMemoryBufferImpl {
public:
MojoGpuMemoryBufferImpl(const gfx::Size& size,
gfx::BufferFormat format,
......@@ -49,4 +51,4 @@ class MojoGpuMemoryBufferImpl : public mus::GpuMemoryBufferImpl {
} // namespace mus
#endif // COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_H_
#endif // COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_H_
......@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "base/logging.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer.h"
#include "components/mus/common/mojo_gpu_memory_buffer.h"
namespace mus {
......
......@@ -2,17 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
#define COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
#ifndef COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
#define COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
#include <memory>
#include "base/macros.h"
#include "components/mus/common/mus_common_export.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
namespace mus {
class MojoGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager {
class MUS_COMMON_EXPORT MojoGpuMemoryBufferManager
: public gpu::GpuMemoryBufferManager {
public:
MojoGpuMemoryBufferManager();
~MojoGpuMemoryBufferManager() override;
......@@ -41,4 +43,4 @@ class MojoGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager {
} // namespace mus
#endif // COMPONENTS_MUS_GLES2_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
#endif // COMPONENTS_MUS_COMMON_MOJO_GPU_MEMORY_BUFFER_MANAGER_H_
......@@ -68,14 +68,6 @@ source_set("gles2") {
source_set("lib") {
sources = [
"gpu_memory_buffer_impl.cc",
"gpu_memory_buffer_impl.h",
"mojo_buffer_backing.cc",
"mojo_buffer_backing.h",
"mojo_gpu_memory_buffer.cc",
"mojo_gpu_memory_buffer.h",
"mojo_gpu_memory_buffer_manager.cc",
"mojo_gpu_memory_buffer_manager.h",
"raster_thread_helper.cc",
"raster_thread_helper.h",
]
......
......@@ -11,10 +11,10 @@
#include "base/memory/shared_memory.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "components/mus/common/mojo_buffer_backing.h"
#include "components/mus/gles2/gl_surface_adapter.h"
#include "components/mus/gles2/gpu_memory_tracker.h"
#include "components/mus/gles2/gpu_state.h"
#include "components/mus/gles2/mojo_buffer_backing.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/command_executor.h"
......
......@@ -10,12 +10,12 @@
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/mus/common/gpu_type_converters.h"
#include "components/mus/common/mojo_buffer_backing.h"
#include "components/mus/common/mojo_gpu_memory_buffer.h"
#include "components/mus/gles2/command_buffer_driver.h"
#include "components/mus/gles2/command_buffer_local_client.h"
#include "components/mus/gles2/gpu_memory_tracker.h"
#include "components/mus/gles2/gpu_state.h"
#include "components/mus/gles2/mojo_buffer_backing.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer.h"
#include "gpu/command_buffer/client/gpu_control_client.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/common/sync_token.h"
......
......@@ -7,7 +7,7 @@
#include <memory>
#include "components/mus/gles2/gpu_memory_buffer_impl.h"
#include "components/mus/common/gpu_memory_buffer_impl.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/native_widget_types.h"
......
......@@ -9,8 +9,6 @@ source_set("gpu") {
output_name = "mus_gpu"
sources = [
"gpu_memory_buffer_manager_mus_local.cc",
"gpu_memory_buffer_manager_mus_local.h",
"gpu_service_impl.cc",
"gpu_service_impl.h",
"gpu_service_mus.cc",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/gpu/gpu_memory_buffer_manager_mus_local.h"
namespace mus {
GpuMemoryBufferManagerMusLocal::GpuMemoryBufferManagerMusLocal(
int gpu_client_id,
uint64_t gpu_client_tracing_id) {}
GpuMemoryBufferManagerMusLocal::~GpuMemoryBufferManagerMusLocal() {}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMusLocal::AllocateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMusLocal::CreateGpuMemoryBufferFromHandle(
const gfx::GpuMemoryBufferHandle& handle,
const gfx::Size& size,
gfx::BufferFormat format) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMusLocal::CreateGpuMemoryBufferFromClientId(
int client_id,
const gfx::GpuMemoryBufferId& gpu_memory_buffer_id) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
gfx::GpuMemoryBuffer*
GpuMemoryBufferManagerMusLocal::GpuMemoryBufferFromClientBuffer(
ClientBuffer buffer) {
NOTIMPLEMENTED();
return nullptr;
}
void GpuMemoryBufferManagerMusLocal::SetDestructionSyncToken(
gfx::GpuMemoryBuffer* buffer,
const gpu::SyncToken& sync_token) {
NOTIMPLEMENTED();
}
} // namespace mus
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_GPU_GPU_MEMORY_BUFFER_MANAGER_MUS_LOCAL_H_
#define COMPONENTS_MUS_GPU_GPU_MEMORY_BUFFER_MANAGER_MUS_LOCAL_H_
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
namespace mus {
// A GpuMemoryBufferManager used locally.
class GpuMemoryBufferManagerMusLocal : public gpu::GpuMemoryBufferManager {
public:
GpuMemoryBufferManagerMusLocal(int gpu_client_id,
uint64_t gpu_client_tracing_id);
~GpuMemoryBufferManagerMusLocal() override;
// Overridden from gpu::GpuMemoryBufferManager:
std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle) override;
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle(
const gfx::GpuMemoryBufferHandle& handle,
const gfx::Size& size,
gfx::BufferFormat format) override;
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromClientId(
int client_id,
const gfx::GpuMemoryBufferId& gpu_memory_buffer_id) override;
gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
ClientBuffer buffer) override;
void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
const gpu::SyncToken& sync_token) override;
private:
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferManagerMusLocal);
};
} // namespace mus
#endif // COMPONENTS_MUS_GPU_GPU_MEMORY_BUFFER_MANAGER_MUS_LOCAL_H_
......@@ -13,8 +13,8 @@ namespace mus {
namespace {
void EstablishGpuChannelDone(
int32_t client_id,
const mojom::GpuService::EstablishGpuChannelCallback& callback,
int32_t client_id,
const IPC::ChannelHandle& channel_handle) {
// TODO(penghuang): Send the real GPUInfo to the client.
callback.Run(client_id, mojom::ChannelHandle::From(channel_handle),
......@@ -25,29 +25,24 @@ void EstablishGpuChannelDone(
GpuServiceImpl::GpuServiceImpl(
mojo::InterfaceRequest<mojom::GpuService> request,
shell::Connection* connection)
: binding_(this, std::move(request)),
client_id_(connection->GetRemoteInstanceID() + 1) {
// Use remote instead id + 1 as client id, so every GpuServiceImpl instances
// for a same client will have the same client id.
// Make sure client_id_ is greater than 1, because 1 is used for the local
// GpuChannel.
DCHECK_GT(client_id_, 1);
}
: binding_(this, std::move(request)) {}
GpuServiceImpl::~GpuServiceImpl() {}
void GpuServiceImpl::EstablishGpuChannel(
const mojom::GpuService::EstablishGpuChannelCallback& callback) {
GpuServiceMus* service = GpuServiceMus::GetInstance();
// TODO(penghuang): crbug.com/617415 figure out how to generate a meaningful
// tracing id.
const uint64_t client_tracing_id = 0;
// TODO(penghuang): windows server may want to control those flags.
// Add a private interface for windows server.
const bool preempts = false;
const bool allow_view_command_buffers = false;
const bool allow_real_time_streams = false;
service->EstablishGpuChannel(
client_id_, client_id_, preempts, allow_view_command_buffers,
allow_real_time_streams,
base::Bind(&EstablishGpuChannelDone, client_id_, callback));
client_tracing_id, preempts, allow_view_command_buffers,
allow_real_time_streams, base::Bind(&EstablishGpuChannelDone, callback));
}
void GpuServiceImpl::CreateGpuMemoryBuffer(
......
......@@ -49,9 +49,6 @@ class GpuServiceImpl : public mojom::GpuService {
private:
mojo::StrongBinding<GpuService> binding_;
// A unique client id for constructing the GpuChannel.
const int32_t client_id_;
DISALLOW_COPY_AND_ASSIGN(GpuServiceImpl);
};
......
......@@ -8,7 +8,7 @@
#include "base/memory/singleton.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/mus/gpu/gpu_memory_buffer_manager_mus_local.h"
#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/config/gpu_info_collector.h"
......@@ -36,14 +36,16 @@ const int kLocalGpuChannelClientId = 1;
const uint64_t kLocalGpuChannelClientTracingId = 1;
void EstablishGpuChannelDone(
int client_id,
std::unique_ptr<IPC::ChannelHandle> channel_handle,
const GpuServiceMus::EstablishGpuChannelCallback& callback) {
callback.Run(*channel_handle);
callback.Run(channel_handle ? client_id : -1, *channel_handle);
}
}
GpuServiceMus::GpuServiceMus()
: main_message_loop_(base::MessageLoop::current()),
: next_client_id_(kLocalGpuChannelClientId),
main_message_loop_(base::MessageLoop::current()),
shutdown_event_(true, false),
gpu_thread_("GpuThread"),
io_thread_("GpuIOThread") {
......@@ -60,19 +62,19 @@ GpuServiceMus::~GpuServiceMus() {
}
void GpuServiceMus::EstablishGpuChannel(
int client_id,
uint64_t client_tracing_id,
bool preempts,
bool allow_view_command_buffers,
bool allow_real_time_streams,
const EstablishGpuChannelCallback& callback) {
DCHECK_GT(client_id, kLocalGpuChannelClientId);
DCHECK(CalledOnValidThread());
if (!gpu_channel_manager_) {
callback.Run(IPC::ChannelHandle());
callback.Run(-1, IPC::ChannelHandle());
return;
}
const int client_id = ++next_client_id_;
std::unique_ptr<IPC::ChannelHandle> channel_handle(new IPC::ChannelHandle);
gpu_thread_.task_runner()->PostTaskAndReply(
FROM_HERE,
......@@ -80,8 +82,8 @@ void GpuServiceMus::EstablishGpuChannel(
base::Unretained(this), client_id, client_tracing_id, preempts,
allow_view_command_buffers, allow_real_time_streams,
base::Unretained(channel_handle.get())),
base::Bind(&EstablishGpuChannelDone, base::Passed(&channel_handle),
callback));
base::Bind(&EstablishGpuChannelDone, client_id,
base::Passed(&channel_handle), callback));
}
gfx::GpuMemoryBufferHandle GpuServiceMus::CreateGpuMemoryBuffer(
......@@ -91,6 +93,7 @@ gfx::GpuMemoryBufferHandle GpuServiceMus::CreateGpuMemoryBuffer(
gfx::BufferUsage usage,
int client_id,
gpu::SurfaceHandle surface_handle) {
DCHECK(CalledOnValidThread());
return gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
id, size, format, usage, client_id, surface_handle);
}
......@@ -101,6 +104,8 @@ gfx::GpuMemoryBufferHandle GpuServiceMus::CreateGpuMemoryBufferFromeHandle(
const gfx::Size& size,
gfx::BufferFormat format,
int client_id) {
DCHECK(CalledOnValidThread());
return gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle(
buffer_handle, id, size, format, client_id);
}
......@@ -108,6 +113,8 @@ gfx::GpuMemoryBufferHandle GpuServiceMus::CreateGpuMemoryBufferFromeHandle(
void GpuServiceMus::DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
int client_id,
const gpu::SyncToken& sync_token) {
DCHECK(CalledOnValidThread());
if (gpu_channel_manager_)
gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token);
}
......@@ -154,6 +161,7 @@ void GpuServiceMus::SetActiveURL(const GURL& url) {
}
void GpuServiceMus::Initialize() {
DCHECK(CalledOnValidThread());
base::Thread::Options thread_options(base::MessageLoop::TYPE_DEFAULT, 0);
thread_options.priority = base::ThreadPriority::NORMAL;
CHECK(gpu_thread_.StartWithOptions(thread_options));
......@@ -176,11 +184,10 @@ void GpuServiceMus::Initialize() {
base::Unretained(this), &channel_handle, &event));
event.Wait();
gpu_memory_buffer_manager_mus_local_.reset(new GpuMemoryBufferManagerMusLocal(
kLocalGpuChannelClientId, kLocalGpuChannelClientTracingId));
gpu_memory_buffer_manager_local_.reset(new MojoGpuMemoryBufferManager);
gpu_channel_local_ = gpu::GpuChannelHost::Create(
this, kLocalGpuChannelClientId, gpu_info_, channel_handle,
&shutdown_event_, gpu_memory_buffer_manager_mus_local_.get());
&shutdown_event_, gpu_memory_buffer_manager_local_.get());
}
void GpuServiceMus::InitializeOnGpuThread(IPC::ChannelHandle* channel_handle,
......
......@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "gpu/command_buffer/service/gpu_preferences.h"
......@@ -41,18 +42,18 @@ class MediaService;
namespace mus {
class GpuMemoryBufferManagerMusLocal;
class MojoGpuMemoryBufferManager;
// TODO(fsamuel): GpuServiceMus is intended to be the Gpu thread within Mus.
// Similar to GpuChildThread, it is a GpuChannelManagerDelegate and will have a
// GpuChannelManager.
class GpuServiceMus : public gpu::GpuChannelManagerDelegate,
public gpu::GpuChannelHostFactory {
public gpu::GpuChannelHostFactory,
public base::NonThreadSafe {
public:
typedef base::Callback<void(const IPC::ChannelHandle&)>
typedef base::Callback<void(int client_id, const IPC::ChannelHandle&)>
EstablishGpuChannelCallback;
void EstablishGpuChannel(int client_id,
uint64_t client_tracing_id,
void EstablishGpuChannel(uint64_t client_tracing_id,
bool preempts,
bool allow_view_command_buffers,
bool allow_real_time_streams,
......@@ -122,6 +123,9 @@ class GpuServiceMus : public gpu::GpuChannelManagerDelegate,
bool allow_real_time_streams,
IPC::ChannelHandle* channel_handle);
// The next client id.
int next_client_id_;
// The main thread message loop.
base::MessageLoop* main_message_loop_;
......@@ -143,8 +147,7 @@ class GpuServiceMus : public gpu::GpuChannelManagerDelegate,
std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_;
// A GPU memory buffer manager used locally.
std::unique_ptr<GpuMemoryBufferManagerMusLocal>
gpu_memory_buffer_manager_mus_local_;
std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_local_;
// A GPU channel used locally.
scoped_refptr<gpu::GpuChannelHost> gpu_channel_local_;
......
......@@ -11,10 +11,6 @@ source_set("cpp") {
"lib/command_buffer_client_impl.h",
"lib/context_provider.cc",
"lib/gles2_context.cc",
"lib/gpu_memory_buffer_manager_mus.cc",
"lib/gpu_memory_buffer_manager_mus.h",
"lib/gpu_service.cc",
"lib/gpu_service.h",
"lib/in_flight_change.cc",
"lib/in_flight_change.h",
"lib/output_surface.cc",
......
......@@ -14,8 +14,8 @@
#include "base/process/process_handle.h"
#include "base/threading/thread_restrictions.h"
#include "components/mus/common/gpu_type_converters.h"
#include "components/mus/gles2/mojo_buffer_backing.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer.h"
#include "components/mus/common/mojo_buffer_backing.h"
#include "components/mus/common/mojo_gpu_memory_buffer.h"
#include "gpu/command_buffer/client/gpu_control_client.h"
#include "gpu/command_buffer/common/command_buffer_id.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
......
......@@ -9,8 +9,8 @@
#include <utility>
#include "components/mus/common/gpu_service.h"
#include "components/mus/public/cpp/lib/command_buffer_client_impl.h"
#include "components/mus/public/cpp/lib/gpu_service.h"
#include "components/mus/public/interfaces/command_buffer.mojom.h"
#include "components/mus/public/interfaces/gpu_service.mojom.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/mus/public/cpp/lib/gpu_memory_buffer_manager_mus.h"
namespace mus {
GpuMemoryBufferManagerMus::GpuMemoryBufferManagerMus() {}
GpuMemoryBufferManagerMus::~GpuMemoryBufferManagerMus() {}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMus::AllocateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMus::CreateGpuMemoryBufferFromHandle(
const gfx::GpuMemoryBufferHandle& handle,
const gfx::Size& size,
gfx::BufferFormat format) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
std::unique_ptr<gfx::GpuMemoryBuffer>
GpuMemoryBufferManagerMus::CreateGpuMemoryBufferFromClientId(
int client_id,
const gfx::GpuMemoryBufferId& gpu_memory_buffer_id) {
NOTIMPLEMENTED();
return std::unique_ptr<gfx::GpuMemoryBuffer>();
}
gfx::GpuMemoryBuffer*
GpuMemoryBufferManagerMus::GpuMemoryBufferFromClientBuffer(
ClientBuffer buffer) {
NOTIMPLEMENTED();
return nullptr;
}
void GpuMemoryBufferManagerMus::SetDestructionSyncToken(
gfx::GpuMemoryBuffer* buffer,
const gpu::SyncToken& sync_token) {
NOTIMPLEMENTED();
}
} // namespace mus
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_MEMORY_BUFFER_MANAGER_MUS_H_
#define COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_MEMORY_BUFFER_MANAGER_MUS_H_
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
namespace mus {
// A GpuMemoryBufferManager used locally.
class GpuMemoryBufferManagerMus : public gpu::GpuMemoryBufferManager {
public:
GpuMemoryBufferManagerMus();
~GpuMemoryBufferManagerMus() override;
// Overridden from gpu::GpuMemoryBufferManager:
std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer(
const gfx::Size& size,
gfx::BufferFormat format,
gfx::BufferUsage usage,
gpu::SurfaceHandle surface_handle) override;
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle(
const gfx::GpuMemoryBufferHandle& handle,
const gfx::Size& size,
gfx::BufferFormat format) override;
std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromClientId(
int client_id,
const gfx::GpuMemoryBufferId& gpu_memory_buffer_id) override;
gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer(
ClientBuffer buffer) override;
void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer,
const gpu::SyncToken& sync_token) override;
private:
DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferManagerMus);
};
} // namespace mus
#endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_GPU_MEMORY_BUFFER_MANAGER_MUS_H_
......@@ -11,7 +11,7 @@
#include "cc/output/context_provider.h"
#include "cc/output/output_surface_client.h"
#include "components/display_compositor/buffer_queue.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/surfaces/surfaces_context_provider.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
......
......@@ -53,6 +53,7 @@ component("mus") {
"//cc",
"//cc/surfaces",
"//components/bitmap_uploader",
"//components/mus/common:mus_common",
"//components/mus/gles2:lib",
"//components/mus/public/cpp",
"//components/mus/public/cpp/surfaces",
......
......@@ -8,7 +8,7 @@
#include <stdint.h>
#include "base/macros.h"
#include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
#include "components/mus/gles2/raster_thread_helper.h"
#include "components/mus/public/interfaces/window_tree.mojom.h"
#include "ui/compositor/compositor.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment