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

Commit 4ed8c820 authored by Pablo Ceballos's avatar Pablo Ceballos Committed by android-build-merger
Browse files

Merge "SF: Fix camera orientation on virtual displays" into nyc-dev am: 55b29f2e am: 0aa4eaff

am: c281fa96

* commit 'c281fa96':
  SF: Fix camera orientation on virtual displays

Change-Id: I25ef230b5af41e698b78fc271e92d287d817e65a
parents ece45f9a c281fa96
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ inline void eglSetSwapRectangleANDROID (EGLDisplay, EGLSurface, EGLint, EGLint,
 *
 */

uint32_t DisplayDevice::sPrimaryDisplayOrientation = 0;

DisplayDevice::DisplayDevice(
        const sp<SurfaceFlinger>& flinger,
        DisplayType type,
@@ -550,10 +552,32 @@ void DisplayDevice::setProjection(int orientation,
    }

    mOrientation = orientation;
    if (mType == DisplayType::DISPLAY_PRIMARY) {
        uint32_t transform = 0;
        switch (mOrientation) {
            case DisplayState::eOrientationDefault:
                transform = Transform::ROT_0;
                break;
            case DisplayState::eOrientation90:
                transform = Transform::ROT_90;
                break;
            case DisplayState::eOrientation180:
                transform = Transform::ROT_180;
                break;
            case DisplayState::eOrientation270:
                transform = Transform::ROT_270;
                break;
        }
        sPrimaryDisplayOrientation = transform;
    }
    mViewport = viewport;
    mFrame = frame;
}

uint32_t DisplayDevice::getPrimaryDisplayOrientationTransform() {
    return sPrimaryDisplayOrientation;
}

void DisplayDevice::dump(String8& result) const {
    const Transform& tr(mGlobalTransform);
    result.appendFormat(
+2 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ public:

    int                     getOrientation() const { return mOrientation; }
    uint32_t                getOrientationTransform() const;
    static uint32_t         getPrimaryDisplayOrientationTransform();
    const Transform&        getTransform() const { return mGlobalTransform; }
    const Rect              getViewport() const { return mViewport; }
    const Rect              getFrame() const { return mFrame; }
@@ -238,6 +239,7 @@ private:

    uint32_t mLayerStack;
    int mOrientation;
    static uint32_t sPrimaryDisplayOrientation;
    // user-provided visible area of the layer stack
    Rect mViewport;
    // user-provided rectangle where mViewport gets mapped to
+13 −10
Original line number Diff line number Diff line
@@ -434,9 +434,11 @@ FloatRect Layer::computeCrop(const sp<const DisplayDevice>& hw) const {
    uint32_t invTransform = mCurrentTransform;
    if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
        /*
         * the code below applies the display's inverse transform to the buffer
         * the code below applies the primary display's inverse transform to the
         * buffer
         */
        uint32_t invTransformOrient = hw->getOrientationTransform();
        uint32_t invTransformOrient =
                DisplayDevice::getPrimaryDisplayOrientationTransform();
        // calculate the inverse transform
        if (invTransformOrient & NATIVE_WINDOW_TRANSFORM_ROT_90) {
            invTransformOrient ^= NATIVE_WINDOW_TRANSFORM_FLIP_V |
@@ -633,13 +635,12 @@ void Layer::setGeometry(

    if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {
        /*
         * the code below applies the display's inverse transform to the buffer
         * the code below applies the primary display's inverse transform to the
         * buffer
         */
#ifdef USE_HWC2
        uint32_t invTransform = displayDevice->getOrientationTransform();
#else
        uint32_t invTransform = hw->getOrientationTransform();
#endif
        uint32_t invTransform =
                DisplayDevice::getPrimaryDisplayOrientationTransform();

        uint32_t t_orientation = transform.getOrientation();
        // calculate the inverse transform
        if (invTransform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
@@ -940,7 +941,8 @@ void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
        if (mSurfaceFlingerConsumer->getTransformToDisplayInverse()) {

            /*
             * the code below applies the display's inverse transform to the texture transform
             * the code below applies the primary display's inverse transform to
             * the texture transform
             */

            // create a 4x4 transform matrix from the display transform flags
@@ -949,7 +951,8 @@ void Layer::onDraw(const sp<const DisplayDevice>& hw, const Region& clip,
            const mat4 rot90( 0,1,0,0, -1,0,0,0, 0,0,1,0, 1,0,0,1);

            mat4 tr;
            uint32_t transform = hw->getOrientationTransform();
            uint32_t transform =
                    DisplayDevice::getPrimaryDisplayOrientationTransform();
            if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90)
                tr = tr * rot90;
            if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H)