summaryrefslogtreecommitdiffstats
path: root/content/common
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 01:17:00 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 01:17:00 +0000
commit22f320a27d8b7e45221fd92ce1964716a7277821 (patch)
treed11cd935d327658829a199d9e1c59a6aa7d3f73f /content/common
parentc16ed34dad105cd5e8a1f0215f3650cf31507bc6 (diff)
downloadchromium_src-22f320a27d8b7e45221fd92ce1964716a7277821.zip
chromium_src-22f320a27d8b7e45221fd92ce1964716a7277821.tar.gz
chromium_src-22f320a27d8b7e45221fd92ce1964716a7277821.tar.bz2
Added GPU process "echo" IPC message.
The echo message is essentially an async fence with event based notification. The client gets a notification when the GPU process has completed all the work up to the last flush. I used it to replace the SwapBuffers / OnSwapBuffers synchronization and got rid of some of the callbacks in the lower layers of the stack. The SwapBuffers callbacks in the GPU process are only needed on mac now and I will replace them with something more generic soon. Review URL: http://codereview.chromium.org/7762013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common')
-rw-r--r--content/common/gpu/gpu_channel.cc6
-rw-r--r--content/common/gpu/gpu_channel.h2
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.cc20
-rw-r--r--content/common/gpu/gpu_command_buffer_stub.h4
-rw-r--r--content/common/gpu/gpu_messages.h10
5 files changed, 28 insertions, 14 deletions
diff --git a/content/common/gpu/gpu_channel.cc b/content/common/gpu/gpu_channel.cc
index 2bc36ba..287f345 100644
--- a/content/common/gpu/gpu_channel.cc
+++ b/content/common/gpu/gpu_channel.cc
@@ -260,6 +260,7 @@ bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroySurface, OnDestroySurface)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateTransportTexture,
OnCreateTransportTexture)
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_Echo, OnEcho);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
DCHECK(handled) << msg.type();
@@ -411,6 +412,11 @@ void GpuChannel::OnCreateTransportTexture(int32 context_route_id,
#endif
}
+void GpuChannel::OnEcho(const IPC::Message& message) {
+ TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnEcho");
+ Send(new IPC::Message(message));
+}
+
bool GpuChannel::Init(base::MessageLoopProxy* io_message_loop,
base::WaitableEvent* shutdown_event) {
// Check whether we're already initialized.
diff --git a/content/common/gpu/gpu_channel.h b/content/common/gpu/gpu_channel.h
index ed4a5a6..4b8deb7 100644
--- a/content/common/gpu/gpu_channel.h
+++ b/content/common/gpu/gpu_channel.h
@@ -150,6 +150,8 @@ class GpuChannel : public IPC::Channel::Listener,
void OnCreateTransportTexture(int32 context_route_id, int32 host_id);
+ void OnEcho(const IPC::Message& message);
+
// The lifetime of objects of this class is managed by a GpuChannelManager.
// The GpuChannelManager destroy all the GpuChannels that they own when they
// are destroyed. So a raw pointer is safe.
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc
index a565f79..2f1caec 100644
--- a/content/common/gpu/gpu_command_buffer_stub.cc
+++ b/content/common/gpu/gpu_command_buffer_stub.cc
@@ -197,8 +197,12 @@ void GpuCommandBufferStub::OnInitialize(
NewCallback(this, &GpuCommandBufferStub::OnParseError));
scheduler_->SetScheduledCallback(
NewCallback(channel_, &GpuChannel::OnScheduled));
+
+#if defined(OS_MACOSX)
scheduler_->SetSwapBuffersCallback(
NewCallback(this, &GpuCommandBufferStub::OnSwapBuffers));
+#endif
+
// On TOUCH_UI, the ImageTransportSurface handles co-ordinating the
// resize with the browser process. The ImageTransportSurface sets it's
// own resize callback, so we shouldn't do it here.
@@ -407,11 +411,9 @@ void GpuCommandBufferStub::OnGetTransferBuffer(
Send(reply_message);
}
+#if defined(OS_MACOSX)
void GpuCommandBufferStub::OnSwapBuffers() {
TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnSwapBuffers");
- ReportState();
-
-#if defined(OS_MACOSX)
if (handle_) {
// To swap on OSX, we have to send a message to the browser to get the
// context put onscreen.
@@ -427,11 +429,8 @@ void GpuCommandBufferStub::OnSwapBuffers() {
new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params));
scheduler_->SetScheduled(false);
}
-#else
- // Notify the upstream commandbuffer that the swapbuffers has completed.
- Send(new GpuCommandBufferMsg_SwapBuffers(route_id_));
-#endif
}
+#endif
void GpuCommandBufferStub::OnCommandProcessed() {
if (watchdog_)
@@ -455,10 +454,9 @@ void GpuCommandBufferStub::AcceleratedSurfaceBuffersSwapped(
scheduler_->set_acknowledged_swap_buffers_count(swap_buffers_count);
for(uint64 i = 0; i < delta; i++) {
- // Notify the upstream commandbuffer that the swapbuffers has completed.
- Send(new GpuCommandBufferMsg_SwapBuffers(route_id_));
-
- // Wake up the GpuScheduler to start doing work again.
+ // Wake up the GpuScheduler to start doing work again. When the scheduler
+ // wakes up, it will send any deferred echo acknowledgements, triggering
+ // associated swapbuffer callbacks.
scheduler_->SetScheduled(true);
}
}
diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h
index ef2dabb..e7c4050 100644
--- a/content/common/gpu/gpu_command_buffer_stub.h
+++ b/content/common/gpu/gpu_command_buffer_stub.h
@@ -102,6 +102,7 @@ class GpuCommandBufferStub
uint32 flush_count,
IPC::Message* reply_message);
void OnAsyncFlush(int32 put_offset, uint32 flush_count);
+ void OnEcho(const IPC::Message& message);
void OnRescheduled();
void OnCreateTransferBuffer(int32 size,
int32 id_request,
@@ -117,7 +118,10 @@ class GpuCommandBufferStub
IPC::Message* reply_message);
void OnDestroyVideoDecoder(int32 decoder_route_id);
+#if defined(OS_MACOSX)
void OnSwapBuffers();
+#endif
+
void OnCommandProcessed();
void OnParseError();
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 777fede..9d66de4 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -307,6 +307,10 @@ IPC_MESSAGE_CONTROL2(GpuChannelMsg_CreateTransportTexture,
int32, /* context_route_id */
int32 /* host_id */)
+// Request that the GPU process reply with the given message.
+IPC_MESSAGE_CONTROL1(GpuChannelMsg_Echo,
+ IPC::Message /* reply */)
+
//------------------------------------------------------------------------------
// GPU Command Buffer Messages
// These are messages between a renderer process to the GPU process relating to
@@ -357,9 +361,6 @@ IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_Rescheduled)
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_UpdateState,
gpu::CommandBuffer::State /* state */)
-// Indicates that a SwapBuffers call has been issued.
-IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_SwapBuffers)
-
// Create a shared memory transfer buffer. Returns an id that can be used to
// identify the transfer buffer from a comment.
IPC_SYNC_MESSAGE_ROUTED2_1(GpuCommandBufferMsg_CreateTransferBuffer,
@@ -418,6 +419,9 @@ IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetWindowSize,
IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_Destroyed,
gpu::error::ContextLostReason /* reason */)
+// Response to a GpuChannelMsg_Echo message.
+IPC_MESSAGE_ROUTED0(GpuCommandBufferMsg_EchoAck)
+
// --------------------------------------------------------------------------
// TransportTexture messages
//