OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/gpu_process_host_ui_shim.h" | 5 #include "content/browser/gpu_process_host_ui_shim.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 bool GpuProcessHostUIShim::OnControlMessageReceived( | 220 bool GpuProcessHostUIShim::OnControlMessageReceived( |
221 const IPC::Message& message) { | 221 const IPC::Message& message) { |
222 DCHECK(CalledOnValidThread()); | 222 DCHECK(CalledOnValidThread()); |
223 | 223 |
224 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 224 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
225 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 225 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
226 OnLogMessage) | 226 OnLogMessage) |
227 #if defined(OS_LINUX) && !defined(TOUCH_UI) | 227 #if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN) |
228 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) | 228 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) |
229 #elif defined(OS_MACOSX) | 229 #elif defined(OS_MACOSX) |
230 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 230 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
231 OnAcceleratedSurfaceSetIOSurface) | 231 OnAcceleratedSurfaceSetIOSurface) |
232 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 232 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
233 OnAcceleratedSurfaceBuffersSwapped) | 233 OnAcceleratedSurfaceBuffersSwapped) |
234 #elif defined(OS_WIN) | 234 #elif defined(OS_WIN) |
235 IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite); | 235 IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite); |
236 #endif | 236 #endif |
237 IPC_MESSAGE_UNHANDLED_ERROR() | 237 IPC_MESSAGE_UNHANDLED_ERROR() |
238 IPC_END_MESSAGE_MAP() | 238 IPC_END_MESSAGE_MAP() |
239 | 239 |
240 return true; | 240 return true; |
241 } | 241 } |
242 | 242 |
243 void GpuProcessHostUIShim::OnLogMessage( | 243 void GpuProcessHostUIShim::OnLogMessage( |
244 int level, | 244 int level, |
245 const std::string& header, | 245 const std::string& header, |
246 const std::string& message) { | 246 const std::string& message) { |
247 DictionaryValue* dict = new DictionaryValue(); | 247 DictionaryValue* dict = new DictionaryValue(); |
248 dict->SetInteger("level", level); | 248 dict->SetInteger("level", level); |
249 dict->SetString("header", header); | 249 dict->SetString("header", header); |
250 dict->SetString("message", message); | 250 dict->SetString("message", message); |
251 GpuDataManager::GetInstance()->AddLogMessage(dict); | 251 GpuDataManager::GetInstance()->AddLogMessage(dict); |
252 } | 252 } |
253 | 253 |
| 254 #if defined(OS_LINUX) && !defined(TOUCH_UI) || defined(OS_WIN) |
| 255 |
| 256 void GpuProcessHostUIShim::OnResizeView(int32 renderer_id, |
| 257 int32 render_view_id, |
| 258 int32 command_buffer_route_id, |
| 259 gfx::Size size) { |
| 260 RenderViewHost* host = RenderViewHost::FromID(renderer_id, render_view_id); |
| 261 if (host) { |
| 262 RenderWidgetHostView* view = host->view(); |
| 263 if (view) { |
| 264 gfx::PluginWindowHandle handle = view->GetCompositingSurface(); |
| 265 |
| 266 // Resize the window synchronously. The GPU process must not issue GL |
| 267 // calls on the command buffer until the window is the size it expects it |
| 268 // to be. |
254 #if defined(OS_LINUX) && !defined(TOUCH_UI) | 269 #if defined(OS_LINUX) && !defined(TOUCH_UI) |
255 | 270 GdkWindow* window = reinterpret_cast<GdkWindow*>( |
256 void GpuProcessHostUIShim::OnResizeXID(unsigned long xid, gfx::Size size, | 271 gdk_xid_table_lookup(handle)); |
257 IPC::Message *reply_msg) { | 272 if (window) { |
258 GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid)); | 273 Display* display = GDK_WINDOW_XDISPLAY(window); |
259 if (window) { | 274 gdk_window_resize(window, size.width(), size.height()); |
260 Display* display = GDK_WINDOW_XDISPLAY(window); | 275 XSync(display, False); |
261 gdk_window_resize(window, size.width(), size.height()); | 276 } |
262 XSync(display, False); | 277 #elif defined(OS_WIN) |
| 278 SetWindowPos(handle, |
| 279 NULL, |
| 280 0, 0, |
| 281 size.width(), |
| 282 size.height(), |
| 283 SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOZORDER | |
| 284 SWP_NOACTIVATE | SWP_DEFERERASE | SWP_SHOWWINDOW); |
| 285 #endif |
| 286 } |
263 } | 287 } |
264 | 288 |
265 GpuHostMsg_ResizeXID::WriteReplyParams(reply_msg, (window != NULL)); | 289 // Always respond even if the window no longer exists. The GPU process cannot |
266 Send(reply_msg); | 290 // make progress on the resizing command buffer until it receives the |
| 291 // response. |
| 292 Send(new GpuMsg_ResizeViewACK(renderer_id, command_buffer_route_id)); |
267 } | 293 } |
268 | 294 |
269 #elif defined(OS_MACOSX) | 295 #elif defined(OS_MACOSX) |
270 | 296 |
271 void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface( | 297 void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface( |
272 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) { | 298 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) { |
273 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 299 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
274 params.render_view_id); | 300 params.render_view_id); |
275 if (!host) | 301 if (!host) |
276 return; | 302 return; |
(...skipping 19 matching lines...) Expand all Loading... |
296 // Parameters needed to swap the IOSurface. | 322 // Parameters needed to swap the IOSurface. |
297 params.window, | 323 params.window, |
298 params.surface_id, | 324 params.surface_id, |
299 // Parameters needed to formulate an acknowledgment. | 325 // Parameters needed to formulate an acknowledgment. |
300 params.renderer_id, | 326 params.renderer_id, |
301 params.route_id, | 327 params.route_id, |
302 host_id_, | 328 host_id_, |
303 params.swap_buffers_count); | 329 params.swap_buffers_count); |
304 } | 330 } |
305 | 331 |
306 #elif defined(OS_WIN) | 332 #endif |
| 333 |
| 334 #if defined(OS_WIN) |
307 | 335 |
308 void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, | 336 void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, |
309 int render_view_id) { | 337 int render_view_id) { |
310 RenderViewHost* host = RenderViewHost::FromID(renderer_id, | 338 RenderViewHost* host = RenderViewHost::FromID(renderer_id, |
311 render_view_id); | 339 render_view_id); |
312 if (!host) { | 340 if (!host) { |
313 return; | 341 return; |
314 } | 342 } |
315 host->ScheduleComposite(); | 343 host->ScheduleComposite(); |
316 } | 344 } |
317 | 345 |
318 #endif | 346 #endif |
OLD | NEW |