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

Commit da424fa6 authored by Chia-I Wu's avatar Chia-I Wu Committed by Luca Stefani
Browse files

surfaceflinger: fix captureScreen for landscape LCM

Make DisplayRenderArea::getSourceCrop return the display scissor
when the source crop is empty.  Force the source crop to be empty in
captureScreen.  This makes sure the install orientation is applied
on the source crop once, not twice.

Bug: 113041375
Test: force primaryDisplayOrientation, rotate screen, and switch
      apps
Change-Id: I15006f867ff2d4a92ebccb1334ce59ab32abe69a
Merged-In: I15006f867ff2d4a92ebccb1334ce59ab32abe69a
parent 14ebd1a7
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -357,10 +357,14 @@ public:
    bool isSecure() const override { return mDevice->isSecure(); }
    bool isSecure() const override { return mDevice->isSecure(); }


    bool needsFiltering() const override {
    bool needsFiltering() const override {
        // check if the projection from the logical display to the physical
        // display needs filtering
        if (mDevice->needsFiltering()) {
        if (mDevice->needsFiltering()) {
            return true;
            return true;
        }
        }


        // check if the projection from the logical render area (i.e., the
        // physical display) to the physical render area requires filtering
        const Rect sourceCrop = getSourceCrop();
        const Rect sourceCrop = getSourceCrop();
        int width = sourceCrop.width();
        int width = sourceCrop.width();
        int height = sourceCrop.height();
        int height = sourceCrop.height();
@@ -371,11 +375,17 @@ public:
    }
    }


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

        const int orientation = mDevice->getInstallOrientation();
        const int orientation = mDevice->getInstallOrientation();
        if (orientation == DisplayState::eOrientationDefault) {
        if (orientation == DisplayState::eOrientationDefault) {
            return mSourceCrop;
            return mSourceCrop;
        }
        }


        // Install orientation is transparent to the callers.  Apply it now.
        uint32_t flags = 0x00;
        uint32_t flags = 0x00;
        switch (orientation) {
        switch (orientation) {
            case DisplayState::eOrientation90:
            case DisplayState::eOrientation90:
@@ -394,6 +404,8 @@ public:
    }
    }


private:
private:
    // Install orientation is transparent to the callers.  We need to cancel
    // it out by modifying rotation flags.
    static Transform::orientation_flags getDisplayRotation(
    static Transform::orientation_flags getDisplayRotation(
            Transform::orientation_flags rotation, int orientation) {
            Transform::orientation_flags rotation, int orientation) {
        if (orientation == DisplayState::eOrientationDefault) {
        if (orientation == DisplayState::eOrientationDefault) {
+3 −5
Original line number Original line Diff line number Diff line
@@ -4890,9 +4890,9 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
        device = getDisplayDeviceLocked(display);
        device = getDisplayDeviceLocked(display);
        if (!device) return BAD_VALUE;
        if (!device) return BAD_VALUE;


        // set the source crop to the (projected) logical display viewport
        // ignore sourceCrop (i.e., use the projected logical display
        // unconditionally until the framework is fixed
        // viewport) until the framework is fixed
        sourceCrop.set(device->getScissor());
        sourceCrop.clear();


        // set the requested width/height to the logical display viewport size
        // set the requested width/height to the logical display viewport size
        // by default
        // by default
@@ -4900,8 +4900,6 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
            reqWidth = uint32_t(device->getViewport().width());
            reqWidth = uint32_t(device->getViewport().width());
            reqHeight = uint32_t(device->getViewport().height());
            reqHeight = uint32_t(device->getViewport().height());
        }
        }

        // XXX display->getInstallOrientation() is ignored
    }
    }


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