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

Commit efc7ab6d authored by Jamie Gennis's avatar Jamie Gennis Committed by Mathias Agopian
Browse files

libgui: Add plumbing for active rectangle

This change adds the plumbing to SurfaceTextureClient, BufferQueue, and
SurfaceTexture to get the active rectangle passed to the ANativeWindow to
the buffer consumer.

Change-Id: I35da0889b266327ebb079b6a7136fa3e2e8b00e6
parent f4b32280
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ public:
           mFrameNumber(0),
           mBuf(INVALID_BUFFER_SLOT) {
             mCrop.makeInvalid();
             mActiveRect.makeInvalid();
         }
        // mGraphicBuffer points to the buffer allocated for this slot or is NULL
        // if no buffer has been allocated.
@@ -191,9 +192,13 @@ public:
        // mFrameNumber is the number of the queued frame for this slot.
        uint64_t mFrameNumber;

        // buf is the slot index of this buffer
        // mBuf is the slot index of this buffer
        int mBuf;

        // mActiveRect is the active rectangle for the buffer.  Pixels outside
        // this rectangle are considered completely transparent for the purposes
        // of window composition.
        Rect mActiveRect;
    };

    // The following public functions is the consumer facing interface
@@ -297,6 +302,7 @@ private:
          mAcquireCalled(false),
          mNeedsCleanupOnRelease(false) {
            mCrop.makeInvalid();
            mActiveRect.makeInvalid();
        }

        // mGraphicBuffer points to the buffer allocated for this slot or is NULL
@@ -353,6 +359,12 @@ private:
        // mCrop is the current crop rectangle for this buffer slot.
        Rect mCrop;

        // mActiveRect is the current active rectangle for this buffer slot.
        // Pixels outside of this rectangle are to be treated as completely
        // transparent during window composition.  The rectangle is in buffer
        // pixel coordinates.
        Rect mActiveRect;

        // mTransform is the current transform flags for this buffer slot.
        uint32_t mTransform;

+7 −3
Original line number Diff line number Diff line
@@ -86,21 +86,25 @@ protected:
    // QueueBufferInput must be a POD structure
    struct QueueBufferInput {
        inline QueueBufferInput(int64_t timestamp,
                const Rect& crop, int scalingMode, uint32_t transform)
                const Rect& crop, int scalingMode, uint32_t transform,
                const Rect& activeRect)
        : timestamp(timestamp), crop(crop), scalingMode(scalingMode),
          transform(transform) { }
          transform(transform), activeRect(activeRect) { }
        inline void deflate(int64_t* outTimestamp, Rect* outCrop,
                int* outScalingMode, uint32_t* outTransform) const {
                int* outScalingMode, uint32_t* outTransform,
                Rect* outActiveRect) const {
            *outTimestamp = timestamp;
            *outCrop = crop;
            *outScalingMode = scalingMode;
            *outTransform = transform;
            *outActiveRect = activeRect;
        }
    private:
        int64_t timestamp;
        Rect crop;
        int scalingMode;
        uint32_t transform;
        Rect activeRect;
    };

    // QueueBufferOutput must be a POD structure
+12 −3
Original line number Diff line number Diff line
@@ -151,13 +151,16 @@ public:
    // texture as returned by updateTexImage().
    GLenum getCurrentTextureTarget() const;

    // getCurrentCrop returns the cropping rectangle of the current buffer
    // getCurrentCrop returns the cropping rectangle of the current buffer.
    Rect getCurrentCrop() const;

    // getCurrentTransform returns the transform of the current buffer
    // getCurrentActiveRect returns the active rectangle of the current buffer.
    Rect getCurrentActiveRect() const;

    // getCurrentTransform returns the transform of the current buffer.
    uint32_t getCurrentTransform() const;

    // getCurrentScalingMode returns the scaling mode of the current buffer
    // getCurrentScalingMode returns the scaling mode of the current buffer.
    uint32_t getCurrentScalingMode() const;

    // isSynchronousMode returns whether the SurfaceTexture is currently in
