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

Commit 58e24a36 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Allow SurfaceFlinger to be subclassed

1) Make the destructor protected instead of private.
2) Make setClientStateLocked virtual for overriding.
3) Refactor commitTransaction to introduce a new virtual
   commitTransactionLocked for overriding.

Test: go/wm-smoke
Bug: 121291683
Change-Id: Iaa164b3c0f1f00ddf1e8ed468c0014e80adab843
parent 6c564cfd
Loading
Loading
Loading
Loading
+38 −36
Original line number Diff line number Diff line
@@ -2566,7 +2566,14 @@ void SurfaceFlinger::initScheduler(DisplayId primaryDisplayId) {

void SurfaceFlinger::commitTransaction()
{
    withTracingLock([&]() {
    withTracingLock([this]() { commitTransactionLocked(); });

    mTransactionPending = false;
    mAnimTransactionPending = false;
    mTransactionCV.broadcast();
}

void SurfaceFlinger::commitTransactionLocked() {
    if (!mLayersPendingRemoval.isEmpty()) {
        // Notify removed layers now that they can't be drawn from
        for (const auto& l : mLayersPendingRemoval) {
@@ -2606,11 +2613,6 @@ void SurfaceFlinger::commitTransaction()
    });

    commitOffscreenLayers();
    });

    mTransactionPending = false;
    mAnimTransactionPending = false;
    mTransactionCV.broadcast();
}

void SurfaceFlinger::withTracingLock(std::function<void()> lockedOperation) {
+10 −4
Original line number Diff line number Diff line
@@ -346,9 +346,11 @@ private:
    static const size_t MAX_LAYERS = 4096;
    static const int MAX_TRACING_MEMORY = 100 * 1024 * 1024; // 100MB

protected:
    // We're reference counted, never destroy SurfaceFlinger directly
    virtual ~SurfaceFlinger();

private:
    /* ------------------------------------------------------------------------
     * Internal data structures
     */
@@ -584,15 +586,19 @@ private:
    bool transactionIsReadyToBeApplied(int64_t desiredPresentTime,
                                       bool useCachedExpectedPresentTime,
                                       const Vector<ComposerState>& states);
    uint32_t setClientStateLocked(
    uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock);
    uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands)
            REQUIRES(mStateLock);

protected:
    virtual uint32_t setClientStateLocked(
            const ComposerState& composerState, int64_t desiredPresentTime, int64_t postTime,
            bool privileged,
            std::unordered_set<ListenerCallbacks, ListenerCallbacksHash>& listenerCallbacks)
            REQUIRES(mStateLock);
    uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock);
    uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands)
            REQUIRES(mStateLock);
    virtual void commitTransactionLocked();

private:
    /* ------------------------------------------------------------------------
     * Layer management
     */