Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 544b5f5b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "vsyncId should always be incremental" into sc-dev

parents eb87d4ea 505e730e
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -15,22 +15,28 @@
 */
#include "TimeLord.h"
#include <limits>
#include "FrameInfo.h"

namespace android {
namespace uirenderer {
namespace renderthread {

TimeLord::TimeLord() : mFrameIntervalNanos(milliseconds_to_nanoseconds(16)),
                       mFrameTimeNanos(0),
                       mFrameIntendedTimeNanos(0),
                       mFrameVsyncId(-1),
                       mFrameDeadline(std::numeric_limits<int64_t>::max()){}
TimeLord::TimeLord()
        : mFrameIntervalNanos(milliseconds_to_nanoseconds(16))
        , mFrameTimeNanos(0)
        , mFrameIntendedTimeNanos(0)
        , mFrameVsyncId(UiFrameInfoBuilder::INVALID_VSYNC_ID)
        , mFrameDeadline(std::numeric_limits<int64_t>::max()) {}

bool TimeLord::vsyncReceived(nsecs_t vsync, nsecs_t intendedVsync, int64_t vsyncId,
                             int64_t frameDeadline, nsecs_t frameInterval) {
    if (intendedVsync > mFrameIntendedTimeNanos) {
        mFrameIntendedTimeNanos = intendedVsync;
        mFrameVsyncId = vsyncId;

        // The intendedVsync might have been advanced to account for scheduling
        // jitter. Since we don't have a way to advance the vsync id we just
        // reset it.
        mFrameVsyncId = (vsyncId > mFrameVsyncId) ? vsyncId : UiFrameInfoBuilder::INVALID_VSYNC_ID;
        mFrameDeadline = frameDeadline;
        if (frameInterval > 0) {
            mFrameIntervalNanos = frameInterval;