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

Commit 6df5400e authored by Chia-I Wu's avatar Chia-I Wu Committed by Yiwei Zhang
Browse files

surfaceflinger: clean up captureScreen

dispScissor is never empty.  Remove the check and update the
comments so that the intention is clear.

It also becomes obvious that reqWidth/reqHeight is never zero when
we reach "// get screen geometry".  All code following the comment
is actually dead, which means we probably broke it since commit
06a58e22.

Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: Ida1430383ce62271365d9ef64ad9b055638e1eac
Merged-In: Ida1430383ce62271365d9ef64ad9b055638e1eac
parent 89e1ec27
Loading
Loading
Loading
Loading
+9 −25
Original line number Diff line number Diff line
@@ -4863,34 +4863,18 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
        device = getDisplayDeviceLocked(display);
        if (!device) return BAD_VALUE;

        const Rect& dispScissor = device->getScissor();
        if (!dispScissor.isEmpty()) {
            sourceCrop.set(dispScissor);
            // adb shell screencap will default reqWidth and reqHeight to zeros.
        // set the source crop to the (projected) logical display viewport
        // unconditionally until the framework is fixed
        sourceCrop.set(device->getScissor());

        // set the requested width/height to the logical display viewport size
        // by default
        if (reqWidth == 0 || reqHeight == 0) {
            reqWidth = uint32_t(device->getViewport().width());
            reqHeight = uint32_t(device->getViewport().height());
        }
        }

        // get screen geometry
        uint32_t width = device->getWidth();
        uint32_t height = device->getHeight();

        if (renderAreaRotation & Transform::ROT_90) {
            std::swap(width, height);
        }

        if (mPrimaryDisplayOrientation & DisplayState::eOrientationSwapMask) {
            std::swap(width, height);
        }

        if (reqWidth == 0) {
            reqWidth = width;
        }
        if (reqHeight == 0) {
            reqHeight = height;
        }
        // XXX mPrimaryDisplayOrientation is ignored
    }

    DisplayRenderArea renderArea(device, sourceCrop, reqWidth, reqHeight, renderAreaRotation);