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

Commit 897215d7 authored by Robert Carr's avatar Robert Carr
Browse files

Remove code for seamlessly rotating SurfaceView's.

No longer required :D

Bug: 36230754
Bug: 36727915
Test: Rotate camera in different modes.
Change-Id: I7708d61646a36bc0c35cfa91d441296eb49eff9a
parent 78f5c26f
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -451,10 +451,6 @@ public class SurfaceControl {
        return nativeGetHandle(mNativeObject);
        return nativeGetHandle(mNativeObject);
    }
    }


    public boolean getTransformToDisplayInverse() {
        return nativeGetTransformToDisplayInverse(mNativeObject);
    }

    /** flag the transaction as an animation */
    /** flag the transaction as an animation */
    public static void setAnimationTransaction() {
    public static void setAnimationTransaction() {
        nativeSetAnimationTransaction();
        nativeSetAnimationTransaction();
+0 −12
Original line number Original line Diff line number Diff line
@@ -735,16 +735,6 @@ static jobject nativeGetHandle(JNIEnv* env, jclass clazz, jlong nativeObject) {
    return javaObjectForIBinder(env, ctrl->getHandle());
    return javaObjectForIBinder(env, ctrl->getHandle());
}
}


static jboolean nativeGetTransformToDisplayInverse(JNIEnv* env, jclass clazz, jlong nativeObject) {
    bool out = false;
    auto ctrl = reinterpret_cast<SurfaceControl *>(nativeObject);
    status_t status = ctrl->getTransformToDisplayInverse(&out);
    if (status != NO_ERROR) {
        return false;
    }
    return out;
}

static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
static jobject nativeGetHdrCapabilities(JNIEnv* env, jclass clazz, jobject tokenObject) {
    sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
    sp<IBinder> token(ibinderForJavaObject(env, tokenObject));
    if (token == NULL) return NULL;
    if (token == NULL) return NULL;
@@ -854,8 +844,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeSetOverrideScalingMode },
            (void*)nativeSetOverrideScalingMode },
    {"nativeGetHandle", "(J)Landroid/os/IBinder;",
    {"nativeGetHandle", "(J)Landroid/os/IBinder;",
            (void*)nativeGetHandle },
            (void*)nativeGetHandle },
    {"nativeGetTransformToDisplayInverse", "(J)Z",
     (void*)nativeGetTransformToDisplayInverse },
    {"nativeScreenshotToBuffer",
    {"nativeScreenshotToBuffer",
     "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;",
     "(Landroid/os/IBinder;Landroid/graphics/Rect;IIIIZZI)Landroid/graphics/GraphicBuffer;",
     (void*)nativeScreenshotToBuffer },
     (void*)nativeScreenshotToBuffer },
+3 −23
Original line number Original line Diff line number Diff line
@@ -893,9 +893,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        final int lastOrientation = mLastOrientation;
        final int lastOrientation = mLastOrientation;
        final boolean oldAltOrientation = mAltOrientation;
        final boolean oldAltOrientation = mAltOrientation;
        int rotation = mService.mPolicy.rotationForOrientationLw(lastOrientation, oldRotation);
        int rotation = mService.mPolicy.rotationForOrientationLw(lastOrientation, oldRotation);
        final boolean rotateSeamlessly;
        final boolean rotateSeamlessly = mService.mPolicy.shouldRotateSeamlessly(oldRotation,
                rotation);


        if (mService.mPolicy.shouldRotateSeamlessly(oldRotation, rotation)) {
        if (rotateSeamlessly) {
            final WindowState seamlessRotated = getWindow((w) -> w.mSeamlesslyRotated);
            final WindowState seamlessRotated = getWindow((w) -> w.mSeamlesslyRotated);
            if (seamlessRotated != null) {
            if (seamlessRotated != null) {
                // We can't rotate (seamlessly or not) while waiting for the last seamless rotation
                // We can't rotate (seamlessly or not) while waiting for the last seamless rotation
@@ -904,27 +905,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                // window-removal.
                // window-removal.
                return false;
                return false;
            }
            }

            final WindowState cantSeamlesslyRotate = getWindow((w) ->
                    w.isChildWindow() && w.isVisibleNow()
                            && !w.mWinAnimator.mSurfaceController.getTransformToDisplayInverse());
            if (cantSeamlesslyRotate != null) {
                // In what can only be called an unfortunate workaround we require seamlessly
                // rotated child windows to have the TRANSFORM_TO_DISPLAY_INVERSE flag. Due to
                // limitations in the client API, there is no way for the client to set this flag in
                // a race free fashion. If we seamlessly rotate a window which does not have this
                // flag, but then gains it, we will get an incorrect visual result
                // (rotated viewfinder). This means if we want to support seamlessly rotating
                // windows which could gain this flag, we can't rotate windows without it. This
                // limits seamless rotation in N to camera framework users, windows without
                // children, and native code. This is unfortunate but having the camera work is our
                // primary goal.
                rotateSeamlessly = false;
            } else {
                rotateSeamlessly = true;
            }
        } else {
            rotateSeamlessly = false;
        }
        }


        // TODO: Implement forced rotation changes.
        // TODO: Implement forced rotation changes.
