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

Commit 84a794e0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Idd883e15,I9e13e04f

* changes:
  Re-enable default display when switching to VR mode.
  Add LambdaMessage to SurfaceFlinger
parents 53d285dd 933ed5ce
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@

#include "Barrier.h"

#include <functional>

namespace android {

class IDisplayEventConnection;
@@ -58,6 +60,21 @@ private:
    mutable Barrier barrier;
};

class LambdaMessage : public MessageBase {
public:
    explicit LambdaMessage(std::function<void()> handler)
          : MessageBase(), mHandler(std::move(handler)) {}

    bool handler() override {
        mHandler();
        // This return value is no longer checked, so it's always safe to return true
        return true;
    }

private:
    const std::function<void()> mHandler;
};

// ---------------------------------------------------------------------------

class MessageQueue {
+15 −5
Original line number Diff line number Diff line
@@ -1323,11 +1323,21 @@ void SurfaceFlinger::updateVrFlinger() {
    // parts of this class rely on the primary display always being available.
    createDefaultDisplayDevice();

    // Re-enable default display.
    sp<LambdaMessage> requestMessage = new LambdaMessage([&]() {
        sp<DisplayDevice> hw(getDisplayDevice(mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]));
        setPowerModeInternal(hw, HWC_POWER_MODE_NORMAL);

        // Reset the timing values to account for the period of the swapped in HWC
        const auto& activeConfig = mHwc->getActiveConfig(HWC_DISPLAY_PRIMARY);
        const nsecs_t period = activeConfig->getVsyncPeriod();
        mAnimFrameTracker.setDisplayRefreshPeriod(period);

        // Use phase of 0 since phase is not known.
        // Use latency of 0, which will snap to the ideal latency.
        setCompositorTimingSnapped(0, period, 0);
    });
    postMessageAsync(requestMessage);

    android_atomic_or(1, &mRepaintEverything);
    setTransactionFlags(eDisplayTransactionNeeded);