Merge "Split out whether frame callback and tick is scheduled" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
756efea145
@@ -87,8 +87,18 @@ public class WindowAnimator {
|
|||||||
private final SurfaceFlingerVsyncChoreographer mSfChoreographer;
|
private final SurfaceFlingerVsyncChoreographer mSfChoreographer;
|
||||||
|
|
||||||
private Choreographer mChoreographer;
|
private Choreographer mChoreographer;
|
||||||
private boolean mAnimationScheduled;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether we have an animation frame callback scheduled, which will happen at
|
||||||
|
* vsync-app and then schedule the animation tick at the right time (vsync-sf).
|
||||||
|
*/
|
||||||
|
private boolean mAnimationFrameCallbackScheduled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether we have an animation tick scheduled. The tick is the thing that actually
|
||||||
|
* executes the animation step, which will happen at vsync-sf.
|
||||||
|
*/
|
||||||
|
private boolean mAnimationTickScheduled;
|
||||||
|
|
||||||
WindowAnimator(final WindowManagerService service) {
|
WindowAnimator(final WindowManagerService service) {
|
||||||
mService = service;
|
mService = service;
|
||||||
@@ -104,13 +114,20 @@ public class WindowAnimator {
|
|||||||
mService.getDefaultDisplayContentLocked().getDisplay(), mChoreographer);
|
mService.getDefaultDisplayContentLocked().getDisplay(), mChoreographer);
|
||||||
mAnimationTick = () -> {
|
mAnimationTick = () -> {
|
||||||
synchronized (mService.mWindowMap) {
|
synchronized (mService.mWindowMap) {
|
||||||
mAnimationScheduled = false;
|
mAnimationTickScheduled = false;
|
||||||
animateLocked(mCurrentFrameTime);
|
animateLocked(mCurrentFrameTime);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mAnimationFrameCallback = frameTimeNs -> {
|
mAnimationFrameCallback = frameTimeNs -> {
|
||||||
mCurrentFrameTime = frameTimeNs;
|
synchronized (mService.mWindowMap) {
|
||||||
mSfChoreographer.scheduleAtSfVsync(mAnimationTick);
|
mCurrentFrameTime = frameTimeNs;
|
||||||
|
mAnimationFrameCallbackScheduled = false;
|
||||||
|
if (mAnimationTickScheduled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mAnimationTickScheduled = true;
|
||||||
|
mSfChoreographer.scheduleAtSfVsync(mAnimationTick);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,8 +388,8 @@ public class WindowAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void scheduleAnimation() {
|
void scheduleAnimation() {
|
||||||
if (!mAnimationScheduled) {
|
if (!mAnimationFrameCallbackScheduled) {
|
||||||
mAnimationScheduled = true;
|
mAnimationFrameCallbackScheduled = true;
|
||||||
mChoreographer.postFrameCallback(mAnimationFrameCallback);
|
mChoreographer.postFrameCallback(mAnimationFrameCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,7 +403,7 @@ public class WindowAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean isAnimationScheduled() {
|
boolean isAnimationScheduled() {
|
||||||
return mAnimationScheduled;
|
return mAnimationFrameCallbackScheduled || mAnimationTickScheduled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Choreographer getChoreographer() {
|
Choreographer getChoreographer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user