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

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

Merge changes from topic "blast frame"

* changes:
  blast: use frame instead of size and position
  Change what in layer_state_t to 64 bit.
parents 161410bc 861616df
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#define LOG_TAG "LayerState"

#include <inttypes.h>

#include <utils/Errors.h>
#include <binder/Parcel.h>
#include <gui/ISurfaceComposerClient.h>
@@ -27,7 +29,7 @@ namespace android {
status_t layer_state_t::write(Parcel& output) const
{
    output.writeStrongBinder(surface);
    output.writeUint32(what);
    output.writeUint64(what);
    output.writeFloat(x);
    output.writeFloat(y);
    output.writeInt32(z);
@@ -57,6 +59,7 @@ status_t layer_state_t::write(Parcel& output) const
    output.writeUint32(transform);
    output.writeBool(transformToDisplayInverse);
    output.write(crop);
    output.write(frame);
    if (buffer) {
        output.writeBool(true);
        output.write(*buffer);
@@ -97,7 +100,7 @@ status_t layer_state_t::write(Parcel& output) const
status_t layer_state_t::read(const Parcel& input)
{
    surface = input.readStrongBinder();
    what = input.readUint32();
    what = input.readUint64();
    x = input.readFloat();
    y = input.readFloat();
    z = input.readInt32();
@@ -133,6 +136,7 @@ status_t layer_state_t::read(const Parcel& input)
    transform = input.readUint32();
    transformToDisplayInverse = input.readBool();
    input.read(crop);
    input.read(frame);
    buffer = new GraphicBuffer();
    if (input.readBool()) {
        input.read(*buffer);
@@ -320,6 +324,10 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eCropChanged;
        crop = other.crop;
    }
    if (other.what & eFrameChanged) {
        what |= eFrameChanged;
        frame = other.frame;
    }
    if (other.what & eBufferChanged) {
        what |= eBufferChanged;
        buffer = other.buffer;
@@ -366,7 +374,7 @@ void layer_state_t::merge(const layer_state_t& other) {

    if ((other.what & what) != other.what) {
        ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
              "other.what=0x%X what=0x%X",
              "other.what=0x%" PRIu64 " what=0x%" PRIu64,
              other.what, what);
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -609,6 +609,20 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setCrop(
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame(
        const sp<SurfaceControl>& sc, const Rect& frame) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eFrameChanged;
    s->frame = frame;

    registerSurfaceControlForCallback(sc);
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBuffer(
        const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer) {
    layer_state_t* s = getLayerState(sc);
+4 −1
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ struct layer_state_t {
        eListenerCallbacksChanged = 0x20000000,
        eInputInfoChanged = 0x40000000,
        eCornerRadiusChanged = 0x80000000,
        eFrameChanged = 0x1'00000000,
    };

    layer_state_t()
@@ -104,6 +105,7 @@ struct layer_state_t {
            transform(0),
            transformToDisplayInverse(false),
            crop(Rect::INVALID_RECT),
            frame(Rect::INVALID_RECT),
            dataspace(ui::Dataspace::UNKNOWN),
            surfaceDamageRegion(),
            api(-1),
@@ -124,7 +126,7 @@ struct layer_state_t {
        float dsdy{0};
    };
    sp<IBinder> surface;
    uint32_t what;
    uint64_t what;
    float x;
    float y;
    int32_t z;
@@ -157,6 +159,7 @@ struct layer_state_t {
    uint32_t transform;
    bool transformToDisplayInverse;
    Rect crop;
    Rect frame;
    sp<GraphicBuffer> buffer;
    sp<Fence> acquireFence;
    ui::Dataspace dataspace;
+1 −0
Original line number Diff line number Diff line
@@ -295,6 +295,7 @@ public:
        Transaction& setTransformToDisplayInverse(const sp<SurfaceControl>& sc,
                                                  bool transformToDisplayInverse);
        Transaction& setCrop(const sp<SurfaceControl>& sc, const Rect& crop);
        Transaction& setFrame(const sp<SurfaceControl>& sc, const Rect& frame);
        Transaction& setBuffer(const sp<SurfaceControl>& sc, const sp<GraphicBuffer>& buffer);
        Transaction& setAcquireFence(const sp<SurfaceControl>& sc, const sp<Fence>& fence);
        Transaction& setDataspace(const sp<SurfaceControl>& sc, ui::Dataspace dataspace);
+51 −38
Original line number Diff line number Diff line
@@ -97,10 +97,9 @@ bool BufferStateLayer::applyPendingStates(Layer::State* stateToCommit) {
    return stateUpdateAvailable;
}

Rect BufferStateLayer::getCrop(const Layer::State& s) const {
    return (getEffectiveScalingMode() == NATIVE_WINDOW_SCALING_MODE_SCALE_CROP)
            ? GLConsumer::scaleDownCrop(s.crop, s.active.w, s.active.h)
            : s.crop;
// Crop that applies to the window
Rect BufferStateLayer::getCrop(const Layer::State& /*s*/) const {
    return Rect::INVALID_RECT;
}

bool BufferStateLayer::setTransform(uint32_t transform) {
@@ -130,6 +129,30 @@ bool BufferStateLayer::setCrop(const Rect& crop) {
    return true;
}

bool BufferStateLayer::setFrame(const Rect& frame) {
    int x = frame.left;
    int y = frame.top;
    int w = frame.getWidth();
    int h = frame.getHeight();

    if (mCurrentState.active.transform.tx() == x && mCurrentState.active.transform.ty() == y &&
        mCurrentState.active.w == w && mCurrentState.active.h == h) {
        return false;
    }

    if (!frame.isValid()) {
        x = y = w = h = 0;
    }
    mCurrentState.active.transform.set(x, y);
    mCurrentState.active.w = w;
    mCurrentState.active.h = h;

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

bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer) {
    if (mCurrentState.buffer) {
        mReleasePreviousBuffer = true;
@@ -239,27 +262,6 @@ bool BufferStateLayer::setTransactionCompletedListeners(
    return willPresent;
}

bool BufferStateLayer::setSize(uint32_t w, uint32_t h) {
    if (mCurrentState.active.w == w && mCurrentState.active.h == h) return false;
    mCurrentState.active.w = w;
    mCurrentState.active.h = h;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
}

bool BufferStateLayer::setPosition(float x, float y, bool /*immediate*/) {
    if (mCurrentState.active.transform.tx() == x && mCurrentState.active.transform.ty() == y)
        return false;

    mCurrentState.active.transform.set(x, y);

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

bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) {
    mCurrentState.transparentRegionHint = transparent;
    mCurrentState.modified = true;
@@ -267,21 +269,26 @@ bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) {
    return true;
}

bool BufferStateLayer::setMatrix(const layer_state_t::matrix22_t& matrix,
                                 bool allowNonRectPreservingTransforms) {
    ui::Transform t;
    t.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
Rect BufferStateLayer::getBufferSize(const State& s) const {
    // for buffer state layers we use the display frame size as the buffer size.
    if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
        return Rect(getActiveWidth(s), getActiveHeight(s));
    }

    if (!allowNonRectPreservingTransforms && !t.preserveRects()) {
        ALOGW("Attempt to set rotation matrix without permission ACCESS_SURFACE_FLINGER ignored");
        return false;
    // if the display frame is not defined, use the parent bounds as the buffer size.
    const auto& p = mDrawingParent.promote();
    if (p != nullptr) {
        Rect parentBounds = Rect(p->computeBounds(Region()));
        if (!parentBounds.isEmpty()) {
            return parentBounds;
        }
    }

    mCurrentState.sequence++;
    mCurrentState.active.transform.set(matrix.dsdx, matrix.dtdy, matrix.dtdx, matrix.dsdy);
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
    // if there is no parent layer, use the buffer's bounds as the buffer size
    if (s.buffer) {
        return s.buffer->getBounds();
    }
    return Rect::INVALID_RECT;
}
// -----------------------------------------------------------------------

@@ -317,8 +324,14 @@ ui::Dataspace BufferStateLayer::getDrawingDataSpace() const {
    return getDrawingState().dataspace;
}

// Crop that applies to the buffer
Rect BufferStateLayer::getDrawingCrop() const {
    return Rect::INVALID_RECT;
    const State& s(getDrawingState());

    if (s.crop.isEmpty() && s.buffer) {
        return s.buffer->getBounds();
    }
    return s.crop;
}

uint32_t BufferStateLayer::getDrawingScalingMode() const {
Loading