summaryrefslogtreecommitdiff
path: root/android/view/Choreographer.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/view/Choreographer.java')
-rw-r--r--android/view/Choreographer.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/android/view/Choreographer.java b/android/view/Choreographer.java
index 2ffa1c5e..ba6b6cf6 100644
--- a/android/view/Choreographer.java
+++ b/android/view/Choreographer.java
@@ -164,6 +164,7 @@ public final class Choreographer {
private long mLastFrameTimeNanos;
private long mFrameIntervalNanos;
private boolean mDebugPrintNextFrameTimeDelta;
+ private int mFPSDivisor = 1;
/**
* Contains information about the current frame for jank-tracking,
@@ -601,6 +602,11 @@ public final class Choreographer {
}
}
+ void setFPSDivisor(int divisor) {
+ if (divisor <= 0) divisor = 1;
+ mFPSDivisor = divisor;
+ }
+
void doFrame(long frameTimeNanos, int frame) {
final long startNanos;
synchronized (mLock) {
@@ -643,6 +649,14 @@ public final class Choreographer {
return;
}
+ if (mFPSDivisor > 1) {
+ long timeSinceVsync = frameTimeNanos - mLastFrameTimeNanos;
+ if (timeSinceVsync < (mFrameIntervalNanos * mFPSDivisor) && timeSinceVsync > 0) {
+ scheduleVsyncLocked();
+ return;
+ }
+ }
+
mFrameInfo.setVsync(intendedFrameTimeNanos, frameTimeNanos);
mFrameScheduled = false;
mLastFrameTimeNanos = frameTimeNanos;