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

Commit 6e0a04a9 authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge changes I2e94156c,I55828d7f,I912e5dd0,Ie7acd1d5 into main

* changes:
  [legacy sf flag] - Remove enableNewFrontEnd()
  [legacy sf flag] - LayerRenderArea cleanup
  [legacy sf flag] - setInitialValuesForClone
  [legacy sf flag] - skipReportingTransformHint
parents 15e6660a 6270d198
Loading
Loading
Loading
Loading
+3 −28
Original line number Diff line number Diff line
@@ -1549,10 +1549,6 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const {
    return usage;
}

void Layer::skipReportingTransformHint() {
    mSkipReportingTransformHint = true;
}

void Layer::updateTransformHint(ui::Transform::RotationFlags transformHint) {
    if (mFlinger->mDebugDisableTransformHint || transformHint & ui::Transform::ROT_INVALID) {
        transformHint = ui::Transform::ROT_0;
@@ -2618,19 +2614,6 @@ Region Layer::getVisibleRegion(const DisplayDevice* display) const {
    return outputLayer ? outputLayer->getState().visibleRegion : Region();
}

void Layer::setInitialValuesForClone(const sp<Layer>& clonedFrom, uint32_t mirrorRootId) {
    if (mFlinger->mLayerLifecycleManagerEnabled) return;
    mSnapshot->path.id = clonedFrom->getSequence();
    mSnapshot->path.mirrorRootIds.emplace_back(mirrorRootId);

    cloneDrawingState(clonedFrom.get());
    mClonedFrom = clonedFrom;
    mPremultipliedAlpha = clonedFrom->mPremultipliedAlpha;
    mPotentialCursor = clonedFrom->mPotentialCursor;
    mProtectedByApp = clonedFrom->mProtectedByApp;
    updateCloneBufferInfo();
}

void Layer::updateCloneBufferInfo() {
    if (!isClone() || !isClonedFromAlive()) {
        return;
@@ -2730,7 +2713,7 @@ void Layer::updateClonedChildren(const sp<Layer>& mirrorRoot,
        }
        sp<Layer> clonedChild = clonedLayersMap[child];
        if (clonedChild == nullptr) {
            clonedChild = child->createClone(mirrorRoot->getSequence());
            clonedChild = child->createClone();
            clonedLayersMap[child] = clonedChild;
        }
        addChildToDrawing(clonedChild);
@@ -2976,13 +2959,7 @@ void Layer::onSurfaceFrameCreated(

void Layer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
    for (const auto& handle : mDrawingState.callbackHandles) {
        if (mFlinger->mLayerLifecycleManagerEnabled) {
        handle->transformHint = mTransformHint;
        } else {
            handle->transformHint = mSkipReportingTransformHint
                    ? std::nullopt
                    : std::make_optional<uint32_t>(mTransformHintLegacy);
        }
        handle->dequeueReadyTime = dequeueReadyTime;
        handle->currentMaxAcquiredBufferCount =
                mFlinger->getMaxAcquiredBufferCountForCurrentRefreshRate(mOwnerUid);
@@ -3706,11 +3683,10 @@ Rect Layer::computeBufferCrop(const State& s) {
    }
}

sp<Layer> Layer::createClone(uint32_t mirrorRootId) {
sp<Layer> Layer::createClone() {
    surfaceflinger::LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0,
                                           LayerMetadata());
    sp<Layer> layer = mFlinger->getFactory().createBufferStateLayer(args);
    layer->setInitialValuesForClone(sp<Layer>::fromExisting(this), mirrorRootId);
    return layer;
}

@@ -4326,7 +4302,6 @@ void Layer::setTransformHintLegacy(ui::Transform::RotationFlags displayTransform
    if (mTransformHintLegacy == ui::Transform::ROT_INVALID) {
        mTransformHintLegacy = displayTransformHint;
    }
    mSkipReportingTransformHint = false;
}

const std::shared_ptr<renderengine::ExternalTexture>& Layer::getExternalTexture() const {
+1 −4
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ public:
    // true if this layer is visible, false otherwise
    virtual bool isVisible() const;

    virtual sp<Layer> createClone(uint32_t mirrorRoot);
    virtual sp<Layer> createClone();

    // Set a 2x2 transformation matrix on the layer. This transform
    // will be applied after parent transforms, but before any final
@@ -698,7 +698,6 @@ public:
     * Sets display transform hint on BufferLayerConsumer.
     */
    void updateTransformHint(ui::Transform::RotationFlags);
    void skipReportingTransformHint();
    inline const State& getDrawingState() const { return mDrawingState; }
    inline State& getDrawingState() { return mDrawingState; }

@@ -977,7 +976,6 @@ protected:
    friend class TransactionFrameTracerTest;
    friend class TransactionSurfaceFrameTest;

    virtual void setInitialValuesForClone(const sp<Layer>& clonedFrom, uint32_t mirrorRootId);
    void preparePerFrameCompositionState();
    void preparePerFrameBufferCompositionState();
    void preparePerFrameEffectsCompositionState();
@@ -1259,7 +1257,6 @@ private:
    // Transform hint provided to the producer. This must be accessed holding
    // the mStateLock.
    ui::Transform::RotationFlags mTransformHintLegacy = ui::Transform::ROT_0;
    bool mSkipReportingTransformHint = true;
    std::optional<ui::Transform::RotationFlags> mTransformHint = std::nullopt;

    ReleaseCallbackId mPreviousReleaseCallbackId = ReleaseCallbackId::INVALID_ID;
+5 −68
Original line number Diff line number Diff line
@@ -24,31 +24,17 @@
#include "SurfaceFlinger.h"

namespace android {
namespace {

void reparentForDrawing(const sp<Layer>& oldParent, const sp<Layer>& newParent,
                   const Rect& drawingBounds) {
        // Compute and cache the bounds for the new parent layer.
        newParent->computeBounds(drawingBounds.toFloatRect(), ui::Transform(),
            0.f /* shadowRadius */);
        newParent->updateSnapshot(true /* updateGeometry */);
        oldParent->setChildrenDrawingParent(newParent);
};

} // namespace

LayerRenderArea::LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop,
                                 ui::Size reqSize, ui::Dataspace reqDataSpace, bool childrenOnly,
                                 bool allowSecureLayers, const ui::Transform& layerTransform,
                                 const Rect& layerBufferSize, bool hintForSeamlessTransition)
LayerRenderArea::LayerRenderArea(sp<Layer> layer, const Rect& crop, ui::Size reqSize,
                                 ui::Dataspace reqDataSpace, bool allowSecureLayers,
                                 const ui::Transform& layerTransform, const Rect& layerBufferSize,
                                 bool hintForSeamlessTransition)
      : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, hintForSeamlessTransition,
                   allowSecureLayers),
        mLayer(std::move(layer)),
        mLayerTransform(layerTransform),
        mLayerBufferSize(layerBufferSize),
        mCrop(crop),
        mFlinger(flinger),
        mChildrenOnly(childrenOnly) {}
        mTransform(layerTransform) {}

const ui::Transform& LayerRenderArea::getTransform() const {
    return mTransform;
@@ -71,53 +57,4 @@ Rect LayerRenderArea::getSourceCrop() const {
    }
}

void LayerRenderArea::render(std::function<void()> drawLayers) {
    using namespace std::string_literals;

    if (!mChildrenOnly) {
        mTransform = mLayerTransform.inverse();
    }

    if (mFlinger.mLayerLifecycleManagerEnabled) {
        drawLayers();
        return;
    }
    // If layer is offscreen, update mirroring info if it exists
    if (mLayer->isRemovedFromCurrentState()) {
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateMirrorInfo({}); });
        mLayer->traverse(LayerVector::StateSet::Drawing,
                         [&](Layer* layer) { layer->updateCloneBufferInfo(); });
    }

    if (!mChildrenOnly) {
        // If the layer is offscreen, compute bounds since we don't compute bounds for offscreen
        // layers in a regular cycles.
        if (mLayer->isRemovedFromCurrentState()) {
            FloatRect maxBounds = mFlinger.getMaxDisplayBounds();
            mLayer->computeBounds(maxBounds, ui::Transform(), 0.f /* shadowRadius */);
        }
        drawLayers();
    } else {
        // In the "childrenOnly" case we reparent the children to a screenshot
        // layer which has no properties set and which does not draw.
        //  We hold the statelock as the reparent-for-drawing operation modifies the
        //  hierarchy and there could be readers on Binder threads, like dump.
        auto screenshotParentLayer = mFlinger.getFactory().createEffectLayer(
                {&mFlinger, nullptr, "Screenshot Parent"s, ISurfaceComposerClient::eNoColorFill,
                 LayerMetadata()});
        {
            Mutex::Autolock _l(mFlinger.mStateLock);
            reparentForDrawing(mLayer, screenshotParentLayer, getSourceCrop());
        }
        drawLayers();
        {
            Mutex::Autolock _l(mFlinger.mStateLock);
            mLayer->setChildrenDrawingParent(mLayer);
        }
    }
    mLayer->updateSnapshot(/*updateGeometry=*/true);
    mLayer->updateChildrenSnapshots(/*updateGeometry=*/true);
}

} // namespace android
+3 −9
Original line number Diff line number Diff line
@@ -32,29 +32,23 @@ class SurfaceFlinger;

class LayerRenderArea : public RenderArea {
public:
    LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop, ui::Size reqSize,
                    ui::Dataspace reqDataSpace, bool childrenOnly, bool allowSecureLayers,
                    const ui::Transform& layerTransform, const Rect& layerBufferSize,
                    bool hintForSeamlessTransition);
    LayerRenderArea(sp<Layer> layer, const Rect& crop, ui::Size reqSize, ui::Dataspace reqDataSpace,
                    bool allowSecureLayers, const ui::Transform& layerTransform,
                    const Rect& layerBufferSize, bool hintForSeamlessTransition);

    const ui::Transform& getTransform() const override;
    bool isSecure() const override;
    sp<const DisplayDevice> getDisplayDevice() const override;
    Rect getSourceCrop() const override;

    void render(std::function<void()> drawLayers) override;
    virtual sp<Layer> getParentLayer() const { return mLayer; }

private:
    const sp<Layer> mLayer;
    const ui::Transform mLayerTransform;
    const Rect mLayerBufferSize;
    const Rect mCrop;

    ui::Transform mTransform;

    SurfaceFlinger& mFlinger;
    const bool mChildrenOnly;
};

} // namespace android
+0 −3
Original line number Diff line number Diff line
@@ -47,9 +47,6 @@ public:

    virtual ~RenderArea() = default;

    // Invoke drawLayers to render layers into the render area.
    virtual void render(std::function<void()> drawLayers) { drawLayers(); }

    // Returns true if the render area is secure.  A secure layer should be
    // blacked out / skipped when rendered to an insecure render area.
    virtual bool isSecure() const = 0;
Loading