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

Commit 6010c245 authored by Anton Ivanov's avatar Anton Ivanov
Browse files

Full TransactionState.

Combine the Simple, Complex, and Mutable pieces into a single class.

Flag: EXEMPT refactor
Bug: 385156191
Test: presubmit

Change-Id: I731d0d29f2d919a0e430da2e2242214ddc9be9f8
parent b03b9812
Loading
Loading
Loading
Loading
+6 −16
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@
#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/LayerState.h>
#include <gui/LayerState.h>
#include <gui/SchedulingPolicy.h>
#include <gui/SchedulingPolicy.h>
#include <gui/SimpleTransactionState.h>
#include <gui/TransactionState.h>
#include <gui/TransactionState.h>
#include <private/gui/ParcelUtils.h>
#include <private/gui/ParcelUtils.h>
#include <stdint.h>
#include <stdint.h>
@@ -58,19 +57,14 @@ public:


    virtual ~BpSurfaceComposer();
    virtual ~BpSurfaceComposer();


    status_t setTransactionState(const SimpleTransactionState simpleState,
    status_t setTransactionState(TransactionState&& state, const sp<IBinder>& applyToken) override {
                                 const ComplexTransactionState& complexState,
                                 MutableTransactionState& mutableState,
                                 const sp<IBinder>& applyToken) override {
        Parcel data, reply;
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());


        SAFE_PARCEL(mutableState.writeToParcel, &data);
        SAFE_PARCEL(state.writeToParcel, &data);
        SAFE_PARCEL(simpleState.writeToParcel, &data);
        SAFE_PARCEL(complexState.writeToParcel, &data);
        SAFE_PARCEL(data.writeStrongBinder, applyToken);
        SAFE_PARCEL(data.writeStrongBinder, applyToken);


        if (simpleState.mFlags & ISurfaceComposer::eOneWay) {
        if (state.mFlags & ISurfaceComposer::eOneWay) {
            return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply,
            return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply,
                                      IBinder::FLAG_ONEWAY);
                                      IBinder::FLAG_ONEWAY);
        } else {
        } else {
@@ -93,17 +87,13 @@ status_t BnSurfaceComposer::onTransact(uint32_t code, const Parcel& data, Parcel
        case SET_TRANSACTION_STATE: {
        case SET_TRANSACTION_STATE: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            CHECK_INTERFACE(ISurfaceComposer, data, reply);


            MutableTransactionState mutableState;
            TransactionState state;
            SAFE_PARCEL(mutableState.readFromParcel, &data);
            SAFE_PARCEL(state.readFromParcel, &data);
            SimpleTransactionState simpleState;
            SAFE_PARCEL(simpleState.readFromParcel, &data);
            ComplexTransactionState complexState;
            SAFE_PARCEL(complexState.readFromParcel, &data);


            sp<IBinder> applyToken;
            sp<IBinder> applyToken;
            SAFE_PARCEL(data.readStrongBinder, &applyToken);
            SAFE_PARCEL(data.readStrongBinder, &applyToken);


            return setTransactionState(simpleState, complexState, mutableState, applyToken);
            return setTransactionState(std::move(state), applyToken);
        }
        }
        case GET_SCHEDULING_POLICY: {
        case GET_SCHEDULING_POLICY: {
            gui::SchedulingPolicy policy;
            gui::SchedulingPolicy policy;
+44 −62
Original line number Original line Diff line number Diff line
@@ -824,14 +824,12 @@ void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId) {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


SurfaceComposerClient::Transaction::Transaction() {
SurfaceComposerClient::Transaction::Transaction() {
    mSimpleState.mId = generateId();
    mState.mId = generateId();
    mTransactionCompletedListener = TransactionCompletedListener::getInstance();
    mTransactionCompletedListener = TransactionCompletedListener::getInstance();
}
}


SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
      : mSimpleState(other.mSimpleState),
      : mState(other.mState),
        mComplexState(other.mComplexState),
        mMutableState(other.mMutableState),
        mMayContainBuffer(other.mMayContainBuffer),
        mMayContainBuffer(other.mMayContainBuffer),
        mApplyToken(other.mApplyToken) {
        mApplyToken(other.mApplyToken) {
    mListenerCallbacks = other.mListenerCallbacks;
    mListenerCallbacks = other.mListenerCallbacks;
@@ -839,14 +837,15 @@ SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
}
}


void SurfaceComposerClient::Transaction::sanitize(int pid, int uid) {
void SurfaceComposerClient::Transaction::sanitize(int pid, int uid) {
    // TODO(b/356936695) move to TransactionState.
    uint32_t permissions = LayerStatePermissions::getTransactionPermissions(pid, uid);
    uint32_t permissions = LayerStatePermissions::getTransactionPermissions(pid, uid);
    for (auto& composerState : mMutableState.mComposerStates) {
    for (auto& composerState : mState.mComposerStates) {
        composerState.state.sanitize(permissions);
        composerState.state.sanitize(permissions);
    }
    }
    if (!mComplexState.mInputWindowCommands.empty() &&
    if (!mState.mInputWindowCommands.empty() &&
        (permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER) == 0) {
        (permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER) == 0) {
        ALOGE("Only privileged callers are allowed to send input commands.");
        ALOGE("Only privileged callers are allowed to send input commands.");
        mComplexState.mInputWindowCommands.clear();
        mState.mInputWindowCommands.clear();
    }
    }
}
}


@@ -860,12 +859,8 @@ SurfaceComposerClient::Transaction::createFromParcel(const Parcel* parcel) {
}
}


status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) {
status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel) {
    SimpleTransactionState simpleState;
    TransactionState state;
    SAFE_PARCEL(simpleState.readFromParcel, parcel);
    SAFE_PARCEL(state.readFromParcel, parcel);
    ComplexTransactionState complexState;
    SAFE_PARCEL(complexState.readFromParcel, parcel);
    MutableTransactionState mutableState;
    SAFE_PARCEL(mutableState.readFromParcel, parcel);
    const bool logCallPoints = parcel->readBool();
    const bool logCallPoints = parcel->readBool();


    sp<IBinder> applyToken;
    sp<IBinder> applyToken;
@@ -900,9 +895,7 @@ status_t SurfaceComposerClient::Transaction::readFromParcel(const Parcel* parcel
    }
    }


    // Parsing was successful. Update the object.
    // Parsing was successful. Update the object.
    mSimpleState = std::move(simpleState);
    mState = std::move(state);
    mComplexState = std::move(complexState);
    mMutableState = std::move(mutableState);
    mListenerCallbacks = listenerCallbacks;
    mListenerCallbacks = listenerCallbacks;
    mApplyToken = applyToken;
    mApplyToken = applyToken;
    return NO_ERROR;
    return NO_ERROR;
@@ -922,9 +915,7 @@ status_t SurfaceComposerClient::Transaction::writeToParcel(Parcel* parcel) const


    const_cast<SurfaceComposerClient::Transaction*>(this)->cacheBuffers();
    const_cast<SurfaceComposerClient::Transaction*>(this)->cacheBuffers();


    SAFE_PARCEL(mSimpleState.writeToParcel, parcel);
    SAFE_PARCEL(mState.writeToParcel, parcel);
    SAFE_PARCEL(mComplexState.writeToParcel, parcel);
    SAFE_PARCEL(mMutableState.writeToParcel, parcel);
    parcel->writeBool(mLogCallPoints);
    parcel->writeBool(mLogCallPoints);
    parcel->writeStrongBinder(mApplyToken);
    parcel->writeStrongBinder(mApplyToken);


@@ -988,12 +979,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
        }
        }
    }
    }


    mSimpleState.merge(other.mSimpleState);
    mState.merge(std::move(other.mState),
    mComplexState.merge(other.mComplexState);
                 [this](const layer_state_t& state) { releaseBufferIfOverwriting(state); });
    mComplexState.mMergedTransactionIds.insert(mComplexState.mMergedTransactionIds.begin(),
                                               other.mSimpleState.mId);
    mMutableState.merge(other.mMutableState,
                        [this](const auto& state) { releaseBufferIfOverwriting(state); });
    mMayContainBuffer |= other.mMayContainBuffer;
    mMayContainBuffer |= other.mMayContainBuffer;
    mApplyToken = other.mApplyToken;
    mApplyToken = other.mApplyToken;


