Merge changes I5762a98d,I39f4e015 into oc-dev
* changes: ViewRootImpl: More careful draw accounting. SurfaceView: Avoid over-reporting DRAW_FINISHED.
This commit is contained in:
committed by
Android (Google) Code Review
commit
c56b1d3c98
@@ -264,6 +264,22 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
|
|||||||
updateSurface();
|
updateSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void performDrawFinished() {
|
||||||
|
if (mPendingReportDraws > 0) {
|
||||||
|
mDrawFinished = true;
|
||||||
|
if (mAttachedToWindow) {
|
||||||
|
mParent.requestTransparentRegion(SurfaceView.this);
|
||||||
|
|
||||||
|
notifyDrawFinished();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, System.identityHashCode(this) + "finished drawing"
|
||||||
|
+ " but no pending report draw (extra call"
|
||||||
|
+ " to draw completion runnable?)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void notifyDrawFinished() {
|
void notifyDrawFinished() {
|
||||||
ViewRootImpl viewRoot = getViewRootImpl();
|
ViewRootImpl viewRoot = getViewRootImpl();
|
||||||
if (viewRoot != null) {
|
if (viewRoot != null) {
|
||||||
@@ -729,12 +745,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
mDrawFinished = true;
|
performDrawFinished();
|
||||||
if (mAttachedToWindow) {
|
|
||||||
mParent.requestTransparentRegion(SurfaceView.this);
|
|
||||||
notifyDrawFinished();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2330,7 +2330,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|
|
||||||
// Remember if we must report the next draw.
|
// Remember if we must report the next draw.
|
||||||
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
|
if ((relayoutResult & WindowManagerGlobal.RELAYOUT_RES_FIRST_TIME) != 0) {
|
||||||
mReportNextDraw = true;
|
reportNextDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean cancelDraw = mAttachInfo.mTreeObserver.dispatchOnPreDraw() || !isViewVisible;
|
boolean cancelDraw = mAttachInfo.mTreeObserver.dispatchOnPreDraw() || !isViewVisible;
|
||||||
@@ -2731,11 +2731,8 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
/**
|
/**
|
||||||
* A count of the number of calls to pendingDrawFinished we
|
* A count of the number of calls to pendingDrawFinished we
|
||||||
* require to notify the WM drawing is complete.
|
* require to notify the WM drawing is complete.
|
||||||
*
|
|
||||||
* This starts at 1, for the ViewRootImpl surface itself.
|
|
||||||
* Subsurfaces may debt the value with drawPending.
|
|
||||||
*/
|
*/
|
||||||
int mDrawsNeededToReport = 1;
|
int mDrawsNeededToReport = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delay notifying WM of draw finished until
|
* Delay notifying WM of draw finished until
|
||||||
@@ -2761,7 +2758,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|
|
||||||
private void reportDrawFinished() {
|
private void reportDrawFinished() {
|
||||||
try {
|
try {
|
||||||
mDrawsNeededToReport = 1;
|
mDrawsNeededToReport = 0;
|
||||||
mWindowSession.finishDrawing(mWindow);
|
mWindowSession.finishDrawing(mWindow);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Have fun!
|
// Have fun!
|
||||||
@@ -3772,13 +3769,12 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
args.recycle();
|
args.recycle();
|
||||||
|
|
||||||
if (msg.what == MSG_RESIZED_REPORT) {
|
if (msg.what == MSG_RESIZED_REPORT) {
|
||||||
mReportNextDraw = true;
|
reportNextDraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mView != null && framesChanged) {
|
if (mView != null && framesChanged) {
|
||||||
forceLayout(mView);
|
forceLayout(mView);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -7343,6 +7339,14 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void reportNextDraw() {
|
||||||
|
if (mReportNextDraw == false) {
|
||||||
|
drawPending();
|
||||||
|
}
|
||||||
|
mReportNextDraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Force the window to report its next draw.
|
* Force the window to report its next draw.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -7352,7 +7356,7 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void setReportNextDraw() {
|
public void setReportNextDraw() {
|
||||||
mReportNextDraw = true;
|
reportNextDraw();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user