Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b96776e2 authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge changes from topic "new-z-order"

* changes:
  Reimplement DimLayer's using hierarchy.
  Re-implement Z-ordering based off SurfaceControl hierarchy.
parents ac06857f f59b8ddd
Loading
Loading
Loading
Loading
+25 −1
Original line number Original line Diff line number Diff line
@@ -61,6 +61,8 @@ public class SurfaceControl {
    private static native long nativeCreateTransaction();
    private static native long nativeCreateTransaction();
    private static native long nativeGetNativeTransactionFinalizer();
    private static native long nativeGetNativeTransactionFinalizer();
    private static native void nativeApplyTransaction(long transactionObj, boolean sync);
    private static native void nativeApplyTransaction(long transactionObj, boolean sync);
    private static native void nativeMergeTransaction(long transactionObj,
            long otherTransactionObj);
    private static native void nativeSetAnimationTransaction(long transactionObj);
    private static native void nativeSetAnimationTransaction(long transactionObj);


    private static native void nativeSetLayer(long transactionObj, long nativeObject, int zorder);
    private static native void nativeSetLayer(long transactionObj, long nativeObject, int zorder);
@@ -654,6 +656,19 @@ public class SurfaceControl {
        }
        }
    }
    }


    /**
     * Merge the supplied transaction in to the deprecated "global" transaction.
     * This clears the supplied transaction in an identical fashion to {@link Transaction#merge}.
     * <p>
     * This is a utility for interop with legacy-code and will go away with the Global Transaction.
     */
    @Deprecated
    public static void mergeToGlobalTransaction(Transaction t) {
        synchronized(sGlobalTransaction) {
            sGlobalTransaction.merge(t);
        }
    }

    /** end a transaction */
    /** end a transaction */
    public static void closeTransaction() {
    public static void closeTransaction() {
        closeTransaction(false);
        closeTransaction(false);
@@ -1368,7 +1383,7 @@ public class SurfaceControl {
         * Sets the security of the surface.  Setting the flag is equivalent to creating the
         * Sets the security of the surface.  Setting the flag is equivalent to creating the
         * Surface with the {@link #SECURE} flag.
         * Surface with the {@link #SECURE} flag.
         */
         */
        Transaction setSecure(SurfaceControl sc, boolean isSecure) {
        public Transaction setSecure(SurfaceControl sc, boolean isSecure) {
            sc.checkNotReleased();
            sc.checkNotReleased();
            if (isSecure) {
            if (isSecure) {
                nativeSetFlags(mNativeObject, sc.mNativeObject, SECURE, SECURE);
                nativeSetFlags(mNativeObject, sc.mNativeObject, SECURE, SECURE);
@@ -1449,5 +1464,14 @@ public class SurfaceControl {
            nativeSetAnimationTransaction(mNativeObject);
            nativeSetAnimationTransaction(mNativeObject);
            return this;
            return this;
        }
        }

        /**
         * Merge the other transaction into this transaction, clearing the
         * other transaction as if it had been applied.
         */
        public Transaction merge(Transaction other) {
            nativeMergeTransaction(mNativeObject, other.mNativeObject);
            return this;
        }
    }
    }
}
}
+0 −8
Original line number Original line Diff line number Diff line
@@ -1662,14 +1662,6 @@ public interface WindowManagerPolicy {
     */
     */
    void writeToProto(ProtoOutputStream proto, long fieldId);
    void writeToProto(ProtoOutputStream proto, long fieldId);


    /**
     * Returns whether a given window type can be magnified.
     *
     * @param windowType The window type.
     * @return True if the window can be magnified.
     */
    public boolean canMagnifyWindow(int windowType);

    /**
    /**
     * Returns whether a given window type is considered a top level one.
     * Returns whether a given window type is considered a top level one.
     * A top level window does not have a container, i.e. attached window,
     * A top level window does not have a container, i.e. attached window,
+10 −0
Original line number Original line Diff line number Diff line
@@ -311,6 +311,14 @@ static void nativeApplyTransaction(JNIEnv* env, jclass clazz, jlong transactionO
    transaction->apply(sync);
    transaction->apply(sync);
}
}


static void nativeMergeTransaction(JNIEnv* env, jclass clazz,
        jlong transactionObj, jlong otherTransactionObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto otherTransaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(
            otherTransactionObj);
    transaction->merge(std::move(*otherTransaction));
}

static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) {
static void nativeSetAnimationTransaction(JNIEnv* env, jclass clazz, jlong transactionObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    transaction->setAnimationTransaction();
    transaction->setAnimationTransaction();
@@ -882,6 +890,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeApplyTransaction },
            (void*)nativeApplyTransaction },
    {"nativeGetNativeTransactionFinalizer", "()J",
    {"nativeGetNativeTransactionFinalizer", "()J",
            (void*)nativeGetNativeTransactionFinalizer },
            (void*)nativeGetNativeTransactionFinalizer },
    {"nativeMergeTransaction", "(JJ)V",
            (void*)nativeMergeTransaction },
    {"nativeSetAnimationTransaction", "(J)V",
    {"nativeSetAnimationTransaction", "(J)V",
            (void*)nativeSetAnimationTransaction },
            (void*)nativeSetAnimationTransaction },
    {"nativeSetLayer", "(JJI)V",
    {"nativeSetLayer", "(JJI)V",
+0 −13
Original line number Original line Diff line number Diff line
@@ -8061,19 +8061,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mKeyguardDelegate.setSwitchingUser(switching);
        mKeyguardDelegate.setSwitchingUser(switching);
    }
    }


    @Override
    public boolean canMagnifyWindow(int windowType) {
        switch (windowType) {
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD:
            case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG:
            case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR:
            case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: {
                return false;
            }
        }
        return true;
    }

    @Override
    @Override
    public boolean isTopLevelWindow(int windowType) {
    public boolean isTopLevelWindow(int windowType) {
        if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW
        if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW
+14 −7
Original line number Original line Diff line number Diff line
@@ -292,6 +292,8 @@ final class AccessibilityController {
        public void setMagnificationSpecLocked(MagnificationSpec spec) {
        public void setMagnificationSpecLocked(MagnificationSpec spec) {
            mMagnifedViewport.updateMagnificationSpecLocked(spec);
            mMagnifedViewport.updateMagnificationSpecLocked(spec);
            mMagnifedViewport.recomputeBoundsLocked();
            mMagnifedViewport.recomputeBoundsLocked();

            mService.applyMagnificationSpec(spec);
            mService.scheduleAnimationLocked();
            mService.scheduleAnimationLocked();
        }
        }


@@ -421,7 +423,7 @@ final class AccessibilityController {
        public MagnificationSpec getMagnificationSpecForWindowLocked(WindowState windowState) {
        public MagnificationSpec getMagnificationSpecForWindowLocked(WindowState windowState) {
            MagnificationSpec spec = mMagnifedViewport.getMagnificationSpecLocked();
            MagnificationSpec spec = mMagnifedViewport.getMagnificationSpecLocked();
            if (spec != null && !spec.isNop()) {
            if (spec != null && !spec.isNop()) {
                if (!mService.mPolicy.canMagnifyWindow(windowState.mAttrs.type)) {
                if (!windowState.shouldMagnify()) {
                    return null;
                    return null;
                }
                }
            }
            }
@@ -476,6 +478,7 @@ final class AccessibilityController {
            private final ViewportWindow mWindow;
            private final ViewportWindow mWindow;


            private boolean mFullRedrawNeeded;
            private boolean mFullRedrawNeeded;
            private int mTempLayer = 0;


            public MagnifiedViewport() {
            public MagnifiedViewport() {
                mWindowManager = (WindowManager) mContext.getSystemService(Service.WINDOW_SERVICE);
                mWindowManager = (WindowManager) mContext.getSystemService(Service.WINDOW_SERVICE);
@@ -565,7 +568,7 @@ final class AccessibilityController {
                    portionOfWindowAlreadyAccountedFor.op(nonMagnifiedBounds, Region.Op.UNION);
                    portionOfWindowAlreadyAccountedFor.op(nonMagnifiedBounds, Region.Op.UNION);
                    windowBounds.op(portionOfWindowAlreadyAccountedFor, Region.Op.DIFFERENCE);
                    windowBounds.op(portionOfWindowAlreadyAccountedFor, Region.Op.DIFFERENCE);


                    if (mService.mPolicy.canMagnifyWindow(windowState.mAttrs.type)) {
                    if (windowState.shouldMagnify()) {
                        mMagnificationRegion.op(windowBounds, Region.Op.UNION);
                        mMagnificationRegion.op(windowBounds, Region.Op.UNION);
                        mMagnificationRegion.op(availableBounds, Region.Op.INTERSECT);
                        mMagnificationRegion.op(availableBounds, Region.Op.INTERSECT);
                    } else {
                    } else {
@@ -676,10 +679,12 @@ final class AccessibilityController {


            private void populateWindowsOnScreenLocked(SparseArray<WindowState> outWindows) {
            private void populateWindowsOnScreenLocked(SparseArray<WindowState> outWindows) {
                final DisplayContent dc = mService.getDefaultDisplayContentLocked();
                final DisplayContent dc = mService.getDefaultDisplayContentLocked();
                mTempLayer = 0;
                dc.forAllWindows((w) -> {
                dc.forAllWindows((w) -> {
                    if (w.isOnScreen() && w.isVisibleLw()
                    if (w.isOnScreen() && w.isVisibleLw()
                            && !w.mWinAnimator.mEnterAnimationPending) {
                            && !w.mWinAnimator.mEnterAnimationPending) {
                        outWindows.put(w.mLayer, w);
                        mTempLayer++;
                        outWindows.put(mTempLayer, w);
                    }
                    }
                }, false /* traverseTopToBottom */ );
                }, false /* traverseTopToBottom */ );
            }
            }
