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

Commit 10f53def authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "SF: use TextureView hint when selecting the refresh rate" into udc-dev...

Merge "SF: use TextureView hint when selecting the refresh rate" into udc-dev am: 8b0d097a am: c594886e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23118717



Change-Id: I8e95c661f8d421d3ef786f1cad893e4e9ff3840a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 795e0b1d c594886e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1871,12 +1871,14 @@ int Surface::dispatchSetFrameTimelineInfo(va_list args) {
    auto frameTimelineVsyncId = static_cast<int64_t>(va_arg(args, int64_t));
    auto inputEventId = static_cast<int32_t>(va_arg(args, int32_t));
    auto startTimeNanos = static_cast<int64_t>(va_arg(args, int64_t));
    auto useForRefreshRateSelection = static_cast<bool>(va_arg(args, int32_t));

    ALOGV("Surface::%s", __func__);
    FrameTimelineInfo ftlInfo;
    ftlInfo.vsyncId = frameTimelineVsyncId;
    ftlInfo.inputEventId = inputEventId;
    ftlInfo.startTimeNanos = startTimeNanos;
    ftlInfo.useForRefreshRateSelection = useForRefreshRateSelection;
    return setFrameTimelineInfo(frameNumber, ftlInfo);
}

+3 −0
Original line number Diff line number Diff line
@@ -2245,11 +2245,13 @@ void SurfaceComposerClient::Transaction::mergeFrameTimelineInfo(FrameTimelineInf
            t.vsyncId = other.vsyncId;
            t.inputEventId = other.inputEventId;
            t.startTimeNanos = other.startTimeNanos;
            t.useForRefreshRateSelection = other.useForRefreshRateSelection;
        }
    } else if (t.vsyncId == FrameTimelineInfo::INVALID_VSYNC_ID) {
        t.vsyncId = other.vsyncId;
        t.inputEventId = other.inputEventId;
        t.startTimeNanos = other.startTimeNanos;
        t.useForRefreshRateSelection = other.useForRefreshRateSelection;
    }
}

@@ -2258,6 +2260,7 @@ void SurfaceComposerClient::Transaction::clearFrameTimelineInfo(FrameTimelineInf
    t.vsyncId = FrameTimelineInfo::INVALID_VSYNC_ID;
    t.inputEventId = os::IInputConstants::INVALID_INPUT_EVENT_ID;
    t.startTimeNanos = 0;
    t.useForRefreshRateSelection = false;
}

SurfaceComposerClient::Transaction&
+4 −0
Original line number Diff line number Diff line
@@ -33,4 +33,8 @@ parcelable FrameTimelineInfo {

    // The current time in nanoseconds the application started to render the frame.
    long startTimeNanos = 0;

    // Whether this vsyncId should be used to heuristically select the display refresh rate
    // TODO(b/281695725): Clean this up once TextureView use setFrameRate API
    boolean useForRefreshRateSelection = false;
}
+5 −6
Original line number Diff line number Diff line
@@ -1066,13 +1066,12 @@ static inline int native_window_set_frame_rate(struct ANativeWindow* window, flo
                           (int)compatibility, (int)changeFrameRateStrategy);
}

static inline int native_window_set_frame_timeline_info(struct ANativeWindow* window,
                                                        uint64_t frameNumber,
                                                        int64_t frameTimelineVsyncId,
                                                        int32_t inputEventId,
                                                        int64_t startTimeNanos) {
static inline int native_window_set_frame_timeline_info(
        struct ANativeWindow* window, uint64_t frameNumber, int64_t frameTimelineVsyncId,
        int32_t inputEventId, int64_t startTimeNanos, int32_t useForRefreshRateSelection) {
    return window->perform(window, NATIVE_WINDOW_SET_FRAME_TIMELINE_INFO, frameNumber,
                           frameTimelineVsyncId, inputEventId, startTimeNanos);
                           frameTimelineVsyncId, inputEventId, startTimeNanos,
                           useForRefreshRateSelection);
}

// ------------------------------------------------------------------------------------------------
+21 −4
Original line number Diff line number Diff line
@@ -3077,6 +3077,7 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    mDrawingState.desiredPresentTime = desiredPresentTime;
    mDrawingState.isAutoTimestamp = isAutoTimestamp;
    mDrawingState.latchedVsyncId = info.vsyncId;
    mDrawingState.useVsyncIdForRefreshRateSelection = info.useForRefreshRateSelection;
    mDrawingState.modified = true;
    if (!buffer) {
        resetDrawingStateBufferInfo();
@@ -3139,15 +3140,31 @@ void Layer::setDesiredPresentTime(nsecs_t desiredPresentTime, bool isAutoTimesta
}

void Layer::recordLayerHistoryBufferUpdate(const scheduler::LayerProps& layerProps) {
    ATRACE_CALL();
    const nsecs_t presentTime = [&] {
        if (!mDrawingState.isAutoTimestamp) return mDrawingState.desiredPresentTime;
        if (!mDrawingState.isAutoTimestamp) {
            ATRACE_FORMAT_INSTANT("desiredPresentTime");
            return mDrawingState.desiredPresentTime;
        }

        const auto prediction = mFlinger->mFrameTimeline->getTokenManager()->getPredictionsForToken(
        if (mDrawingState.useVsyncIdForRefreshRateSelection) {
            const auto prediction =
                    mFlinger->mFrameTimeline->getTokenManager()->getPredictionsForToken(
                            mDrawingState.latchedVsyncId);
        if (prediction.has_value()) return prediction->presentTime;
            if (prediction.has_value()) {
                ATRACE_FORMAT_INSTANT("predictedPresentTime");
                return prediction->presentTime;
            }
        }

        return static_cast<nsecs_t>(0);
    }();

    if (ATRACE_ENABLED() && presentTime > 0) {
        const auto presentIn = TimePoint::fromNs(presentTime) - TimePoint::now();
        ATRACE_FORMAT_INSTANT("presentIn %s", to_string(presentIn).c_str());
    }

    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
                                             scheduler::LayerHistory::LayerUpdateType::Buffer);
}
Loading