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 51b4e0929e44420125aed1faba9062a95cc54334..e5b1f714ebf160ec5c5f94436ee096d33f2a250c 100644 |
--- a/content/common/gpu/gpu_channel_manager.cc |
+++ b/content/common/gpu/gpu_channel_manager.cc |
@@ -13,11 +13,15 @@ |
#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" |
@@ -44,7 +48,7 @@ const int kMaxKeepAliveTimeMs = 200; |
} |
GpuChannelManager::GpuChannelManager( |
- IPC::SyncChannel* channel, |
+ GpuChannelManagerDelegate* delegate, |
GpuWatchdog* watchdog, |
base::SingleThreadTaskRunner* task_runner, |
base::SingleThreadTaskRunner* io_task_runner, |
@@ -53,7 +57,7 @@ GpuChannelManager::GpuChannelManager( |
GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
: task_runner_(task_runner), |
io_task_runner_(io_task_runner), |
- channel_(channel), |
+ delegate_(delegate), |
watchdog_(watchdog), |
shutdown_event_(shutdown_event), |
share_group_(new gfx::GLShareGroup), |
@@ -108,7 +112,7 @@ GpuChannelManager::framebuffer_completeness_cache() { |
} |
void GpuChannelManager::RemoveChannel(int client_id) { |
- Send(new GpuHostMsg_DestroyChannel(client_id)); |
+ delegate_->DidDestroyChannel(client_id); |
gpu_channels_.erase(client_id); |
} |
@@ -117,44 +121,28 @@ int GpuChannelManager::GenerateRouteID() { |
return ++last_id; |
} |
-void GpuChannelManager::AddRoute(int32_t routing_id, IPC::Listener* listener) { |
- router_.AddRoute(routing_id, listener); |
+void GpuChannelManager::AddImageTransportSurface( |
+ int32_t routing_id, |
no sievers
2016/02/22 21:57:42
If this doesn't use AddRoute() can you rename it?
Fady Samuel
2016/02/23 04:45:26
Done.
|
+ ImageTransportHelper* image_transport_helper) { |
+ image_transport_map_.AddWithID(image_transport_helper, routing_id); |
} |
-void GpuChannelManager::RemoveRoute(int32_t routing_id) { |
- router_.RemoveRoute(routing_id); |
+void GpuChannelManager::RemoveImageTransportSurface(int32_t routing_id) { |
+ image_transport_map_.Remove(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; |
+#if defined(OS_MACOSX) |
+void GpuChannelManager::BufferPresented(int32_t routing_id, |
+ const BufferPresentedParams& params) { |
+ ImageTransportHelper* helper = image_transport_map_.Lookup(routing_id); |
+ if (helper) |
+ helper->BufferPresented(params); |
} |
- |
-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); |
+GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { |
+ const auto& it = gpu_channels_.find(client_id); |
+ return it != gpu_channels_.end() ? it->second : nullptr; |
} |
scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
@@ -170,8 +158,7 @@ scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( |
allow_view_command_buffers, allow_real_time_streams)); |
} |
-void GpuChannelManager::OnEstablishChannel( |
- const GpuMsg_EstablishChannel_Params& params) { |
+void GpuChannelManager::EstablishChannel(const EstablishChannelParams& 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)); |
@@ -181,11 +168,10 @@ void GpuChannelManager::OnEstablishChannel( |
gpu_channels_.set(params.client_id, std::move(channel)); |
- Send(new GpuHostMsg_ChannelEstablished(channel_handle)); |
+ delegate_->ChannelEstablished(channel_handle); |
} |
-void GpuChannelManager::OnCloseChannel( |
- const IPC::ChannelHandle& channel_handle) { |
+void GpuChannelManager::CloseChannel(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); |
@@ -194,21 +180,22 @@ void GpuChannelManager::OnCloseChannel( |
} |
} |
-void GpuChannelManager::DestroyGpuMemoryBuffer( |
+void GpuChannelManager::InternalDestroyGpuMemoryBuffer( |
gfx::GpuMemoryBufferId id, |
int client_id) { |
io_task_runner_->PostTask( |
- FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, |
- base::Unretained(this), id, client_id)); |
+ FROM_HERE, |
+ base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO, |
+ base::Unretained(this), id, client_id)); |
} |
-void GpuChannelManager::DestroyGpuMemoryBufferOnIO( |
+void GpuChannelManager::InternalDestroyGpuMemoryBufferOnIO( |
gfx::GpuMemoryBufferId id, |
int client_id) { |
gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(id, client_id); |
} |
-void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
+void GpuChannelManager::DestroyGpuMemoryBuffer( |
gfx::GpuMemoryBufferId id, |
int client_id, |
const gpu::SyncToken& sync_token) { |
@@ -219,18 +206,19 @@ void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
if (release_state) { |
sync_point_client_waiter_->WaitOutOfOrder( |
release_state.get(), sync_token.release_count(), |
- base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
+ base::Bind(&GpuChannelManager::InternalDestroyGpuMemoryBuffer, |
base::Unretained(this), id, client_id)); |
return; |
} |
} |
// No sync token or invalid sync token, destroy immediately. |
- DestroyGpuMemoryBuffer(id, client_id); |
+ InternalDestroyGpuMemoryBuffer(id, client_id); |
} |
-void GpuChannelManager::OnUpdateValueState( |
- int client_id, unsigned int target, const gpu::ValueState& state) { |
+void GpuChannelManager::UpdateValueState(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); |
@@ -238,7 +226,7 @@ void GpuChannelManager::OnUpdateValueState( |
it->second->HandleUpdateValueState(target, state); |
} |
-void GpuChannelManager::OnLoadedShader(const std::string& program_proto) { |
+void GpuChannelManager::PopulateShaderCache(const std::string& program_proto) { |
if (program_cache()) |
program_cache()->LoadProgram(program_proto); |
} |
@@ -266,11 +254,11 @@ void GpuChannelManager::LoseAllContexts() { |
kv.second->MarkAllContextsLost(); |
} |
task_runner_->PostTask(FROM_HERE, |
- base::Bind(&GpuChannelManager::OnLoseAllContexts, |
+ base::Bind(&GpuChannelManager::DestroyAllChannels, |
weak_factory_.GetWeakPtr())); |
} |
-void GpuChannelManager::OnLoseAllContexts() { |
+void GpuChannelManager::DestroyAllChannels() { |
gpu_channels_.clear(); |
} |
@@ -287,7 +275,7 @@ void GpuChannelManager::DidAccessGpu() { |
last_gpu_access_time_ = base::TimeTicks::Now(); |
} |
-void GpuChannelManager::OnWakeUpGpu() { |
+void GpuChannelManager::WakeUpGpu() { |
begin_wake_up_time_ = base::TimeTicks::Now(); |
ScheduleWakeUpGpu(); |
} |