Chromium Code Reviews| 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/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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, | 200 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, |
| 201 OnAcceleratedSurfacePostSubBuffer) | 201 OnAcceleratedSurfacePostSubBuffer) |
| 202 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, | 202 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, |
| 203 OnAcceleratedSurfaceSuspend) | 203 OnAcceleratedSurfaceSuspend) |
| 204 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 204 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
| 205 OnGraphicsInfoCollected) | 205 OnGraphicsInfoCollected) |
| 206 | 206 |
| 207 #if defined(TOOLKIT_GTK) || defined(OS_WIN) | 207 #if defined(TOOLKIT_GTK) || defined(OS_WIN) |
| 208 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) | 208 IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) |
| 209 #endif | 209 #endif |
| 210 | |
| 211 #if defined(USE_AURA) | |
| 212 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceNew, | 210 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceNew, |
| 213 OnAcceleratedSurfaceNew) | 211 OnAcceleratedSurfaceNew) |
| 214 #endif | |
| 215 | |
| 216 #if defined(USE_AURA) | |
| 217 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, | 212 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, |
| 218 OnAcceleratedSurfaceRelease) | 213 OnAcceleratedSurfaceRelease) |
| 219 #endif | |
| 220 | 214 |
| 221 IPC_MESSAGE_UNHANDLED_ERROR() | 215 IPC_MESSAGE_UNHANDLED_ERROR() |
| 222 IPC_END_MESSAGE_MAP() | 216 IPC_END_MESSAGE_MAP() |
| 223 | 217 |
| 224 return true; | 218 return true; |
| 225 } | 219 } |
| 226 | 220 |
| 227 void GpuProcessHostUIShim::OnLogMessage( | 221 void GpuProcessHostUIShim::OnLogMessage( |
| 228 int level, | 222 int level, |
| 229 const std::string& header, | 223 const std::string& header, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 251 gfx::Size size) { | 245 gfx::Size size) { |
| 252 // Always respond even if the window no longer exists. The GPU process cannot | 246 // Always respond even if the window no longer exists. The GPU process cannot |
| 253 // make progress on the resizing command buffer until it receives the | 247 // make progress on the resizing command buffer until it receives the |
| 254 // response. | 248 // response. |
| 255 ScopedSendOnIOThread delayed_send( | 249 ScopedSendOnIOThread delayed_send( |
| 256 host_id_, | 250 host_id_, |
| 257 new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); | 251 new AcceleratedSurfaceMsg_ResizeViewACK(route_id)); |
| 258 | 252 |
| 259 RenderWidgetHostViewPort* view = | 253 RenderWidgetHostViewPort* view = |
| 260 GetRenderWidgetHostViewFromSurfaceID(surface_id); | 254 GetRenderWidgetHostViewFromSurfaceID(surface_id); |
| 261 if (!view) | 255 if (!view || !view->ResizeNeedsNewSurface()) |
|
Fady Samuel
2012/07/06 15:14:44
Why would a resize not require a new surface?
scshunt
2012/07/06 16:39:03
Various platform-specific reasons (note that this
| |
| 262 return; | 256 return; |
| 263 | 257 |
| 264 gfx::GLSurfaceHandle surface = view->GetCompositingSurface(); | 258 gfx::GLSurfaceHandle surface = view->GetCompositingSurface(); |
| 265 | 259 |
| 266 // Resize the window synchronously. The GPU process must not issue GL | 260 // 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 | 261 // calls on the command buffer until the window is the size it expects it |
| 268 // to be. | 262 // to be. |
| 269 #if defined(TOOLKIT_GTK) | 263 #if defined(TOOLKIT_GTK) |
| 270 GdkWindow* window = reinterpret_cast<GdkWindow*>( | 264 GdkWindow* window = reinterpret_cast<GdkWindow*>( |
| 271 gdk_xid_table_lookup(surface.handle)); | 265 gdk_xid_table_lookup(surface.handle)); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 282 0, 0, | 276 0, 0, |
| 283 std::max(1, size.width()), | 277 std::max(1, size.width()), |
| 284 std::max(1, size.height()), | 278 std::max(1, size.height()), |
| 285 SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOZORDER | | 279 SWP_NOSENDCHANGING | SWP_NOCOPYBITS | SWP_NOZORDER | |
| 286 SWP_NOACTIVATE | SWP_DEFERERASE); | 280 SWP_NOACTIVATE | SWP_DEFERERASE); |
| 287 #endif | 281 #endif |
| 288 } | 282 } |
| 289 | 283 |
| 290 #endif | 284 #endif |
| 291 | 285 |
| 292 #if defined(USE_AURA) | |
| 293 | |
| 294 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( | 286 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( |
| 295 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { | 287 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { |
| 296 ScopedSendOnIOThread delayed_send( | 288 ScopedSendOnIOThread delayed_send( |
| 297 host_id_, | 289 host_id_, |
| 298 new AcceleratedSurfaceMsg_NewACK( | 290 new AcceleratedSurfaceMsg_NewACK( |
| 299 params.route_id, | 291 params.route_id, |
| 300 params.surface_handle, | 292 params.surface_handle, |
| 301 TransportDIB::DefaultHandleValue())); | 293 TransportDIB::DefaultHandleValue())); |
| 302 | 294 |
| 303 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 295 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
| 304 params.surface_id); | 296 params.surface_id); |
| 305 if (!view) | 297 if (!view) |
| 306 return; | 298 return; |
| 307 | 299 |
| 308 uint64 surface_handle = params.surface_handle; | 300 uint64 surface_handle = params.surface_handle; |
| 309 TransportDIB::Handle shm_handle = TransportDIB::DefaultHandleValue(); | 301 TransportDIB::Handle shm_handle = TransportDIB::DefaultHandleValue(); |
| 310 | 302 |
| 311 view->AcceleratedSurfaceNew( | 303 view->AcceleratedSurfaceNew( |
| 312 params.width, params.height, &surface_handle, &shm_handle); | 304 params.width, params.height, &surface_handle, &shm_handle); |
| 313 delayed_send.Cancel(); | 305 delayed_send.Cancel(); |
| 314 Send(new AcceleratedSurfaceMsg_NewACK( | 306 Send(new AcceleratedSurfaceMsg_NewACK( |
| 315 params.route_id, surface_handle, shm_handle)); | 307 params.route_id, surface_handle, shm_handle)); |
| 316 } | 308 } |
| 317 | 309 |
| 318 #endif | |
| 319 | |
| 320 static base::TimeDelta GetSwapDelay() { | 310 static base::TimeDelta GetSwapDelay() { |
| 321 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 311 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 322 int delay = 0; | 312 int delay = 0; |
| 323 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { | 313 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { |
| 324 base::StringToInt(cmd_line->GetSwitchValueNative( | 314 base::StringToInt(cmd_line->GetSwitchValueNative( |
| 325 switches::kGpuSwapDelay).c_str(), &delay); | 315 switches::kGpuSwapDelay).c_str(), &delay); |
| 326 } | 316 } |
| 327 return base::TimeDelta::FromMilliseconds(delay); | 317 return base::TimeDelta::FromMilliseconds(delay); |
| 328 } | 318 } |
| 329 | 319 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 "GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend"); | 366 "GpuProcessHostUIShim::OnAcceleratedSurfaceSuspend"); |
| 377 | 367 |
| 378 RenderWidgetHostViewPort* view = | 368 RenderWidgetHostViewPort* view = |
| 379 GetRenderWidgetHostViewFromSurfaceID(surface_id); | 369 GetRenderWidgetHostViewFromSurfaceID(surface_id); |
| 380 if (!view) | 370 if (!view) |
| 381 return; | 371 return; |
| 382 | 372 |
| 383 view->AcceleratedSurfaceSuspend(); | 373 view->AcceleratedSurfaceSuspend(); |
| 384 } | 374 } |
| 385 | 375 |
| 386 #if defined(USE_AURA) | |
| 387 | |
| 388 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( | 376 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( |
| 389 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { | 377 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { |
| 390 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 378 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
| 391 params.surface_id); | 379 params.surface_id); |
| 392 if (!view) | 380 if (!view) |
| 393 return; | 381 return; |
| 394 view->AcceleratedSurfaceRelease(params.identifier); | 382 view->AcceleratedSurfaceRelease(params.identifier); |
| 395 } | 383 } |
| 396 | |
| 397 #endif | |
| OLD | NEW |