SurfaceFlinger: refresh rate heuristic for TextureView

When an app uses a TextureView (or any other hwui based view)
hwui will attach presentation timestamps to each buffer for
for implementing its render ahead logic. SurfaceFlinger looks at
those timestamps and based on the frame rate it may decide to switch
to a refresh rate that better matches the content. When the refresh rate
changes, hwui may stop doing render ahead and therefore stop attaching
presentation timestamps. The way SurfaceFlinger handles that is by
calculating the content refresh rate by looking at the time the buffer
was queued. SurfaceFlinger will look at the queue time only if this
layer was providing presentation timestamps in the past.

Bug: 155710271
Test: Facebook feed playing video
Test: YouTube video with 24, 25, 30, 60 fps content
Change-Id: I3e981d192ec569087aa16d4c952ef9565d6fb234
2 files changed