OSDN Git Service

SF: Use last call time to rate limit resyncs
authorDan Stoza <stoza@google.com>
Mon, 8 May 2017 21:03:54 +0000 (14:03 -0700)
committerDan Stoza <stoza@google.com>
Mon, 8 May 2017 21:03:54 +0000 (14:03 -0700)
commit57164302da664fc58c3fd3c1ed9980bc1c9bdf1f
tree30e69ac5f47a3d48fff1984e40605e1aa31a3bcf
parent584bc3cebf3f23d378fc7ed06e71c5d1722373dd
SF: Use last call time to rate limit resyncs

SurfaceFlinger has a method which tells it to resync to hardware vsync
as long as it hasn't resynced too recently. This is used when we
receive a request for a Choreographer wakeup since if it has been a
while since we animated, we have likely drifted.

To determine whether we should actually resync or whether we should
instead rate-limit the call, we compare the current time to the last
time we drew, but this is problematic. When we first start animating
after a period of inactivity, this triggers a resync every time the
method is called until we receive the first frame and draw it, even if
we are already mid-resync, which delays the time until we can lock onto
the hardware vsync phase and has the side-effect of causing weird wakeup
times in both Choreographer and SurfaceFlinger.

This change instead keeps a local timestamp which is updated every time
the method is called and therefore effectively rate limits even before
the first frame is received.

Bug: 38117777
Test: ApiDemos/ListView + manual inspection of systraces
Change-Id: I7210594f9ed6ed5397bb0f3f14a8966503454643
services/surfaceflinger/SurfaceFlinger.cpp