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

Commit d63fd945 authored by Chia-I Wu's avatar Chia-I Wu Committed by Yiwei Zhang
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
Merged-In: I085178803bc897e3e9201fd10bd8731cc5b617c1
parent 6df5400e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -610,7 +610,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
@@ -166,7 +166,7 @@ bool SurfaceFlinger::useVrFlinger;
int64_t SurfaceFlinger::maxFrameBufferAcquiredBuffers;
// TODO(courtneygo): Rename hasWideColorDisplay to clarify its actual meaning.
bool SurfaceFlinger::hasWideColorDisplay;

int SurfaceFlinger::primaryDisplayOrientation = DisplayState::eOrientationDefault;

std::string getHwcServiceName() {
    char value[PROPERTY_VALUE_MAX] = {};
@@ -300,19 +300,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);

    mPrimaryDispSync.init(SurfaceFlinger::hasSyncFramework, SurfaceFlinger::dispSyncPresentTimeOffset);

@@ -974,7 +974,7 @@ status_t SurfaceFlinger::getDisplayConfigs(const sp<IBinder>& display,
        info.secure = true;

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

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

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

    DisplayRenderArea renderArea(device, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
@@ -5095,7 +5095,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 {
@@ -5107,10 +5107,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) {
        Transform tr;
        uint32_t flags = 0x00;
        switch (mPrimaryDisplayOrientation) {
        switch (primaryDisplayOrientation) {
            case DisplayState::eOrientation90:
                flags = Transform::ROT_90;
                break;
@@ -5133,12 +5133,12 @@ void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
    engine.checkErrors();

    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 = Transform::ROT_90;
                hw_flip_hv = Transform::ROT_180;
+2 −3
Original line number Diff line number Diff line
@@ -286,6 +286,8 @@ public:
    // want to support color management to disable color management.
    static bool hasWideColorDisplay;

    static int primaryDisplayOrientation;

    static char const* getServiceName() ANDROID_API {
        return "SurfaceFlinger";
    }
@@ -345,8 +347,6 @@ public:
    bool authenticateSurfaceTextureLocked(
        const sp<IGraphicBufferProducer>& bufferProducer) const;

    int getPrimaryDisplayOrientation() const { return mPrimaryDisplayOrientation; }

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

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

    auto& mutableHasWideColorDisplay() { return SurfaceFlinger::hasWideColorDisplay; }

    auto& mutablePrimaryDisplayOrientation() { return SurfaceFlinger::primaryDisplayOrientation; }
    auto& mutableBuiltinDisplays() { return mFlinger->mBuiltinDisplays; }
    auto& mutableCurrentState() { return mFlinger->mCurrentState; }
    auto& mutableDisplays() { return mFlinger->mDisplays; }