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

Commit a8bf68ad authored by Nicolas Capens's avatar Nicolas Capens Committed by Automerger Merge Worker
Browse files

Check if the buffer is actually being scaled instead of only checking scaling...

Check if the buffer is actually being scaled instead of only checking scaling mode am: b087db35 am: 1215460c

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1652827

Change-Id: I26195656e43614dd2e9d759d5be1dd49fc0649e8
parents 42e4b351 1215460c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -211,8 +211,8 @@ std::optional<compositionengine::LayerFE::LayerSettings> BufferLayer::prepareCli
    layer.frameNumber = mCurrentFrameNumber;
    layer.bufferId = mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getId() : 0;

    // TODO: we could be more subtle with isFixedSize()
    const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize();
    const bool useFiltering =
            targetSettings.needsFiltering || mNeedsFiltering || bufferNeedsFiltering();

    // Query the texture matrix given our current filtering mode.
    float textureMatrix[16];
@@ -847,6 +847,10 @@ void BufferLayer::setTransformHint(ui::Transform::RotationFlags displayTransform
    }
}

bool BufferLayer::bufferNeedsFiltering() const {
    return isFixedSize();
}

} // namespace android

#if defined(__gl_h_)
+4 −0
Original line number Diff line number Diff line
@@ -118,6 +118,10 @@ public:

    ui::Transform::RotationFlags getTransformHint() const override { return mTransformHint; }

    // Returns true if the transformed buffer size does not match the layer size and we need
    // to apply filtering.
    virtual bool bufferNeedsFiltering() const;

    // -----------------------------------------------------------------------
    // Functions that must be implemented by derived classes
    // -----------------------------------------------------------------------
+25 −0
Original line number Diff line number Diff line
@@ -760,6 +760,31 @@ Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const {
                                        static_cast<float>(s.active.transform.ty() + s.active.h)),
                              radius);
}

bool BufferStateLayer::bufferNeedsFiltering() const {
    const State& s(getDrawingState());
    if (!s.buffer) {
        return false;
    }

    uint32_t bufferWidth = s.buffer->width;
    uint32_t bufferHeight = s.buffer->height;

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

    if (s.transformToDisplayInverse) {
        uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
        if (invTransform & ui::Transform::ROT_90) {
            std::swap(bufferWidth, bufferHeight);
        }
    }

    const Rect layerSize{getBounds()};
    return layerSize.width() != bufferWidth || layerSize.height() != bufferHeight;
}
} // namespace android

// TODO(b/129481165): remove the #pragma below and fix conversion issues
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@ private:
    friend class SlotGenerationTest;
    bool willPresentCurrentTransaction() const;

    bool bufferNeedsFiltering() const override;

    static const std::array<float, 16> IDENTITY_MATRIX;

    std::unique_ptr<renderengine::Image> mTextureImage;