@@ -1001,7 +988,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
    if (mLogCallPoints) {
    if (mLogCallPoints) {
        ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY,
        ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY,
             "Transaction %" PRIu64 " merged with transaction %" PRIu64, other.getId(),
             "Transaction %" PRIu64 " merged with transaction %" PRIu64, other.getId(),
             mSimpleState.mId);
             mState.getId());
    }
    }


    other.clear();
    other.clear();
@@ -1010,9 +997,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr
}
}


void SurfaceComposerClient::Transaction::clear() {
void SurfaceComposerClient::Transaction::clear() {
    mSimpleState.clear();
    mState.clear();
    mComplexState.clear();
    mMutableState.clear();
    mListenerCallbacks.clear();
    mListenerCallbacks.clear();
    mMayContainBuffer = false;
    mMayContainBuffer = false;
    mApplyToken = nullptr;
    mApplyToken = nullptr;
@@ -1020,27 +1005,23 @@ void SurfaceComposerClient::Transaction::clear() {
}
}


uint64_t SurfaceComposerClient::Transaction::getId() {
uint64_t SurfaceComposerClient::Transaction::getId() {
    return mSimpleState.mId;
    return mState.getId();
}
}


std::vector<uint64_t> SurfaceComposerClient::Transaction::getMergedTransactionIds() {
std::vector<uint64_t> SurfaceComposerClient::Transaction::getMergedTransactionIds() {
    return mComplexState.mMergedTransactionIds;
    return mState.mMergedTransactionIds;
}
}


void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
void SurfaceComposerClient::doUncacheBufferTransaction(uint64_t cacheId) {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());


    ComplexTransactionState complexState;
    TransactionState state(generateId(), ISurfaceComposer::eOneWay, systemTime(), true);
    client_cache_t uncacheBuffer;
    client_cache_t uncacheBuffer;
    uncacheBuffer.token = BufferCache::getInstance().getToken();
    uncacheBuffer.token = BufferCache::getInstance().getToken();
    uncacheBuffer.id = cacheId;
    uncacheBuffer.id = cacheId;
    complexState.mUncacheBuffers.emplace_back(std::move(uncacheBuffer));
    state.mUncacheBuffers.emplace_back(std::move(uncacheBuffer));
    MutableTransactionState mutableState;
    status_t status =
    status_t status =
            sf->setTransactionState(SimpleTransactionState(generateId(), ISurfaceComposer::eOneWay,
            sf->setTransactionState(std::move(state), Transaction::getDefaultApplyToken());
                                                           systemTime(), true),
                                    complexState, mutableState,
                                    Transaction::getDefaultApplyToken());
    if (status != NO_ERROR) {
    if (status != NO_ERROR) {
        ALOGE_AND_TRACE("SurfaceComposerClient::doUncacheBufferTransaction - %s",
        ALOGE_AND_TRACE("SurfaceComposerClient::doUncacheBufferTransaction - %s",
                        strerror(-status));
                        strerror(-status));
@@ -1053,7 +1034,7 @@ void SurfaceComposerClient::Transaction::cacheBuffers() {
    }
    }


    size_t count = 0;
    size_t count = 0;
    for (auto& cs : mMutableState.mComposerStates) {
    for (auto& cs : mState.mComposerStates) {
        layer_state_t* s = &cs.state;
        layer_state_t* s = &cs.state;
        if (!(s->what & layer_state_t::eBufferChanged)) {
        if (!(s->what & layer_state_t::eBufferChanged)) {
            continue;
            continue;
@@ -1081,7 +1062,7 @@ void SurfaceComposerClient::Transaction::cacheBuffers() {
            std::optional<client_cache_t> uncacheBuffer;
            std::optional<client_cache_t> uncacheBuffer;
            cacheId = BufferCache::getInstance().cache(s->bufferData->buffer, uncacheBuffer);
            cacheId = BufferCache::getInstance().cache(s->bufferData->buffer, uncacheBuffer);
            if (uncacheBuffer) {
            if (uncacheBuffer) {
                mComplexState.mUncacheBuffers.push_back(*uncacheBuffer);
                mState.mUncacheBuffers.push_back(*uncacheBuffer);
            }
            }
        }
        }
        s->bufferData->flags |= BufferData::BufferDataChange::cachedBufferChanged;
        s->bufferData->flags |= BufferData::BufferDataChange::cachedBufferChanged;
@@ -1150,7 +1131,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
                                        /*callbackContext=*/nullptr);
                                        /*callbackContext=*/nullptr);
    }
    }


    TransactionListenerCallbacks& listenerCallbacks = mComplexState.mCallbacks;
    TransactionListenerCallbacks& listenerCallbacks = mState.mCallbacks;
    listenerCallbacks.clear();
    listenerCallbacks.clear();
    listenerCallbacks.mHasListenerCallbacks = !mListenerCallbacks.empty();
    listenerCallbacks.mHasListenerCallbacks = !mListenerCallbacks.empty();
    // For every listener with registered callbacks
    // For every listener with registered callbacks
@@ -1187,22 +1168,23 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay
            ALOGE("Transaction attempted to set synchronous and one way at the same time"
            ALOGE("Transaction attempted to set synchronous and one way at the same time"
                  " this is an invalid request. Synchronous will win for safety");
                  " this is an invalid request. Synchronous will win for safety");
        } else {
        } else {
            mSimpleState.mFlags |= ISurfaceComposer::eOneWay;
            mState.mFlags |= ISurfaceComposer::eOneWay;
        }
        }
    }
    }


    // If both ISurfaceComposer::eEarlyWakeupStart and ISurfaceComposer::eEarlyWakeupEnd are set
    // If both ISurfaceComposer::eEarlyWakeupStart and ISurfaceComposer::eEarlyWakeupEnd are set
    // it is equivalent for none
    // it is equivalent for none
    uint32_t wakeupFlags = ISurfaceComposer::eEarlyWakeupStart | ISurfaceComposer::eEarlyWakeupEnd;
    uint32_t wakeupFlags = ISurfaceComposer::eEarlyWakeupStart | ISurfaceComposer::eEarlyWakeupEnd;
    if ((mSimpleState.mFlags & wakeupFlags) == wakeupFlags) {
    if ((mState.mFlags & wakeupFlags) == wakeupFlags) {
        mSimpleState.mFlags &= ~(wakeupFlags);
        mState.mFlags &= ~(wakeupFlags);
    }
    }
    sp<IBinder> applyToken = mApplyToken ? mApplyToken : getDefaultApplyToken();
    sp<IBinder> applyToken = mApplyToken ? mApplyToken : getDefaultApplyToken();


    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    status_t binderStatus =
    TransactionState state = std::move(mState);
            sf->setTransactionState(mSimpleState, mComplexState, mMutableState, applyToken);
    mState = TransactionState();
    mSimpleState.mId = generateId();
    mState.mId = generateId();
    status_t binderStatus = sf->setTransactionState(std::move(state), applyToken);


    // Clear the current states and flags
    // Clear the current states and flags
    clear();
    clear();
