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

Commit cf26a0a9 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

BlastBufferQueue: Add support for auto refresh

When BQ is in shared bufer mode, the client can request
the consumer to aquire frames as fast as possible before
waiting for a frame to be available. To support this for
BLAST, pass the state via a transaction.

Fixes: 168506187
Test: atest SurfaceViewBufferTests
Change-Id: I25ddd98671a08e56798612b7e5dc72095b2c4b7b
parent ea0de00d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -289,6 +289,11 @@ void BLASTBufferQueue::processNextBufferLocked(bool useNextTransaction) {
    t->setDesiredPresentTime(bufferItem.mTimestamp);
    t->setFrameNumber(mSurfaceControl, bufferItem.mFrameNumber);

    if (mAutoRefresh != bufferItem.mAutoRefresh) {
        t->setAutoRefresh(mSurfaceControl, bufferItem.mAutoRefresh);
        mAutoRefresh = bufferItem.mAutoRefresh;
    }

    if (applyTransaction) {
        t->apply();
    }
+19 −1
Original line number Diff line number Diff line
@@ -61,7 +61,9 @@ layer_state_t::layer_state_t()
        frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        shouldBeSeamless(true),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        frameNumber(0) {
        frameNumber(0),
        frameTimelineVsyncId(ISurfaceComposer::INVALID_VSYNC_ID),
        autoRefresh(false) {
    matrix.dsdx = matrix.dtdy = 1.0f;
    matrix.dsdy = matrix.dtdx = 0.0f;
    hdrMetadata.validTypes = 0;
@@ -149,6 +151,7 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeUint32, fixedTransformHint);
    SAFE_PARCEL(output.writeUint64, frameNumber);
    SAFE_PARCEL(output.writeInt64, frameTimelineVsyncId);
    SAFE_PARCEL(output.writeBool, autoRefresh);

    SAFE_PARCEL(output.writeUint32, blurRegions.size());
    for (auto region : blurRegions) {
@@ -269,6 +272,7 @@ status_t layer_state_t::read(const Parcel& input)
    fixedTransformHint = static_cast<ui::Transform::RotationFlags>(tmpUint32);
    SAFE_PARCEL(input.readUint64, &frameNumber);
    SAFE_PARCEL(input.readInt64, &frameTimelineVsyncId);
    SAFE_PARCEL(input.readBool, &autoRefresh);

    uint32_t numRegions = 0;
    SAFE_PARCEL(input.readUint32, &numRegions);
@@ -534,6 +538,20 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eFrameNumberChanged;
        frameNumber = other.frameNumber;
    }
    if (other.what & eFrameTimelineVsyncChanged) {
        // When merging vsync Ids we take the oldest valid one
        if (frameTimelineVsyncId != ISurfaceComposer::INVALID_VSYNC_ID &&
            other.frameTimelineVsyncId != ISurfaceComposer::INVALID_VSYNC_ID) {
            frameTimelineVsyncId = std::max(frameTimelineVsyncId, other.frameTimelineVsyncId);
        } else if (frameTimelineVsyncId == ISurfaceComposer::INVALID_VSYNC_ID) {
            frameTimelineVsyncId = other.frameTimelineVsyncId;
        }
        what |= eFrameTimelineVsyncChanged;
    }
    if (other.what & eAutoRefreshChanged) {
        what |= eAutoRefreshChanged;
        autoRefresh = other.autoRefresh;
    }
    if ((other.what & what) != other.what) {
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
+13 −0
Original line number Diff line number Diff line
@@ -1527,6 +1527,19 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAutoRefresh(
        const sp<SurfaceControl>& sc, bool autoRefresh) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }

    s->what |= layer_state_t::eAutoRefreshChanged;
    s->autoRefresh = autoRefresh;
    return *this;
}

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

DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
+4 −0
Original line number Diff line number Diff line
@@ -139,6 +139,10 @@ private:
    // If set to true, the next queue buffer will wait until the shadow queue has been processed by
    // the adapter.
    bool mFlushShadowQueue = false;
    // Last requested auto refresh state set by the producer. The state indicates that the consumer
    // should acquire the next frame as soon as it can and not wait for a frame to become available.
    // This is only relevant for shared buffer mode.
    bool mAutoRefresh GUARDED_BY(mMutex) = false;
};

} // namespace android
+6 −0
Original line number Diff line number Diff line
@@ -130,6 +130,7 @@ struct layer_state_t {
        eFrameNumberChanged = 0x400'00000000,
        eFrameTimelineVsyncChanged = 0x800'00000000,
        eBlurRegionsChanged = 0x1000'00000000,
        eAutoRefreshChanged = 0x2000'00000000,
    };

    layer_state_t();
@@ -234,6 +235,11 @@ struct layer_state_t {
    uint64_t frameNumber;

    int64_t frameTimelineVsyncId;

    // Indicates that the consumer should acquire the next frame as soon as it
    // can and not wait for a frame to become available. This is only relevant
    // in shared buffer mode.
    bool autoRefresh;
};

struct ComposerState {
Loading