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

Commit 11dcc220 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Pass surface control instead of handle as reference to layers in

LayerState

Allows us to have access to the layer id stored in surface control so that it can be dumped when tracing the transaction merges

Test: Existing tests
Change-Id: I3e466c69585937d8ce74a29a49fdbb7b3353a460
parent 97651d23
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -584,9 +584,7 @@ void Replayer::setDeferredTransaction(SurfaceComposerClient::Transaction& t,
        return;
    }

    auto handle = mLayers[dtc.layer_id()]->getHandle();

    t.deferTransactionUntil_legacy(mLayers[id], handle, dtc.frame_number());
    t.deferTransactionUntil_legacy(mLayers[id], mLayers[dtc.layer_id()], dtc.frame_number());
}

void Replayer::setDisplaySurface(SurfaceComposerClient::Transaction& t,
@@ -706,11 +704,11 @@ status_t Replayer::loadSurfaceComposerClient() {

void Replayer::setReparentChange(SurfaceComposerClient::Transaction& t,
        layer_id id, const ReparentChange& c) {
    sp<IBinder> newParentHandle = nullptr;
    sp<SurfaceControl> newSurfaceControl = nullptr;
    if (mLayers.count(c.parent_id()) != 0 && mLayers[c.parent_id()] != nullptr) {
        newParentHandle = mLayers[c.parent_id()]->getHandle();
        newSurfaceControl = mLayers[c.parent_id()];
    }
    t.reparent(mLayers[id], newParentHandle);
    t.reparent(mLayers[id], newSurfaceControl);
}

void Replayer::setRelativeParentChange(SurfaceComposerClient::Transaction& t,
@@ -719,7 +717,7 @@ void Replayer::setRelativeParentChange(SurfaceComposerClient::Transaction& t,
        ALOGE("Layer %d not found in set relative parent transaction", c.relative_parent_id());
        return;
    }
    t.setRelativeLayer(mLayers[id], mLayers[c.relative_parent_id()]->getHandle(), c.z());
    t.setRelativeLayer(mLayers[id], mLayers[c.relative_parent_id()], c.z());
}

void Replayer::setDetachChildrenChange(SurfaceComposerClient::Transaction& t,
@@ -733,7 +731,7 @@ void Replayer::setReparentChildrenChange(SurfaceComposerClient::Transaction& t,
        ALOGE("Layer %d not found in reparent children transaction", c.parent_id());
        return;
    }
    t.reparentChildren(mLayers[id], mLayers[c.parent_id()]->getHandle());
    t.reparentChildren(mLayers[id], mLayers[c.parent_id()]);
}

void Replayer::setShadowRadiusChange(SurfaceComposerClient::Transaction& t,
+54 −14
Original line number Diff line number Diff line
@@ -18,16 +18,55 @@

#include <inttypes.h>

#include <utils/Errors.h>
#include <binder/Parcel.h>
#include <gui/ISurfaceComposerClient.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/ISurfaceComposerClient.h>
#include <gui/LayerState.h>
#include <utils/Errors.h>

#include <cmath>

namespace android {

layer_state_t::layer_state_t()
      : what(0),
        x(0),
        y(0),
        z(0),
        w(0),
        h(0),
        layerStack(0),
        alpha(0),
        flags(0),
        mask(0),
        reserved(0),
        crop_legacy(Rect::INVALID_RECT),
        cornerRadius(0.0f),
        backgroundBlurRadius(0),
        barrierFrameNumber(0),
        overrideScalingMode(-1),
        transform(0),
        transformToDisplayInverse(false),
        crop(Rect::INVALID_RECT),
        orientedDisplaySpaceRect(Rect::INVALID_RECT),
        dataspace(ui::Dataspace::UNKNOWN),
        surfaceDamageRegion(),
        api(-1),
        colorTransform(mat4()),
        bgColorAlpha(0),
        bgColorDataspace(ui::Dataspace::UNKNOWN),
        colorSpaceAgnostic(false),
        shadowRadius(0.0f),
        frameRateSelectionPriority(-1),
        frameRate(0.0f),
        frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
        fixedTransformHint(ui::Transform::ROT_INVALID),
        frameNumber(0) {
    matrix.dsdx = matrix.dtdy = 1.0f;
    matrix.dsdy = matrix.dtdx = 0.0f;
    hdrMetadata.validTypes = 0;
}

status_t layer_state_t::write(Parcel& output) const
{
    SAFE_PARCEL(output.writeStrongBinder, surface);
@@ -44,13 +83,13 @@ status_t layer_state_t::write(Parcel& output) const
    SAFE_PARCEL(output.writeUint32, mask);
    SAFE_PARCEL(matrix.write, output);
    SAFE_PARCEL(output.write, crop_legacy);
    SAFE_PARCEL(output.writeStrongBinder, barrierHandle_legacy);
    SAFE_PARCEL(output.writeStrongBinder, reparentHandle);
    SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, barrierSurfaceControl_legacy);
    SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, reparentSurfaceControl);
    SAFE_PARCEL(output.writeUint64, barrierFrameNumber);
    SAFE_PARCEL(output.writeInt32, overrideScalingMode);
    SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(barrierGbp_legacy));
    SAFE_PARCEL(output.writeStrongBinder, relativeLayerHandle);
    SAFE_PARCEL(output.writeStrongBinder, parentHandleForChild);
    SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, relativeLayerSurfaceControl);
    SAFE_PARCEL(SurfaceControl::writeNullableToParcel, output, parentSurfaceControlForChild);
    SAFE_PARCEL(output.writeFloat, color.r);
    SAFE_PARCEL(output.writeFloat, color.g);
    SAFE_PARCEL(output.writeFloat, color.b);
@@ -135,8 +174,8 @@ status_t layer_state_t::read(const Parcel& input)

    SAFE_PARCEL(matrix.read, input);
    SAFE_PARCEL(input.read, crop_legacy);
    SAFE_PARCEL(input.readNullableStrongBinder, &barrierHandle_legacy);
    SAFE_PARCEL(input.readNullableStrongBinder, &reparentHandle);
    SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &barrierSurfaceControl_legacy);
    SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &reparentSurfaceControl);
    SAFE_PARCEL(input.readUint64, &barrierFrameNumber);
    SAFE_PARCEL(input.readInt32, &overrideScalingMode);