@@ -1213,7 +1195,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay


    if (mLogCallPoints) {
    if (mLogCallPoints) {
        ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY, "Transaction %" PRIu64 " applied",
        ALOG(LOG_DEBUG, LOG_SURFACE_CONTROL_REGISTRY, "Transaction %" PRIu64 " applied",
             mSimpleState.mId);
             mState.mId);
    }
    }


    mStatus = NO_ERROR;
    mStatus = NO_ERROR;
@@ -1306,23 +1288,23 @@ std::optional<gui::StalledTransactionInfo> SurfaceComposerClient::getStalledTran
}
}


void SurfaceComposerClient::Transaction::setAnimationTransaction() {
void SurfaceComposerClient::Transaction::setAnimationTransaction() {
    mSimpleState.mFlags |= ISurfaceComposer::eAnimation;
    mState.mFlags |= ISurfaceComposer::eAnimation;
}
}


void SurfaceComposerClient::Transaction::setEarlyWakeupStart(gui::EarlyWakeupInfo earlyWakeupInfo) {
void SurfaceComposerClient::Transaction::setEarlyWakeupStart(gui::EarlyWakeupInfo earlyWakeupInfo) {
    earlyWakeupInfo.isStartRequest = true;
    earlyWakeupInfo.isStartRequest = true;
    mComplexState.mEarlyWakeupInfos.push_back(std::move(earlyWakeupInfo));
    mState.mEarlyWakeupInfos.push_back(std::move(earlyWakeupInfo));
    mSimpleState.mFlags |= ISurfaceComposer::eEarlyWakeupStart;
    mState.mFlags |= ISurfaceComposer::eEarlyWakeupStart;
}
}


