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

Commit 1878450a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "ASC-SF"

* changes:
  blast: cache buffers
  blast: add desired present time
parents 30a52c80 ebc2c059
Loading
Loading
Loading
Loading
+85 −2
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ public:
    virtual void setTransactionState(const Vector<ComposerState>& state,
                                     const Vector<DisplayState>& displays, uint32_t flags,
                                     const sp<IBinder>& applyToken,
                                     const InputWindowCommands& commands) {
                                     const InputWindowCommands& commands,
                                     int64_t desiredPresentTime) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

@@ -83,6 +84,7 @@ public:
        data.writeUint32(flags);
        data.writeStrongBinder(applyToken);
        commands.write(data);
        data.writeInt64(desiredPresentTime);
        remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
    }

@@ -693,6 +695,42 @@ public:
        }
        return err;
    }

    virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer,
                                 int32_t* outBufferId) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

        data.writeStrongBinder(token);
        if (buffer) {
            data.writeBool(true);
            data.write(*buffer);
        } else {
            data.writeBool(false);
        }

        status_t result = remote()->transact(BnSurfaceComposer::CACHE_BUFFER, data, &reply);
        if (result != NO_ERROR) {
            return result;
        }

        int32_t id = -1;
        result = reply.readInt32(&id);
        if (result == NO_ERROR) {
            *outBufferId = id;
        }
        return result;
    }

    virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) {
        Parcel data, reply;
        data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());

        data.writeStrongBinder(token);
        data.writeInt32(bufferId);

        return remote()->transact(BnSurfaceComposer::UNCACHE_BUFFER, data, &reply);
    }
};

// Out-of-line virtual method definition to trigger vtable emission in this
@@ -748,7 +786,10 @@ status_t BnSurfaceComposer::onTransact(
            sp<IBinder> applyToken = data.readStrongBinder();
            InputWindowCommands inputWindowCommands;
            inputWindowCommands.read(data);
            setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands);

            int64_t desiredPresentTime = data.readInt64();
            setTransactionState(state, displays, stateFlags, applyToken, inputWindowCommands,
                                desiredPresentTime);
            return NO_ERROR;
        }
        case BOOT_FINISHED: {
@@ -1131,6 +1172,48 @@ status_t BnSurfaceComposer::onTransact(
            }
            return error;
        }
        case CACHE_BUFFER: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> token;
            status_t result = data.readStrongBinder(&token);
            if (result != NO_ERROR) {
                ALOGE("cache buffer failure in reading token: %d", result);
                return result;
            }

            sp<GraphicBuffer> buffer = new GraphicBuffer();
            if (data.readBool()) {
                result = data.read(*buffer);
                if (result != NO_ERROR) {
                    ALOGE("cache buffer failure in reading buffer: %d", result);
                    return result;
                }
            }
            int32_t bufferId = -1;
            status_t error = cacheBuffer(token, buffer, &bufferId);
            if (error == NO_ERROR) {
                reply->writeInt32(bufferId);
            }
            return error;
        }
        case UNCACHE_BUFFER: {
            CHECK_INTERFACE(ISurfaceComposer, data, reply);
            sp<IBinder> token;
            status_t result = data.readStrongBinder(&token);
            if (result != NO_ERROR) {
                ALOGE("uncache buffer failure in reading token: %d", result);
                return result;
            }

            int32_t bufferId = -1;
            result = data.readInt32(&bufferId);
            if (result != NO_ERROR) {
                ALOGE("uncache buffer failure in reading buffer id: %d", result);
                return result;
            }

            return uncacheBuffer(token, bufferId);
        }
        default: {
            return BBinder::onTransact(code, data, reply, flags);
        }
+10 −0
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ status_t layer_state_t::write(Parcel& output) const
        }
    }

    output.writeStrongBinder(cachedBuffer.token);
    output.writeInt32(cachedBuffer.bufferId);

    return NO_ERROR;
}

@@ -164,6 +167,9 @@ status_t layer_state_t::read(const Parcel& input)
        listenerCallbacks.emplace_back(listener, callbackIds);
    }

    cachedBuffer.token = input.readStrongBinder();
    cachedBuffer.bufferId = input.readInt32();

    return NO_ERROR;
}

@@ -372,6 +378,10 @@ void layer_state_t::merge(const layer_state_t& other) {
    }
