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

Commit 766c9c53 authored by chaviw's avatar chaviw
Browse files

Simplify width, height, transform variable for BSL

Initial refactor to remove setFrame and use crop and transform instead.
Renamed some BSL variables to avoid confusion.

Test: Builds
Bug: 170765639
Change-Id: I907940638c32103cb867c3b1566b9d4ce26c7274
parent 785ac97f
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -255,8 +255,8 @@ Rect BufferStateLayer::getCrop(const Layer::State& /*s*/) const {
}

bool BufferStateLayer::setTransform(uint32_t transform) {
    if (mCurrentState.transform == transform) return false;
    mCurrentState.transform = transform;
    if (mCurrentState.bufferTransform == transform) return false;
    mCurrentState.bufferTransform = transform;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    return true;
@@ -308,17 +308,17 @@ bool BufferStateLayer::setFrame(const Rect& frame) {
        h = frame.bottom;
    }

    if (mCurrentState.active.transform.tx() == x && mCurrentState.active.transform.ty() == y &&
        mCurrentState.active.w == w && mCurrentState.active.h == h) {
    if (mCurrentState.transform.tx() == x && mCurrentState.transform.ty() == y &&
        mCurrentState.width == w && mCurrentState.height == 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.transform.set(x, y);
    mCurrentState.width = w;
    mCurrentState.height = h;

    mCurrentState.sequence++;
    mCurrentState.modified = true;
@@ -779,7 +779,7 @@ void BufferStateLayer::gatherBufferInfo() {
    mBufferInfo.mDesiredPresentTime = s.desiredPresentTime;
    mBufferInfo.mFenceTime = std::make_shared<FenceTime>(s.acquireFence);
    mBufferInfo.mFence = s.acquireFence;
    mBufferInfo.mTransform = s.transform;
    mBufferInfo.mTransform = s.bufferTransform;
    mBufferInfo.mDataspace = translateDataspace(s.dataspace);
    mBufferInfo.mCrop = computeCrop(s);
    mBufferInfo.mScaleMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
@@ -846,10 +846,10 @@ Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const {
    const State& s(getDrawingState());
    if (radius <= 0 || (getActiveWidth(s) == UINT32_MAX && getActiveHeight(s) == UINT32_MAX))
        return RoundedCornerState();
    return RoundedCornerState(FloatRect(static_cast<float>(s.active.transform.tx()),
                                        static_cast<float>(s.active.transform.ty()),
                                        static_cast<float>(s.active.transform.tx() + s.active.w),
                                        static_cast<float>(s.active.transform.ty() + s.active.h)),
    return RoundedCornerState(FloatRect(static_cast<float>(s.transform.tx()),
                                        static_cast<float>(s.transform.ty()),
                                        static_cast<float>(s.transform.tx() + s.width),
                                        static_cast<float>(s.transform.ty() + s.height)),
                              radius);
}

@@ -863,7 +863,7 @@ bool BufferStateLayer::bufferNeedsFiltering() const {
    uint32_t bufferHeight = s.buffer->height;

    // Undo any transformations on the buffer and return the result.
    if (s.transform & ui::Transform::ROT_90) {
    if (s.bufferTransform & ui::Transform::ROT_90) {
        std::swap(bufferWidth, bufferHeight);
    }

+3 −5
Original line number Diff line number Diff line
@@ -55,11 +55,9 @@ public:
    void pushPendingState() override;*/
    bool applyPendingStates(Layer::State* stateToCommit) override;

    uint32_t getActiveWidth(const Layer::State& s) const override { return s.active.w; }
    uint32_t getActiveHeight(const Layer::State& s) const override { return s.active.h; }
    ui::Transform getActiveTransform(const Layer::State& s) const override {
        return s.active.transform;
    }
    uint32_t getActiveWidth(const Layer::State& s) const override { return s.width; }
    uint32_t getActiveHeight(const Layer::State& s) const override { return s.height; }
    ui::Transform getActiveTransform(const Layer::State& s) const override { return s.transform; }
    Region getActiveTransparentRegion(const Layer::State& s) const override {
        return s.transparentRegionHint;
    }
+7 −8
Original line number Diff line number Diff line
@@ -109,11 +109,11 @@ Layer::Layer(const LayerCreationArgs& args)
    mCurrentState.layerStack = 0;
    mCurrentState.sequence = 0;
    mCurrentState.requested_legacy = mCurrentState.active_legacy;
    mCurrentState.active.w = UINT32_MAX;
    mCurrentState.active.h = UINT32_MAX;
    mCurrentState.active.transform.set(0, 0);
    mCurrentState.width = UINT32_MAX;
    mCurrentState.height = UINT32_MAX;
    mCurrentState.transform.set(0, 0);
    mCurrentState.frameNumber = 0;
    mCurrentState.transform = 0;
    mCurrentState.bufferTransform = 0;
    mCurrentState.transformToDisplayInverse = false;
    mCurrentState.crop.makeInvalid();
    mCurrentState.acquireFence = new Fence(-1);
@@ -2431,7 +2431,7 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
    const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
    const State& state = useDrawing ? mDrawingState : mCurrentState;

    ui::Transform requestedTransform = state.active_legacy.transform;
    ui::Transform requestedTransform = state.transform;

    if (traceFlags & SurfaceTracing::TRACE_CRITICAL) {
        layerInfo->set_id(sequence);
@@ -2460,11 +2460,10 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
                                                   return layerInfo->mutable_requested_position();
                                               });

        LayerProtoHelper::writeSizeToProto(state.active_legacy.w, state.active_legacy.h,
        LayerProtoHelper::writeSizeToProto(state.width, state.height,
                                           [&]() { return layerInfo->mutable_size(); });

        LayerProtoHelper::writeToProto(state.crop_legacy,
                                       [&]() { return layerInfo->mutable_crop(); });
        LayerProtoHelper::writeToProto(state.crop, [&]() { return layerInfo->mutable_crop(); });

        layerInfo->set_is_opaque(isOpaque(state));

+4 −2
Original line number Diff line number Diff line
@@ -250,9 +250,11 @@ public:

        // The fields below this point are only used by BufferStateLayer
        uint64_t frameNumber;
        Geometry active;
        uint32_t width;
        uint32_t height;
        ui::Transform transform;

        uint32_t transform;
        uint32_t bufferTransform;
        bool transformToDisplayInverse;

        Rect crop;
+2 −2
Original line number Diff line number Diff line
@@ -836,8 +836,8 @@ struct BaseLayerVariant {
    static void initLayerDrawingStateAndComputeBounds(CompositionTest* test, sp<L> layer) {
        auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer);
        layerDrawingState.layerStack = DEFAULT_LAYER_STACK;
        layerDrawingState.active.w = 100;
        layerDrawingState.active.h = 100;
        layerDrawingState.width = 100;
        layerDrawingState.height = 100;
        layerDrawingState.color = half4(LayerProperties::COLOR[0], LayerProperties::COLOR[1],
                                        LayerProperties::COLOR[2], LayerProperties::COLOR[3]);
        layer->computeBounds(FloatRect(0, 0, 100, 100), ui::Transform(), 0.f /* shadowRadius */);