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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 params.route_id = route_id(); | 386 params.route_id = route_id(); |
387 params.swap_buffers_count = scheduler_->swap_buffers_count(); | 387 params.swap_buffers_count = scheduler_->swap_buffers_count(); |
388 gpu_channel_manager->Send( | 388 gpu_channel_manager->Send( |
389 new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 389 new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
390 | 390 |
391 scheduler_->SetScheduled(false); | 391 scheduler_->SetScheduled(false); |
392 } | 392 } |
393 | 393 |
394 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped( | 394 void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped( |
395 uint64 swap_buffers_count) { | 395 uint64 swap_buffers_count) { |
396 TRACE_EVENT0("gpu", | 396 TRACE_EVENT1("gpu", |
397 "GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped"); | 397 "GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped", |
| 398 "frame", swap_buffers_count); |
398 | 399 |
399 // Multiple swapbuffers may get consolidated together into a single | 400 // Multiple swapbuffers may get consolidated together into a single |
400 // AcceleratedSurfaceBuffersSwapped call. Since OnSwapBuffers expects to be | 401 // AcceleratedSurfaceBuffersSwapped call. Since OnSwapBuffers expects to be |
401 // called one time for every swap, make up the difference here. | 402 // called one time for every swap, make up the difference here. |
402 uint64 delta = swap_buffers_count - | 403 uint64 delta = swap_buffers_count - |
403 scheduler_->acknowledged_swap_buffers_count(); | 404 scheduler_->acknowledged_swap_buffers_count(); |
404 | |
405 scheduler_->set_acknowledged_swap_buffers_count(swap_buffers_count); | 405 scheduler_->set_acknowledged_swap_buffers_count(swap_buffers_count); |
406 | 406 |
407 for(uint64 i = 0; i < delta; i++) | 407 for(uint64 i = 0; i < delta; i++) { |
408 OnSwapBuffers(); | 408 OnSwapBuffers(); |
409 | 409 // Wake up the GpuScheduler to start doing work again. |
410 // Wake up the GpuScheduler to start doing work again. | 410 scheduler_->SetScheduled(true); |
411 scheduler_->SetScheduled(true); | 411 } |
412 } | 412 } |
413 #endif // defined(OS_MACOSX) | 413 #endif // defined(OS_MACOSX) |
414 | 414 |
| 415 void GpuCommandBufferStub::CommandBufferWasDestroyed() { |
| 416 TRACE_EVENT0("gpu", "GpuCommandBufferStub::CommandBufferWasDestroyed"); |
| 417 // In case the renderer is currently blocked waiting for a sync reply from |
| 418 // the stub, this method allows us to cleanup and unblock pending messages. |
| 419 while (!scheduler_->IsScheduled()) |
| 420 scheduler_->SetScheduled(true); |
| 421 // Handle any deferred messages now that the scheduler is scheduled. |
| 422 HandleDeferredMessages(); |
| 423 } |
| 424 |
415 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { | 425 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { |
416 if (handle_ == gfx::kNullPluginWindow) { | 426 if (handle_ == gfx::kNullPluginWindow) { |
417 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); | 427 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); |
418 scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); | 428 scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); |
419 } else { | 429 } else { |
420 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) | 430 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
421 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 431 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
422 gpu_channel_manager->Send( | 432 gpu_channel_manager->Send( |
423 new GpuHostMsg_ResizeView(renderer_id_, | 433 new GpuHostMsg_ResizeView(renderer_id_, |
424 render_view_id_, | 434 render_view_id_, |
(...skipping 28 matching lines...) Expand all Loading... |
453 gfx::GLContext::LosesAllContextsOnContextLost()) { | 463 gfx::GLContext::LosesAllContextsOnContextLost()) { |
454 channel_->LoseAllContexts(); | 464 channel_->LoseAllContexts(); |
455 } else { | 465 } else { |
456 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 466 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); |
457 msg->set_unblock(true); | 467 msg->set_unblock(true); |
458 Send(msg); | 468 Send(msg); |
459 } | 469 } |
460 } | 470 } |
461 | 471 |
462 #endif // defined(ENABLE_GPU) | 472 #endif // defined(ENABLE_GPU) |
OLD | NEW |