Use System.nanoTime() to calculate frame delay compensation

Use System.nanoTime() instead of SystemClock.elapsedRealtime()
This commit is contained in:
seven332 committed 2016-05-07 14:17:10 +08:00
1 parent 1bc07a89b8
commit 1feca40a5c
1 file changed
+3 -3
@@ -249,7 +249,7 @@ public class ImageTexture implements Texture, Animatable {
private class AnimateRunnable implements Runnable {
public void doRun() {
long lastTime = SystemClock.elapsedRealtime();
long lastTime = System.nanoTime();
long lastDelay = -1L;
synchronized (mImage) {
@@ -319,9 +319,9 @@ public class ImageTexture implements Texture, Animatable {
mImage.advance();
long delay = mImage.getDelay();
long time = SystemClock.elapsedRealtime();
long time = System.nanoTime();
if (-1L != lastDelay) {
delay -= (time - lastTime) - lastDelay;
delay -= (time - lastTime) / 1000000 - lastDelay;
}
lastTime = time;
lastDelay = delay;