| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 NewCallback(scheduler_.get(), | 145 NewCallback(scheduler_.get(), |
| 146 &gpu::GpuScheduler::PutChanged)); | 146 &gpu::GpuScheduler::PutChanged)); |
| 147 command_buffer_->SetParseErrorCallback( | 147 command_buffer_->SetParseErrorCallback( |
| 148 NewCallback(this, &GpuCommandBufferStub::OnParseError)); | 148 NewCallback(this, &GpuCommandBufferStub::OnParseError)); |
| 149 scheduler_->SetSwapBuffersCallback( | 149 scheduler_->SetSwapBuffersCallback( |
| 150 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); | 150 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); |
| 151 scheduler_->SetLatchCallback(base::Bind( | 151 scheduler_->SetLatchCallback(base::Bind( |
| 152 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_)); | 152 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_)); |
| 153 scheduler_->SetScheduledCallback( | 153 scheduler_->SetScheduledCallback( |
| 154 NewCallback(this, &GpuCommandBufferStub::OnScheduled)); | 154 NewCallback(this, &GpuCommandBufferStub::OnScheduled)); |
| 155 scheduler_->SetTokenCallback(base::Bind( |
| 156 &GpuCommandBufferStub::OnSetToken, base::Unretained(this))); |
| 155 if (watchdog_) | 157 if (watchdog_) |
| 156 scheduler_->SetCommandProcessedCallback( | 158 scheduler_->SetCommandProcessedCallback( |
| 157 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); | 159 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); |
| 158 | 160 |
| 159 #if defined(OS_MACOSX) || defined(TOUCH_UI) | 161 #if defined(OS_MACOSX) || defined(TOUCH_UI) |
| 160 if (handle_) { | 162 if (handle_) { |
| 161 // This context conceptually puts its output directly on the | 163 // This context conceptually puts its output directly on the |
| 162 // screen, rendered by the accelerated plugin layer in | 164 // screen, rendered by the accelerated plugin layer in |
| 163 // RenderWidgetHostViewMac. Set up a pathway to notify the | 165 // RenderWidgetHostViewMac. Set up a pathway to notify the |
| 164 // browser process when its contents change. | 166 // browser process when its contents change. |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // the stub, this method allows us to cleanup and unblock pending messages. | 483 // the stub, this method allows us to cleanup and unblock pending messages. |
| 482 if (scheduler_.get()) { | 484 if (scheduler_.get()) { |
| 483 while (!scheduler_->IsScheduled()) | 485 while (!scheduler_->IsScheduled()) |
| 484 scheduler_->SetScheduled(true); | 486 scheduler_->SetScheduled(true); |
| 485 } | 487 } |
| 486 // Handle any deferred messages now that the scheduler is not blocking | 488 // Handle any deferred messages now that the scheduler is not blocking |
| 487 // message handling. | 489 // message handling. |
| 488 HandleDeferredMessages(); | 490 HandleDeferredMessages(); |
| 489 } | 491 } |
| 490 | 492 |
| 493 void GpuCommandBufferStub::AddSetTokenCallback( |
| 494 const base::Callback<void(int32)>& callback) { |
| 495 set_token_callbacks_.push_back(callback); |
| 496 } |
| 497 |
| 498 void GpuCommandBufferStub::OnSetToken(int32 token) { |
| 499 for (size_t i = 0; i < set_token_callbacks_.size(); ++i) |
| 500 set_token_callbacks_[i].Run(token); |
| 501 } |
| 502 |
| 491 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { | 503 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { |
| 492 if (handle_ == gfx::kNullPluginWindow) { | 504 if (handle_ == gfx::kNullPluginWindow) { |
| 493 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); | 505 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); |
| 494 scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); | 506 scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); |
| 495 } else { | 507 } else { |
| 496 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) | 508 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) |
| 497 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 509 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); |
| 498 gpu_channel_manager->Send( | 510 gpu_channel_manager->Send( |
| 499 new GpuHostMsg_ResizeView(renderer_id_, | 511 new GpuHostMsg_ResizeView(renderer_id_, |
| 500 render_view_id_, | 512 render_view_id_, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 gfx::GLContext::LosesAllContextsOnContextLost()) { | 566 gfx::GLContext::LosesAllContextsOnContextLost()) { |
| 555 channel_->LoseAllContexts(); | 567 channel_->LoseAllContexts(); |
| 556 } else { | 568 } else { |
| 557 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); | 569 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); |
| 558 msg->set_unblock(true); | 570 msg->set_unblock(true); |
| 559 Send(msg); | 571 Send(msg); |
| 560 } | 572 } |
| 561 } | 573 } |
| 562 | 574 |
| 563 #endif // defined(ENABLE_GPU) | 575 #endif // defined(ENABLE_GPU) |
| OLD | NEW |