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

Commit 9ed43398 authored by Arthur Hung's avatar Arthur Hung
Browse files

Reduce setInputWindows call (1/2)

The cursor surface and hotspot surface would cause the visible region
dirty when moving on the screen. That would also cause SF update the
input infos to InputFlinger.

To reduce unecessary updating, add more checking for same value and
ignore updating if just the cursor moving.

Test: enable setInputWindow log, connect a mouse device and move.
Bug: 133780957
Change-Id: I099c1175e291adccfafce49536acfdfb38c40371
parent 55b2c0b5
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -732,6 +732,10 @@ uint32_t Layer::doTransaction(uint32_t flags) {
        mNeedsFiltering = getActiveTransform(s).needsBilinearFiltering();
    }

    if (!mPotentialCursor && (flags & Layer::eVisibleRegion)) {
        mFlinger->mUpdateInputInfo = true;
    }

    commitTransaction(mDrawingState);

    return flags;
@@ -882,7 +886,7 @@ bool Layer::setTrustedOverlay(bool isTrustedOverlay) {
    if (mDrawingState.isTrustedOverlay == isTrustedOverlay) return false;
    mDrawingState.isTrustedOverlay = isTrustedOverlay;
    mDrawingState.modified = true;
    mFlinger->mInputInfoChanged = true;
    mFlinger->mUpdateInputInfo = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
}
@@ -979,6 +983,13 @@ bool Layer::setBackgroundBlurRadius(int backgroundBlurRadius) {
    return true;
}
bool Layer::setMatrix(const layer_state_t::matrix22_t& matrix) {
    if (matrix.dsdx == mDrawingState.transform.dsdx() &&
        matrix.dtdy == mDrawingState.transform.dtdy() &&
        matrix.dtdx == mDrawingState.transform.dtdx() &&
        matrix.dsdy == mDrawingState.transform.dsdy()) {
        return false;
    }

    ui::Transform t;
    t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);

@@ -2051,7 +2062,7 @@ void Layer::setInputInfo(const WindowInfo& info) {
    mDrawingState.inputInfo = info;
    mDrawingState.touchableRegionCrop = fromHandle(info.touchableRegionCropHandle.promote());
    mDrawingState.modified = true;
    mFlinger->mInputInfoChanged = true;
    mFlinger->mUpdateInputInfo = true;
    setTransactionFlags(eTransactionNeeded);
}

+9 −5
Original line number Diff line number Diff line
@@ -3115,6 +3115,7 @@ void SurfaceFlinger::processDisplayChangesLocked() {
    const KeyedVector<wp<IBinder>, DisplayDeviceState>& draw(mDrawingState.displays);
    if (!curr.isIdenticalTo(draw)) {
        mVisibleRegionsDirty = true;
        mUpdateInputInfo = true;

        // find the displays that were removed
        // (ie: in drawing state but not in current state)
@@ -3159,6 +3160,7 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
    if (mSomeChildrenChanged) {
        mVisibleRegionsDirty = true;
        mSomeChildrenChanged = false;
        mUpdateInputInfo = true;
    }

    // Update transform hint.
@@ -3222,6 +3224,7 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
        mLayersAdded = false;
        // Layers have been added.
        mVisibleRegionsDirty = true;
        mUpdateInputInfo = true;
    }

    // some layers might have been removed, so
@@ -3229,6 +3232,7 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) {
    if (mLayersRemoved) {
        mLayersRemoved = false;
        mVisibleRegionsDirty = true;
        mUpdateInputInfo = true;
        mDrawingState.traverseInZOrder([&](Layer* layer) {
            if (mLayersPendingRemoval.indexOf(layer) >= 0) {
                // this layer is not visible anymore
@@ -3253,14 +3257,14 @@ void SurfaceFlinger::updateInputFlinger() {
    std::vector<WindowInfo> windowInfos;
    std::vector<DisplayInfo> displayInfos;
    bool updateWindowInfo = false;
    if (mVisibleRegionsDirty || mInputInfoChanged) {
        mInputInfoChanged = false;
    if (mUpdateInputInfo) {
        mUpdateInputInfo = false;
        updateWindowInfo = true;
        buildWindowInfos(windowInfos, displayInfos);
    }
    if (!updateWindowInfo && mInputWindowCommands.empty()) {
    } else if (mInputWindowCommands.empty()) {
        return;
    }

    BackgroundExecutor::getInstance().sendCallbacks({[updateWindowInfo,
                                                      windowInfos = std::move(windowInfos),
                                                      displayInfos = std::move(displayInfos),
@@ -4609,7 +4613,7 @@ uint32_t SurfaceFlinger::setClientStateLocked(const FrameTimelineInfo& frameTime
    if (what & layer_state_t::eDropInputModeChanged) {
        if (layer->setDropInputMode(s.dropInputMode)) {
            flags |= eTraversalNeeded;
            mInputInfoChanged = true;
            mUpdateInputInfo = true;
        }
    }
    // This has to happen after we reparent children because when we reparent to null we remove
+1 −1
Original line number Diff line number Diff line
@@ -1203,7 +1203,7 @@ private:
    // Set during transaction application stage to track if the input info or children
    // for a layer has changed.
    // TODO: Also move visibleRegions over to a boolean system.
    bool mInputInfoChanged = false;
    bool mUpdateInputInfo = false;
    bool mSomeChildrenChanged;
    bool mSomeDataspaceChanged = false;
    bool mForceTransactionDisplayChange = false;