Merge "Boost the anim thread priority when doing a bounds animation." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
167f0001b8
@@ -206,6 +206,10 @@ public class BoundsAnimationController {
|
|||||||
mTmpRect.set(mFrom.left, mFrom.top, mFrom.left + mFrozenTaskWidth,
|
mTmpRect.set(mFrom.left, mFrom.top, mFrom.left + mFrozenTaskWidth,
|
||||||
mFrom.top + mFrozenTaskHeight);
|
mFrom.top + mFrozenTaskHeight);
|
||||||
|
|
||||||
|
// Boost the thread priority of the animation thread while the bounds animation is
|
||||||
|
// running
|
||||||
|
updateBooster();
|
||||||
|
|
||||||
// Ensure that we have prepared the target for animation before
|
// Ensure that we have prepared the target for animation before
|
||||||
// we trigger any size changes, so it can swap surfaces
|
// we trigger any size changes, so it can swap surfaces
|
||||||
// in to appropriate modes, or do as it wishes otherwise.
|
// in to appropriate modes, or do as it wishes otherwise.
|
||||||
@@ -316,6 +320,9 @@ public class BoundsAnimationController {
|
|||||||
removeListener(this);
|
removeListener(this);
|
||||||
removeUpdateListener(this);
|
removeUpdateListener(this);
|
||||||
mRunningAnimations.remove(mTarget);
|
mRunningAnimations.remove(mTarget);
|
||||||
|
|
||||||
|
// Reset the thread priority of the animation thread after the bounds animation is done
|
||||||
|
updateBooster();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -446,4 +453,9 @@ public class BoundsAnimationController {
|
|||||||
b.resume();
|
b.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBooster() {
|
||||||
|
WindowManagerService.sThreadPriorityBooster.setBoundsAnimationRunning(
|
||||||
|
!mRunningAnimations.isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import static android.os.Process.setThreadPriority;
|
|||||||
import static com.android.server.LockGuard.INDEX_WINDOW;
|
import static com.android.server.LockGuard.INDEX_WINDOW;
|
||||||
import static com.android.server.am.ActivityManagerService.TOP_APP_PRIORITY_BOOST;
|
import static com.android.server.am.ActivityManagerService.TOP_APP_PRIORITY_BOOST;
|
||||||
|
|
||||||
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.server.AnimationThread;
|
import com.android.server.AnimationThread;
|
||||||
import com.android.server.ThreadPriorityBooster;
|
import com.android.server.ThreadPriorityBooster;
|
||||||
|
|
||||||
@@ -32,12 +33,18 @@ import com.android.server.ThreadPriorityBooster;
|
|||||||
*/
|
*/
|
||||||
class WindowManagerThreadPriorityBooster extends ThreadPriorityBooster {
|
class WindowManagerThreadPriorityBooster extends ThreadPriorityBooster {
|
||||||
|
|
||||||
private final AnimationThread mAnimationThread;
|
private final Object mLock = new Object();
|
||||||
|
|
||||||
|
private final int mAnimationThreadId;
|
||||||
|
|
||||||
|
@GuardedBy("mLock")
|
||||||
private boolean mAppTransitionRunning;
|
private boolean mAppTransitionRunning;
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private boolean mBoundsAnimationRunning;
|
||||||
|
|
||||||
WindowManagerThreadPriorityBooster() {
|
WindowManagerThreadPriorityBooster() {
|
||||||
super(THREAD_PRIORITY_DISPLAY, INDEX_WINDOW);
|
super(THREAD_PRIORITY_DISPLAY, INDEX_WINDOW);
|
||||||
mAnimationThread = AnimationThread.get();
|
mAnimationThreadId = AnimationThread.get().getThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,7 +52,7 @@ class WindowManagerThreadPriorityBooster extends ThreadPriorityBooster {
|
|||||||
|
|
||||||
// Do not boost the animation thread. As the animation thread is changing priorities,
|
// Do not boost the animation thread. As the animation thread is changing priorities,
|
||||||
// boosting it might mess up the priority because we reset it the the previous priority.
|
// boosting it might mess up the priority because we reset it the the previous priority.
|
||||||
if (myTid() == mAnimationThread.getThreadId()) {
|
if (myTid() == mAnimationThreadId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.boost();
|
super.boost();
|
||||||
@@ -55,24 +62,35 @@ class WindowManagerThreadPriorityBooster extends ThreadPriorityBooster {
|
|||||||
public void reset() {
|
public void reset() {
|
||||||
|
|
||||||
// See comment in boost().
|
// See comment in boost().
|
||||||
if (myTid() == mAnimationThread.getThreadId()) {
|
if (myTid() == mAnimationThreadId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.reset();
|
super.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAppTransitionRunning(boolean running) {
|
void setAppTransitionRunning(boolean running) {
|
||||||
if (mAppTransitionRunning == running) {
|
synchronized (mLock) {
|
||||||
return;
|
if (mAppTransitionRunning != running) {
|
||||||
|
mAppTransitionRunning = running;
|
||||||
|
updatePriorityLocked();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int priority = calculatePriority(running);
|
|
||||||
setBoostToPriority(priority);
|
|
||||||
setThreadPriority(mAnimationThread.getThreadId(), priority);
|
|
||||||
mAppTransitionRunning = running;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculatePriority(boolean appTransitionRunning) {
|
void setBoundsAnimationRunning(boolean running) {
|
||||||
return appTransitionRunning ? TOP_APP_PRIORITY_BOOST : THREAD_PRIORITY_DISPLAY;
|
synchronized (mLock) {
|
||||||
|
if (mBoundsAnimationRunning != running) {
|
||||||
|
mBoundsAnimationRunning = running;
|
||||||
|
updatePriorityLocked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private void updatePriorityLocked() {
|
||||||
|
int priority = (mAppTransitionRunning || mBoundsAnimationRunning)
|
||||||
|
? TOP_APP_PRIORITY_BOOST : THREAD_PRIORITY_DISPLAY;
|
||||||
|
setBoostToPriority(priority);
|
||||||
|
setThreadPriority(mAnimationThreadId, priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user