| 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/gpu_process_host_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/gpu/gpu_data_manager.h" | 14 #include "content/browser/gpu/gpu_data_manager.h" |
| 15 #include "content/browser/gpu/gpu_process_host.h" | 15 #include "content/browser/gpu/gpu_process_host.h" |
| 16 #include "content/browser/renderer_host/render_process_host.h" | 16 #include "content/browser/renderer_host/render_process_host.h" |
| 17 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
| 18 #include "content/browser/renderer_host/render_widget_host_view.h" | 18 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 20 | 20 |
| 21 #if defined(TOOLKIT_USES_GTK) | 21 #if defined(TOOLKIT_USES_GTK) |
| 22 // These two #includes need to come after gpu_messages.h. | 22 // These two #includes need to come after gpu_messages.h. |
| 23 #include <gdk/gdkwindow.h> // NOLINT | 23 #include <gdk/gdkwindow.h> // NOLINT |
| 24 #include <gdk/gdkx.h> // NOLINT | 24 #include <gdk/gdkx.h> // NOLINT |
| 25 #include "ui/base/x/x11_util.h" | 25 #include "ui/base/x/x11_util.h" |
| 26 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
| 27 #endif | 27 #endif |
| 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // One of the linux specific headers defines this as a macro. | 31 // One of the linux specific headers defines this as a macro. |
| 31 #ifdef DestroyAll | 32 #ifdef DestroyAll |
| 32 #undef DestroyAll | 33 #undef DestroyAll |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id( | 36 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id( |
| 36 base::LINKER_INITIALIZED); | 37 base::LINKER_INITIALIZED); |
| 37 | 38 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 DCHECK(CalledOnValidThread()); | 154 DCHECK(CalledOnValidThread()); |
| 154 | 155 |
| 155 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 156 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
| 156 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 157 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
| 157 OnLogMessage) | 158 OnLogMessage) |
| 158 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) | 159 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
| 159 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) | 160 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) |
| 160 #endif | 161 #endif |
| 161 | 162 |
| 162 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 163 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
| 163 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 164 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceNew, |
| 164 OnAcceleratedSurfaceSetIOSurface) | 165 OnAcceleratedSurfaceNew) |
| 165 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 166 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 166 OnAcceleratedSurfaceBuffersSwapped) | 167 OnAcceleratedSurfaceBuffersSwapped) |
| 167 #endif | 168 #endif |
| 168 | 169 |
| 169 #if defined(TOUCH_UI) | 170 #if defined(TOUCH_UI) |
| 170 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, | 171 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, |
| 171 OnAcceleratedSurfaceRelease) | 172 OnAcceleratedSurfaceRelease) |
| 172 #endif | 173 #endif |
| 173 IPC_MESSAGE_UNHANDLED_ERROR() | 174 IPC_MESSAGE_UNHANDLED_ERROR() |
| 174 IPC_END_MESSAGE_MAP() | 175 IPC_END_MESSAGE_MAP() |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // Always respond even if the window no longer exists. The GPU process cannot | 228 // Always respond even if the window no longer exists. The GPU process cannot |
| 228 // make progress on the resizing command buffer until it receives the | 229 // make progress on the resizing command buffer until it receives the |
| 229 // response. | 230 // response. |
| 230 Send(new GpuMsg_ResizeViewACK(renderer_id, command_buffer_route_id)); | 231 Send(new GpuMsg_ResizeViewACK(renderer_id, command_buffer_route_id)); |
| 231 } | 232 } |
| 232 | 233 |
| 233 #endif | 234 #endif |
| 234 | 235 |
| 235 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 236 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
| 236 | 237 |
| 237 void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface( | 238 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( |
| 238 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) { | 239 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { |
| 239 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 240 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
| 240 params.render_view_id); | 241 params.render_view_id); |
| 241 if (!host) | 242 if (!host) |
| 242 return; | 243 return; |
| 243 RenderWidgetHostView* view = host->view(); | 244 RenderWidgetHostView* view = host->view(); |
| 244 if (!view) | 245 if (!view) |
| 245 return; | 246 return; |
| 247 |
| 246 #if defined(OS_MACOSX) | 248 #if defined(OS_MACOSX) |
| 247 view->AcceleratedSurfaceSetIOSurface(params.window, | 249 view->AcceleratedSurfaceSetIOSurface(params.window, |
| 248 params.width, | 250 params.width, |
| 249 params.height, | 251 params.height, |
| 250 params.identifier); | 252 params.identifier); |
| 251 #elif defined(TOUCH_UI) | 253 #elif defined(TOUCH_UI) |
| 252 view->AcceleratedSurfaceSetIOSurface( | 254 uint64 surface_id; |
| 253 params.width, params.height, params.identifier); | 255 TransportDIB::Handle surface_handle; |
| 254 Send(new AcceleratedSurfaceMsg_SetSurfaceACK( | 256 |
| 255 params.route_id, params.identifier)); | 257 surface_id = params.identifier; |
| 258 view->AcceleratedSurfaceNew( |
| 259 params.width, params.height, &surface_id, &surface_handle); |
| 260 |
| 261 Send(new AcceleratedSurfaceMsg_NewACK( |
| 262 params.route_id, surface_id, surface_handle)); |
| 256 #endif | 263 #endif |
| 257 } | 264 } |
| 258 | 265 |
| 259 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 266 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
| 260 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 267 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 261 TRACE_EVENT0("renderer", | 268 TRACE_EVENT0("renderer", |
| 262 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 269 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
| 263 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, | 270 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
| 264 params.render_view_id); | 271 params.render_view_id); |
| 265 if (!host) | 272 if (!host) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 294 params.render_view_id); | 301 params.render_view_id); |
| 295 if (!host) | 302 if (!host) |
| 296 return; | 303 return; |
| 297 RenderWidgetHostView* view = host->view(); | 304 RenderWidgetHostView* view = host->view(); |
| 298 if (!view) | 305 if (!view) |
| 299 return; | 306 return; |
| 300 view->AcceleratedSurfaceRelease(params.identifier); | 307 view->AcceleratedSurfaceRelease(params.identifier); |
| 301 } | 308 } |
| 302 | 309 |
| 303 #endif | 310 #endif |
| OLD | NEW |