@@ -144,9 +183,10 @@ status_t layer_state_t::read(const Parcel& input)
    SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder);
    barrierGbp_legacy = interface_cast<IGraphicBufferProducer>(tmpBinder);

    SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &relativeLayerSurfaceControl);
    SAFE_PARCEL(SurfaceControl::readNullableFromParcel, input, &parentSurfaceControlForChild);

    float tmpFloat = 0;
    SAFE_PARCEL(input.readNullableStrongBinder, &relativeLayerHandle);
    SAFE_PARCEL(input.readNullableStrongBinder, &parentHandleForChild);
    SAFE_PARCEL(input.readFloat, &tmpFloat);
    color.r = tmpFloat;
    SAFE_PARCEL(input.readFloat, &tmpFloat);
@@ -342,7 +382,7 @@ void layer_state_t::merge(const layer_state_t& other) {
    }
    if (other.what & eDeferTransaction_legacy) {
        what |= eDeferTransaction_legacy;
        barrierHandle_legacy = other.barrierHandle_legacy;
        barrierSurfaceControl_legacy = other.barrierSurfaceControl_legacy;
        barrierGbp_legacy = other.barrierGbp_legacy;
        barrierFrameNumber = other.barrierFrameNumber;
    }
@@ -352,7 +392,7 @@ void layer_state_t::merge(const layer_state_t& other) {
    }
    if (other.what & eReparentChildren) {
        what |= eReparentChildren;
        reparentHandle = other.reparentHandle;
        reparentSurfaceControl = other.reparentSurfaceControl;
    }
    if (other.what & eDetachChildren) {
        what |= eDetachChildren;
@@ -361,11 +401,11 @@ void layer_state_t::merge(const layer_state_t& other) {
        what |= eRelativeLayerChanged;
        what &= ~eLayerChanged;
        z = other.z;
        relativeLayerHandle = other.relativeLayerHandle;
        relativeLayerSurfaceControl = other.relativeLayerSurfaceControl;
    }
    if (other.what & eReparent) {
        what |= eReparent;
        parentHandleForChild = other.parentHandleForChild;
        parentSurfaceControlForChild = other.parentSurfaceControlForChild;
    }
    if (other.what & eDestroySurface) {
        what |= eDestroySurface;
+11 −13
Original line number Diff line number Diff line
@@ -875,8 +875,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setLayer
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelativeLayer(const sp<SurfaceControl>& sc, const sp<IBinder>& relativeTo,
        int32_t z) {
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelativeLayer(
        const sp<SurfaceControl>& sc, const sp<SurfaceControl>& relativeTo, int32_t z) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
@@ -884,7 +884,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setRelat
    }
    s->what |= layer_state_t::eRelativeLayerChanged;
    s->what &= ~layer_state_t::eLayerChanged;
    s->relativeLayerHandle = relativeTo;
    s->relativeLayerSurfaceControl = relativeTo;
    s->z = z;

    registerSurfaceControlForCallback(sc);
@@ -1028,8 +1028,8 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setBackg
}

SurfaceComposerClient::Transaction&
SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<SurfaceControl>& sc,
                                                                 const sp<IBinder>& handle,
SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(
        const sp<SurfaceControl>& sc, const sp<SurfaceControl>& barrierSurfaceControl,
        uint64_t frameNumber) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
@@ -1037,7 +1037,7 @@ SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<Surfac
        return *this;
    }
    s->what |= layer_state_t::eDeferTransaction_legacy;
    s->barrierHandle_legacy = handle;
    s->barrierSurfaceControl_legacy = barrierSurfaceControl;
    s->barrierFrameNumber = frameNumber;

    registerSurfaceControlForCallback(sc);