void SurfaceComposerClient::Transaction::setEarlyWakeupEnd(gui::EarlyWakeupInfo earlyWakeupInfo) {
void SurfaceComposerClient::Transaction::setEarlyWakeupEnd(gui::EarlyWakeupInfo earlyWakeupInfo) {
    earlyWakeupInfo.isStartRequest = false;
    earlyWakeupInfo.isStartRequest = false;
    mComplexState.mEarlyWakeupInfos.push_back(std::move(earlyWakeupInfo));
    mState.mEarlyWakeupInfos.push_back(std::move(earlyWakeupInfo));
    mSimpleState.mFlags |= ISurfaceComposer::eEarlyWakeupEnd;
    mState.mFlags |= ISurfaceComposer::eEarlyWakeupEnd;
}
}


layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) {
layer_state_t* SurfaceComposerClient::Transaction::getLayerState(const sp<SurfaceControl>& sc) {
    return mMutableState.getLayerState(sc);
    return mState.getLayerState(sc);
}
}


void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback(
void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback(
@@ -1706,8 +1688,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe
        setReleaseBufferCallback(bufferData.get(), callback);
        setReleaseBufferCallback(bufferData.get(), callback);
    }
    }


    if (mSimpleState.mIsAutoTimestamp) {
    if (mState.mIsAutoTimestamp) {
        mSimpleState.mDesiredPresentTime = systemTime();
        mState.mDesiredPresentTime = systemTime();
    }
    }
    s->what |= layer_state_t::eBufferChanged;
    s->what |= layer_state_t::eBufferChanged;
    s->bufferData = std::move(bufferData);
    s->bufferData = std::move(bufferData);
