flutter_flutter/scheduler/time_interval.cc
Adam Barth 70604d6c23 Add a simple scheduler for animation frames
This CL adds a simple scheduler for animation frames that holds a given interval
in a given phase.  The scheduler can be told the estimated duration of the
BeginFrame callback and can adjust the callback to hit a given vsync interval.

This CL also makes ganesh_app use this scheduler to animate.

R=jamesr@chromium.org, ernstm@chromium.org

Review URL: https://codereview.chromium.org/731893002
2014-11-17 11:24:07 -08:00

18 lines
514 B
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "sky/scheduler/time_interval.h"
#include <cstdlib>
namespace sky {
base::TimeTicks TimeInterval::NextAfter(base::TimeTicks when) {
int64 offset = std::abs((when - base).ToInternalValue());
base::TimeDelta excess =
base::TimeDelta::FromInternalValue(offset % duration.ToInternalValue());
return when + duration - excess;
}
}