OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/common/child_thread.h" | 8 #include "content/common/child_thread.h" |
9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
11 #include "content/common/gpu/gpu_memory_manager.h" | 11 #include "content/common/gpu/gpu_memory_manager.h" |
| 12 #include "ui/gfx/gl/gl_share_group.h" |
12 | 13 |
13 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, | 14 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, |
14 GpuWatchdog* watchdog, | 15 GpuWatchdog* watchdog, |
15 base::MessageLoopProxy* io_message_loop, | 16 base::MessageLoopProxy* io_message_loop, |
16 base::WaitableEvent* shutdown_event) | 17 base::WaitableEvent* shutdown_event) |
17 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 18 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
18 io_message_loop_(io_message_loop), | 19 io_message_loop_(io_message_loop), |
19 shutdown_event_(shutdown_event), | 20 shutdown_event_(shutdown_event), |
20 gpu_child_thread_(gpu_child_thread), | 21 gpu_child_thread_(gpu_child_thread), |
21 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, | 22 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 OnCreateViewCommandBuffer) | 76 OnCreateViewCommandBuffer) |
76 IPC_MESSAGE_UNHANDLED(handled = false) | 77 IPC_MESSAGE_UNHANDLED(handled = false) |
77 IPC_END_MESSAGE_MAP_EX() | 78 IPC_END_MESSAGE_MAP_EX() |
78 return handled; | 79 return handled; |
79 } | 80 } |
80 | 81 |
81 bool GpuChannelManager::Send(IPC::Message* msg) { | 82 bool GpuChannelManager::Send(IPC::Message* msg) { |
82 return gpu_child_thread_->Send(msg); | 83 return gpu_child_thread_->Send(msg); |
83 } | 84 } |
84 | 85 |
85 void GpuChannelManager::OnEstablishChannel(int client_id, int share_client_id) { | 86 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { |
86 IPC::ChannelHandle channel_handle; | 87 IPC::ChannelHandle channel_handle; |
87 | 88 |
88 gfx::GLShareGroup* share_group = NULL; | 89 gfx::GLShareGroup* share_group = NULL; |
89 if (share_client_id) { | 90 if (share_context) { |
90 GpuChannel* share_channel = gpu_channels_[share_client_id]; | 91 if (!share_group_) |
91 DCHECK(share_channel); | 92 share_group_ = new gfx::GLShareGroup; |
92 share_group = share_channel->share_group(); | 93 share_group = share_group_; |
93 } | 94 } |
94 | 95 |
95 scoped_refptr<GpuChannel> channel = new GpuChannel(this, | 96 scoped_refptr<GpuChannel> channel = new GpuChannel(this, |
96 watchdog_, | 97 watchdog_, |
97 share_group, | 98 share_group, |
98 client_id, | 99 client_id, |
99 false); | 100 false); |
100 if (channel->Init(io_message_loop_, shutdown_event_)) { | 101 if (channel->Init(io_message_loop_, shutdown_event_)) { |
101 gpu_channels_[client_id] = channel; | 102 gpu_channels_[client_id] = channel; |
102 channel_handle.name = channel->GetChannelName(); | 103 channel_handle.name = channel->GetChannelName(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void GpuChannelManager::LoseAllContexts() { | 145 void GpuChannelManager::LoseAllContexts() { |
145 MessageLoop::current()->PostTask( | 146 MessageLoop::current()->PostTask( |
146 FROM_HERE, | 147 FROM_HERE, |
147 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 148 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
148 weak_factory_.GetWeakPtr())); | 149 weak_factory_.GetWeakPtr())); |
149 } | 150 } |
150 | 151 |
151 void GpuChannelManager::OnLoseAllContexts() { | 152 void GpuChannelManager::OnLoseAllContexts() { |
152 gpu_channels_.clear(); | 153 gpu_channels_.clear(); |
153 } | 154 } |
OLD | NEW |