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

Commit 0bfc4046 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12385180 from 322fb3b7 to 24Q4-release

Change-Id: I082f60ec03cd648696bbca0095ec4cacddcff69c
parents 13355431 322fb3b7
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ struct Resampler {
    virtual ~Resampler() = default;

    /**
     * Tries to resample motionEvent at resampleTime. The provided resampleTime must be greater than
     * Tries to resample motionEvent at frameTime. The provided frameTime must be greater than
     * the latest sample time of motionEvent. It is not guaranteed that resampling occurs at
     * resampleTime. Interpolation may occur is futureSample is available. Otherwise, motionEvent
     * frameTime. Interpolation may occur is futureSample is available. Otherwise, motionEvent
     * may be resampled by another method, or not resampled at all. Furthermore, it is the
     * implementer's responsibility to guarantee the following:
     * - If resampling occurs, a single additional sample should be added to motionEvent. That is,
@@ -45,15 +45,14 @@ struct Resampler {
     * samples by the end of the resampling. No other field of motionEvent should be modified.
     * - If resampling does not occur, then motionEvent must not be modified in any way.
     */
    virtual void resampleMotionEvent(std::chrono::nanoseconds resampleTime,
                                     MotionEvent& motionEvent,
    virtual void resampleMotionEvent(std::chrono::nanoseconds frameTime, MotionEvent& motionEvent,
                                     const InputMessage* futureSample) = 0;
};

class LegacyResampler final : public Resampler {
public:
    /**
     * Tries to resample `motionEvent` at `resampleTime` by adding a resampled sample at the end of
     * Tries to resample `motionEvent` at `frameTime` by adding a resampled sample at the end of
     * `motionEvent` with eventTime equal to `resampleTime` and pointer coordinates determined by
     * linear interpolation or linear extrapolation. An earlier `resampleTime` will be used if
     * extrapolation takes place and `resampleTime` is too far in the future. If `futureSample` is
@@ -61,7 +60,7 @@ public:
     * data, LegacyResampler will extrapolate. Otherwise, no resampling takes place and
     * `motionEvent` is unmodified.
     */
    void resampleMotionEvent(std::chrono::nanoseconds resampleTime, MotionEvent& motionEvent,
    void resampleMotionEvent(std::chrono::nanoseconds frameTime, MotionEvent& motionEvent,
                             const InputMessage* futureSample) override;

private:
+1 −1
Original line number Diff line number Diff line
@@ -137,9 +137,9 @@ TEST_F(LibbinderCacheTest, RemoveFromCacheOnServerDeath) {
    ASSERT_EQ(binder1, result);

    // Kill the server, this should remove from cache.
    foo.killServer(binder1);
    pid_t pid;
    ASSERT_EQ(OK, binder1->getDebugPid(&pid));
    foo.killServer(binder1);
    system(("kill -9 " + std::to_string(pid)).c_str());

    sp<IBinder> binder2 = sp<BBinder>::make();
+5 −0
Original line number Diff line number Diff line
@@ -1266,6 +1266,11 @@ void BLASTBufferQueue::setTransactionHangCallback(
    mTransactionHangCallback = std::move(callback);
}

void BLASTBufferQueue::setApplyToken(sp<IBinder> applyToken) {
    std::lock_guard _lock{mMutex};
    mApplyToken = std::move(applyToken);
}

#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BUFFER_RELEASE_CHANNEL)

BLASTBufferQueue::BufferReleaseReader::BufferReleaseReader(
+2 −2
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public:
     * indicates the reason for the hang.
     */
    void setTransactionHangCallback(std::function<void(const std::string&)> callback);

    void setApplyToken(sp<IBinder>);
    virtual ~BLASTBufferQueue();

    void onFirstRef() override;
@@ -272,7 +272,7 @@ private:

    // Queues up transactions using this token in SurfaceFlinger. This prevents queued up
    // transactions from other parts of the client from blocking this transaction.
    const sp<IBinder> mApplyToken GUARDED_BY(mMutex) = sp<BBinder>::make();
    sp<IBinder> mApplyToken GUARDED_BY(mMutex) = sp<BBinder>::make();

    // Guards access to mDequeueTimestamps since we cannot hold to mMutex in onFrameDequeued or
    // we will deadlock.
+67 −0
Original line number Diff line number Diff line
@@ -186,6 +186,10 @@ public:
        mBlastBufferQueueAdapter->mergeWithNextTransaction(merge, frameNumber);
    }

    void setApplyToken(sp<IBinder> applyToken) {
        mBlastBufferQueueAdapter->setApplyToken(std::move(applyToken));
    }

private:
    sp<TestBLASTBufferQueue> mBlastBufferQueueAdapter;
};
@@ -511,6 +515,69 @@ TEST_F(BLASTBufferQueueTest, TripleBuffering) {
    adapter.waitForCallbacks();
}

class WaitForCommittedCallback {
public:
    WaitForCommittedCallback() = default;
    ~WaitForCommittedCallback() = default;

    void wait() {
        std::unique_lock lock(mMutex);
        cv.wait(lock, [this] { return mCallbackReceived; });
    }

    void notify() {
        std::unique_lock lock(mMutex);
        mCallbackReceived = true;
        cv.notify_one();
        mCallbackReceivedTimeStamp = std::chrono::system_clock::now();
    }
    auto getCallback() {
        return [this](void* /* unused context */, nsecs_t /* latchTime */,
                      const sp<Fence>& /* presentFence */,
                      const std::vector<SurfaceControlStats>& /* stats */) { notify(); };
    }
    std::chrono::time_point<std::chrono::system_clock> mCallbackReceivedTimeStamp;

private:
    std::mutex mMutex;
    std::condition_variable cv;
    bool mCallbackReceived = false;
};

TEST_F(BLASTBufferQueueTest, setApplyToken) {
    sp<IBinder> applyToken = sp<BBinder>::make();
    WaitForCommittedCallback firstTransaction;
    WaitForCommittedCallback secondTransaction;
    {
        BLASTBufferQueueHelper adapter(mSurfaceControl, mDisplayWidth, mDisplayHeight);
        adapter.setApplyToken(applyToken);
        sp<IGraphicBufferProducer> igbProducer;
        setUpProducer(adapter, igbProducer);

        Transaction t;
        t.addTransactionCommittedCallback(firstTransaction.getCallback(), nullptr);
        adapter.mergeWithNextTransaction(&t, 1);
        queueBuffer(igbProducer, 127, 127, 127,
                    /*presentTimeDelay*/ std::chrono::nanoseconds(500ms).count());
    }
    {
        BLASTBufferQueueHelper adapter(mSurfaceControl, mDisplayWidth, mDisplayHeight);
        adapter.setApplyToken(applyToken);
        sp<IGraphicBufferProducer> igbProducer;
        setUpProducer(adapter, igbProducer);

        Transaction t;
        t.addTransactionCommittedCallback(secondTransaction.getCallback(), nullptr);
        adapter.mergeWithNextTransaction(&t, 1);
        queueBuffer(igbProducer, 127, 127, 127, /*presentTimeDelay*/ 0);
    }

    firstTransaction.wait();
    secondTransaction.wait();
    EXPECT_GT(secondTransaction.mCallbackReceivedTimeStamp,
              firstTransaction.mCallbackReceivedTimeStamp);
}

TEST_F(BLASTBufferQueueTest, SetCrop_Item) {
    uint8_t r = 255;
    uint8_t g = 0;
Loading