Java Code Examples for android.view.SurfaceControl#Transaction

The following examples show how to use android.view.SurfaceControl#Transaction . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragState.java    From android_9.0.0_r45 with Apache License 2.0 9 votes vote down vote up
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    try (final SurfaceControl.Transaction transaction = new SurfaceControl.Transaction()) {
        transaction.setPosition(
                mSurfaceControl,
                (float) animation.getAnimatedValue(ANIMATED_PROPERTY_X),
                (float) animation.getAnimatedValue(ANIMATED_PROPERTY_Y));
        transaction.setAlpha(
                mSurfaceControl,
                (float) animation.getAnimatedValue(ANIMATED_PROPERTY_ALPHA));
        transaction.setMatrix(
                mSurfaceControl,
                (float) animation.getAnimatedValue(ANIMATED_PROPERTY_SCALE), 0,
                0, (float) animation.getAnimatedValue(ANIMATED_PROPERTY_SCALE));
        transaction.apply();
    }
}
 
Example 2
Source File: Letterbox.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void applySurfaceChanges(SurfaceControl.Transaction t) {
    if (mSurfaceFrame.equals(mLayoutFrame)) {
        // Nothing changed.
        return;
    }
    mSurfaceFrame.set(mLayoutFrame);
    if (!mSurfaceFrame.isEmpty()) {
        if (mSurface == null) {
            createSurface();
        }
        t.setPosition(mSurface, mSurfaceFrame.left, mSurfaceFrame.top);
        t.setSize(mSurface, mSurfaceFrame.width(), mSurfaceFrame.height());
        t.show(mSurface);
    } else if (mSurface != null) {
        t.hide(mSurface);
    }
}
 
Example 3
Source File: DisplayManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
void performTraversalInternal(SurfaceControl.Transaction t) {
    synchronized (mSyncRoot) {
        if (!mPendingTraversal) {
            return;
        }
        mPendingTraversal = false;

        performTraversalLocked(t);
    }

    // List is self-synchronized copy-on-write.
    for (DisplayTransactionListener listener : mDisplayTransactionListeners) {
        listener.onDisplayTransaction();
    }
}
 
Example 4
Source File: DisplayManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void performTraversalLocked(SurfaceControl.Transaction t) {
    // Clear all viewports before configuring displays so that we can keep
    // track of which ones we have configured.
    clearViewportsLocked();

    // Configure each display device.
    final int count = mDisplayDevices.size();
    for (int i = 0; i < count; i++) {
        DisplayDevice device = mDisplayDevices.get(i);
        configureDisplayLocked(t, device);
        device.performTraversalLocked(t);
    }

    // Tell the input system about these new viewports.
    if (mInputManagerInternal != null) {
        mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT);
    }
}
 
Example 5
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Finish a dim started by dimAbove in the case there was no call to dimAbove.
 *
 * @param t A Transaction in which to finish the dim.
 */
void stopDim(SurfaceControl.Transaction t) {
    if (mDimState != null) {
        t.hide(mDimState.mDimLayer);
        mDimState.isVisible = false;
        mDimState.mDontReset = false;
    }
}
 
Example 6
Source File: BlackFrame.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void clearMatrix(SurfaceControl.Transaction t) {
    for (int i=0; i<mBlackSurfaces.length; i++) {
        if (mBlackSurfaces[i] != null) {
            mBlackSurfaces[i].clearMatrix(t);
        }
    }
}
 
Example 7
Source File: WindowSurfaceController.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void hideSurface(SurfaceControl.Transaction transaction) {
    if (mSurfaceControl == null) {
        return;
    }
    setShown(false);
    try {
        transaction.hide(mSurfaceControl);
    } catch (RuntimeException e) {
        Slog.w(TAG, "Exception hiding surface in " + this);
    }
}
 
Example 8
Source File: VirtualDisplayAdapter.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void performTraversalLocked(SurfaceControl.Transaction t) {
    if ((mPendingChanges & PENDING_RESIZE) != 0) {
        t.setDisplaySize(getDisplayTokenLocked(), mWidth, mHeight);
    }
    if ((mPendingChanges & PENDING_SURFACE_CHANGE) != 0) {
        setSurfaceLocked(t, mSurface);
    }
    mPendingChanges = 0;
}
 
Example 9
Source File: BlackFrame.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void setAlpha(SurfaceControl.Transaction t, float alpha) {
    for (int i=0; i<mBlackSurfaces.length; i++) {
        if (mBlackSurfaces[i] != null) {
            mBlackSurfaces[i].setAlpha(t, alpha);
        }
    }
}
 