@@ -1901,8 +1883,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb


SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime(
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime(
        nsecs_t desiredPresentTime) {
        nsecs_t desiredPresentTime) {
    mSimpleState.mDesiredPresentTime = desiredPresentTime;
    mState.mDesiredPresentTime = desiredPresentTime;
    mSimpleState.mIsAutoTimestamp = false;
    mState.mIsAutoTimestamp = false;
    return *this;
    return *this;
}
}


@@ -1991,14 +1973,14 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setInput


SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFocusedWindow(
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFocusedWindow(
        const FocusRequest& request) {
        const FocusRequest& request) {
    mComplexState.mInputWindowCommands.addFocusRequest(request);
    mState.mInputWindowCommands.addFocusRequest(request);
    return *this;
    return *this;
}
}


SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::addWindowInfosReportedListener(
SurfaceComposerClient::Transaction::addWindowInfosReportedListener(
        sp<gui::IWindowInfosReportedListener> windowInfosReportedListener) {
        sp<gui::IWindowInfosReportedListener> windowInfosReportedListener) {
    mComplexState.mInputWindowCommands.addWindowInfosReportedListener(windowInfosReportedListener);
    mState.mInputWindowCommands.addWindowInfosReportedListener(windowInfosReportedListener);
    return *this;
    return *this;
}
}


