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

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

Merge "Remove extra glFlush from handleMessageRefresh()."

parents 66254d2d 56e538fd
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -380,8 +380,7 @@ bool BufferLayer::onPostComposition(const std::optional<DisplayId>& displayId,
    return true;
}

bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
                              const sp<Fence>& releaseFence) {
bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) {
    ATRACE_CALL();

    bool refreshRequired = latchSidebandStream(recomputeVisibleRegions);
@@ -420,7 +419,7 @@ bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
        return false;
    }

    status_t err = updateTexImage(recomputeVisibleRegions, latchTime, releaseFence);
    status_t err = updateTexImage(recomputeVisibleRegions, latchTime);
    if (err != NO_ERROR) {
        return false;
    }
+2 −7
Original line number Diff line number Diff line
@@ -93,11 +93,7 @@ public:
    // the visible regions need to be recomputed (this is a fairly heavy
    // operation, so this should be set only if needed). Typically this is used
    // to figure out if the content or size of a surface has changed.
    // If there was a GL composition step rendering the previous frame, then
    // releaseFence will be populated with a native fence that fires when
    // composition has completed.
    bool latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
                     const sp<Fence>& releaseFence) override;
    bool latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) override;

    bool isBufferLatched() const override { return mRefreshPending; }

@@ -142,8 +138,7 @@ private:
    virtual void setFilteringEnabled(bool enabled) = 0;

    virtual status_t bindTextureImage() = 0;
    virtual status_t updateTexImage(bool& recomputeVisibleRegions, nsecs_t latchTime,
                                    const sp<Fence>& flushFence) = 0;
    virtual status_t updateTexImage(bool& recomputeVisibleRegions, nsecs_t latchTime) = 0;

    virtual status_t updateActiveBuffer() = 0;
    virtual status_t updateFrameNumber(nsecs_t latchTime) = 0;