Example 10
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void startDimEnter(WindowContainer container, SurfaceAnimator animator,
        SurfaceControl.Transaction t) {
    startAnim(container, animator, t, 0 /* startAlpha */, 1 /* endAlpha */);
}
 
Example 11
Source File: ScreenRotationAnimation.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void updateSurfaces(SurfaceControl.Transaction t) {
    if (!mStarted) {
        return;
    }

    if (mSurfaceControl != null) {
        if (!mMoreStartExit && !mMoreFinishExit && !mMoreRotateExit) {
            if (DEBUG_STATE) Slog.v(TAG, "Exit animations done, hiding screenshot surface");
            t.hide(mSurfaceControl);
        }
    }

    if (mCustomBlackFrame != null) {
        if (!mMoreStartFrame && !mMoreFinishFrame && !mMoreRotateFrame) {
            if (DEBUG_STATE) Slog.v(TAG, "Frame animations done, hiding black frame");
            mCustomBlackFrame.hide(t);
        } else {
            mCustomBlackFrame.setMatrix(t, mFrameTransformation.getMatrix());
        }
    }

    if (mExitingBlackFrame != null) {
        if (!mMoreStartExit && !mMoreFinishExit && !mMoreRotateExit) {
            if (DEBUG_STATE) Slog.v(TAG, "Frame animations done, hiding exiting frame");
            mExitingBlackFrame.hide(t);
        } else {
            mExitFrameFinalMatrix.setConcat(mExitTransformation.getMatrix(), mFrameInitialMatrix);
            mExitingBlackFrame.setMatrix(t, mExitFrameFinalMatrix);
            if (mForceDefaultOrientation) {
                mExitingBlackFrame.setAlpha(t, mExitTransformation.getAlpha());
            }
        }
    }

    if (mEnteringBlackFrame != null) {
        if (!mMoreStartEnter && !mMoreFinishEnter && !mMoreRotateEnter) {
            if (DEBUG_STATE) Slog.v(TAG, "Frame animations done, hiding entering frame");
            mEnteringBlackFrame.hide(t);
        } else {
            mEnteringBlackFrame.setMatrix(t, mEnterTransformation.getMatrix());
        }
    }

    setSnapshotTransform(t, mSnapshotFinalMatrix, mExitTransformation.getAlpha());
}
 
Example 12
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void onAnimationLeashCreated(SurfaceControl.Transaction t, SurfaceControl leash) {
}
 
Example 13
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public SurfaceControl.Transaction getPendingTransaction() {
    return mHost.getPendingTransaction();
}
 
Example 14
Source File: Letterbox.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public void applySurfaceChanges(SurfaceControl.Transaction t) {
    mTop.applySurfaceChanges(t);
    mLeft.applySurfaceChanges(t);
    mBottom.applySurfaceChanges(t);
    mRight.applySurfaceChanges(t);
}
 
Example 15
Source File: BlackFrame.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void setAlpha(SurfaceControl.Transaction t, float alpha) {
    t.setAlpha(surface, alpha);
}
 
Example 16
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
void startAnimation(SurfaceAnimator surfaceAnimator, SurfaceControl.Transaction t,
AnimationAdapter anim, boolean hidden);
 
Example 17
Source File: Dimmer.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void startAnim(WindowContainer container, SurfaceAnimator animator,
        SurfaceControl.Transaction t, float startAlpha, float endAlpha) {
    mSurfaceAnimatorStarter.startAnimation(animator, t, new LocalAnimationAdapter(
            new AlphaAnimationSpec(startAlpha, endAlpha, getDimDuration(container)),
            mHost.mService.mSurfaceAnimationRunner), false /* hidden */);
}
 
Example 18
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Here we satisfy an unfortunate special case of the IME in split-screen mode. Imagine
 * that the IME target is one of the docked applications. We'd like the docked divider to be
 * above both of the applications, and we'd like the IME to be above the docked divider.
 * However we need child windows of the applications to be above the IME (Text drag handles).
 * This is a non-strictly hierarcical layering and we need to break out of the Z ordering
 * somehow. We do this by relatively ordering children of the target to the IME in cooperation
 * with {@link #WindowState#assignLayer}
 */
void assignRelativeLayerForImeTargetChild(SurfaceControl.Transaction t, WindowContainer child) {
    child.assignRelativeLayer(t, mImeWindowsContainers.getSurfaceControl(), 1);
}
 
Example 19
Source File: DisplayManagerInternal.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Called by the window manager to perform traversals while holding a
 * surface flinger transaction.
 */
public abstract void performTraversal(SurfaceControl.Transaction t);
 
Example 20
Source File: DisplayDevice.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Gives the display device a chance to update its properties while in a transaction.
 */
public void performTraversalLocked(SurfaceControl.Transaction t) {
}