diff options
| author | 2022-11-24 00:22:03 +0000 | |
|---|---|---|
| committer | 2022-11-24 00:22:03 +0000 | |
| commit | 4e1d9153a8ea135ade90ead4015ee4e3ca6efc73 (patch) | |
| tree | 6c4db61b1ea6ae4797113afb99849f9f0581ac7c | |
| parent | 347f7b09cdbeb632e3cbdf10c8e2760b23f73556 (diff) | |
| parent | 36a47145c6b29c55cb45a7e20a026ffc9d7c5db7 (diff) | |
Merge "Don't swallow exceptions"
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 184 |
1 files changed, 90 insertions, 94 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 720813ad81ef..ef18458d3244 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -947,112 +947,108 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall + " left=" + (mWindowSpaceLeft != mLocation[0]) + " top=" + (mWindowSpaceTop != mLocation[1])); - try { - mVisible = mRequestedVisible; - mWindowSpaceLeft = mLocation[0]; - mWindowSpaceTop = mLocation[1]; - mSurfaceWidth = myWidth; - mSurfaceHeight = myHeight; - mFormat = mRequestedFormat; - mAlpha = alpha; - mLastWindowVisibility = mWindowVisibility; - mTransformHint = viewRoot.getBufferTransformHint(); - mSubLayer = mRequestedSubLayer; - - mScreenRect.left = mWindowSpaceLeft; - mScreenRect.top = mWindowSpaceTop; - mScreenRect.right = mWindowSpaceLeft + getWidth(); - mScreenRect.bottom = mWindowSpaceTop + getHeight(); - if (translator != null) { - translator.translateRectInAppWindowToScreen(mScreenRect); - } - - final Rect surfaceInsets = viewRoot.mWindowAttributes.surfaceInsets; - mScreenRect.offset(surfaceInsets.left, surfaceInsets.top); - // Collect all geometry changes and apply these changes on the RenderThread worker - // via the RenderNode.PositionUpdateListener. - final Transaction surfaceUpdateTransaction = new Transaction(); - if (creating) { - updateOpaqueFlag(); - final String name = "SurfaceView[" + viewRoot.getTitle().toString() + "]"; - createBlastSurfaceControls(viewRoot, name, surfaceUpdateTransaction); - } else if (mSurfaceControl == null) { - return; - } + mVisible = mRequestedVisible; + mWindowSpaceLeft = mLocation[0]; + mWindowSpaceTop = mLocation[1]; + mSurfaceWidth = myWidth; + mSurfaceHeight = myHeight; + mFormat = mRequestedFormat; + mAlpha = alpha; + mLastWindowVisibility = mWindowVisibility; + mTransformHint = viewRoot.getBufferTransformHint(); + mSubLayer = mRequestedSubLayer; + + mScreenRect.left = mWindowSpaceLeft; + mScreenRect.top = mWindowSpaceTop; + mScreenRect.right = mWindowSpaceLeft + getWidth(); + mScreenRect.bottom = mWindowSpaceTop + getHeight(); + if (translator != null) { + translator.translateRectInAppWindowToScreen(mScreenRect); + } - final boolean redrawNeeded = sizeChanged || creating || hintChanged - || (mVisible && !mDrawFinished) || alphaChanged || relativeZChanged; - boolean shouldSyncBuffer = - redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInLocalSync(); - SyncBufferTransactionCallback syncBufferTransactionCallback = null; - if (shouldSyncBuffer) { - syncBufferTransactionCallback = new SyncBufferTransactionCallback(); - mBlastBufferQueue.syncNextTransaction( - false /* acquireSingleBuffer */, - syncBufferTransactionCallback::onTransactionReady); - } + final Rect surfaceInsets = viewRoot.mWindowAttributes.surfaceInsets; + mScreenRect.offset(surfaceInsets.left, surfaceInsets.top); + // Collect all geometry changes and apply these changes on the RenderThread worker + // via the RenderNode.PositionUpdateListener. + final Transaction surfaceUpdateTransaction = new Transaction(); + if (creating) { + updateOpaqueFlag(); + final String name = "SurfaceView[" + viewRoot.getTitle().toString() + "]"; + createBlastSurfaceControls(viewRoot, name, surfaceUpdateTransaction); + } else if (mSurfaceControl == null) { + return; + } - final boolean realSizeChanged = performSurfaceTransaction(viewRoot, translator, - creating, sizeChanged, hintChanged, relativeZChanged, - surfaceUpdateTransaction); + final boolean redrawNeeded = sizeChanged || creating || hintChanged + || (mVisible && !mDrawFinished) || alphaChanged || relativeZChanged; + boolean shouldSyncBuffer = + redrawNeeded && viewRoot.wasRelayoutRequested() && viewRoot.isInLocalSync(); + SyncBufferTransactionCallback syncBufferTransactionCallback = null; + if (shouldSyncBuffer) { + syncBufferTransactionCallback = new SyncBufferTransactionCallback(); + mBlastBufferQueue.syncNextTransaction( + false /* acquireSingleBuffer */, + syncBufferTransactionCallback::onTransactionReady); + } - try { - SurfaceHolder.Callback[] callbacks = null; + final boolean realSizeChanged = performSurfaceTransaction(viewRoot, translator, + creating, sizeChanged, hintChanged, relativeZChanged, + surfaceUpdateTransaction); - final boolean surfaceChanged = creating; - if (mSurfaceCreated && (surfaceChanged || (!mVisible && visibleChanged))) { - mSurfaceCreated = false; - notifySurfaceDestroyed(); - } + try { + SurfaceHolder.Callback[] callbacks = null; - copySurface(creating /* surfaceControlCreated */, sizeChanged); + final boolean surfaceChanged = creating; + if (mSurfaceCreated && (surfaceChanged || (!mVisible && visibleChanged))) { + mSurfaceCreated = false; + notifySurfaceDestroyed(); + } - if (mVisible && mSurface.isValid()) { - if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) { - mSurfaceCreated = true; - mIsCreating = true; - if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " - + "visibleChanged -- surfaceCreated"); - callbacks = getSurfaceCallbacks(); - for (SurfaceHolder.Callback c : callbacks) { - c.surfaceCreated(mSurfaceHolder); - } + copySurface(creating /* surfaceControlCreated */, sizeChanged); + + if (mVisible && mSurface.isValid()) { + if (!mSurfaceCreated && (surfaceChanged || visibleChanged)) { + mSurfaceCreated = true; + mIsCreating = true; + if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + + "visibleChanged -- surfaceCreated"); + callbacks = getSurfaceCallbacks(); + for (SurfaceHolder.Callback c : callbacks) { + c.surfaceCreated(mSurfaceHolder); } - if (creating || formatChanged || sizeChanged || hintChanged - || visibleChanged || realSizeChanged) { - if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " - + "surfaceChanged -- format=" + mFormat - + " w=" + myWidth + " h=" + myHeight); - if (callbacks == null) { - callbacks = getSurfaceCallbacks(); - } - for (SurfaceHolder.Callback c : callbacks) { - c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); - } + } + if (creating || formatChanged || sizeChanged || hintChanged + || visibleChanged || realSizeChanged) { + if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + + "surfaceChanged -- format=" + mFormat + + " w=" + myWidth + " h=" + myHeight); + if (callbacks == null) { + callbacks = getSurfaceCallbacks(); } - if (redrawNeeded) { - if (DEBUG) { - Log.i(TAG, System.identityHashCode(this) + " surfaceRedrawNeeded"); - } - if (callbacks == null) { - callbacks = getSurfaceCallbacks(); - } - - if (shouldSyncBuffer) { - handleSyncBufferCallback(callbacks, syncBufferTransactionCallback); - } else { - handleSyncNoBuffer(callbacks); - } + for (SurfaceHolder.Callback c : callbacks) { + c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } - } finally { - mIsCreating = false; - if (mSurfaceControl != null && !mSurfaceCreated) { - releaseSurfaces(false /* releaseSurfacePackage*/); + if (redrawNeeded) { + if (DEBUG) { + Log.i(TAG, System.identityHashCode(this) + " surfaceRedrawNeeded"); + } + if (callbacks == null) { + callbacks = getSurfaceCallbacks(); + } + + if (shouldSyncBuffer) { + handleSyncBufferCallback(callbacks, syncBufferTransactionCallback); + } else { + handleSyncNoBuffer(callbacks); + } } } - } catch (Exception ex) { - Log.e(TAG, "Exception configuring surface", ex); + } finally { + mIsCreating = false; + if (mSurfaceControl != null && !mSurfaceCreated) { + releaseSurfaces(false /* releaseSurfacePackage*/); + } } if (DEBUG) Log.v( TAG, "Layout: x=" + mScreenRect.left + " y=" + mScreenRect.top |