@@ -1062,30 +1062,28 @@ SurfaceComposerClient::Transaction::deferTransactionUntil_legacy(const sp<Surfac
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::reparentChildren(
        const sp<SurfaceControl>& sc,
        const sp<IBinder>& newParentHandle) {
        const sp<SurfaceControl>& sc, const sp<SurfaceControl>& newParent) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eReparentChildren;
    s->reparentHandle = newParentHandle;
    s->reparentSurfaceControl = newParent;

    registerSurfaceControlForCallback(sc);
    return *this;
}

SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::reparent(
        const sp<SurfaceControl>& sc,
        const sp<IBinder>& newParentHandle) {
        const sp<SurfaceControl>& sc, const sp<SurfaceControl>& newParent) {
    layer_state_t* s = getLayerState(sc);
    if (!s) {
        mStatus = BAD_INDEX;
        return *this;
    }
    s->what |= layer_state_t::eReparent;
    s->parentHandleForChild = newParentHandle;
    s->parentSurfaceControlForChild = newParent;

    registerSurfaceControlForCallback(sc);
    return *this;
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <android/native_window.h>

#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/Log.h>
#include <utils/threads.h>

+6 −42
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@

#include <gui/ISurfaceComposer.h>
#include <gui/LayerMetadata.h>
#include <gui/SurfaceControl.h>
#include <math/vec3.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
@@ -128,44 +129,7 @@ struct layer_state_t {
        eFrameNumberChanged = 0x400'00000000,
    };

    layer_state_t()
          : what(0),
            x(0),
            y(0),
            z(0),
            w(0),
            h(0),
            layerStack(0),
            alpha(0),
            flags(0),
            mask(0),
            reserved(0),
            crop_legacy(Rect::INVALID_RECT),
            cornerRadius(0.0f),
            backgroundBlurRadius(0),
            barrierFrameNumber(0),
            overrideScalingMode(-1),
            transform(0),
            transformToDisplayInverse(false),
            crop(Rect::INVALID_RECT),
            orientedDisplaySpaceRect(Rect::INVALID_RECT),
            dataspace(ui::Dataspace::UNKNOWN),
            surfaceDamageRegion(),
            api(-1),
            colorTransform(mat4()),
            bgColorAlpha(0),
            bgColorDataspace(ui::Dataspace::UNKNOWN),
            colorSpaceAgnostic(false),
            shadowRadius(0.0f),
            frameRateSelectionPriority(-1),
            frameRate(0.0f),
            frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
            fixedTransformHint(ui::Transform::ROT_INVALID),
            frameNumber(0) {
        matrix.dsdx = matrix.dtdy = 1.0f;
        matrix.dsdy = matrix.dtdx = 0.0f;
        hdrMetadata.validTypes = 0;
    }
    layer_state_t();

    void merge(const layer_state_t& other);
    status_t write(Parcel& output) const;
@@ -196,16 +160,16 @@ struct layer_state_t {
    Rect crop_legacy;
    float cornerRadius;
    uint32_t backgroundBlurRadius;
    sp<IBinder> barrierHandle_legacy;
    sp<IBinder> reparentHandle;
    sp<SurfaceControl> barrierSurfaceControl_legacy;
    sp<SurfaceControl> reparentSurfaceControl;
    uint64_t barrierFrameNumber;
    int32_t overrideScalingMode;

    sp<IGraphicBufferProducer> barrierGbp_legacy;

    sp<IBinder> relativeLayerHandle;
    sp<SurfaceControl> relativeLayerSurfaceControl;

    sp<IBinder> parentHandleForChild;
    sp<SurfaceControl> parentSurfaceControlForChild;

    half3 color;

Loading