@@ -2200,7 +2182,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFixed


SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineInfo(
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrameTimelineInfo(
        const FrameTimelineInfo& frameTimelineInfo) {
        const FrameTimelineInfo& frameTimelineInfo) {
    mComplexState.mergeFrameTimelineInfo(frameTimelineInfo);
    mState.mergeFrameTimelineInfo(frameTimelineInfo);
    return *this;
    return *this;
}
}


@@ -2367,7 +2349,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setConte
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
    return mMutableState.getDisplayState(token);
    return mState.getDisplayState(token);
}
}


status_t SurfaceComposerClient::Transaction::setDisplaySurface(
status_t SurfaceComposerClient::Transaction::setDisplaySurface(
+45 −203

File changed.

Preview size limit exceeded, changes collapsed.

+2 −6
Original line number Original line Diff line number Diff line
@@ -66,9 +66,7 @@ struct DisplayState;
struct InputWindowCommands;
struct InputWindowCommands;
class HdrCapabilities;
class HdrCapabilities;
class Rect;
class Rect;
struct SimpleTransactionState;
class TransactionState;
struct ComplexTransactionState;
struct MutableTransactionState;


using gui::FrameTimelineInfo;
using gui::FrameTimelineInfo;
using gui::IDisplayEventConnection;
using gui::IDisplayEventConnection;
@@ -109,9 +107,7 @@ public:
    };
    };


    /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
    /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
    virtual status_t setTransactionState(SimpleTransactionState simpleState,
    virtual status_t setTransactionState(TransactionState&& state,
                                         const ComplexTransactionState& complexState,
                                         MutableTransactionState& mutableState,
                                         const sp<IBinder>& applyToken) = 0;
                                         const sp<IBinder>& applyToken) = 0;
};
};


+0 −61
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <cstdint>

#include <gui/LayerState.h>

namespace android {

// Defined in its own header to avoid circular dependencies in includes.
struct SimpleTransactionState {
    uint64_t mId = 0;
    uint32_t mFlags = 0;
    // mDesiredPresentTime is the time in nanoseconds that the client would like the transaction
    // to be presented. When it is not possible to present at exactly that time, it will be
    // presented after the time has passed.
    //
    // If the client didn't pass a desired presentation time, mDesiredPresentTime will be
    // populated to the time setBuffer was called, and mIsAutoTimestamp will be set to true.
    //
    // Desired present times that are more than 1 second in the future may be ignored.
    // When a desired present time has already passed, the transaction will be presented as soon
    // as possible.
    //
    // Transactions from the same process are presented in the same order that they are applied.
    // The desired present time does not affect this ordering.
    int64_t mDesiredPresentTime = 0;
    bool mIsAutoTimestamp = true;

    SimpleTransactionState() = default;
    SimpleTransactionState(uint64_t id, uint32_t flags, int64_t desiredPresentTime,
                           bool isAutoTimestamp)
          : mId(id),
            mFlags(flags),
            mDesiredPresentTime(desiredPresentTime),
            mIsAutoTimestamp(isAutoTimestamp) {}
    bool operator==(const SimpleTransactionState& rhs) const = default;
    bool operator!=(const SimpleTransactionState& rhs) const = default;

    status_t writeToParcel(Parcel* parcel) const;
    status_t readFromParcel(const Parcel* parcel);
    void merge(const SimpleTransactionState& other);
    void clear();
};

} // namespace android
Loading