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

Commit 14e54ba7 authored by Dan Stoza's avatar Dan Stoza
Browse files

SF: Remove forced transaction on screenshot

Removes the forced transaction that screenshots used to perform
before capturing the screen. This was initially added to prevent
screenshot capture from sneaking in between when a transaction is
closed and when it is actually applied (at the next vsync), but in
the presence of deferred transactions today, forcing a transaction
to occur doesn't guarantee that the last transaction that
WindowManager pushed has actually been committed yet, since it may be
waiting for a buffer with which to synchronize.

If WindowManager wants to guarantee some arrangement of windows is
present for a screenshot, it needs to set the synchronous flag to
true when calling closeGlobalTransaction and wait for the call to
return.

Bug: 27098060
Change-Id: Iaa36d76df521076cc8ed16576f651543bae419a8
parent 853f8f9c
Loading
Loading
Loading
Loading
+0 −14
Original line number Original line Diff line number Diff line
@@ -61,12 +61,6 @@ void MessageQueue::Handler::dispatchInvalidate() {
    }
    }
}
}


void MessageQueue::Handler::dispatchTransaction() {
    if ((android_atomic_or(eventMaskTransaction, &mEventMask) & eventMaskTransaction) == 0) {
        mQueue.mLooper->sendMessage(this, Message(MessageQueue::TRANSACTION));
    }
}

void MessageQueue::Handler::handleMessage(const Message& message) {
void MessageQueue::Handler::handleMessage(const Message& message) {
    switch (message.what) {
    switch (message.what) {
        case INVALIDATE:
        case INVALIDATE:
@@ -77,10 +71,6 @@ void MessageQueue::Handler::handleMessage(const Message& message) {
            android_atomic_and(~eventMaskRefresh, &mEventMask);
            android_atomic_and(~eventMaskRefresh, &mEventMask);
            mQueue.mFlinger->onMessageReceived(message.what);
            mQueue.mFlinger->onMessageReceived(message.what);
            break;
            break;
        case TRANSACTION:
            android_atomic_and(~eventMaskTransaction, &mEventMask);
            mQueue.mFlinger->onMessageReceived(message.what);
            break;
    }
    }
}
}


@@ -155,10 +145,6 @@ status_t MessageQueue::postMessage(
 */
 */
#define INVALIDATE_ON_VSYNC 1
#define INVALIDATE_ON_VSYNC 1


void MessageQueue::invalidateTransactionNow() {
    mHandler->dispatchTransaction();
}

void MessageQueue::invalidate() {
void MessageQueue::invalidate() {
#if INVALIDATE_ON_VSYNC
#if INVALIDATE_ON_VSYNC
    mEvents->requestNextVsync();
    mEvents->requestNextVsync();
+0 −4
Original line number Original line Diff line number Diff line
@@ -73,7 +73,6 @@ class MessageQueue {
        virtual void handleMessage(const Message& message);
        virtual void handleMessage(const Message& message);
        void dispatchRefresh();
        void dispatchRefresh();
        void dispatchInvalidate();
        void dispatchInvalidate();
        void dispatchTransaction();
    };
    };


    friend class Handler;
    friend class Handler;
@@ -93,7 +92,6 @@ public:
    enum {
    enum {
        INVALIDATE  = 0,
        INVALIDATE  = 0,
        REFRESH     = 1,
        REFRESH     = 1,
        TRANSACTION = 2
    };
    };


    MessageQueue();
    MessageQueue();
@@ -108,8 +106,6 @@ public:
    void invalidate();
    void invalidate();
    // sends REFRESH message at next VSYNC
    // sends REFRESH message at next VSYNC
    void refresh();
    void refresh();
    // sends TRANSACTION message immediately
    void invalidateTransactionNow();
};
};


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
+0 −11
Original line number Original line Diff line number Diff line
@@ -903,10 +903,6 @@ void SurfaceFlinger::setVsyncEnabled(int disp, int enabled) {
void SurfaceFlinger::onMessageReceived(int32_t what) {
void SurfaceFlinger::onMessageReceived(int32_t what) {
    ATRACE_CALL();
    ATRACE_CALL();
    switch (what) {
    switch (what) {
        case MessageQueue::TRANSACTION: {
            handleMessageTransaction();
            break;
        }
        case MessageQueue::INVALIDATE: {
        case MessageQueue::INVALIDATE: {
            bool refreshNeeded = handleMessageTransaction();
            bool refreshNeeded = handleMessageTransaction();
            refreshNeeded |= handleMessageInvalidate();
            refreshNeeded |= handleMessageInvalidate();
@@ -3274,13 +3270,6 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
        }
        }
    };
    };


    // make sure to process transactions before screenshots -- a transaction
    // might already be pending but scheduled for VSYNC; this guarantees we
    // will handle it before the screenshot. When VSYNC finally arrives
    // the scheduled transaction will be a no-op. If no transactions are
    // scheduled at this time, this will end-up being a no-op as well.
    mEventQueue.invalidateTransactionNow();

    // this creates a "fake" BBinder which will serve as a "fake" remote
    // this creates a "fake" BBinder which will serve as a "fake" remote
    // binder to receive the marshaled calls and forward them to the
    // binder to receive the marshaled calls and forward them to the
    // real remote (a BpGraphicBufferProducer)
    // real remote (a BpGraphicBufferProducer)
+0 −11
Original line number Original line Diff line number Diff line
@@ -907,10 +907,6 @@ void SurfaceFlinger::eventControl(int disp, int event, int enabled) {
void SurfaceFlinger::onMessageReceived(int32_t what) {
void SurfaceFlinger::onMessageReceived(int32_t what) {
    ATRACE_CALL();
    ATRACE_CALL();
    switch (what) {
    switch (what) {
        case MessageQueue::TRANSACTION: {
            handleMessageTransaction();
            break;
        }
        case MessageQueue::INVALIDATE: {
        case MessageQueue::INVALIDATE: {
            bool refreshNeeded = handleMessageTransaction();
            bool refreshNeeded = handleMessageTransaction();
            refreshNeeded |= handleMessageInvalidate();
            refreshNeeded |= handleMessageInvalidate();
@@ -3297,13 +3293,6 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
        }
        }
    };
    };


    // make sure to process transactions before screenshots -- a transaction
    // might already be pending but scheduled for VSYNC; this guarantees we
    // will handle it before the screenshot. When VSYNC finally arrives
    // the scheduled transaction will be a no-op. If no transactions are
    // scheduled at this time, this will end-up being a no-op as well.
    mEventQueue.invalidateTransactionNow();

    // this creates a "fake" BBinder which will serve as a "fake" remote
    // this creates a "fake" BBinder which will serve as a "fake" remote
    // binder to receive the marshaled calls and forward them to the
    // binder to receive the marshaled calls and forward them to the
    // real remote (a BpGraphicBufferProducer)
    // real remote (a BpGraphicBufferProducer)