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

Commit 690a76f1 authored by Chia-I Wu's avatar Chia-I Wu Committed by Yiwei Zhang
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
Merged-In: Ibffe47033276e938388af775749c56f170fe8c77
parent d63fd945
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -224,6 +224,7 @@ DisplayDevice::DisplayDevice(
        std::unique_ptr<RE::Surface> renderSurface,
        std::unique_ptr<RE::Surface> renderSurface,
        int displayWidth,
        int displayWidth,
        int displayHeight,
        int displayHeight,
        int displayInstallOrientation,
        bool hasWideColorGamut,
        bool hasWideColorGamut,
        const HdrCapabilities& hdrCapabilities,
        const HdrCapabilities& hdrCapabilities,
        const int32_t supportedPerFrameMetadata,
        const int32_t supportedPerFrameMetadata,
@@ -239,6 +240,7 @@ DisplayDevice::DisplayDevice(
      mSurface{std::move(renderSurface)},
      mSurface{std::move(renderSurface)},
      mDisplayWidth(displayWidth),
      mDisplayWidth(displayWidth),
      mDisplayHeight(displayHeight),
      mDisplayHeight(displayHeight),
      mDisplayInstallOrientation(displayInstallOrientation),
      mPageFlipCount(0),
      mPageFlipCount(0),
      mIsSecure(isSecure),
      mIsSecure(isSecure),
      mLayerStack(NO_LAYER_STACK),
      mLayerStack(NO_LAYER_STACK),
@@ -610,9 +612,8 @@ void DisplayDevice::setProjection(int orientation,
    // need to take care of primary display rotation for mGlobalTransform
    // need to take care of primary display rotation for mGlobalTransform
    // for case if the panel is not installed aligned with device orientation
    // for case if the panel is not installed aligned with device orientation
    if (mType == DisplayType::DISPLAY_PRIMARY) {
    if (mType == DisplayType::DISPLAY_PRIMARY) {
        int primaryDisplayOrientation = SurfaceFlinger::primaryDisplayOrientation;
        DisplayDevice::orientationToTransfrom(
        DisplayDevice::orientationToTransfrom(
                (orientation + primaryDisplayOrientation) % (DisplayState::eOrientation270 + 1),
                (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
                w, h, &R);
                w, h, &R);
    }
    }


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


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


    void                    setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
    void                    setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
    const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
    const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
@@ -233,6 +235,7 @@ private:
    std::unique_ptr<RE::Surface> mSurface;
    std::unique_ptr<RE::Surface> mSurface;
    int             mDisplayWidth;
    int             mDisplayWidth;
    int             mDisplayHeight;
    int             mDisplayHeight;
    const int       mDisplayInstallOrientation;
    mutable uint32_t mPageFlipCount;
    mutable uint32_t mPageFlipCount;
    String8         mDisplayName;
    String8         mDisplayName;
    bool            mIsSecure;
    bool            mIsSecure;
+5 −2
Original line number Original line Diff line number Diff line
@@ -2417,6 +2417,9 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
        nativeWindow->setSwapInterval(nativeWindow.get(), 0);
        nativeWindow->setSwapInterval(nativeWindow.get(), 0);
    }
    }


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

    // virtual displays are always considered enabled
    // virtual displays are always considered enabled
    auto initialPowerMode = (state.type >= DisplayDevice::DISPLAY_VIRTUAL) ? HWC_POWER_MODE_NORMAL
    auto initialPowerMode = (state.type >= DisplayDevice::DISPLAY_VIRTUAL) ? HWC_POWER_MODE_NORMAL
                                                                           : HWC_POWER_MODE_OFF;
                                                                           : HWC_POWER_MODE_OFF;
@@ -2424,7 +2427,7 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
    sp<DisplayDevice> hw =
    sp<DisplayDevice> hw =
            new DisplayDevice(this, state.type, hwcId, state.isSecure, display, nativeWindow,
            new DisplayDevice(this, state.type, hwcId, state.isSecure, display, nativeWindow,
                              dispSurface, std::move(renderSurface), displayWidth, displayHeight,
                              dispSurface, std::move(renderSurface), displayWidth, displayHeight,
                              hasWideColorGamut, hdrCapabilities,
                              displayInstallOrientation, hasWideColorGamut, hdrCapabilities,
                              supportedPerFrameMetadata, hwcColorModes, initialPowerMode);
                              supportedPerFrameMetadata, hwcColorModes, initialPowerMode);


    if (maxFrameBufferAcquiredBuffers >= 3) {
    if (maxFrameBufferAcquiredBuffers >= 3) {
@@ -4874,7 +4877,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
            reqHeight = uint32_t(device->getViewport().height());
            reqHeight = uint32_t(device->getViewport().height());
        }
        }


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


    DisplayRenderArea renderArea(device, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
    DisplayRenderArea renderArea(device, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
+5 −4
Original line number Original line Diff line number Diff line
@@ -320,10 +320,11 @@ public:
        sp<DisplayDevice> inject() {
        sp<DisplayDevice> inject() {
            std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hdrAndRenderIntents;
            std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hdrAndRenderIntents;
            sp<DisplayDevice> device =
            sp<DisplayDevice> device =
                    new DisplayDevice(mFlinger.mFlinger.get(), mType, mHwcId, mSecure, mDisplayToken,
                    new DisplayDevice(mFlinger.mFlinger.get(), mType, mHwcId, mSecure,
                                      mNativeWindow, mDisplaySurface, std::move(mRenderSurface), 0,
                                      mDisplayToken, mNativeWindow, mDisplaySurface,
                                      0, false, HdrCapabilities(), 0, hdrAndRenderIntents,
                                      std::move(mRenderSurface), 0, 0,
                                      HWC_POWER_MODE_NORMAL);
                                      DisplayState::eOrientationDefault, false, HdrCapabilities(),
                                      0, hdrAndRenderIntents, HWC_POWER_MODE_NORMAL);
            mFlinger.mutableDisplays().add(mDisplayToken, device);
            mFlinger.mutableDisplays().add(mDisplayToken, device);


            DisplayDeviceState state(mType, mSecure);
            DisplayDeviceState state(mType, mSecure);