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

Commit 0699eff8 authored by xiaodan zhang's avatar xiaodan zhang Committed by Łukasz Patron
Browse files

Fix captureScreen when 90/180/270 LCM

if the LCM is 90/180/270 degree, there is screenshot issue when take
a screenshot or rotate the panel.
to fix it, the rotation should be corrected by the lcm orientation.

Bug: 168580111
Test: manual take screenshot and rotate screen. check screenshot png
and display is nomal or not.

Change-Id: I10b59f9ee23a002859bad3821d73c3ff9079a407
parent fef4a284
Loading
Loading
Loading
Loading
+35 −1
Original line number Diff line number Diff line
@@ -5435,6 +5435,15 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,
        display = getDisplayDeviceLocked(displayToken);
        if (!display) return NAME_NOT_FOUND;

        if (display->isPrimary()) {
            const auto physicalOrientation = display->getPhysicalOrientation();
            renderAreaRotation = ui::Transform::toRotationFlags(rotation + physicalOrientation);
            if (renderAreaRotation == ui::Transform::ROT_INVALID) {
                ALOGE("%s: Invalid rotation: %s", __FUNCTION__, toCString(rotation));
                renderAreaRotation = ui::Transform::ROT_0;
            }
        }

        // set the requested width/height to the logical display viewport size
        // by default
        if (reqWidth == 0 || reqHeight == 0) {
@@ -5508,6 +5517,7 @@ status_t SurfaceFlinger::captureScreen(uint64_t displayOrLayerStack, Dataspace*
    uint32_t width;
    uint32_t height;
    ui::Transform::RotationFlags captureOrientation;
    ui::Rotation correctOrientation;
    {
        Mutex::Autolock lock(mStateLock);
        display = getDisplayByIdOrLayerStack(displayOrLayerStack);
@@ -5519,7 +5529,31 @@ status_t SurfaceFlinger::captureScreen(uint64_t displayOrLayerStack, Dataspace*
        height = uint32_t(display->getViewport().height());

        const auto orientation = display->getOrientation();
        const auto physicalOrientation = display->getPhysicalOrientation();
        if (display->isPrimary()) {
            switch (physicalOrientation) {
            case ui::Rotation::Rotation0:
                correctOrientation = orientation;
                break;
            case ui::Rotation::Rotation90:
                correctOrientation = orientation + ui::Rotation::Rotation270;
                break;

            case ui::Rotation::Rotation180:
                correctOrientation = orientation + ui::Rotation::Rotation180;
                break;

            case ui::Rotation::Rotation270:
                correctOrientation = orientation + ui::Rotation::Rotation90;
                break;

            default:
                break;
            }
            captureOrientation = ui::Transform::toRotationFlags(correctOrientation);
        } else {
            captureOrientation = ui::Transform::toRotationFlags(orientation);
        }

        switch (captureOrientation) {
            case ui::Transform::ROT_90: