| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 265 } |
| 266 | 266 |
| 267 namespace { | 267 namespace { |
| 268 | 268 |
| 269 class BuffersSwappedDispatcher : public Task { | 269 class BuffersSwappedDispatcher : public Task { |
| 270 public: | 270 public: |
| 271 BuffersSwappedDispatcher( | 271 BuffersSwappedDispatcher( |
| 272 int32 renderer_id, | 272 int32 renderer_id, |
| 273 int32 render_view_id, | 273 int32 render_view_id, |
| 274 gfx::PluginWindowHandle window, | 274 gfx::PluginWindowHandle window, |
| 275 uint64 surface_id) | 275 uint64 surface_id, |
| 276 int32 route_id, |
| 277 uint64 swap_buffers_count) |
| 276 : renderer_id_(renderer_id), | 278 : renderer_id_(renderer_id), |
| 277 render_view_id_(render_view_id), | 279 render_view_id_(render_view_id), |
| 278 window_(window), | 280 window_(window), |
| 279 surface_id_(surface_id) { | 281 surface_id_(surface_id), |
| 282 route_id_(route_id), |
| 283 swap_buffers_count_(swap_buffers_count) { |
| 280 } | 284 } |
| 281 | 285 |
| 282 void Run() { | 286 void Run() { |
| 283 RenderViewHost* host = RenderViewHost::FromID(renderer_id_, | 287 RenderViewHost* host = RenderViewHost::FromID(renderer_id_, |
| 284 render_view_id_); | 288 render_view_id_); |
| 285 if (!host) | 289 if (!host) |
| 286 return; | 290 return; |
| 287 RenderWidgetHostView* view = host->view(); | 291 RenderWidgetHostView* view = host->view(); |
| 288 if (!view) | 292 if (!view) |
| 289 return; | 293 return; |
| 290 view->AcceleratedSurfaceBuffersSwapped(window_, surface_id_); | 294 view->AcceleratedSurfaceBuffersSwapped( |
| 295 // Parameters needed to swap the IOSurface. |
| 296 window_, |
| 297 surface_id_, |
| 298 // Parameters needed to formulate an acknowledgment. |
| 299 renderer_id_, |
| 300 route_id_, |
| 301 swap_buffers_count_); |
| 291 } | 302 } |
| 292 | 303 |
| 293 private: | 304 private: |
| 294 int32 renderer_id_; | 305 int32 renderer_id_; |
| 295 int32 render_view_id_; | 306 int32 render_view_id_; |
| 296 gfx::PluginWindowHandle window_; | 307 gfx::PluginWindowHandle window_; |
| 297 uint64 surface_id_; | 308 uint64 surface_id_; |
| 309 int32 route_id_; |
| 310 uint64 swap_buffers_count_; |
| 298 | 311 |
| 299 DISALLOW_COPY_AND_ASSIGN(BuffersSwappedDispatcher); | 312 DISALLOW_COPY_AND_ASSIGN(BuffersSwappedDispatcher); |
| 300 }; | 313 }; |
| 301 | 314 |
| 302 } // namespace | 315 } // namespace |
| 303 | 316 |
| 304 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 317 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 305 int32 renderer_id, | 318 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 306 int32 render_view_id, | |
| 307 gfx::PluginWindowHandle window, | |
| 308 uint64 surface_id) { | |
| 309 BrowserThread::PostTask( | 319 BrowserThread::PostTask( |
| 310 BrowserThread::UI, FROM_HERE, | 320 BrowserThread::UI, FROM_HERE, |
| 311 new BuffersSwappedDispatcher( | 321 new BuffersSwappedDispatcher( |
| 312 renderer_id, render_view_id, window, surface_id)); | 322 // These are the parameters needed to look up the IOSurface |
| 323 // on this side. |
| 324 params.renderer_id, |
| 325 params.render_view_id, |
| 326 params.window, |
| 327 params.surface_id, |
| 328 // These are additional parameters needed to formulate an |
| 329 // acknowledgment. |
| 330 params.route_id, |
| 331 params.swap_buffers_count)); |
| 313 } | 332 } |
| 314 #endif | 333 #endif |
| 315 | 334 |
| 316 void GpuProcessHost::SendEstablishChannelReply( | 335 void GpuProcessHost::SendEstablishChannelReply( |
| 317 const IPC::ChannelHandle& channel, | 336 const IPC::ChannelHandle& channel, |
| 318 const GPUInfo& gpu_info, | 337 const GPUInfo& gpu_info, |
| 319 ResourceMessageFilter* filter) { | 338 ResourceMessageFilter* filter) { |
| 320 ViewMsg_GpuChannelEstablished* message = | 339 ViewMsg_GpuChannelEstablished* message = |
| 321 new ViewMsg_GpuChannelEstablished(channel, gpu_info); | 340 new ViewMsg_GpuChannelEstablished(channel, gpu_info); |
| 322 // If the renderer process is performing synchronous initialization, | 341 // If the renderer process is performing synchronous initialization, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 FilePath(), | 408 FilePath(), |
| 390 #elif defined(OS_POSIX) | 409 #elif defined(OS_POSIX) |
| 391 false, // Never use the zygote (GPU plugin can't be sandboxed). | 410 false, // Never use the zygote (GPU plugin can't be sandboxed). |
| 392 base::environment_vector(), | 411 base::environment_vector(), |
| 393 #endif | 412 #endif |
| 394 cmd_line); | 413 cmd_line); |
| 395 | 414 |
| 396 return true; | 415 return true; |
| 397 } | 416 } |
| 398 | 417 |
| OLD | NEW |