#endif

    if (other.what & eCachedBufferChanged) {
        what |= eCachedBufferChanged;
        cachedBuffer = other.cachedBuffer;
    }
    if ((other.what & what) != other.what) {
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
+50 −7
Original line number Diff line number Diff line
@@ -159,11 +159,12 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener

// ---------------------------------------------------------------------------

SurfaceComposerClient::Transaction::Transaction(const Transaction& other) :
    mForceSynchronous(other.mForceSynchronous),
SurfaceComposerClient::Transaction::Transaction(const Transaction& other)
      : mForceSynchronous(other.mForceSynchronous),
        mTransactionNestCount(other.mTransactionNestCount),
        mAnimation(other.mAnimation),
    mEarlyWakeup(other.mEarlyWakeup) {
        mEarlyWakeup(other.mEarlyWakeup),
        mDesiredPresentTime(other.mDesiredPresentTime) {
    mDisplayStates = other.mDisplayStates;
    mComposerStates = other.mComposerStates;
    mInputWindowCommands = other.mInputWindowCommands;
@@ -218,7 +219,7 @@ void SurfaceComposerClient::doDropReferenceTransaction(const sp<IBinder>& handle
    s.state.parentHandleForChild = nullptr;

    composerStates.add(s);
    sf->setTransactionState(composerStates, displayStates, 0, nullptr, {});
    sf->setTransactionState(composerStates, displayStates, 0, nullptr, {}, -1);
}

status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
@@ -284,7 +285,8 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous) {
    mEarlyWakeup = false;

    sp<IBinder> applyToken = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands);
    sf->setTransactionState(composerStates, displayStates, flags, applyToken, mInputWindowCommands,
                            mDesiredPresentTime);
    mInputWindowCommands.clear();
    mStatus = NO_ERROR;
    return NO_ERROR;
@@ -658,6 +660,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffe
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCachedBuffer(
        const sp<SurfaceControl>& sc, int32_t bufferId) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eCachedBufferChanged;
    s->cachedBuffer.token = IInterface::asBinder(TransactionCompletedListener::getIInstance());
    s->cachedBuffer.bufferId = bufferId;

    registerSurfaceControlForCallback(sc);
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAcquireFence(
        const sp<SurfaceControl>& sc, const sp<Fence>& fence) {
    layer_state_t* s = getLayerState(sc);
@@ -742,6 +759,12 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setSideb
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setDesiredPresentTime(
        nsecs_t desiredPresentTime) {
    mDesiredPresentTime = desiredPresentTime;
    return *this;
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::addTransactionCompletedCallback(
        TransactionCompletedCallbackTakesContext callback, void* callbackContext) {
@@ -1049,6 +1072,26 @@ status_t SurfaceComposerClient::getLayerFrameStats(const sp<IBinder>& token,

// ----------------------------------------------------------------------------

status_t SurfaceComposerClient::cacheBuffer(const sp<GraphicBuffer>& buffer, int32_t* outBufferId) {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    if (buffer == nullptr || outBufferId == nullptr) {
        return BAD_VALUE;
    }
    return sf->cacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()),
                           buffer, outBufferId);
}

status_t SurfaceComposerClient::uncacheBuffer(int32_t bufferId) {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    if (bufferId < 0) {
        return BAD_VALUE;
    }
    return sf->uncacheBuffer(IInterface::asBinder(TransactionCompletedListener::getIInstance()),
                             bufferId);
}

// ----------------------------------------------------------------------------

status_t SurfaceComposerClient::enableVSyncInjections(bool enable) {
    sp<ISurfaceComposer> sf(ComposerService::getComposerService());
    return sf->enableVSyncInjections(enable);
+9 −1
Original line number Diff line number Diff line
@@ -116,7 +116,8 @@ public:
    virtual void setTransactionState(const Vector<ComposerState>& state,
                                     const Vector<DisplayState>& displays, uint32_t flags,
                                     const sp<IBinder>& applyToken,
                                     const InputWindowCommands& inputWindowCommands) = 0;
                                     const InputWindowCommands& inputWindowCommands,
                                     int64_t desiredPresentTime) = 0;

    /* signal that we're done booting.
     * Requires ACCESS_SURFACE_FLINGER permission
@@ -315,6 +316,11 @@ public:
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
    virtual status_t getProtectedContentSupport(bool* outSupported) const = 0;

    virtual status_t cacheBuffer(const sp<IBinder>& token, const sp<GraphicBuffer>& buffer,
                                 int32_t* outBufferId) = 0;

    virtual status_t uncacheBuffer(const sp<IBinder>& token, int32_t bufferId) = 0;
};

// ----------------------------------------------------------------------------
@@ -357,6 +363,8 @@ public:
        SET_DISPLAY_CONTENT_SAMPLING_ENABLED,
        GET_DISPLAYED_CONTENT_SAMPLE,
        GET_PROTECTED_CONTENT_SUPPORT,
        CACHE_BUFFER,
        UNCACHE_BUFFER,
    };

    virtual status_t onTransact(uint32_t code, const Parcel& data,
+7 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ struct layer_state_t {
        eInputInfoChanged = 0x40000000,
        eCornerRadiusChanged = 0x80000000,
        eFrameChanged = 0x1'00000000,
        eCachedBufferChanged = 0x2'00000000,
    };

    layer_state_t()
@@ -125,6 +126,10 @@ struct layer_state_t {
        float dtdy{0};
        float dsdy{0};
    };
    struct cached_buffer_t {
        sp<IBinder> token = nullptr;
        int32_t bufferId = -1;
    };
    sp<IBinder> surface;
    uint64_t what;
    float x;
@@ -173,6 +178,8 @@ struct layer_state_t {
#ifndef NO_INPUT
    InputWindowInfo inputInfo;
#endif

    cached_buffer_t cachedBuffer;
};

struct ComposerState {
Loading