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

Commit cb02315a authored by Chia-I Wu's avatar Chia-I Wu
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
parent 5e3afa61
Loading
Loading
Loading
Loading
+9 −25
Original line number Diff line number Diff line
@@ -5082,34 +5082,18 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,
        display = getDisplayDeviceLocked(displayToken);
        if (!display) return BAD_VALUE;

        const Rect& dispScissor = display->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(display->getScissor());

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

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

        if (renderAreaRotation & ui::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(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);