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

Commit 095079c0 authored by Alec Mouri's avatar Alec Mouri Committed by android-build-merger
Browse files

Merge "Fix the source crop for screenshots for notch hide"

am: 0a75a6ae

Change-Id: I742c1f91cbeabb96e3c85c6f4ecd80d0e91fb9d6
parents 1191d131 0a75a6ae
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -375,16 +375,21 @@ public:
    }

    Rect getSourceCrop() const override {
        // use the (projected) logical display viewport by default
        // use the projected display viewport by default.
        if (mSourceCrop.isEmpty()) {
            return mDevice->getScissor();
        }

        const int orientation = mDevice->getInstallOrientation();
        if (orientation == DisplayState::eOrientationDefault) {
            return mSourceCrop;
        }
        // Recompute the device transformation for the source crop.
        Transform rotation;
        Transform translatePhysical;
        Transform translateLogical;
        Transform scale;
        const Rect& viewport = mDevice->getViewport();
        const Rect& scissor = mDevice->getScissor();
        const Rect& frame = mDevice->getFrame();

        const int orientation = mDevice->getInstallOrientation();
        // Install orientation is transparent to the callers.  Apply it now.
        uint32_t flags = 0x00;
        switch (orientation) {
@@ -397,10 +402,17 @@ public:
            case DisplayState::eOrientation270:
                flags = Transform::ROT_270;
                break;
            default:
                break;
        }
        Transform tr;
        tr.set(flags, getWidth(), getHeight());
        return tr.transform(mSourceCrop);
        rotation.set(flags, getWidth(), getHeight());
        translateLogical.set(-viewport.left, -viewport.top);
        translatePhysical.set(scissor.left, scissor.top);
        scale.set(frame.getWidth() / float(viewport.getWidth()), 0, 0,
                  frame.getHeight() / float(viewport.getHeight()));
        const Transform finalTransform =
                rotation * translatePhysical * scale * translateLogical;
        return finalTransform.transform(mSourceCrop);
    }

private: