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 "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
10 #include "content/common/gpu/gpu_channel.h" | 10 #include "content/common/gpu/gpu_channel.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 base::MessageLoopProxy* io_message_loop, | 23 base::MessageLoopProxy* io_message_loop, |
24 base::WaitableEvent* shutdown_event) | 24 base::WaitableEvent* shutdown_event) |
25 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 25 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
26 io_message_loop_(io_message_loop), | 26 io_message_loop_(io_message_loop), |
27 shutdown_event_(shutdown_event), | 27 shutdown_event_(shutdown_event), |
28 gpu_child_thread_(gpu_child_thread), | 28 gpu_child_thread_(gpu_child_thread), |
29 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, | 29 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, |
30 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), | 30 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), |
31 watchdog_(watchdog), | 31 watchdog_(watchdog), |
32 sync_point_manager_(new SyncPointManager), | 32 sync_point_manager_(new SyncPointManager), |
33 program_cache_(NULL) { | 33 program_cache_(NULL), |
34 image_sync_point_(0) { | |
34 DCHECK(gpu_child_thread); | 35 DCHECK(gpu_child_thread); |
35 DCHECK(io_message_loop); | 36 DCHECK(io_message_loop); |
36 DCHECK(shutdown_event); | 37 DCHECK(shutdown_event); |
37 } | 38 } |
38 | 39 |
39 GpuChannelManager::~GpuChannelManager() { | 40 GpuChannelManager::~GpuChannelManager() { |
40 gpu_channels_.clear(); | 41 gpu_channels_.clear(); |
41 if (default_offscreen_surface_.get()) { | 42 if (default_offscreen_surface_.get()) { |
42 default_offscreen_surface_->Destroy(); | 43 default_offscreen_surface_->Destroy(); |
43 default_offscreen_surface_ = NULL; | 44 default_offscreen_surface_ = NULL; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 } | 89 } |
89 | 90 |
90 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { | 91 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
91 bool msg_is_ok = true; | 92 bool msg_is_ok = true; |
92 bool handled = true; | 93 bool handled = true; |
93 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) | 94 IPC_BEGIN_MESSAGE_MAP_EX(GpuChannelManager, msg, msg_is_ok) |
94 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 95 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
95 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 96 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
96 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 97 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
97 OnCreateViewCommandBuffer) | 98 OnCreateViewCommandBuffer) |
99 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage) | |
100 IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage) | |
98 IPC_MESSAGE_UNHANDLED(handled = false) | 101 IPC_MESSAGE_UNHANDLED(handled = false) |
99 IPC_END_MESSAGE_MAP_EX() | 102 IPC_END_MESSAGE_MAP_EX() |
100 return handled; | 103 return handled; |
101 } | 104 } |
102 | 105 |
103 bool GpuChannelManager::Send(IPC::Message* msg) { | 106 bool GpuChannelManager::Send(IPC::Message* msg) { |
104 return gpu_child_thread_->Send(msg); | 107 return gpu_child_thread_->Send(msg); |
105 } | 108 } |
106 | 109 |
107 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { | 110 void GpuChannelManager::OnEstablishChannel(int client_id, bool share_context) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 | 165 |
163 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | 166 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
164 if (iter != gpu_channels_.end()) { | 167 if (iter != gpu_channels_.end()) { |
165 iter->second->CreateViewCommandBuffer( | 168 iter->second->CreateViewCommandBuffer( |
166 window, surface_id, init_params, &route_id); | 169 window, surface_id, init_params, &route_id); |
167 } | 170 } |
168 | 171 |
169 Send(new GpuHostMsg_CommandBufferCreated(route_id)); | 172 Send(new GpuHostMsg_CommandBufferCreated(route_id)); |
170 } | 173 } |
171 | 174 |
175 void GpuChannelManager::OnCreateImageSyncPointRetired( | |
176 gfx::PluginWindowHandle window, | |
177 int32 client_id, | |
178 int32 image_id) { | |
179 gfx::Size size; | |
180 | |
181 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | |
182 if (iter != gpu_channels_.end()) { | |
183 iter->second->CreateImage(window, image_id, &size); | |
184 } | |
185 | |
186 Send(new GpuHostMsg_ImageCreated(size)); | |
187 } | |
188 | |
189 void GpuChannelManager::OnCreateImage( | |
190 gfx::PluginWindowHandle window, | |
191 int32 client_id, | |
192 int32 image_id) { | |
193 DCHECK(image_id); | |
194 | |
195 if (image_sync_point_) | |
piman
2012/10/13 18:00:38
I'm not convinced :)
It's possible - at least in t
reveman
2012/10/17 07:37:11
Latest patch puts all image ops in a queue and pop
| |
196 sync_point_manager()->AddSyncPointCallback( | |
197 image_sync_point_, | |
198 base::Bind(&GpuChannelManager::OnCreateImageSyncPointRetired, | |
199 base::Unretained(this), | |
200 window, | |
201 client_id, | |
202 image_id)); | |
203 else | |
204 OnCreateImageSyncPointRetired(window, client_id, image_id); | |
205 } | |
206 | |
207 void GpuChannelManager::OnDeleteImageSyncPointRetired( | |
208 int32 client_id, | |
209 int32 image_id) { | |
210 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | |
211 if (iter != gpu_channels_.end()) { | |
212 iter->second->DeleteImage(image_id); | |
213 } | |
214 } | |
215 | |
216 void GpuChannelManager::OnDeleteImage( | |
217 int32 client_id, | |
218 int32 image_id, | |
219 int32 sync_point) { | |
220 DCHECK(image_id); | |
221 | |
222 if (sync_point) | |
223 image_sync_point_ = sync_point; | |
224 | |
225 if (image_sync_point_) | |
piman
2012/10/13 18:00:38
nit: style requires braces (on both clauses) when
reveman
2012/10/17 07:37:11
Done.
| |
226 sync_point_manager()->AddSyncPointCallback( | |
227 sync_point, | |
228 base::Bind(&GpuChannelManager::OnDeleteImageSyncPointRetired, | |
229 base::Unretained(this), | |
230 client_id, | |
231 image_id)); | |
232 else | |
233 OnDeleteImageSyncPointRetired(client_id, image_id); | |
234 } | |
235 | |
172 void GpuChannelManager::LoseAllContexts() { | 236 void GpuChannelManager::LoseAllContexts() { |
173 MessageLoop::current()->PostTask( | 237 MessageLoop::current()->PostTask( |
174 FROM_HERE, | 238 FROM_HERE, |
175 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 239 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
176 weak_factory_.GetWeakPtr())); | 240 weak_factory_.GetWeakPtr())); |
177 } | 241 } |
178 | 242 |
179 void GpuChannelManager::OnLoseAllContexts() { | 243 void GpuChannelManager::OnLoseAllContexts() { |
180 gpu_channels_.clear(); | 244 gpu_channels_.clear(); |
181 } | 245 } |
182 | 246 |
183 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 247 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
184 if (!default_offscreen_surface_.get()) { | 248 if (!default_offscreen_surface_.get()) { |
185 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( | 249 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( |
186 false, gfx::Size(1, 1)); | 250 false, gfx::Size(1, 1)); |
187 } | 251 } |
188 return default_offscreen_surface_.get(); | 252 return default_offscreen_surface_.get(); |
189 } | 253 } |
OLD | NEW |