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

Commit 341ef1b0 authored by Dan Stoza's avatar Dan Stoza Committed by Automerger Merge Worker
Browse files

Merge changes Iefa0e017,I79cc96c6,I14e31679,Ie490113e into rvc-dev am: b0c9b69e

Change-Id: I09bca026a70151049bc002036e6aa7f199548a42
parents c7083678 b0c9b69e
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -306,6 +306,10 @@ void Region::addRectUnchecked(int l, int t, int r, int b)
// ----------------------------------------------------------------------------

Region& Region::orSelf(const Rect& r) {
    if (isEmpty()) {
        set(r);
        return *this;
    }
    return operationSelf(r, op_or);
}
Region& Region::xorSelf(const Rect& r) {
@@ -326,6 +330,10 @@ Region& Region::operationSelf(const Rect& r, uint32_t op) {
// ----------------------------------------------------------------------------

Region& Region::orSelf(const Region& rhs) {
    if (isEmpty()) {
        *this = rhs;
        return *this;
    }
    return operationSelf(rhs, op_or);
}
Region& Region::xorSelf(const Region& rhs) {
+167 −165
Original line number Diff line number Diff line
@@ -1782,11 +1782,10 @@ bool SurfaceFlinger::previousFramePending(int graceTimeMs) NO_THREAD_SAFETY_ANAL
        return false;
    }

    if (graceTimeMs > 0 && fence->getStatus() == Fence::Status::Unsignaled) {
        fence->wait(graceTimeMs);
    }

    return (fence->getStatus() == Fence::Status::Unsignaled);
    const status_t status = fence->wait(graceTimeMs);
    // This is the same as Fence::Status::Unsignaled, but it saves a getStatus() call,
    // which calls wait(0) again internally
    return status == -ETIME;
}

nsecs_t SurfaceFlinger::previousFramePresentTime() NO_THREAD_SAFETY_ANALYSIS {
@@ -1812,6 +1811,19 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    ATRACE_CALL();
    switch (what) {
        case MessageQueue::INVALIDATE: {
            onMessageInvalidate(expectedVSyncTime);
            break;
        }
        case MessageQueue::REFRESH: {
            onMessageRefresh();
            break;
        }
    }
}

void SurfaceFlinger::onMessageInvalidate(nsecs_t expectedVSyncTime) NO_THREAD_SAFETY_ANALYSIS {
    ATRACE_CALL();

    const nsecs_t frameStart = systemTime();
    // calculate the expected present time once and use the cached
    // value throughout this frame to make sure all layers are
@@ -1830,8 +1842,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what,

    // Pending frames may trigger backpressure propagation.
    const TracedOrdinal<bool> framePending = {"PrevFramePending",
                                                      previousFramePending(
                                                              graceTimeForPresentFenceMs)};
                                              previousFramePending(graceTimeForPresentFenceMs)};

    // Frame missed counts for metrics tracking.
    // A frame is missed if the prior frame is still pending. If no longer pending,
@@ -1845,11 +1856,11 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    mScheduler->getDisplayStatInfo(&stats);
    const nsecs_t frameMissedSlop = stats.vsyncPeriod / 2;
    const nsecs_t previousPresentTime = previousFramePresentTime();
            const TracedOrdinal<bool> frameMissed =
                    {"PrevFrameMissed",
    const TracedOrdinal<bool> frameMissed = {"PrevFrameMissed",
                                             framePending ||
                                                     (previousPresentTime >= 0 &&
                              (lastExpectedPresentTime < previousPresentTime - frameMissedSlop))};
                                                      (lastExpectedPresentTime <
                                                       previousPresentTime - frameMissedSlop))};
    const TracedOrdinal<bool> hwcFrameMissed = {"PrevHwcFrameMissed",
                                                mHadDeviceComposition && frameMissed};
    const TracedOrdinal<bool> gpuFrameMissed = {"PrevGpuFrameMissed",
@@ -1877,7 +1888,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    if (mSetActiveConfigPending) {
        if (framePending) {
            mEventQueue->invalidate();
                    break;
            return;
        }

        // We received the present fence from the HWC, so we assume it successfully updated
@@ -1887,10 +1898,9 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
    }

    if (framePending && mPropagateBackpressure) {
                if ((hwcFrameMissed && !gpuFrameMissed) ||
                    mPropagateBackpressureClientComposition) {
        if ((hwcFrameMissed && !gpuFrameMissed) || mPropagateBackpressureClientComposition) {
            signalLayerUpdate();
                    break;
            return;
        }
    }

@@ -1981,13 +1991,6 @@ void SurfaceFlinger::onMessageReceived(int32_t what,
        }
        signalRefresh();
    }
            break;
        }
        case MessageQueue::REFRESH: {
            handleMessageRefresh();
            break;
        }
    }
}

bool SurfaceFlinger::handleMessageTransaction() {
@@ -2012,7 +2015,7 @@ bool SurfaceFlinger::handleMessageTransaction() {
    return runHandleTransaction;
}

void SurfaceFlinger::handleMessageRefresh() {
void SurfaceFlinger::onMessageRefresh() {
    ATRACE_CALL();

    mRefreshPending = false;
@@ -2110,7 +2113,6 @@ void SurfaceFlinger::handleMessageRefresh() {
    }
}


bool SurfaceFlinger::handleMessageInvalidate() {
    ATRACE_CALL();
    bool refreshNeeded = handlePageFlip();
+8 −2
Original line number Diff line number Diff line
@@ -580,14 +580,20 @@ private:
            const std::optional<scheduler::RefreshRateConfigs::Policy>& policy, bool overridePolicy)
            EXCLUDES(mStateLock);

    // Handle the INVALIDATE message queue event, latching new buffers and applying
    // incoming transactions
    void onMessageInvalidate(nsecs_t expectedVSyncTime);

    // Returns whether the transaction actually modified any state
    bool handleMessageTransaction();

    // Handle the REFRESH message queue event, sending the current frame down to RenderEngine and
    // the Composer HAL for presentation
    void onMessageRefresh();

    // Returns whether a new buffer has been latched (see handlePageFlip())
    bool handleMessageInvalidate();

    void handleMessageRefresh();

    void handleTransaction(uint32_t transactionFlags);
    void handleTransactionLocked(uint32_t transactionFlags) REQUIRES(mStateLock);

+16 −4
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

#pragma once
#include <android-base/stringprintf.h>
#include <cutils/compiler.h>
#include <utils/Trace.h>
#include <cmath>
#include <string>

namespace android {

template <typename T>
class TracedOrdinal {
public:
@@ -27,9 +30,8 @@ public:
                  "Type is not supported. Please test it with systrace before adding "
                  "it to the list.");

    TracedOrdinal(const std::string& name, T initialValue)
          : mName(name),
            mNameNegative(android::base::StringPrintf("%sNegative", name.c_str())),
    TracedOrdinal(std::string name, T initialValue)
          : mName(std::move(name)),
            mHasGoneNegative(std::signbit(initialValue)),
            mData(initialValue) {
        trace();
@@ -46,6 +48,14 @@ public:

private:
    void trace() {
        if (CC_LIKELY(!ATRACE_ENABLED())) {
            return;
        }

        if (mNameNegative.empty()) {
            mNameNegative = base::StringPrintf("%sNegative", mName.c_str());
        }

        if (!std::signbit(mData)) {
            ATRACE_INT64(mName.c_str(), int64_t(mData));
            if (mHasGoneNegative) {
@@ -58,7 +68,9 @@ private:
    }

    const std::string mName;
    const std::string mNameNegative;
    std::string mNameNegative;
    bool mHasGoneNegative;
    T mData;
};

} // namespace android