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

Commit f3f40fef authored by chaviw's avatar chaviw
Browse files

Added setBufferCrop

Added setBufferCrop to handle setGeometry calls from the public
SurfaceControl. This is because setGeometry gets crop in buffer space,
but setCrop can only handle layer space crop. Added setBufferCrop to
handle this case

Test: ASurfaceControlTest
Fixes: 186266903

Change-Id: I14fb329d2d6f504ca8fa8e330c8a036cbde56f28
parent cfd247d3
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -98,7 +98,6 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.write, transparentRegion);
    SAFE_PARCEL(output.write, transparentRegion);
    SAFE_PARCEL(output.writeUint32, transform);
    SAFE_PARCEL(output.writeUint32, transform);
    SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
    SAFE_PARCEL(output.writeBool, transformToDisplayInverse);
    SAFE_PARCEL(output.write, crop);
    SAFE_PARCEL(output.write, orientedDisplaySpaceRect);
    SAFE_PARCEL(output.write, orientedDisplaySpaceRect);


    if (buffer) {
    if (buffer) {
@@ -167,6 +166,7 @@ status_t layer_state_t::write(Parcel& output) const
    }
    }


    SAFE_PARCEL(output.write, stretchEffect);
    SAFE_PARCEL(output.write, stretchEffect);
    SAFE_PARCEL(output.write, bufferCrop);


    return NO_ERROR;
    return NO_ERROR;
}
}
@@ -209,7 +209,6 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.read, transparentRegion);
    SAFE_PARCEL(input.read, transparentRegion);
    SAFE_PARCEL(input.readUint32, &transform);
    SAFE_PARCEL(input.readUint32, &transform);
    SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
    SAFE_PARCEL(input.readBool, &transformToDisplayInverse);
    SAFE_PARCEL(input.read, crop);
    SAFE_PARCEL(input.read, orientedDisplaySpaceRect);
    SAFE_PARCEL(input.read, orientedDisplaySpaceRect);


    bool tmpBool = false;
    bool tmpBool = false;
@@ -296,6 +295,7 @@ status_t layer_state_t::read(const Parcel& input)
    }
    }


    SAFE_PARCEL(input.read, stretchEffect);
    SAFE_PARCEL(input.read, stretchEffect);
    SAFE_PARCEL(input.read, bufferCrop);


    return NO_ERROR;
    return NO_ERROR;
}
}
@@ -539,6 +539,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eStretchChanged;
        what |= eStretchChanged;
        stretchEffect = other.stretchEffect;
        stretchEffect = other.stretchEffect;
    }
    }
    if (other.what & eBufferCropChanged) {
        what |= eBufferCropChanged;
        bufferCrop = other.bufferCrop;
    }
    if ((other.what & what) != other.what) {
    if ((other.what & what) != other.what) {
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
+15 −0
Original line number Original line Diff line number Diff line
@@ -1664,6 +1664,21 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setStret
    return *this;
    return *this;
}
}


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

    s->what |= layer_state_t::eBufferCropChanged;
    s->bufferCrop = bufferCrop;

    registerSurfaceControlForCallback(sc);
    return *this;
}

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


DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
DisplayState& SurfaceComposerClient::Transaction::getDisplayState(const sp<IBinder>& token) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -85,7 +85,7 @@ struct layer_state_t {
        eReleaseBufferListenerChanged = 0x00000400,
        eReleaseBufferListenerChanged = 0x00000400,
        eShadowRadiusChanged = 0x00000800,
        eShadowRadiusChanged = 0x00000800,
        eLayerCreated = 0x00001000,
        eLayerCreated = 0x00001000,
        /* was eDetachChildren, now available 0x00002000, */
        eBufferCropChanged = 0x00002000,
        eRelativeLayerChanged = 0x00004000,
        eRelativeLayerChanged = 0x00004000,
        eReparent = 0x00008000,
        eReparent = 0x00008000,
        eColorChanged = 0x00010000,
        eColorChanged = 0x00010000,
@@ -227,6 +227,8 @@ struct layer_state_t {
    // Stretch effect to be applied to this layer
    // Stretch effect to be applied to this layer
    StretchEffect stretchEffect;
    StretchEffect stretchEffect;


    Rect bufferCrop;

    // Listens to when the buffer is safe to be released. This is used for blast
    // Listens to when the buffer is safe to be released. This is used for blast
    // layers only. The callback includes a release fence as well as the graphic
    // layers only. The callback includes a release fence as well as the graphic
    // buffer id to identify the buffer.
    // buffer id to identify the buffer.
+2 −0
Original line number Original line Diff line number Diff line
@@ -542,6 +542,8 @@ public:
                                      float right, float bottom, float vecX, float vecY,
                                      float right, float bottom, float vecX, float vecY,
                                      float maxAmount);
                                      float maxAmount);


        Transaction& setBufferCrop(const sp<SurfaceControl>& sc, const Rect& bufferCrop);

        status_t setDisplaySurface(const sp<IBinder>& token,
        status_t setDisplaySurface(const sp<IBinder>& token,
                const sp<IGraphicBufferProducer>& bufferProducer);
                const sp<IGraphicBufferProducer>& bufferProducer);


+18 −2
Original line number Original line Diff line number Diff line
@@ -284,6 +284,17 @@ bool BufferStateLayer::setCrop(const Rect& crop) {
    return true;
    return true;
}
}


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

    mCurrentState.sequence++;
    mCurrentState.bufferCrop = bufferCrop;

    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
}

bool BufferStateLayer::setMatrix(const layer_state_t::matrix22_t& matrix,
bool BufferStateLayer::setMatrix(const layer_state_t::matrix22_t& matrix,
                                 bool allowNonRectPreservingTransforms) {
                                 bool allowNonRectPreservingTransforms) {
    if (mCurrentState.transform.dsdx() == matrix.dsdx &&
    if (mCurrentState.transform.dsdx() == matrix.dsdx &&
@@ -809,10 +820,15 @@ uint32_t BufferStateLayer::getEffectiveScalingMode() const {
}
}


Rect BufferStateLayer::computeBufferCrop(const State& s) {
Rect BufferStateLayer::computeBufferCrop(const State& s) {
    if (s.buffer) {
    if (s.buffer && !s.bufferCrop.isEmpty()) {
        Rect bufferCrop;
        s.buffer->getBuffer()->getBounds().intersect(s.bufferCrop, &bufferCrop);
        return bufferCrop;
    } else if (s.buffer) {
        return s.buffer->getBuffer()->getBounds();
        return s.buffer->getBuffer()->getBounds();
    } else {
        return s.bufferCrop;
    }
    }
    return Rect::INVALID_RECT;
}
}


sp<Layer> BufferStateLayer::createClone() {
sp<Layer> BufferStateLayer::createClone() {
Loading