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

Commit 6faafea0 authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge changes I463f4a0c,I09748008,I0c008ea8 into main

* changes:
  [legacy layer cleanup] Misc dead code in Layer
  [legacy layer cleanup] Transaction methods
  [legacy layer cleanup] Crop and transform methods
parents 0b950098 7d410016
Loading
Loading
Loading
Loading
+0 −64
Original line number Diff line number Diff line
@@ -355,26 +355,6 @@ aidl::android::hardware::graphics::composer3::Composition Layer::getCompositionT
// transaction
// ----------------------------------------------------------------------------

uint32_t Layer::doTransaction(uint32_t flags) {
    SFTRACE_CALL();

    const State& s(getDrawingState());

    if (s.sequence != mLastCommittedTxSequence) {
        // invalidate and recompute the visible regions if needed
        mLastCommittedTxSequence = s.sequence;
        flags |= eVisibleRegion;
    }

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

    commitTransaction();

    return flags;
}

void Layer::commitTransaction() {
    // Set the present state for all bufferlessSurfaceFramesTX to Presented. The
    // bufferSurfaceFrameTX will be presented in latchBuffer.
@@ -389,12 +369,6 @@ void Layer::commitTransaction() {
    mDrawingState.bufferlessSurfaceFramesTX.clear();
}

uint32_t Layer::clearTransactionFlags(uint32_t mask) {
    const auto flags = mTransactionFlags & mask;
    mTransactionFlags &= ~mask;
    return flags;
}

void Layer::setTransactionFlags(uint32_t mask) {
    mTransactionFlags |= mask;
}
@@ -867,16 +841,6 @@ bool Layer::setTransformToDisplayInverse(bool transformToDisplayInverse) {
    return true;
}

bool Layer::setBufferCrop(const Rect& bufferCrop) {
    if (mDrawingState.bufferCrop == bufferCrop) return false;

    mDrawingState.sequence++;
    mDrawingState.bufferCrop = bufferCrop;

    setTransactionFlags(eTransactionNeeded);
    return true;
}

void Layer::releasePreviousBuffer() {
    mReleasePreviousBuffer = true;
    if (!mBufferInfo.mBuffer ||
@@ -1491,10 +1455,6 @@ void Layer::onCompositionPresented(const DisplayDevice* display,
    mBufferInfo.mFrameLatencyNeeded = false;
}

bool Layer::willReleaseBufferOnLatch() const {
    return !mDrawingState.buffer && mBufferInfo.mBuffer;
}

bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bool bgColorOnly) {
    SFTRACE_FORMAT_INSTANT("latchBuffer %s - %" PRIu64, getDebugName(),
                           getDrawingState().frameNumber);
@@ -1555,34 +1515,10 @@ bool Layer::latchBufferImpl(bool& recomputeVisibleRegions, nsecs_t latchTime, bo
    return true;
}

bool Layer::isProtected() const {
    return (mBufferInfo.mBuffer != nullptr) &&
            (mBufferInfo.mBuffer->getUsage() & GRALLOC_USAGE_PROTECTED);
}

bool Layer::getTransformToDisplayInverse() const {
    return mBufferInfo.mTransformToDisplayInverse;
}

Rect Layer::getBufferCrop() const {
    // this is the crop rectangle that applies to the buffer
    // itself (as opposed to the window)
    if (!mBufferInfo.mCrop.isEmpty()) {
        // if the buffer crop is defined, we use that
        return mBufferInfo.mCrop;
    } else if (mBufferInfo.mBuffer != nullptr) {
        // otherwise we use the whole buffer
        return mBufferInfo.mBuffer->getBounds();
    } else {
        // if we don't have a buffer yet, we use an empty/invalid crop
        return Rect();
    }
}

uint32_t Layer::getBufferTransform() const {
    return mBufferInfo.mTransform;
}

ui::Dataspace Layer::translateDataspace(ui::Dataspace dataspace) {
    ui::Dataspace updatedDataspace = dataspace;
    // translate legacy dataspaces to modern dataspaces
+1 −72
Original line number Diff line number Diff line
@@ -88,12 +88,6 @@ public:
    // Windows that are not in focus, but voted for a specific mode ID.
    static constexpr int32_t PRIORITY_NOT_FOCUSED_WITH_MODE = 2;

    enum { // flags for doTransaction()
        eDontUpdateGeometryState = 0x00000001,
        eVisibleRegion = 0x00000002,
        eInputInfoChanged = 0x00000004
    };

    using FrameRate = scheduler::LayerInfo::FrameRate;
    using FrameRateCompatibility = scheduler::FrameRateCompatibility;
    using FrameRateSelectionStrategy = scheduler::LayerInfo::FrameRateSelectionStrategy;
@@ -171,9 +165,6 @@ public:
    static bool isLayerFocusedBasedOnPriority(int32_t priority);
    static void miniDumpHeader(std::string& result);

    // Provide unique string for each class type in the Layer hierarchy
    const char* getType() const { return "Layer"; }

    // This second set of geometry attributes are controlled by
    // setGeometryAppliesWithResize, and their default mode is to be
    // immediate. If setGeometryAppliesWithResize is specified
@@ -200,7 +191,6 @@ public:
                                          bool willPresent);

    sp<LayerFE> getCompositionEngineLayerFE(const frontend::LayerHierarchy::TraversalPath&);
    sp<LayerFE> getOrCreateCompositionEngineLayerFE(const frontend::LayerHierarchy::TraversalPath&);

    // If we have received a new buffer this frame, we will pass its surface
    // damage down to hardware composer. Otherwise, we must send a region with
@@ -208,18 +198,7 @@ public:
    Region getVisibleRegion(const DisplayDevice*) const;
    void updateLastLatchTime(nsecs_t latchtime);

    /*
     * isProtected - true if the layer may contain protected contents in the
     * GRALLOC_USAGE_PROTECTED sense.
     */
    bool isProtected() const;
    /*
     * usesSourceCrop - true if content should use a source crop
     */
    bool usesSourceCrop() const { return hasBufferOrSidebandStream(); }

    Rect getCrop(const Layer::State& s) const { return s.crop; }
    bool needsFiltering(const DisplayDevice*) const;

    // from graphics API
    static ui::Dataspace translateDataspace(ui::Dataspace dataspace);
@@ -242,23 +221,6 @@ public:
    bool latchBufferImpl(bool& /*recomputeVisibleRegions*/, nsecs_t /*latchTime*/,
                         bool bgColorOnly);

    /*
     * Returns true if the currently presented buffer will be released when this layer state
     * is latched. This will return false if there is no buffer currently presented.
     */
    bool willReleaseBufferOnLatch() const;

    /*
     * returns the rectangle that crops the content of the layer and scales it
     * to the layer's size.
     */
    Rect getBufferCrop() const;

    /*
     * Returns the transform applied to the buffer.
     */
    uint32_t getBufferTransform() const;

    sp<GraphicBuffer> getBuffer() const;
    /**
     * Returns active buffer size in the correct orientation. Buffer size is determined by undoing
@@ -313,8 +275,6 @@ public:

    const char* getDebugName() const;

    uint32_t getTransactionFlags() const { return mTransactionFlags; }

    static bool computeTrustedPresentationState(const FloatRect& bounds,
                                                const FloatRect& sourceBounds,
                                                const Region& coveredRegion,
@@ -332,9 +292,6 @@ public:
    // Sets the masked bits.
    void setTransactionFlags(uint32_t mask);

    // Clears and returns the masked bits.
    uint32_t clearTransactionFlags(uint32_t mask);

    int32_t getSequence() const { return sequence; }

    // For tracing.
@@ -348,14 +305,6 @@ public:
    void writeCompositionStateToProto(perfetto::protos::LayerProto* layerProto,
                                      ui::LayerStack layerStack);

    gui::WindowInfo::Type getWindowType() const { return mWindowType; }

    /*
     * doTransaction - process the transaction. This is a good place to figure
     * out which attributes of the surface have changed.
     */
    uint32_t doTransaction(uint32_t transactionFlags);

    inline const State& getDrawingState() const { return mDrawingState; }
    inline State& getDrawingState() { return mDrawingState; }

@@ -366,13 +315,6 @@ public:
    void getFrameStats(FrameStats* outStats) const;
    void onDisconnect();

    ui::Transform getTransform() const;

    half4 getColor() const;
    int32_t getBackgroundBlurRadius() const;
    bool drawShadows() const { return mEffectiveShadowRadius > 0.f; };

    bool isHandleAlive() const { return mHandleAlive; }
    bool onHandleDestroyed() { return mHandleAlive = false; }

    /**
@@ -383,7 +325,6 @@ public:
     */
    Rect getCroppedBufferSize(const Layer::State& s) const;

    void setFrameTimelineInfoForBuffer(const FrameTimelineInfo& /*info*/) {}
    void setFrameTimelineVsyncForBufferTransaction(const FrameTimelineInfo& info, nsecs_t postTime,
                                                   gui::GameMode gameMode);
    void setFrameTimelineVsyncForBufferlessTransaction(const FrameTimelineInfo& info,
@@ -412,14 +353,9 @@ public:
    // this to be called once.
    sp<IBinder> getHandle();
    const std::string& getName() const { return mName; }
    void setInputInfo(const gui::WindowInfo& info);

    virtual uid_t getOwnerUid() const { return mOwnerUid; }

    pid_t getOwnerPid() { return mOwnerPid; }

    int32_t getOwnerAppId() { return mOwnerAppId; }

    // Used to check if mUsedVsyncIdForRefreshRateSelection should be expired when it stop updating.
    nsecs_t mMaxTimeForUseVsyncId = 0;
    // True when DrawState.useVsyncIdForRefreshRateSelection previously set to true during updating
@@ -431,9 +367,6 @@ public:
    // the same.
    const int32_t sequence;

    bool mPendingHWCDestroy{false};

    bool setBufferCrop(const Rect& /* bufferCrop */);
    // See mPendingBufferTransactions
    void decrementPendingBufferCount();
    std::atomic<int32_t>* getPendingBufferCounter() { return &mPendingBufferTransactions; }
@@ -513,10 +446,6 @@ protected:
    int64_t mEnteredTrustedPresentationStateTime = -1;

    uint32_t mTransactionFlags{0};
    // Updated in doTransaction, used to track the last sequence number we
    // committed. Currently this is really only used for updating visible
    // regions.
    int32_t mLastCommittedTxSequence = -1;

    // Timestamp history for UIAutomation. Thread safe.
    FrameTracker mFrameTracker;
@@ -632,7 +561,7 @@ private:
    // You can understand the trace this way:
    //     - If the integer increases, a buffer arrived at the server.
    //     - If the integer decreases in latchBuffer, that buffer was latched
    //     - If the integer decreases in setBuffer or doTransaction, a buffer was dropped
    //     - If the integer decreases in setBuffer, a buffer was dropped
    std::atomic<int32_t> mPendingBufferTransactions{0};

    // Contains requested position and matrix updates. This will be applied if the client does