@@ -705,7 +710,7 @@ final class AccessibilityController {
                    SurfaceControl surfaceControl = null;
                    SurfaceControl surfaceControl = null;
                    try {
                    try {
                        mWindowManager.getDefaultDisplay().getRealSize(mTempPoint);
                        mWindowManager.getDefaultDisplay().getRealSize(mTempPoint);
                        surfaceControl = new SurfaceControl.Builder(mService.mFxSession)
                        surfaceControl = mService.getDefaultDisplayContentLocked().makeOverlay()
                                .setName(SURFACE_TITLE)
                                .setName(SURFACE_TITLE)
                                .setSize(mTempPoint.x, mTempPoint.y) // not a typo
                                .setSize(mTempPoint.x, mTempPoint.y) // not a typo
                                .setFormat(PixelFormat.TRANSLUCENT)
                                .setFormat(PixelFormat.TRANSLUCENT)
@@ -714,8 +719,6 @@ final class AccessibilityController {
                        /* ignore */
                        /* ignore */
                    }
                    }
                    mSurfaceControl = surfaceControl;
                    mSurfaceControl = surfaceControl;
                    mSurfaceControl.setLayerStack(mWindowManager.getDefaultDisplay()
                            .getLayerStack());
                    mSurfaceControl.setLayer(mService.mPolicy.getWindowLayerFromTypeLw(
                    mSurfaceControl.setLayer(mService.mPolicy.getWindowLayerFromTypeLw(
                            TYPE_MAGNIFICATION_OVERLAY)
                            TYPE_MAGNIFICATION_OVERLAY)
                            * WindowManagerService.TYPE_LAYER_MULTIPLIER);
                            * WindowManagerService.TYPE_LAYER_MULTIPLIER);
@@ -1005,6 +1008,8 @@ final class AccessibilityController {


        private final long mRecurringAccessibilityEventsIntervalMillis;
        private final long mRecurringAccessibilityEventsIntervalMillis;


        private int mTempLayer = 0;

        public WindowsForAccessibilityObserver(WindowManagerService windowManagerService,
        public WindowsForAccessibilityObserver(WindowManagerService windowManagerService,
                WindowsForAccessibilityCallback callback) {
                WindowsForAccessibilityCallback callback) {
            mContext = windowManagerService.mContext;
            mContext = windowManagerService.mContext;
@@ -1090,6 +1095,7 @@ final class AccessibilityController {
                    if (isReportedWindowType(windowState.mAttrs.type)) {
                    if (isReportedWindowType(windowState.mAttrs.type)) {
                        // Add the window to the ones to be reported.
                        // Add the window to the ones to be reported.
                        WindowInfo window = obtainPopulatedWindowInfo(windowState, boundsInScreen);
                        WindowInfo window = obtainPopulatedWindowInfo(windowState, boundsInScreen);
                        window.layer = addedWindows.size();
                        addedWindows.add(window.token);
                        addedWindows.add(window.token);
                        windows.add(window);
                        windows.add(window);
                        if (windowState.isFocused()) {
                        if (windowState.isFocused()) {
@@ -1323,9 +1329,10 @@ final class AccessibilityController {


        private void populateVisibleWindowsOnScreenLocked(SparseArray<WindowState> outWindows) {
        private void populateVisibleWindowsOnScreenLocked(SparseArray<WindowState> outWindows) {
            final DisplayContent dc = mService.getDefaultDisplayContentLocked();
            final DisplayContent dc = mService.getDefaultDisplayContentLocked();
            mTempLayer = 0;
            dc.forAllWindows((w) -> {
            dc.forAllWindows((w) -> {
                if (w.isVisibleLw()) {
                if (w.isVisibleLw()) {
                    outWindows.put(w.mLayer, w);
                    outWindows.put(mTempLayer++, w);
                }
                }
            }, false /* traverseTopToBottom */ );
            }, false /* traverseTopToBottom */ );
        }
        }
Loading