Merge "Immediately report drawing" into oc-dev

am: ba21a120c1

Change-Id: Ib38c4093090a2b12d6fb29af20e59aaf1cfe9ae1
This commit is contained in:
Jorim Jaggi
2017-05-16 15:09:33 +00:00
committed by android-build-merger
5 changed files with 39 additions and 31 deletions

View File

@@ -411,7 +411,9 @@ public class AppWindowAnimator {
} }
if (DEBUG_ANIM) Slog.v(TAG, "Animation done in " + mAppToken if (DEBUG_ANIM) Slog.v(TAG, "Animation done in " + mAppToken
+ ": reportedVisible=" + mAppToken.reportedVisible); + ": reportedVisible=" + mAppToken.reportedVisible
+ " okToDisplay=" + mService.okToDisplay()
+ " startingDisplayed=" + mAppToken.startingDisplayed);
transformation.clear(); transformation.clear();

View File

@@ -520,9 +520,16 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
} }
w.mLayoutNeeded = false; w.mLayoutNeeded = false;
w.prelayout(); w.prelayout();
final boolean firstLayout = !w.isLaidOut();
mService.mPolicy.layoutWindowLw(w, null); mService.mPolicy.layoutWindowLw(w, null);
w.mLayoutSeq = mService.mLayoutSeq; w.mLayoutSeq = mService.mLayoutSeq;
// If this is the first layout, we need to initialize the last inset values as
// otherwise we'd immediately cause an unnecessary resize.
if (firstLayout) {
w.updateLastInsetValues();
}
// Window frames may have changed. Update dim layer with the new bounds. // Window frames may have changed. Update dim layer with the new bounds.
final Task task = w.getTask(); final Task task = w.getTask();
if (task != null) { if (task != null) {

View File

@@ -116,7 +116,6 @@ class TaskSnapshotSurface implements StartingSurface {
private final TaskSnapshot mSnapshot; private final TaskSnapshot mSnapshot;
private final CharSequence mTitle; private final CharSequence mTitle;
private boolean mHasDrawn; private boolean mHasDrawn;
private boolean mReportNextDraw;
private long mShownTime; private long mShownTime;
private final Handler mHandler; private final Handler mHandler;
private boolean mSizeMismatch; private boolean mSizeMismatch;
@@ -263,15 +262,11 @@ class TaskSnapshotSurface implements StartingSurface {
} else { } else {
drawSizeMatchSnapshot(buffer); drawSizeMatchSnapshot(buffer);
} }
final boolean reportNextDraw;
synchronized (mService.mWindowMap) { synchronized (mService.mWindowMap) {
mShownTime = SystemClock.uptimeMillis(); mShownTime = SystemClock.uptimeMillis();
mHasDrawn = true; mHasDrawn = true;
reportNextDraw = mReportNextDraw;
}
if (reportNextDraw) {
reportDrawn();
} }
reportDrawn();
} }
private void drawSizeMatchSnapshot(GraphicBuffer buffer) { private void drawSizeMatchSnapshot(GraphicBuffer buffer) {
@@ -356,9 +351,6 @@ class TaskSnapshotSurface implements StartingSurface {
} }
private void reportDrawn() { private void reportDrawn() {
synchronized (mService.mWindowMap) {
mReportNextDraw = false;
}
try { try {
mSession.finishDrawing(mWindow); mSession.finishDrawing(mWindow);
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -376,9 +368,6 @@ class TaskSnapshotSurface implements StartingSurface {
final TaskSnapshotSurface surface = (TaskSnapshotSurface) msg.obj; final TaskSnapshotSurface surface = (TaskSnapshotSurface) msg.obj;
synchronized (surface.mService.mWindowMap) { synchronized (surface.mService.mWindowMap) {
hasDrawn = surface.mHasDrawn; hasDrawn = surface.mHasDrawn;
if (!hasDrawn) {
surface.mReportNextDraw = true;
}
} }
if (hasDrawn) { if (hasDrawn) {
surface.reportDrawn(); surface.reportDrawn();

View File

@@ -52,6 +52,7 @@ public class WindowAnimator {
/** Is any window animating? */ /** Is any window animating? */
private boolean mAnimating; private boolean mAnimating;
private boolean mLastAnimating;
/** Is any app window animating? */ /** Is any app window animating? */
boolean mAppWindowAnimating; boolean mAppWindowAnimating;
@@ -158,7 +159,6 @@ public class WindowAnimator {
*/ */
private void animate(long frameTimeNs) { private void animate(long frameTimeNs) {
boolean transactionOpen = false; boolean transactionOpen = false;
boolean wasAnimating = false;
try { try {
synchronized (mService.mWindowMap) { synchronized (mService.mWindowMap) {
if (!mInitialized) { if (!mInitialized) {
@@ -167,8 +167,7 @@ public class WindowAnimator {
mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS; mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE; mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
wasAnimating = mAnimating; mAnimating = false;
setAnimating(false);
mAppWindowAnimating = false; mAppWindowAnimating = false;
if (DEBUG_WINDOW_TRACE) { if (DEBUG_WINDOW_TRACE) {
Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime); Slog.i(TAG, "!!! animate: entry time=" + mCurrentTime);
@@ -269,25 +268,22 @@ public class WindowAnimator {
mWindowPlacerLocked.requestTraversal(); mWindowPlacerLocked.requestTraversal();
} }
if (mAnimating && !wasAnimating) { if (mAnimating && !mLastAnimating) {
// Usually app transitions but quite a load onto the system already (with all the // Usually app transitions but quite a load onto the system already (with all the
// things happening in app), so pause task snapshot persisting to not increase the // things happening in app), so pause task snapshot persisting to not increase the
// load. // load.
mService.mTaskSnapshotController.setPersisterPaused(true); mService.mTaskSnapshotController.setPersisterPaused(true);
if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
}
} }
if (!mAnimating && mLastAnimating) {
if (!mAnimating && wasAnimating) {
mWindowPlacerLocked.requestTraversal(); mWindowPlacerLocked.requestTraversal();
mService.mTaskSnapshotController.setPersisterPaused(false); mService.mTaskSnapshotController.setPersisterPaused(false);
if (Trace.isTagEnabled(Trace.TRACE_TAG_WINDOW_MANAGER)) { Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
Trace.asyncTraceEnd(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
}
} }
mLastAnimating = mAnimating;
if (mRemoveReplacedWindows) { if (mRemoveReplacedWindows) {
mService.mRoot.removeReplacedWindows(); mService.mRoot.removeReplacedWindows();
mRemoveReplacedWindows = false; mRemoveReplacedWindows = false;

View File

@@ -208,7 +208,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
boolean mHidden; // Used to determine if to show child windows. boolean mHidden; // Used to determine if to show child windows.
boolean mWallpaperVisible; // for wallpaper, what was last vis report? boolean mWallpaperVisible; // for wallpaper, what was last vis report?
private boolean mDragResizing; private boolean mDragResizing;
private boolean mDragResizingChangeReported; private boolean mDragResizingChangeReported = true;
private int mResizeMode; private int mResizeMode;
private RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks; private RemoteCallbackList<IWindowFocusObserver> mFocusCallbacks;
@@ -1155,11 +1155,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return; return;
} }
mLastOverscanInsets.set(mOverscanInsets); updateLastInsetValues();
mLastContentInsets.set(mContentInsets);
mLastVisibleInsets.set(mVisibleInsets);
mLastStableInsets.set(mStableInsets);
mLastOutsets.set(mOutsets);
mService.makeWindowFreezingScreenIfNeededLocked(this); mService.makeWindowFreezingScreenIfNeededLocked(this);
// If the orientation is changing, or we're starting or ending a drag resizing action, // If the orientation is changing, or we're starting or ending a drag resizing action,
@@ -4404,6 +4400,24 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return result; return result;
} }
/**
* @return True if this window has been laid out at least once; false otherwise.
*/
boolean isLaidOut() {
return mLayoutSeq != -1;
}
/**
* Updates the last inset values to the current ones.
*/
void updateLastInsetValues() {
mLastOverscanInsets.set(mOverscanInsets);
mLastContentInsets.set(mContentInsets);
mLastVisibleInsets.set(mVisibleInsets);
mLastStableInsets.set(mStableInsets);
mLastOutsets.set(mOutsets);
}
// TODO: Hack to work around the number of states AppWindowToken needs to access without having // TODO: Hack to work around the number of states AppWindowToken needs to access without having
// access to its windows children. Need to investigate re-writing // access to its windows children. Need to investigate re-writing
// {@link AppWindowToken#updateReportedVisibilityLocked} so this can be removed. // {@link AppWindowToken#updateReportedVisibilityLocked} so this can be removed.