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

Commit 1a8bfd09 authored by Jamie Gennis's avatar Jamie Gennis Committed by Android Git Automerger
Browse files

am cae7c0b9: Merge "libgui: Add support for post-xform crops." into jb-dev

* commit 'cae7c0b9':
  libgui: Add support for post-xform crops.
parents 8d1afba6 cae7c0b9
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -170,7 +170,6 @@ 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.
@@ -194,11 +193,6 @@ public:

        // 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
@@ -302,7 +296,6 @@ private:
          mAcquireCalled(false),
          mNeedsCleanupOnRelease(false) {
            mCrop.makeInvalid();
            mActiveRect.makeInvalid();
        }

        // mGraphicBuffer points to the buffer allocated for this slot or is NULL
@@ -359,12 +352,6 @@ 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;

+3 −7
Original line number Diff line number Diff line
@@ -86,25 +86,21 @@ protected:
    // QueueBufferInput must be a POD structure
    struct QueueBufferInput {
        inline QueueBufferInput(int64_t timestamp,
                const Rect& crop, int scalingMode, uint32_t transform,
                const Rect& activeRect)
                const Rect& crop, int scalingMode, uint32_t transform)
        : timestamp(timestamp), crop(crop), scalingMode(scalingMode),
          transform(transform), activeRect(activeRect) { }
          transform(transform) { }
        inline void deflate(int64_t* outTimestamp, Rect* outCrop,
                int* outScalingMode, uint32_t* outTransform,
                Rect* outActiveRect) const {
                int* outScalingMode, uint32_t* outTransform) 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
+0 −9
Original line number Diff line number Diff line
@@ -154,9 +154,6 @@ public:
    // getCurrentCrop returns the cropping rectangle of the current buffer.
    Rect getCurrentCrop() const;

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

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

@@ -273,12 +270,6 @@ 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;
+9 −6
Original line number Diff line number Diff line
@@ -80,10 +80,10 @@ private:
    int dispatchSetBuffersTransform(va_list args);
    int dispatchSetBuffersTimestamp(va_list args);
    int dispatchSetCrop(va_list args);
    int dispatchSetPostTransformCrop(va_list args);
    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);
@@ -104,10 +104,10 @@ protected:
    virtual int setBuffersTransform(int transform);
    virtual int setBuffersTimestamp(int64_t timestamp);
    virtual int setCrop(Rect const* rect);
    virtual int setPostTransformCrop(Rect const* rect);
    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 };
@@ -159,6 +159,13 @@ private:
    // that gets queued. It is set by calling setCrop.
    Rect mCrop;

    // mCropNeedsTransform indicates whether mCrop is in post-transform
    // coordinates and must be transformed using the inverse of mTransform
    // before being queued with a buffer.  Otherwise the crop is passed
    // untransformed.  It is initialized to false, is set to true by
    // setPostTransformCrop, and set to false by setCrop.
    bool mCropNeedsTransform;

    // mScalingMode is the scaling mode that will be used for the next
    // buffers that get queued. It is set by calling setScalingMode.
    int mScalingMode;
@@ -167,10 +174,6 @@ 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;
+14 −9
Original line number Diff line number Diff line
@@ -540,15 +540,11 @@ status_t BufferQueue::queueBuffer(int buf,
    uint32_t transform;
    int scalingMode;
    int64_t timestamp;
    Rect activeRect;

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

    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);
    ST_LOGV("queueBuffer: slot=%d time=%lld crop=[%d,%d,%d,%d]",
            buf, timestamp, crop.left, crop.top, crop.right, crop.bottom);

    sp<ConsumerListener> listener;

@@ -572,6 +568,16 @@ status_t BufferQueue::queueBuffer(int buf,
            return -EINVAL;
        }

        const sp<GraphicBuffer>& graphicBuffer(mSlots[buf].mGraphicBuffer);
        Rect bufferRect(graphicBuffer->getWidth(), graphicBuffer->getHeight());
        Rect croppedCrop;
        crop.intersect(bufferRect, &croppedCrop);
        if (croppedCrop != crop) {
            ST_LOGE("queueBuffer: crop rect is not contained within the "
                    "buffer in slot %d", buf);
            return -EINVAL;
        }

        if (mSynchronousMode) {
            // In synchronous mode we queue all buffers in a FIFO.
            mQueue.push_back(buf);
@@ -600,12 +606,12 @@ status_t BufferQueue::queueBuffer(int buf,
        mSlots[buf].mTimestamp = timestamp;
        mSlots[buf].mCrop = crop;
        mSlots[buf].mTransform = transform;
        mSlots[buf].mActiveRect = activeRect;

        switch (scalingMode) {
            case NATIVE_WINDOW_SCALING_MODE_FREEZE:
            case NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW:
            case NATIVE_WINDOW_SCALING_MODE_SCALE_CROP:
            case NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP:
                break;
            default:
                ST_LOGE("unknown scaling mode: %d (ignoring)", scalingMode);
@@ -859,7 +865,6 @@ 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