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

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

surfaceflinger: make mPrimaryDisplayOrientation static

The convention is to store configstore values in static variables.

Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: I085178803bc897e3e9201fd10bd8731cc5b617c1
parent cb02315a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -604,7 +604,7 @@ 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 = mFlinger->getPrimaryDisplayOrientation();
        int primaryDisplayOrientation = SurfaceFlinger::primaryDisplayOrientation;
        DisplayDevice::orientationToTransfrom(
                (orientation + primaryDisplayOrientation) % (DisplayState::eOrientation270 + 1),
                w, h, &R);
+13 −13
Original line number Diff line number Diff line
@@ -193,9 +193,9 @@ bool SurfaceFlinger::useVrFlinger;
int64_t SurfaceFlinger::maxFrameBufferAcquiredBuffers;
// TODO(courtneygo): Rename hasWideColorDisplay to clarify its actual meaning.
bool SurfaceFlinger::hasWideColorDisplay;
int SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientationDefault;
bool SurfaceFlinger::useColorManagement;


std::string getHwcServiceName() {
    char value[PROPERTY_VALUE_MAX] = {};
    property_get("debug.sf.hwc_service_name", value, "default");
@@ -329,19 +329,19 @@ SurfaceFlinger::SurfaceFlinger() : SurfaceFlinger(SkipInitialization) {

    switch (primaryDisplayOrientation) {
        case V1_1::DisplayOrientation::ORIENTATION_90:
            mPrimaryDisplayOrientation = DisplayState::eOrientation90;
            SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientation90;
            break;
        case V1_1::DisplayOrientation::ORIENTATION_180:
            mPrimaryDisplayOrientation = DisplayState::eOrientation180;
            SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientation180;
            break;
        case V1_1::DisplayOrientation::ORIENTATION_270:
            mPrimaryDisplayOrientation = DisplayState::eOrientation270;
            SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientation270;
            break;
        default:
            mPrimaryDisplayOrientation = DisplayState::eOrientationDefault;
            SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientationDefault;
            break;
    }
    ALOGV("Primary Display Orientation is set to %2d.", mPrimaryDisplayOrientation);
    ALOGV("Primary Display Orientation is set to %2d.", SurfaceFlinger::primaryDisplayOrientation);

    // Note: We create a local temporary with the real DispSync implementation
    // type temporarily so we can initialize it with the configured values,
@@ -871,7 +871,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& displayToken,
        info.secure = true;

        if (type == DisplayDevice::DISPLAY_PRIMARY &&
            mPrimaryDisplayOrientation & DisplayState::eOrientationSwapMask) {
            primaryDisplayOrientation & DisplayState::eOrientationSwapMask) {
            std::swap(info.w, info.h);
        }

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

        // XXX mPrimaryDisplayOrientation is ignored
        // XXX primaryDisplayOrientation is ignored
    }

    DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
@@ -5316,7 +5316,7 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
    Rect sourceCrop = renderArea.getSourceCrop();

    bool filtering = false;
    if (mPrimaryDisplayOrientation & DisplayState::eOrientationSwapMask) {
    if (primaryDisplayOrientation & DisplayState::eOrientationSwapMask) {
        filtering = static_cast<int32_t>(reqWidth) != raHeight ||
                static_cast<int32_t>(reqHeight) != raWidth;
    } else {
@@ -5328,10 +5328,10 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
    if (sourceCrop.width() == 0 || sourceCrop.height() == 0 || !sourceCrop.isValid()) {
        sourceCrop.setLeftTop(Point(0, 0));
        sourceCrop.setRightBottom(Point(raWidth, raHeight));
    } else if (mPrimaryDisplayOrientation != DisplayState::eOrientationDefault) {
    } else if (primaryDisplayOrientation != DisplayState::eOrientationDefault) {
        ui::Transform tr;
        uint32_t flags = 0x00;
        switch (mPrimaryDisplayOrientation) {
        switch (primaryDisplayOrientation) {
            case DisplayState::eOrientation90:
                flags = ui::Transform::ROT_90;
                break;
@@ -5354,12 +5354,12 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
    engine.checkErrors();

    ui::Transform::orientation_flags rotation = renderArea.getRotationFlags();
    if (mPrimaryDisplayOrientation != DisplayState::eOrientationDefault) {
    if (primaryDisplayOrientation != DisplayState::eOrientationDefault) {
        // convert hw orientation into flag presentation
        // here inverse transform needed
        uint8_t hw_rot_90  = 0x00;
        uint8_t hw_flip_hv = 0x00;
        switch (mPrimaryDisplayOrientation) {
        switch (primaryDisplayOrientation) {
            case DisplayState::eOrientation90:
                hw_rot_90 = ui::Transform::ROT_90;
                hw_flip_hv = ui::Transform::ROT_180;
+2 −3
Original line number Diff line number Diff line
@@ -288,6 +288,8 @@ public:
    // found on devices with wide color gamut (e.g. Display-P3) display.
    static bool hasWideColorDisplay;

    static int primaryDisplayOrientation;

    // Indicate if device wants color management on its display.
    static bool useColorManagement;

@@ -350,8 +352,6 @@ public:
    bool authenticateSurfaceTextureLocked(
        const sp<IGraphicBufferProducer>& bufferProducer) const;

    int getPrimaryDisplayOrientation() const { return mPrimaryDisplayOrientation; }

private:
    friend class Client;
    friend class DisplayEventConnection;
@@ -877,7 +877,6 @@ private:
    mutable std::unique_ptr<MessageQueue> mEventQueue{std::make_unique<impl::MessageQueue>()};
    FrameTracker mAnimFrameTracker;
    std::unique_ptr<DispSync> mPrimaryDispSync;
    int mPrimaryDisplayOrientation = DisplayState::eOrientationDefault;

    // protected by mDestroyedLayerLock;
    mutable Mutex mDestroyedLayerLock;
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public:
     */

    auto& mutableHasWideColorDisplay() { return SurfaceFlinger::hasWideColorDisplay; }
    auto& mutablePrimaryDisplayOrientation() { return SurfaceFlinger::primaryDisplayOrientation; }
    auto& mutableUseColorManagement() { return SurfaceFlinger::useColorManagement; }

    auto& mutableDisplayTokens() { return mFlinger->mDisplayTokens; }