Commit d19f5f10 authored by skyostil@chromium.org's avatar skyostil@chromium.org

Send vsync notification from browser to renderer on Android

Allow the renderer to subscribe to a vsync notification from the
browser. This change adds the necessary IPC plumbing but does not
actually implement the vsync signal source; this is done with a
separate patch.

BUG=149227

Review URL: https://chromiumcodereview.appspot.com/13068002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195136 0039d316-1c4b-4281-b951-d872f2087c98
parent 5614eae1
...@@ -120,6 +120,8 @@ bool RenderWidgetHostViewAndroid::OnMessageReceived( ...@@ -120,6 +120,8 @@ bool RenderWidgetHostViewAndroid::OnMessageReceived(
IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor,
OnDidChangeBodyBackgroundColor) OnDidChangeBodyBackgroundColor)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetVSyncNotificationEnabled,
OnSetVSyncNotificationEnabled)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; return handled;
...@@ -385,6 +387,14 @@ void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( ...@@ -385,6 +387,14 @@ void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor(
content_view_core_->OnBackgroundColorChanged(color); content_view_core_->OnBackgroundColorChanged(color);
} }
void RenderWidgetHostViewAndroid::SendVSync(base::TimeTicks frame_time) {
host_->Send(new ViewMsg_DidVSync(host_->GetRoutingID(), frame_time));
}
void RenderWidgetHostViewAndroid::OnSetVSyncNotificationEnabled(bool enabled) {
// TODO(skyostil): Toggle the Java-side vsync monitor.
}
void RenderWidgetHostViewAndroid::OnStartContentIntent( void RenderWidgetHostViewAndroid::OnStartContentIntent(
const GURL& content_url) { const GURL& content_url) {
if (content_view_core_) if (content_view_core_)
......
...@@ -155,10 +155,12 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { ...@@ -155,10 +155,12 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
void SendMouseEvent(const WebKit::WebMouseEvent& event); void SendMouseEvent(const WebKit::WebMouseEvent& event);
void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event); void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event);
void SendGestureEvent(const WebKit::WebGestureEvent& event); void SendGestureEvent(const WebKit::WebGestureEvent& event);
void SendVSync(base::TimeTicks frame_time);
void OnProcessImeBatchStateAck(bool is_begin); void OnProcessImeBatchStateAck(bool is_begin);
void OnDidChangeBodyBackgroundColor(SkColor color); void OnDidChangeBodyBackgroundColor(SkColor color);
void OnStartContentIntent(const GURL& content_url); void OnStartContentIntent(const GURL& content_url);
void OnSetVSyncNotificationEnabled(bool enabled);
int GetNativeImeAdapter(); int GetNativeImeAdapter();
......
...@@ -760,7 +760,7 @@ IPC_MESSAGE_ROUTED0(ViewMsg_MouseLockLost) ...@@ -760,7 +760,7 @@ IPC_MESSAGE_ROUTED0(ViewMsg_MouseLockLost)
IPC_MESSAGE_ROUTED1(ViewMsg_OrientationChangeEvent, IPC_MESSAGE_ROUTED1(ViewMsg_OrientationChangeEvent,
int /* orientation */) int /* orientation */)
// Sent by the renderer when the parameters for vsync alignment have changed. // Sent by the browser when the parameters for vsync alignment have changed.
IPC_MESSAGE_ROUTED2(ViewMsg_UpdateVSyncParameters, IPC_MESSAGE_ROUTED2(ViewMsg_UpdateVSyncParameters,
base::TimeTicks /* timebase */, base::TimeTicks /* timebase */,
base::TimeDelta /* interval */) base::TimeDelta /* interval */)
...@@ -1368,6 +1368,11 @@ IPC_MESSAGE_ROUTED3(ViewMsg_UpdateTopControlsState, ...@@ -1368,6 +1368,11 @@ IPC_MESSAGE_ROUTED3(ViewMsg_UpdateTopControlsState,
IPC_MESSAGE_ROUTED0(ViewMsg_ShowImeIfNeeded) IPC_MESSAGE_ROUTED0(ViewMsg_ShowImeIfNeeded)
// Sent by the browser when the display vsync signal was triggered and the
// renderer should generate a new frame.
IPC_MESSAGE_ROUTED1(ViewMsg_DidVSync,
base::TimeTicks /* frame_time */)
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// Let the RenderView know its window has changed visibility. // Let the RenderView know its window has changed visibility.
IPC_MESSAGE_ROUTED1(ViewMsg_SetWindowVisibility, IPC_MESSAGE_ROUTED1(ViewMsg_SetWindowVisibility,
...@@ -2351,6 +2356,12 @@ IPC_MESSAGE_CONTROL2(ViewHostMsg_RunWebAudioMediaCodec, ...@@ -2351,6 +2356,12 @@ IPC_MESSAGE_CONTROL2(ViewHostMsg_RunWebAudioMediaCodec,
base::SharedMemoryHandle /* encoded_data_handle */, base::SharedMemoryHandle /* encoded_data_handle */,
base::FileDescriptor /* pcm_output */) base::FileDescriptor /* pcm_output */)
// Sent by renderer to request a ViewMsg_VSync message for upcoming display
// vsync events. If |enabled| is true, the vsync message will continue to be be
// delivered until the notification is disabled.
IPC_MESSAGE_ROUTED1(ViewHostMsg_SetVSyncNotificationEnabled,
bool /* enabled */)
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// Request that the browser load a font into shared memory for us. // Request that the browser load a font into shared memory for us.
IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_LoadFont, IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_LoadFont,
......
...@@ -42,7 +42,10 @@ IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter( ...@@ -42,7 +42,10 @@ IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter(
{ {
uint32 messages_to_filter[] = { uint32 messages_to_filter[] = {
ViewMsg_UpdateVSyncParameters::ID, ViewMsg_UpdateVSyncParameters::ID,
ViewMsg_SwapCompositorFrameAck::ID ViewMsg_SwapCompositorFrameAck::ID,
#if defined(OS_ANDROID)
ViewMsg_DidVSync::ID
#endif
}; };
return new IPC::ForwardingMessageFilter( return new IPC::ForwardingMessageFilter(
...@@ -131,16 +134,30 @@ void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) { ...@@ -131,16 +134,30 @@ void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message) IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters); IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck); IPC_MESSAGE_HANDLER(ViewMsg_SwapCompositorFrameAck, OnSwapAck);
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ViewMsg_DidVSync, OnDidVSync);
#endif
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
} }
void CompositorOutputSurface::OnUpdateVSyncParameters( void CompositorOutputSurface::OnUpdateVSyncParameters(
base::TimeTicks timebase, base::TimeDelta interval) { base::TimeTicks timebase, base::TimeDelta interval) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
DCHECK(client_);
client_->OnVSyncParametersChanged(timebase, interval); client_->OnVSyncParametersChanged(timebase, interval);
} }
#if defined(OS_ANDROID)
void CompositorOutputSurface::EnableVSyncNotification(bool enable) {
DCHECK(CalledOnValidThread());
Send(new ViewHostMsg_SetVSyncNotificationEnabled(routing_id_, enable));
}
void CompositorOutputSurface::OnDidVSync(base::TimeTicks frame_time) {
DCHECK(CalledOnValidThread());
client_->DidVSync(frame_time);
}
#endif // defined(OS_ANDROID)
void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) { void CompositorOutputSurface::OnSwapAck(const cc::CompositorFrameAck& ack) {
client_->OnSendFrameToParentCompositorAck(ack); client_->OnSendFrameToParentCompositorAck(ack);
} }
......
...@@ -51,6 +51,9 @@ class CompositorOutputSurface ...@@ -51,6 +51,9 @@ class CompositorOutputSurface
virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE; virtual void SendFrameToParentCompositor(cc::CompositorFrame*) OVERRIDE;
virtual void PostSubBuffer(gfx::Rect rect, const cc::LatencyInfo&) OVERRIDE; virtual void PostSubBuffer(gfx::Rect rect, const cc::LatencyInfo&) OVERRIDE;
virtual void SwapBuffers(const cc::LatencyInfo&) OVERRIDE; virtual void SwapBuffers(const cc::LatencyInfo&) OVERRIDE;
#if defined(OS_ANDROID)
virtual void EnableVSyncNotification(bool enable) OVERRIDE;
#endif
// TODO(epenner): This seems out of place here and would be a better fit // TODO(epenner): This seems out of place here and would be a better fit
// int CompositorThread after it is fully refactored (http://crbug/170828) // int CompositorThread after it is fully refactored (http://crbug/170828)
...@@ -83,6 +86,9 @@ class CompositorOutputSurface ...@@ -83,6 +86,9 @@ class CompositorOutputSurface
void OnMessageReceived(const IPC::Message& message); void OnMessageReceived(const IPC::Message& message);
void OnUpdateVSyncParameters( void OnUpdateVSyncParameters(
base::TimeTicks timebase, base::TimeDelta interval); base::TimeTicks timebase, base::TimeDelta interval);
#if defined(OS_ANDROID)
void OnDidVSync(base::TimeTicks frame_time);
#endif
bool Send(IPC::Message* message); bool Send(IPC::Message* message);
scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_; scoped_refptr<IPC::ForwardingMessageFilter> output_surface_filter_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment