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

Commit b5a1abe7 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge changes If037270c,I120e89cc into udc-dev

* changes:
  [sf] input snapshot fixes
  [sf] use snapshots to update layer history
parents 7851dca9 40d02283
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -187,6 +187,10 @@ void LayerLifecycleManager::applyTransactions(const std::vector<TransactionState
                continue;
            }

            if (transaction.flags & ISurfaceComposer::eAnimation) {
                layer->changes |= RequestedLayerState::Changes::Animation;
            }

            uint32_t oldParentId = layer->parentId;
            uint32_t oldRelativeParentId = layer->relativeParentId;
            uint32_t oldTouchCropId = layer->touchCropId;
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    scheduler::LayerInfo::FrameRate frameRate;
    ui::Transform::RotationFlags fixedTransformHint;
    bool handleSkipScreenshotFlag = false;
    int32_t frameRateSelectionPriority;
    LayerHierarchy::TraversalPath mirrorRootPath;
    bool unreachable = true;
    ChildState childState;
+9 −5
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ void updateVisibility(LayerSnapshot& snapshot, bool visible) {
    // InputDispatcher, and obviously if they aren't visible they can't occlude
    // anything.
    const bool visibleForInput =
            (snapshot.inputInfo.token != nullptr) ? snapshot.canReceiveInput() : snapshot.isVisible;
            snapshot.hasInputInfo() ? snapshot.canReceiveInput() : snapshot.isVisible;
    snapshot.inputInfo.setInputConfig(gui::WindowInfo::InputConfig::NOT_VISIBLE, !visibleForInput);
}

@@ -773,6 +773,7 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
        snapshot.layerOpaqueFlagSet =
                (requested.flags & layer_state_t::eLayerOpaque) == layer_state_t::eLayerOpaque;
        snapshot.cachingHint = requested.cachingHint;
        snapshot.frameRateSelectionPriority = requested.frameRateSelectionPriority;
    }

    if (forceUpdate || snapshot.changes.any(RequestedLayerState::Changes::Content)) {
@@ -954,12 +955,13 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
        snapshot.inputInfo = *requested.windowInfoHandle->getInfo();
    } else {
        snapshot.inputInfo = {};
    }

        // b/271132344 revisit this and see if we can always use the layers uid/pid
        snapshot.inputInfo.name = requested.name;
    snapshot.inputInfo.id = static_cast<int32_t>(snapshot.uniqueSequence);
        snapshot.inputInfo.ownerUid = static_cast<int32_t>(requested.ownerUid);
        snapshot.inputInfo.ownerPid = requested.ownerPid;
    }

    snapshot.inputInfo.id = static_cast<int32_t>(snapshot.uniqueSequence);
    snapshot.inputInfo.displayId = static_cast<int32_t>(snapshot.outputFilter.layerStack.id);
    if (!needsInputInfo(snapshot, requested)) {
        return;
@@ -983,7 +985,9 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
    }

    snapshot.inputInfo.alpha = snapshot.color.a;
    snapshot.inputInfo.touchOcclusionMode = parentSnapshot.inputInfo.touchOcclusionMode;
    snapshot.inputInfo.touchOcclusionMode = requested.hasInputInfo()
            ? requested.windowInfoHandle->getInfo()->touchOcclusionMode
            : parentSnapshot.inputInfo.touchOcclusionMode;
    if (requested.dropInputMode == gui::DropInputMode::ALL ||
        parentSnapshot.dropInputMode == gui::DropInputMode::ALL) {
        snapshot.dropInputMode = gui::DropInputMode::ALL;
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ struct RequestedLayerState : layer_state_t {
        VisibleRegion = 1u << 14,
        Buffer = 1u << 15,
        SidebandStream = 1u << 16,
        Animation = 1u << 17,
    };
    static Rect reduce(const Rect& win, const Region& exclude);
    RequestedLayerState(const LayerCreationArgs&);
+47 −18
Original line number Diff line number Diff line
@@ -1257,7 +1257,7 @@ bool Layer::propagateFrameRateForLayerTree(FrameRate parentFrameRate, bool* tran
        return parentFrameRate;
    }();

    *transactionNeeded |= setFrameRateForLayerTree(frameRate);
    *transactionNeeded |= setFrameRateForLayerTreeLegacy(frameRate);

    // The frame rate is propagated to the children
    bool childrenHaveFrameRate = false;
@@ -1271,7 +1271,7 @@ bool Layer::propagateFrameRateForLayerTree(FrameRate parentFrameRate, bool* tran
    if (!frameRate.rate.isValid() && frameRate.type != FrameRateCompatibility::NoVote &&
        childrenHaveFrameRate) {
        *transactionNeeded |=
                setFrameRateForLayerTree(FrameRate(Fps(), FrameRateCompatibility::NoVote));
                setFrameRateForLayerTreeLegacy(FrameRate(Fps(), FrameRateCompatibility::NoVote));
    }

    // We return whether this layer ot its children has a vote. We ignore ExactOrMultiple votes for
@@ -1423,7 +1423,7 @@ std::shared_ptr<frametimeline::SurfaceFrame> Layer::createSurfaceFrameForBuffer(
    return surfaceFrame;
}

bool Layer::setFrameRateForLayerTree(FrameRate frameRate) {
bool Layer::setFrameRateForLayerTreeLegacy(FrameRate frameRate) {
    if (mDrawingState.frameRateForLayerTree == frameRate) {
        return false;
    }
@@ -1436,9 +1436,21 @@ bool Layer::setFrameRateForLayerTree(FrameRate frameRate) {
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);

    using LayerUpdateType = scheduler::LayerHistory::LayerUpdateType;
    mFlinger->mScheduler->recordLayerHistory(this, systemTime(), LayerUpdateType::SetFrameRate);
    mFlinger->mScheduler
            ->recordLayerHistory(sequence, getLayerProps(), systemTime(),
                                 scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
    return true;
}

bool Layer::setFrameRateForLayerTree(FrameRate frameRate, const scheduler::LayerProps& layerProps) {
    if (mDrawingState.frameRateForLayerTree == frameRate) {
        return false;
    }

    mDrawingState.frameRateForLayerTree = frameRate;
    mFlinger->mScheduler
            ->recordLayerHistory(sequence, layerProps, systemTime(),
                                 scheduler::LayerHistory::LayerUpdateType::SetFrameRate);
    return true;
}

@@ -3064,7 +3076,7 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    } else {
        mCallbackHandleAcquireTimeOrFence = mDrawingState.acquireFenceTime->getSignalTime();
    }

    mDrawingState.latchedVsyncId = info.vsyncId;
    mDrawingState.modified = true;
    setTransactionFlags(eTransactionNeeded);

@@ -3074,18 +3086,9 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    mDrawingState.desiredPresentTime = desiredPresentTime;
    mDrawingState.isAutoTimestamp = isAutoTimestamp;

    const nsecs_t presentTime = [&] {
        if (!isAutoTimestamp) return desiredPresentTime;

        const auto prediction =
                mFlinger->mFrameTimeline->getTokenManager()->getPredictionsForToken(info.vsyncId);
        if (prediction.has_value()) return prediction->presentTime;

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

    using LayerUpdateType = scheduler::LayerHistory::LayerUpdateType;
    mFlinger->mScheduler->recordLayerHistory(this, presentTime, LayerUpdateType::Buffer);
    if (mFlinger->mLegacyFrontEndEnabled) {
        recordLayerHistoryBufferUpdate(getLayerProps());
    }

    setFrameTimelineVsyncForBufferTransaction(info, postTime);

@@ -3102,6 +3105,32 @@ bool Layer::setBuffer(std::shared_ptr<renderengine::ExternalTexture>& buffer,
    return true;
}

void Layer::setDesiredPresentTime(nsecs_t desiredPresentTime, bool isAutoTimestamp) {
    mDrawingState.desiredPresentTime = desiredPresentTime;
    mDrawingState.isAutoTimestamp = isAutoTimestamp;
}

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

        const auto prediction = mFlinger->mFrameTimeline->getTokenManager()->getPredictionsForToken(
                mDrawingState.latchedVsyncId);
        if (prediction.has_value()) return prediction->presentTime;

        return static_cast<nsecs_t>(0);
    }();
    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
                                             scheduler::LayerHistory::LayerUpdateType::Buffer);
}

void Layer::recordLayerHistoryAnimationTx(const scheduler::LayerProps& layerProps) {
    const nsecs_t presentTime =
            mDrawingState.isAutoTimestamp ? 0 : mDrawingState.desiredPresentTime;
    mFlinger->mScheduler->recordLayerHistory(sequence, layerProps, presentTime,
                                             scheduler::LayerHistory::LayerUpdateType::AnimationTX);
}

bool Layer::setDataspace(ui::Dataspace dataspace) {
    mDrawingState.dataspaceRequested = true;
    if (mDrawingState.dataspace == dataspace) return false;
Loading