+3 −42
Original line number Diff line number Diff line
@@ -100,8 +100,7 @@ void BufferLayerConsumer::setContentsChangedListener(const wp<ContentsChangedLis

status_t BufferLayerConsumer::updateTexImage(BufferRejecter* rejecter, nsecs_t expectedPresentTime,
                                             bool* autoRefresh, bool* queuedBuffer,
                                             uint64_t maxFrameNumber,
                                             const sp<Fence>& releaseFence) {
                                             uint64_t maxFrameNumber) {
    ATRACE_CALL();
    BLC_LOGV("updateTexImage");
    Mutex::Autolock lock(mMutex);
@@ -146,7 +145,7 @@ status_t BufferLayerConsumer::updateTexImage(BufferRejecter* rejecter, nsecs_t e
    }

    // Release the previous buffer.
    err = updateAndReleaseLocked(item, &mPendingRelease, releaseFence);
    err = updateAndReleaseLocked(item, &mPendingRelease);
    if (err != NO_ERROR) {
        return err;
    }
@@ -224,25 +223,11 @@ status_t BufferLayerConsumer::acquireBufferLocked(BufferItem* item, nsecs_t pres
}

status_t BufferLayerConsumer::updateAndReleaseLocked(const BufferItem& item,
                                                     PendingRelease* pendingRelease,
                                                     const sp<Fence>& releaseFence) {
                                                     PendingRelease* pendingRelease) {
    status_t err = NO_ERROR;

    int slot = item.mSlot;

    // Do whatever sync ops we need to do before releasing the old slot.
    if (slot != mCurrentTexture) {
        err = syncForReleaseLocked(releaseFence);
        if (err != NO_ERROR) {
            // Release the buffer we just acquired.  It's not safe to
            // release the old buffer, so instead we just drop the new frame.
            // As we are still under lock since acquireBuffer, it is safe to
            // release by slot.
            releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
            return err;
        }
    }

    BLC_LOGV("updateAndRelease: (slot=%d buf=%p) -> (slot=%d buf=%p)", mCurrentTexture,
             mCurrentTextureBuffer != nullptr ? mCurrentTextureBuffer->handle : 0, slot,
             mSlots[slot].mGraphicBuffer->handle);
@@ -298,30 +283,6 @@ status_t BufferLayerConsumer::bindTextureImageLocked() {
    return mRE.bindExternalTextureBuffer(mTexName, mCurrentTextureBuffer, mCurrentFence, false);
}

status_t BufferLayerConsumer::syncForReleaseLocked(const sp<Fence>& releaseFence) {
    BLC_LOGV("syncForReleaseLocked");

    if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
        if (mRE.useNativeFenceSync() && releaseFence != Fence::NO_FENCE) {
            // TODO(alecmouri): fail further upstream if the fence is invalid
            if (!releaseFence->isValid()) {
                BLC_LOGE("syncForReleaseLocked: failed to flush RenderEngine");
                return UNKNOWN_ERROR;
            }
            status_t err =
                    addReleaseFenceLocked(mCurrentTexture, mCurrentTextureBuffer, releaseFence);
            if (err != OK) {
                BLC_LOGE("syncForReleaseLocked: error adding release fence: "
                         "%s (%d)",
                         strerror(-err), err);
                return err;
            }
        }
    }

    return OK;
}

void BufferLayerConsumer::getTransformMatrix(float mtx[16]) {
    Mutex::Autolock lock(mMutex);
    memcpy(mtx, mCurrentTransformMatrix, sizeof(mCurrentTransformMatrix));
+2 −10
Original line number Diff line number Diff line
@@ -92,8 +92,7 @@ public:
    // used to reject the newly acquired buffer.  It also does not bind the
    // RenderEngine texture until bindTextureImage is called.
    status_t updateTexImage(BufferRejecter* rejecter, nsecs_t expectedPresentTime,
                            bool* autoRefresh, bool* queuedBuffer, uint64_t maxFrameNumber,
                            const sp<Fence>& releaseFence);
                            bool* autoRefresh, bool* queuedBuffer, uint64_t maxFrameNumber);

    // See BufferLayerConsumer::bindTextureImageLocked().
    status_t bindTextureImage();
@@ -212,8 +211,7 @@ protected:
    // completion of the method will instead be returned to the caller, so that
    // it may call releaseBufferLocked itself later.
    status_t updateAndReleaseLocked(const BufferItem& item,
                                    PendingRelease* pendingRelease = nullptr,
                                    const sp<Fence>& releaseFence = Fence::NO_FENCE);
                                    PendingRelease* pendingRelease = nullptr);

    // Binds mTexName and the current buffer to TEXTURE_EXTERNAL target.
    // If the bind succeeds, this calls doFenceWait.
@@ -244,12 +242,6 @@ private:
    // access the current texture buffer.
    status_t doFenceWaitLocked() const;

    // syncForReleaseLocked performs the synchronization needed to release the
    // current slot from RenderEngine.  If needed it will set the current
    // slot's fence to guard against a producer accessing the buffer before
    // the outstanding accesses have completed.
    status_t syncForReleaseLocked(const sp<Fence>& releaseFence);

    // The default consumer usage flags that BufferLayerConsumer always sets on its
    // BufferQueue instance; these will be OR:d with any additional flags passed
    // from the BufferLayerConsumer user. In particular, BufferLayerConsumer will always
+4 −6
Original line number Diff line number Diff line
@@ -225,8 +225,7 @@ status_t BufferQueueLayer::bindTextureImage() {
    return mConsumer->bindTextureImage();
}

status_t BufferQueueLayer::updateTexImage(bool& recomputeVisibleRegions, nsecs_t latchTime,
                                          const sp<Fence>& releaseFence) {
status_t BufferQueueLayer::updateTexImage(bool& recomputeVisibleRegions, nsecs_t latchTime) {
    // This boolean is used to make sure that SurfaceFlinger's shadow copy
    // of the buffer queue isn't modified when the buffer queue is returning
    // BufferItem's that weren't actually queued. This can happen in shared
@@ -264,9 +263,8 @@ status_t BufferQueueLayer::updateTexImage(bool& recomputeVisibleRegions, nsecs_t
    const uint64_t maxFrameNumberToAcquire =
            std::min(mLastFrameNumberReceived.load(), lastSignaledFrameNumber);

    status_t updateResult =
            mConsumer->updateTexImage(&r, expectedPresentTime, &mAutoRefresh, &queuedBuffer,
                                      maxFrameNumberToAcquire, releaseFence);
    status_t updateResult = mConsumer->updateTexImage(&r, expectedPresentTime, &mAutoRefresh,
                                                      &queuedBuffer, maxFrameNumberToAcquire);
    if (updateResult == BufferQueue::PRESENT_LATER) {
        // Producer doesn't want buffer to be displayed yet.  Signal a
        // layer update so we check again at the next opportunity.
@@ -393,7 +391,7 @@ void BufferQueueLayer::setHwcLayerBuffer(const sp<const DisplayDevice>& display)
void BufferQueueLayer::fakeVsync() {
    mRefreshPending = false;
    bool ignored = false;
    latchBuffer(ignored, systemTime(), Fence::NO_FENCE);
    latchBuffer(ignored, systemTime());
    usleep(16000);
    releasePendingBuffer(systemTime());
}
Loading