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

Commit a02871cd authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: add install orientation to DisplayDevice

Rather than querying it from SurfaceFlinger, initialize
DisplayDevice with the install orientation.

Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: Ibffe47033276e938388af775749c56f170fe8c77
parent 304d9cd6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ DisplayDevice::DisplayDevice(
        std::unique_ptr<RE::Surface> renderSurface,
        int displayWidth,
        int displayHeight,
        int displayInstallOrientation,
        bool hasWideColorGamut,
        const HdrCapabilities& hdrCapabilities,
        const int32_t supportedPerFrameMetadata,
@@ -233,6 +234,7 @@ DisplayDevice::DisplayDevice(
      mSurface{std::move(renderSurface)},
      mDisplayWidth(displayWidth),
      mDisplayHeight(displayHeight),
      mDisplayInstallOrientation(displayInstallOrientation),
      mPageFlipCount(0),
      mIsSecure(isSecure),
      mLayerStack(NO_LAYER_STACK),
@@ -604,9 +606,8 @@ void DisplayDevice::setProjection(int orientation,
    // need to take care of primary display rotation for mGlobalTransform
    // for case if the panel is not installed aligned with device orientation
    if (mType == DisplayType::DISPLAY_PRIMARY) {
        int primaryDisplayOrientation = SurfaceFlinger::primaryDisplayOrientation;
        DisplayDevice::orientationToTransfrom(
                (orientation + primaryDisplayOrientation) % (DisplayState::eOrientation270 + 1),
                (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
                w, h, &R);
    }

+3 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public:
            std::unique_ptr<RE::Surface> renderSurface,
            int displayWidth,
            int displayHeight,
            int displayInstallOrientation,
            bool hasWideColorGamut,
            const HdrCapabilities& hdrCapabilities,
            const int32_t supportedPerFrameMetadata,
@@ -110,6 +111,7 @@ public:

    int         getWidth() const;
    int         getHeight() const;
    int         getInstallOrientation() const { return mDisplayInstallOrientation; }

    void                    setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
    const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
@@ -234,6 +236,7 @@ private:
    std::unique_ptr<RE::Surface> mSurface;
    int             mDisplayWidth;
    int             mDisplayHeight;
    const int       mDisplayInstallOrientation;
    mutable uint32_t mPageFlipCount;
    std::string     mDisplayName;
    bool            mIsSecure;
+7 −3
Original line number Diff line number Diff line
@@ -2438,14 +2438,18 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
        nativeWindow->setSwapInterval(nativeWindow.get(), 0);
    }

    const int displayInstallOrientation = state.type == DisplayDevice::DISPLAY_PRIMARY ?
        primaryDisplayOrientation : DisplayState::eOrientationDefault;

    // virtual displays are always considered enabled
    auto initialPowerMode = state.isVirtual() ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF;

    sp<DisplayDevice> display =
            new DisplayDevice(this, state.type, displayId, state.isSecure, displayToken,
                              nativeWindow, dispSurface, std::move(renderSurface), displayWidth,
                              displayHeight, hasWideColorGamut, hdrCapabilities,
                              supportedPerFrameMetadata, hwcColorModes, initialPowerMode);
                              displayHeight, displayInstallOrientation, hasWideColorGamut,
                              hdrCapabilities, supportedPerFrameMetadata, hwcColorModes,
                              initialPowerMode);

    if (maxFrameBufferAcquiredBuffers >= 3) {
        nativeWindowSurface->preallocateBuffers();
@@ -5093,7 +5097,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,
            reqHeight = uint32_t(display->getViewport().height());
        }

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

    DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
+3 −2
Original line number Diff line number Diff line
@@ -329,8 +329,9 @@ public:
            sp<DisplayDevice> device =
                    new DisplayDevice(mFlinger.mFlinger.get(), mType, mDisplayId, mSecure,
                                      mDisplayToken, mNativeWindow, mDisplaySurface,
                                      std::move(mRenderSurface), 0, 0, false, HdrCapabilities(), 0,
                                      hdrAndRenderIntents, HWC_POWER_MODE_NORMAL);
                                      std::move(mRenderSurface), 0, 0,
                                      DisplayState::eOrientationDefault, false, HdrCapabilities(),
                                      0, hdrAndRenderIntents, HWC_POWER_MODE_NORMAL);
            mFlinger.mutableDisplays().emplace(mDisplayToken, device);

            DisplayDeviceState state;