Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 7260008: Implement proper synchronization between HW video decode IPC and CommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/callback.h"
8 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
9 #include "base/process_util.h" 10 #include "base/process_util.h"
10 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "content/common/child_thread.h" 13 #include "content/common/child_thread.h"
13 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
14 #include "content/common/gpu/gpu_channel_manager.h" 15 #include "content/common/gpu/gpu_channel_manager.h"
15 #include "content/common/gpu/gpu_command_buffer_stub.h" 16 #include "content/common/gpu/gpu_command_buffer_stub.h"
16 #include "content/common/gpu/gpu_messages.h" 17 #include "content/common/gpu/gpu_messages.h"
17 #include "content/common/gpu/gpu_watchdog.h" 18 #include "content/common/gpu/gpu_watchdog.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 NewCallback(scheduler_.get(), 146 NewCallback(scheduler_.get(),
146 &gpu::GpuScheduler::PutChanged)); 147 &gpu::GpuScheduler::PutChanged));
147 command_buffer_->SetParseErrorCallback( 148 command_buffer_->SetParseErrorCallback(
148 NewCallback(this, &GpuCommandBufferStub::OnParseError)); 149 NewCallback(this, &GpuCommandBufferStub::OnParseError));
149 scheduler_->SetSwapBuffersCallback( 150 scheduler_->SetSwapBuffersCallback(
150 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers)); 151 NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
151 scheduler_->SetLatchCallback(base::Bind( 152 scheduler_->SetLatchCallback(base::Bind(
152 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_)); 153 &GpuChannel::OnLatchCallback, base::Unretained(channel_), route_id_));
153 scheduler_->SetScheduledCallback( 154 scheduler_->SetScheduledCallback(
154 NewCallback(this, &GpuCommandBufferStub::OnScheduled)); 155 NewCallback(this, &GpuCommandBufferStub::OnScheduled));
156 scheduler_->SetTokenCallback(base::Bind(
157 &GpuCommandBufferStub::OnSetToken, base::Unretained(this)));
155 if (watchdog_) 158 if (watchdog_)
156 scheduler_->SetCommandProcessedCallback( 159 scheduler_->SetCommandProcessedCallback(
157 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed)); 160 NewCallback(this, &GpuCommandBufferStub::OnCommandProcessed));
158 161
159 #if defined(OS_MACOSX) || defined(TOUCH_UI) 162 #if defined(OS_MACOSX) || defined(TOUCH_UI)
160 if (handle_) { 163 if (handle_) {
161 // This context conceptually puts its output directly on the 164 // This context conceptually puts its output directly on the
162 // screen, rendered by the accelerated plugin layer in 165 // screen, rendered by the accelerated plugin layer in
163 // RenderWidgetHostViewMac. Set up a pathway to notify the 166 // RenderWidgetHostViewMac. Set up a pathway to notify the
164 // browser process when its contents change. 167 // browser process when its contents change.
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // the stub, this method allows us to cleanup and unblock pending messages. 484 // the stub, this method allows us to cleanup and unblock pending messages.
482 if (scheduler_.get()) { 485 if (scheduler_.get()) {
483 while (!scheduler_->IsScheduled()) 486 while (!scheduler_->IsScheduled())
484 scheduler_->SetScheduled(true); 487 scheduler_->SetScheduled(true);
485 } 488 }
486 // Handle any deferred messages now that the scheduler is not blocking 489 // Handle any deferred messages now that the scheduler is not blocking
487 // message handling. 490 // message handling.
488 HandleDeferredMessages(); 491 HandleDeferredMessages();
489 } 492 }
490 493
494 void GpuCommandBufferStub::AddSetTokenCallback(
495 const base::Callback<void(int32)>& callback) {
496 set_token_callbacks_.push_back(callback);
497 }
498
499 void GpuCommandBufferStub::OnSetToken(int32 token) {
500 for (size_t i = 0; i < set_token_callbacks_.size(); ++i)
501 set_token_callbacks_[i].Run(token);
piman 2011/06/28 01:19:22 Can the callback remove itself ? See later comment
Ami GONE FROM CHROMIUM 2011/06/28 21:00:53 See later comment for why I don't think we need th
502 }
503
491 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) { 504 void GpuCommandBufferStub::ResizeCallback(gfx::Size size) {
492 if (handle_ == gfx::kNullPluginWindow) { 505 if (handle_ == gfx::kNullPluginWindow) {
493 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size); 506 scheduler_->decoder()->ResizeOffscreenFrameBuffer(size);
494 scheduler_->decoder()->UpdateOffscreenFrameBufferSize(); 507 scheduler_->decoder()->UpdateOffscreenFrameBufferSize();
495 } else { 508 } else {
496 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN) 509 #if defined(TOOLKIT_USES_GTK) && !defined(TOUCH_UI) || defined(OS_WIN)
497 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); 510 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager();
498 gpu_channel_manager->Send( 511 gpu_channel_manager->Send(
499 new GpuHostMsg_ResizeView(renderer_id_, 512 new GpuHostMsg_ResizeView(renderer_id_,
500 render_view_id_, 513 render_view_id_,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 gfx::GLContext::LosesAllContextsOnContextLost()) { 567 gfx::GLContext::LosesAllContextsOnContextLost()) {
555 channel_->LoseAllContexts(); 568 channel_->LoseAllContexts();
556 } else { 569 } else {
557 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state); 570 IPC::Message* msg = new GpuCommandBufferMsg_UpdateState(route_id_, state);
558 msg->set_unblock(true); 571 msg->set_unblock(true);
559 Send(msg); 572 Send(msg);
560 } 573 }
561 } 574 }
562 575
563 #endif // defined(ENABLE_GPU) 576 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698