| Index: content/common/gpu/gpu_channel.cc
|
| diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
|
| index 96c3553010c5a84133af5f625ad8c03200a06799..9785ce70ebae40a90f97171d8aa12e5fcb6f5e10 100644
|
| --- a/content/common/gpu/gpu_channel.cc
|
| +++ b/content/common/gpu/gpu_channel.cc
|
| @@ -59,9 +59,37 @@ GpuChannel::GpuChannel(GpuChannelManager* gpu_channel_manager,
|
| command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds);
|
| }
|
|
|
| -GpuChannel::~GpuChannel() {
|
| +
|
| +bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop,
|
| + base::WaitableEvent* shutdown_event) {
|
| + DCHECK(!channel_.get());
|
| +
|
| + // Map renderer ID to a (single) channel to that process.
|
| + channel_.reset(new IPC::SyncChannel(
|
| + channel_id_,
|
| + IPC::Channel::MODE_SERVER,
|
| + this,
|
| + io_message_loop,
|
| + false,
|
| + shutdown_event));
|
| +
|
| + return true;
|
| }
|
|
|
| +std::string GpuChannel::GetChannelName() {
|
| + return channel_id_;
|
| +}
|
| +
|
| +#if defined(OS_POSIX)
|
| +int GpuChannel::TakeRendererFileDescriptor() {
|
| + if (!channel_.get()) {
|
| + NOTREACHED();
|
| + return -1;
|
| + }
|
| + return channel_->TakeClientFileDescriptor();
|
| +}
|
| +#endif // defined(OS_POSIX)
|
| +
|
| bool GpuChannel::OnMessageReceived(const IPC::Message& message) {
|
| if (log_messages_) {
|
| DVLOG(1) << "received message @" << &message << " on channel @" << this
|
| @@ -146,20 +174,6 @@ void GpuChannel::OnScheduled() {
|
| handle_messages_scheduled_ = true;
|
| }
|
|
|
| -void GpuChannel::LoseAllContexts() {
|
| - gpu_channel_manager_->LoseAllContexts();
|
| -}
|
| -
|
| -void GpuChannel::DestroySoon() {
|
| - MessageLoop::current()->PostTask(
|
| - FROM_HERE, base::Bind(&GpuChannel::OnDestroy, this));
|
| -}
|
| -
|
| -void GpuChannel::OnDestroy() {
|
| - TRACE_EVENT0("gpu", "GpuChannel::OnDestroy");
|
| - gpu_channel_manager_->RemoveChannel(client_id_);
|
| -}
|
| -
|
| void GpuChannel::CreateViewCommandBuffer(
|
| const gfx::GLSurfaceHandle& window,
|
| int32 surface_id,
|
| @@ -196,6 +210,39 @@ GpuCommandBufferStub* GpuChannel::LookupCommandBuffer(int32 route_id) {
|
| return stubs_.Lookup(route_id);
|
| }
|
|
|
| +void GpuChannel::LoseAllContexts() {
|
| + gpu_channel_manager_->LoseAllContexts();
|
| +}
|
| +
|
| +void GpuChannel::DestroySoon() {
|
| + MessageLoop::current()->PostTask(
|
| + FROM_HERE, base::Bind(&GpuChannel::OnDestroy, this));
|
| +}
|
| +
|
| +int GpuChannel::GenerateRouteID() {
|
| + static int last_id = 0;
|
| + return ++last_id;
|
| +}
|
| +
|
| +void GpuChannel::AddRoute(int32 route_id, IPC::Channel::Listener* listener) {
|
| + router_.AddRoute(route_id, listener);
|
| +}
|
| +
|
| +void GpuChannel::RemoveRoute(int32 route_id) {
|
| + router_.RemoveRoute(route_id);
|
| +}
|
| +
|
| +bool GpuChannel::ShouldPreferDiscreteGpu() const {
|
| + return num_contexts_preferring_discrete_gpu_ > 0;
|
| +}
|
| +
|
| +GpuChannel::~GpuChannel() {}
|
| +
|
| +void GpuChannel::OnDestroy() {
|
| + TRACE_EVENT0("gpu", "GpuChannel::OnDestroy");
|
| + gpu_channel_manager_->RemoveChannel(client_id_);
|
| +}
|
| +
|
| bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
|
| // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers
|
| // here. This is so the reply can be delayed if the scheduler is unscheduled.
|
| @@ -284,23 +331,6 @@ void GpuChannel::ScheduleDelayedWork(GpuCommandBufferStub *stub,
|
| }
|
| }
|
|
|
| -int GpuChannel::GenerateRouteID() {
|
| - static int last_id = 0;
|
| - return ++last_id;
|
| -}
|
| -
|
| -void GpuChannel::AddRoute(int32 route_id, IPC::Channel::Listener* listener) {
|
| - router_.AddRoute(route_id, listener);
|
| -}
|
| -
|
| -void GpuChannel::RemoveRoute(int32 route_id) {
|
| - router_.RemoveRoute(route_id);
|
| -}
|
| -
|
| -bool GpuChannel::ShouldPreferDiscreteGpu() const {
|
| - return num_contexts_preferring_discrete_gpu_ > 0;
|
| -}
|
| -
|
| void GpuChannel::OnCreateOffscreenCommandBuffer(
|
| const gfx::Size& size,
|
| const GPUCreateCommandBufferConfig& init_params,
|
| @@ -391,22 +421,6 @@ void GpuChannel::OnCloseChannel() {
|
| // At this point "this" is deleted!
|
| }
|
|
|
| -bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop,
|
| - base::WaitableEvent* shutdown_event) {
|
| - DCHECK(!channel_.get());
|
| -
|
| - // Map renderer ID to a (single) channel to that process.
|
| - channel_.reset(new IPC::SyncChannel(
|
| - channel_id_,
|
| - IPC::Channel::MODE_SERVER,
|
| - this,
|
| - io_message_loop,
|
| - false,
|
| - shutdown_event));
|
| -
|
| - return true;
|
| -}
|
| -
|
| void GpuChannel::WillCreateCommandBuffer(gfx::GpuPreference gpu_preference) {
|
| if (gpu_preference == gfx::PreferDiscreteGpu)
|
| ++num_contexts_preferring_discrete_gpu_;
|
| @@ -417,17 +431,3 @@ void GpuChannel::DidDestroyCommandBuffer(gfx::GpuPreference gpu_preference) {
|
| --num_contexts_preferring_discrete_gpu_;
|
| DCHECK_GE(num_contexts_preferring_discrete_gpu_, 0);
|
| }
|
| -
|
| -std::string GpuChannel::GetChannelName() {
|
| - return channel_id_;
|
| -}
|
| -
|
| -#if defined(OS_POSIX)
|
| -int GpuChannel::TakeRendererFileDescriptor() {
|
| - if (!channel_.get()) {
|
| - NOTREACHED();
|
| - return -1;
|
| - }
|
| - return channel_->TakeClientFileDescriptor();
|
| -}
|
| -#endif // defined(OS_POSIX)
|
|
|