summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/SurfaceView.java111
-rw-r--r--core/java/android/view/ViewRootImpl.java10
2 files changed, 47 insertions, 74 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index b5185ae4f5c9..26e3bb27a788 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -457,18 +457,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
Log.d(TAG, System.identityHashCode(this)
+ " updateSurfaceAlpha RT: set alpha=" + alpha);
}
- if (useBLAST) {
- synchronized (viewRoot.getBlastTransactionLock()) {
- viewRoot.getBLASTSyncTransaction()
- .setAlpha(mSurfaceControl, alpha);
- }
- } else {
- Transaction t = new SurfaceControl.Transaction();
- t.setAlpha(mSurfaceControl, alpha);
- t.deferTransactionUntil(mSurfaceControl,
- viewRoot.getSurfaceControl(), frame);
- t.apply();
- }
+ mRtTransaction.setAlpha(mSurfaceControl, alpha);
+ applyRtTransaction(frame);
}
// It's possible that mSurfaceControl is released in the UI thread before
// the transaction completes. If that happens, an exception is thrown, which
@@ -818,17 +808,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
return;
}
- if (useBLAST) {
- synchronized (viewRoot.getBlastTransactionLock()) {
- updateRelativeZ(viewRoot.getBLASTSyncTransaction());
- }
- } else {
- final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
- updateRelativeZ(t);
- t.deferTransactionUntil(mSurfaceControl,
- viewRoot.getSurfaceControl(), frame);
- t.apply();
- }
+ updateRelativeZ(mRtTransaction);
+ applyRtTransaction(frame);
}
// It's possible that mSurfaceControl is released in the UI thread before
// the transaction completes. If that happens, an exception is thrown, which
@@ -927,7 +908,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
}
private boolean performSurfaceTransaction(ViewRootImpl viewRoot, Translator translator,
- boolean creating, boolean sizeChanged, boolean needBLASTSync) {
+ boolean creating, boolean sizeChanged) {
boolean realSizeChanged = false;
mSurfaceLock.lock();
@@ -990,8 +971,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
mTmpTransaction.setWindowCrop(mSurfaceControl, mSurfaceWidth,
mSurfaceHeight);
}
- } else if (needBLASTSync) {
- viewRoot.setUseBLASTSyncTransaction();
}
mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius);
if (sizeChanged && !creating) {
@@ -1109,11 +1088,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
return;
}
- final boolean needBLASTSync =
- (layoutSizeChanged || positionChanged || visibleChanged) &&
- useBLASTSync(viewRoot);
final boolean realSizeChanged = performSurfaceTransaction(viewRoot,
- translator, creating, sizeChanged, needBLASTSync);
+ translator, creating, sizeChanged);
final boolean redrawNeeded = sizeChanged || creating ||
(mVisible && !mDrawFinished);
@@ -1351,13 +1327,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
}
private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t,
- Rect position, long frameNumber) {
- final ViewRootImpl viewRoot = getViewRootImpl();
- if (frameNumber > 0 && viewRoot != null && !useBLASTSync(viewRoot)) {
- t.deferTransactionUntil(surface, viewRoot.getSurfaceControl(),
- frameNumber);
- }
-
+ Rect position) {
onSetSurfacePositionAndScaleRT(t, surface,
position.left /*positionLeft*/,
position.top /*positionTop*/,
@@ -1378,24 +1348,29 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
return mRTLastReportedPosition;
}
- private void setParentSpaceRectangle(Transaction t, Rect position, long frameNumber) {
+ private void setParentSpaceRectangle(Rect position, long frameNumber) {
final ViewRootImpl viewRoot = getViewRootImpl();
- applySurfaceTransforms(mSurfaceControl, t, position, frameNumber);
- applyChildSurfaceTransaction_renderWorker(t, viewRoot.mSurface, frameNumber);
+ applySurfaceTransforms(mSurfaceControl, mRtTransaction, position);
+ applyChildSurfaceTransaction_renderWorker(mRtTransaction, viewRoot.mSurface, frameNumber);
+ applyRtTransaction(frameNumber);
}
- private void setParentSpaceRectangle(Rect position, long frameNumber) {
+ private void applyRtTransaction(long frameNumber) {
final ViewRootImpl viewRoot = getViewRootImpl();
- final boolean useBLAST = useBLASTSync(viewRoot);
-
+ boolean useBLAST = viewRoot != null && useBLASTSync(viewRoot);
if (useBLAST) {
- synchronized (viewRoot.getBlastTransactionLock()) {
- setParentSpaceRectangle(viewRoot.getBLASTSyncTransaction(), position, frameNumber);
- }
- } else {
- setParentSpaceRectangle(mRtTransaction, position, frameNumber);
- mRtTransaction.apply();
+ // If we are using BLAST, merge the transaction with the viewroot buffer transaction.
+ viewRoot.mergeWithNextTransaction(mRtTransaction, frameNumber);
+ return;
}
+
+ // Otherwise if the if the ViewRoot is not null, use deferred transaction instead.
+ if (frameNumber > 0 && viewRoot != null && viewRoot.mSurface.isValid()
+ && mSurfaceControl != null) {
+ mRtTransaction.deferTransactionUntil(mSurfaceControl,
+ viewRoot.getSurfaceControl(), frameNumber);
+ }
+ mRtTransaction.apply();
}
private Rect mRTLastReportedPosition = new Rect();
@@ -1444,8 +1419,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
@Override
public void positionLost(long frameNumber) {
- final ViewRootImpl viewRoot = getViewRootImpl();
- boolean useBLAST = viewRoot != null && useBLASTSync(viewRoot);
if (DEBUG) {
Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
System.identityHashCode(this), frameNumber));
@@ -1461,30 +1434,20 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
* need to hold the lock here.
*/
synchronized (mSurfaceControlLock) {
- if (useBLAST) {
- synchronized (viewRoot.getBlastTransactionLock()) {
- viewRoot.getBLASTSyncTransaction().hide(mSurfaceControl);
- if (mRtReleaseSurfaces) {
- mRtReleaseSurfaces = false;
- releaseSurfaces(viewRoot.getBLASTSyncTransaction());
- }
- }
- } else {
- if (frameNumber > 0 && viewRoot != null && viewRoot.mSurface.isValid()) {
- mRtTransaction.deferTransactionUntil(mSurfaceControl,
- viewRoot.getSurfaceControl(), frameNumber);
- }
- mRtTransaction.hide(mSurfaceControl);
- if (mRtReleaseSurfaces) {
- mRtReleaseSurfaces = false;
- releaseSurfaces(mRtTransaction);
- }
- // If we aren't using BLAST, we apply the transaction locally, otherwise we let
- // the ViewRoot apply it for us.
- // If the ViewRoot is null, we behave as if we aren't using BLAST so we need to
- // apply the transaction.
- mRtTransaction.apply();
+ final ViewRootImpl viewRoot = getViewRootImpl();
+ boolean deferTransaction = frameNumber > 0 && viewRoot != null
+ && viewRoot.mSurface.isValid() && !useBLASTSync(viewRoot);
+ if (deferTransaction) {
+ mRtTransaction.deferTransactionUntil(mSurfaceControl,
+ viewRoot.getSurfaceControl(), frameNumber);
+ }
+
+ mRtTransaction.hide(mSurfaceControl);
+ if (mRtReleaseSurfaces) {
+ mRtReleaseSurfaces = false;
+ releaseSurfaces(mRtTransaction);
}
+ applyRtTransaction(frameNumber);
mRtHandlingPositionUpdates = false;
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index ecba6156df57..0fc2d7a75ee1 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -10117,4 +10117,14 @@ public final class ViewRootImpl implements ViewParent,
int getSurfaceSequenceId() {
return mSurfaceSequenceId;
}
+
+ /**
+ * Merges the transaction passed in with the next transaction in BLASTBufferQueue. This ensures
+ * you can add transactions to the upcoming frame.
+ */
+ void mergeWithNextTransaction(Transaction t, long frameNumber) {
+ if (mBlastBufferQueue != null) {
+ mBlastBufferQueue.mergeWithNextTransaction(t, frameNumber);
+ }
+ }
}