| Index: content/common/gpu/gpu_channel_manager.cc
|
| diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc
|
| index d5ffd601afedeadd12b1b645ce6f368e19f08916..381292b7d0c847832eb3272554b9d3c3bf413f36 100644
|
| --- a/content/common/gpu/gpu_channel_manager.cc
|
| +++ b/content/common/gpu/gpu_channel_manager.cc
|
| @@ -13,15 +13,11 @@
|
| #include "base/single_thread_task_runner.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "build/build_config.h"
|
| -#include "content/common/gpu/establish_channel_params.h"
|
| #include "content/common/gpu/gpu_channel.h"
|
| -#include "content/common/gpu/gpu_channel_manager_delegate.h"
|
| #include "content/common/gpu/gpu_memory_buffer_factory.h"
|
| #include "content/common/gpu/gpu_memory_manager.h"
|
| #include "content/common/gpu/gpu_messages.h"
|
| -#include "content/common/gpu/image_transport_surface.h"
|
| #include "content/public/common/content_switches.h"
|
| -#include "gpu/command_buffer/common/sync_token.h"
|
| #include "gpu/command_buffer/common/value_state.h"
|
| #include "gpu/command_buffer/service/feature_info.h"
|
| #include "gpu/command_buffer/service/gpu_switches.h"
|
| @@ -34,10 +30,6 @@
|
| #include "ui/gl/gl_bindings.h"
|
| #include "ui/gl/gl_share_group.h"
|
|
|
| -#if defined(OS_MACOSX)
|
| -#include "content/common/gpu/buffer_presented_params_mac.h"
|
| -#endif
|
| -
|
| namespace content {
|
|
|
| namespace {
|
| @@ -52,7 +44,7 @@
|
| }
|
|
|
| GpuChannelManager::GpuChannelManager(
|
| - GpuChannelManagerDelegate* delegate,
|
| + IPC::SyncChannel* channel,
|
| GpuWatchdog* watchdog,
|
| base::SingleThreadTaskRunner* task_runner,
|
| base::SingleThreadTaskRunner* io_task_runner,
|
| @@ -61,7 +53,7 @@
|
| GpuMemoryBufferFactory* gpu_memory_buffer_factory)
|
| : task_runner_(task_runner),
|
| io_task_runner_(io_task_runner),
|
| - delegate_(delegate),
|
| + channel_(channel),
|
| watchdog_(watchdog),
|
| shutdown_event_(shutdown_event),
|
| share_group_(new gfx::GLShareGroup),
|
| @@ -116,31 +108,53 @@
|
| }
|
|
|
| void GpuChannelManager::RemoveChannel(int client_id) {
|
| - delegate_->DidDestroyChannel(client_id);
|
| + Send(new GpuHostMsg_DestroyChannel(client_id));
|
| gpu_channels_.erase(client_id);
|
| }
|
|
|
| -#if defined(OS_MACOSX)
|
| -void GpuChannelManager::AddImageTransportSurface(
|
| - int32_t surface_id,
|
| - ImageTransportHelper* image_transport_helper) {
|
| - image_transport_map_.AddWithID(image_transport_helper, surface_id);
|
| -}
|
| -
|
| -void GpuChannelManager::RemoveImageTransportSurface(int32_t surface_id) {
|
| - image_transport_map_.Remove(surface_id);
|
| -}
|
| -
|
| -void GpuChannelManager::BufferPresented(const BufferPresentedParams& params) {
|
| - ImageTransportHelper* helper = image_transport_map_.Lookup(params.surface_id);
|
| - if (helper)
|
| - helper->BufferPresented(params);
|
| -}
|
| -#endif
|
| +int GpuChannelManager::GenerateRouteID() {
|
| + static int last_id = 0;
|
| + return ++last_id;
|
| +}
|
| +
|
| +void GpuChannelManager::AddRoute(int32_t routing_id, IPC::Listener* listener) {
|
| + router_.AddRoute(routing_id, listener);
|
| +}
|
| +
|
| +void GpuChannelManager::RemoveRoute(int32_t routing_id) {
|
| + router_.RemoveRoute(routing_id);
|
| +}
|
|
|
| GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const {
|
| const auto& it = gpu_channels_.find(client_id);
|
| return it != gpu_channels_.end() ? it->second : nullptr;
|
| +}
|
| +
|
| +bool GpuChannelManager::OnControlMessageReceived(const IPC::Message& msg) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState)
|
| +#if defined(OS_ANDROID)
|
| + IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu);
|
| +#endif
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| + return handled;
|
| +}
|
| +
|
| +bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
|
| + if (msg.routing_id() == MSG_ROUTING_CONTROL)
|
| + return OnControlMessageReceived(msg);
|
| +
|
| + return router_.RouteMessage(msg);
|
| +}
|
| +
|
| +bool GpuChannelManager::Send(IPC::Message* msg) {
|
| + return channel_->Send(msg);
|
| }
|
|
|
| scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel(
|
| @@ -157,7 +171,8 @@
|
| allow_view_command_buffers, allow_real_time_streams));
|
| }
|
|
|
| -void GpuChannelManager::EstablishChannel(const EstablishChannelParams& params) {
|
| +void GpuChannelManager::OnEstablishChannel(
|
| + const GpuMsg_EstablishChannel_Params& params) {
|
| scoped_ptr<GpuChannel> channel(CreateGpuChannel(
|
| params.client_id, params.client_tracing_id, params.preempts,
|
| params.allow_view_command_buffers, params.allow_real_time_streams));
|
| @@ -165,10 +180,11 @@
|
|
|
| gpu_channels_.set(params.client_id, std::move(channel));
|
|
|
| - delegate_->ChannelEstablished(channel_handle);
|
| -}
|
| -
|
| -void GpuChannelManager::CloseChannel(const IPC::ChannelHandle& channel_handle) {
|
| + Send(new GpuHostMsg_ChannelEstablished(channel_handle));
|
| +}
|
| +
|
| +void GpuChannelManager::OnCloseChannel(
|
| + const IPC::ChannelHandle& channel_handle) {
|
| for (auto it = gpu_channels_.begin(); it != gpu_channels_.end(); ++it) {
|
| if (it->second->channel_id() == channel_handle.name) {
|
| gpu_channels_.erase(it);
|
| @@ -177,22 +193,21 @@
|
| }
|
| }
|
|
|
| -void GpuChannelManager::InternalDestroyGpuMemoryBuffer(
|
| +void GpuChannelManager::DestroyGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId id,
|
| int client_id) {
|
| io_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO,
|
| - base::Unretained(this), id, client_id));
|
| -}
|
| -
|
| -void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO(
|
| + FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO,
|
| + base::Unretained(this), id, client_id));
|
| +}
|
| +
|
| +void GpuChannelManager::DestroyGpuMemoryBufferOnIO(
|
| gfx::GpuMemoryBufferId id,
|
| int client_id) {
|
| gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id);
|
| }
|
|
|
| -void GpuChannelManager::DestroyGpuMemoryBuffer(
|
| +void GpuChannelManager::OnDestroyGpuMemoryBuffer(
|
| gfx::GpuMemoryBufferId id,
|
| int client_id,
|
| const gpu::SyncToken& sync_token) {
|
| @@ -203,19 +218,18 @@
|
| if (release_state) {
|
| sync_point_client_waiter_->WaitOutOfOrder(
|
| release_state.get(), sync_token.release_count(),
|
| - base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer,
|
| + base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer,
|
| base::Unretained(this), id, client_id));
|
| return;
|
| }
|
| }
|
|
|
| // No sync token or invalid sync token, destroy immediately.
|
| - InternalDestroyGpuMemoryBuffer(id, client_id);
|
| -}
|
| -
|
| -void GpuChannelManager::UpdateValueState(int client_id,
|
| - unsigned int target,
|
| - const gpu::ValueState& state) {
|
| + DestroyGpuMemoryBuffer(id, client_id);
|
| +}
|
| +
|
| +void GpuChannelManager::OnUpdateValueState(
|
| + int client_id, unsigned int target, const gpu::ValueState& state) {
|
| // Only pass updated state to the channel corresponding to the
|
| // render_widget_host where the event originated.
|
| auto it = gpu_channels_.find(client_id);
|
| @@ -223,7 +237,7 @@
|
| it->second->HandleUpdateValueState(target, state);
|
| }
|
|
|
| -void GpuChannelManager::PopulateShaderCache(const std::string& program_proto) {
|
| +void GpuChannelManager::OnLoadedShader(const std::string& program_proto) {
|
| if (program_cache())
|
| program_cache()->LoadProgram(program_proto);
|
| }
|
| @@ -251,11 +265,11 @@
|
| kv.second->MarkAllContextsLost();
|
| }
|
| task_runner_->PostTask(FROM_HERE,
|
| - base::Bind(&GpuChannelManager::DestroyAllChannels,
|
| + base::Bind(&GpuChannelManager::OnLoseAllContexts,
|
| weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| -void GpuChannelManager::DestroyAllChannels() {
|
| +void GpuChannelManager::OnLoseAllContexts() {
|
| gpu_channels_.clear();
|
| }
|
|
|
| @@ -272,7 +286,7 @@
|
| last_gpu_access_time_ = base::TimeTicks::Now();
|
| }
|
|
|
| -void GpuChannelManager::WakeUpGpu() {
|
| +void GpuChannelManager::OnWakeUpGpu() {
|
| begin_wake_up_time_ = base::TimeTicks::Now();
|
| ScheduleWakeUpGpu();
|
| }
|
|
|