+20 −51
Original line number Original line Diff line number Diff line
@@ -1926,42 +1926,12 @@ class WindowStateAnimator {
        DisplayContent.createRotationMatrix(deltaRotation, x, y, displayWidth, displayHeight,
        DisplayContent.createRotationMatrix(deltaRotation, x, y, displayWidth, displayHeight,
                transform);
                transform);


        // We have two cases:
        // We just need to apply a rotation matrix to the window. For example
        //  1. Windows with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY:
        //     These windows never change buffer size when rotating. Rather the window manager
        //     just updates the scaling factors to fit in the new coordinate system,
        //     and SurfaceFlinger takes care of updating the buffer contents. So in this case
        //     we just need we just need to update the scaling factors and things are seamless
        //     already.
        //  2. Other windows:
        //     In this case, we need to apply a rotation matrix to the window. For example
        // if we have a portrait window and rotate to landscape, the window is still portrait
        // if we have a portrait window and rotate to landscape, the window is still portrait
        // and now extends off the bottom of the screen (and only halfway across). Essentially we
        // and now extends off the bottom of the screen (and only halfway across). Essentially we
        // apply a transform to display the current buffer at it's old position
        // apply a transform to display the current buffer at it's old position
        // (in the new coordinate space). We then freeze layer updates until the resize
        // (in the new coordinate space). We then freeze layer updates until the resize
        // occurs, at which point we undo, them.
        // occurs, at which point we undo, them.
        if (w.isChildWindow() && mSurfaceController.getTransformToDisplayInverse()) {
            frameRect.set(x, y, x + width, y + height);
            transform.mapRect(frameRect);

            final Rect parentWindowFrame = w.getParentWindow().mFrame;
            w.mAttrs.x = (int) frameRect.left - parentWindowFrame.left;
            w.mAttrs.y = (int) frameRect.top - parentWindowFrame.top;
            w.mAttrs.width = (int) Math.ceil(frameRect.width());
            w.mAttrs.height = (int) Math.ceil(frameRect.height());

            w.setWindowScale(w.mRequestedWidth, w.mRequestedHeight);

            w.applyGravityAndUpdateFrame(w.mContainingFrame, w.mDisplayFrame);
            computeShownFrameLocked();
            setSurfaceBoundariesLocked(false);

            // The stack bounds will not yet be rotated at this point so setSurfaceBoundaries locked
            // will crop us incorrectly. Overwrite the crop, exposing the full surface. By the next
            // transaction this will be corrected.
            cropRect.set(0, 0, w.mRequestedWidth, w.mRequestedWidth + w.mRequestedHeight);
            mSurfaceController.setCropInTransaction(cropRect, false);
        } else {
        mService.markForSeamlessRotation(w, true);
        mService.markForSeamlessRotation(w, true);
        transform.getValues(mService.mTmpFloats);
        transform.getValues(mService.mTmpFloats);


@@ -1977,7 +1947,6 @@ class WindowStateAnimator {
                DtDy * w.mHScale,
                DtDy * w.mHScale,
                DsDy * w.mVScale, false);
                DsDy * w.mVScale, false);
    }
    }
    }


    void enableSurfaceTrace(FileDescriptor fd) {
    void enableSurfaceTrace(FileDescriptor fd) {
        if (mSurfaceController != null) {
        if (mSurfaceController != null) {
+0 −4
Original line number Original line Diff line number Diff line
@@ -509,10 +509,6 @@ class WindowSurfaceController {
        return mSurfaceControl.getHandle();
        return mSurfaceControl.getHandle();
    }
    }


    boolean getTransformToDisplayInverse() {
        return mSurfaceControl.getTransformToDisplayInverse();
    }

    void getSurface(Surface outSurface) {
    void getSurface(Surface outSurface) {
        outSurface.copyFrom(mSurfaceControl);
        outSurface.copyFrom(mSurfaceControl);
    }
    }