@@ -270,6 +273,12 @@ private:
    // It gets set each time updateTexImage is called.
    Rect mCurrentCrop;

    // mCurrentActiveRect is the active rectangle that applies to the current
    // texture.  It gets set each time updateTexImage is called.  All pixels
    // outside the active rectangle are be considered completely transparent for
    // the purpose of window composition.
    Rect mCurrentActiveRect;

    // mCurrentTransform is the transform identifier for the current texture. It
    // gets set each time updateTexImage is called.
    uint32_t mCurrentTransform;
+6 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ private:
    int dispatchSetUsage(va_list args);
    int dispatchLock(va_list args);
    int dispatchUnlockAndPost(va_list args);
    int dispatchSetActiveRect(va_list args);

protected:
    virtual int cancelBuffer(ANativeWindowBuffer* buffer);
@@ -106,6 +107,7 @@ protected:
    virtual int setUsage(uint32_t reqUsage);
    virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds);
    virtual int unlockAndPost();
    virtual int setActiveRect(Rect const* rect);

    enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS };
    enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 };
@@ -165,6 +167,10 @@ private:
    // buffer that gets queued. It is set by calling setTransform.
    uint32_t mTransform;

    // mActiveRect is the active rectangle that will be used for the next buffer
    // that gets queued.  It is set by calling setActiveRect.
    Rect mActiveRect;

     // mDefaultWidth is default width of the buffers, regardless of the
     // native_window_set_buffers_dimensions call.
     uint32_t mDefaultWidth;
+18 −14
Original line number Diff line number Diff line
@@ -536,12 +536,19 @@ status_t BufferQueue::queueBuffer(int buf,
    ATRACE_CALL();
    ATRACE_BUFFER_INDEX(buf);

    ST_LOGV("queueBuffer: slot=%d time=%lld crop=[%d,%d,%d,%d]", buf,
            mSlots[buf].mTimestamp,
            mSlots[buf].mCrop.left,
            mSlots[buf].mCrop.top,
            mSlots[buf].mCrop.right,
            mSlots[buf].mCrop.bottom);
    Rect crop;
    uint32_t transform;
    int scalingMode;
    int64_t timestamp;
    Rect activeRect;

    input.deflate(&timestamp, &crop, &scalingMode, &transform,
            &activeRect);

    ST_LOGV("queueBuffer: slot=%d time=%lld crop=[%d,%d,%d,%d] "
            "active=[%d,%d,%d,%d]", buf, timestamp, crop.left, crop.top,
            crop.right, crop.bottom, activeRect.left, activeRect.top,
            activeRect.right, activeRect.bottom);

    sp<ConsumerListener> listener;

@@ -590,14 +597,10 @@ status_t BufferQueue::queueBuffer(int buf,
            }
        }

        int scalingMode;

        input.deflate(
                &mSlots[buf].mTimestamp,
                &mSlots[buf].mCrop,
                &scalingMode,
                &mSlots[buf].mTransform);

        mSlots[buf].mTimestamp = timestamp;
        mSlots[buf].mCrop = crop;
        mSlots[buf].mTransform = transform;
        mSlots[buf].mActiveRect = activeRect;

        switch (scalingMode) {
            case NATIVE_WINDOW_SCALING_MODE_FREEZE:
@@ -856,6 +859,7 @@ status_t BufferQueue::acquireBuffer(BufferItem *buffer) {
        buffer->mFrameNumber = mSlots[buf].mFrameNumber;
        buffer->mTimestamp = mSlots[buf].mTimestamp;
        buffer->mBuf = buf;
        buffer->mActiveRect = mSlots[buf].mActiveRect;
        mSlots[buf].mAcquireCalled = true;

        mSlots[buf].mBufferState = BufferSlot::ACQUIRED;
Loading