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

Commit 144c6b14 authored by Vishnu Nair's avatar Vishnu Nair Committed by Automerger Merge Worker
Browse files

Merge "[sf] fix screenshots when new fe is enabled" into udc-dev am: 401615e0

parents ff843137 401615e0
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
    inputInfo.id = static_cast<int32_t>(uniqueSequence);
    inputInfo.ownerUid = static_cast<int32_t>(state.ownerUid);
    inputInfo.ownerPid = state.ownerPid;
    uid = state.ownerUid;
    pid = state.ownerPid;
    changes = RequestedLayerState::Changes::Created;
    mirrorRootPath = path.variant == LayerHierarchy::Variant::Mirror
            ? path
@@ -179,7 +181,12 @@ std::string LayerSnapshot::getDebugString() const {
    std::stringstream debug;
    debug << "Snapshot{" << path.toString() << name << " isVisible=" << isVisible << " {"
          << getIsVisibleReason() << "} changes=" << changes.string()
          << " layerStack=" << outputFilter.layerStack.id << "}";
          << " layerStack=" << outputFilter.layerStack.id << " geomLayerBounds={"
          << geomLayerBounds.left << "," << geomLayerBounds.top << "," << geomLayerBounds.bottom
          << "," << geomLayerBounds.right << "}"
          << " geomLayerTransform={tx=" << geomLayerTransform.tx()
          << ",ty=" << geomLayerTransform.ty() << "}"
          << "}";
    return debug.str();
}

+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    int32_t frameRateSelectionPriority;
    LayerHierarchy::TraversalPath mirrorRootPath;
    bool unreachable = true;
    uid_t uid;
    pid_t pid;
    ChildState childState;

    static bool isOpaqueFormat(PixelFormat format);
+7 −3
Original line number Diff line number Diff line
@@ -39,9 +39,12 @@ void reparentForDrawing(const sp<Layer>& oldParent, const sp<Layer>& newParent,

LayerRenderArea::LayerRenderArea(SurfaceFlinger& flinger, sp<Layer> layer, const Rect& crop,
                                 ui::Size reqSize, ui::Dataspace reqDataSpace, bool childrenOnly,
                                 bool allowSecureLayers)
                                 bool allowSecureLayers, const ui::Transform& layerTransform,
                                 const Rect& layerBufferSize)
      : RenderArea(reqSize, CaptureFill::CLEAR, reqDataSpace, allowSecureLayers),
        mLayer(std::move(layer)),
        mLayerTransform(layerTransform),
        mLayerBufferSize(layerBufferSize),
        mCrop(crop),
        mFlinger(flinger),
        mChildrenOnly(childrenOnly) {}
@@ -60,7 +63,8 @@ sp<const DisplayDevice> LayerRenderArea::getDisplayDevice() const {

Rect LayerRenderArea::getSourceCrop() const {
    if (mCrop.isEmpty()) {
        return mLayer->getBufferSize(mLayer->getDrawingState());
        // TODO this should probably be mBounds instead of just buffer bounds
        return mLayerBufferSize;
    } else {
        return mCrop;
    }
@@ -70,7 +74,7 @@ void LayerRenderArea::render(std::function<void()> drawLayers) {
    using namespace std::string_literals;

    if (!mChildrenOnly) {
        mTransform = mLayer->getTransform().inverse();
        mTransform = mLayerTransform.inverse();
    }

    if (mFlinger.mLayerLifecycleManagerEnabled) {
+4 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ 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);
                    ui::Dataspace reqDataSpace, bool childrenOnly, bool allowSecureLayers,
                    const ui::Transform& layerTransform, const Rect& layerBufferSize);

    const ui::Transform& getTransform() const override;
    bool isSecure() const override;
@@ -45,6 +46,8 @@ public:

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

    ui::Transform mTransform;
+28 −6
Original line number Diff line number Diff line
@@ -7051,13 +7051,34 @@ status_t SurfaceFlinger::captureLayers(const LayerCaptureArgs& args,

    bool childrenOnly = args.childrenOnly;
    RenderAreaFuture renderAreaFuture = ftl::defer([=]() -> std::unique_ptr<RenderArea> {
        ui::Transform layerTransform;
        Rect layerBufferSize;
        if (mLayerLifecycleManagerEnabled) {
            frontend::LayerSnapshot* snapshot =
                    mLayerSnapshotBuilder.getSnapshot(parent->getSequence());
            if (!snapshot) {
                ALOGW("Couldn't find layer snapshot for %d", parent->getSequence());
            } else {
                layerTransform = snapshot->localTransform;
                layerBufferSize = snapshot->bufferSize;
            }
        } else {
            layerTransform = parent->getTransform();
            layerBufferSize = parent->getBufferSize(parent->getDrawingState());
        }

        return std::make_unique<LayerRenderArea>(*this, parent, crop, reqSize, dataspace,
                                                 childrenOnly, args.captureSecureLayers);
                                                 childrenOnly, args.captureSecureLayers,
                                                 layerTransform, layerBufferSize);
    });
    GetLayerSnapshotsFunction getLayerSnapshots;
    if (mLayerLifecycleManagerEnabled) {
        FloatRect parentCrop = crop.isEmpty() ? FloatRect(0, 0, reqSize.width, reqSize.height)
        std::optional<FloatRect> parentCrop = std::nullopt;
        if (args.childrenOnly) {
            parentCrop = crop.isEmpty() ? FloatRect(0, 0, reqSize.width, reqSize.height)
                                        : crop.toFloatRect();
        }

        getLayerSnapshots = getLayerSnapshotsForScreenshots(parent->sequence, args.uid,
                                                            std::move(excludeLayerIds),
                                                            args.childrenOnly, parentCrop);
@@ -8007,7 +8028,7 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(
                    if (layerStack && snapshot->outputFilter.layerStack != *layerStack) {
                        return;
                    }
                    if (uid != CaptureArgs::UNSET_UID && snapshot->inputInfo.ownerUid != uid) {
                    if (uid != CaptureArgs::UNSET_UID && snapshot->uid != uid) {
                        return;
                    }
                    if (!snapshot->hasSomethingToDraw()) {
@@ -8034,7 +8055,8 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(
std::function<std::vector<std::pair<Layer*, sp<LayerFE>>>()>
SurfaceFlinger::getLayerSnapshotsForScreenshots(uint32_t rootLayerId, uint32_t uid,
                                                std::unordered_set<uint32_t> excludeLayerIds,
                                                bool childrenOnly, const FloatRect& parentCrop) {
                                                bool childrenOnly,
                                                const std::optional<FloatRect>& parentCrop) {
    return [&, rootLayerId, uid, excludeLayerIds = std::move(excludeLayerIds), childrenOnly,
            parentCrop]() {
        auto root = mLayerHierarchyBuilder.getPartialHierarchy(rootLayerId, childrenOnly);
@@ -8047,7 +8069,7 @@ SurfaceFlinger::getLayerSnapshotsForScreenshots(uint32_t rootLayerId, uint32_t u
                     .globalShadowSettings = mDrawingState.globalShadowSettings,
                     .supportsBlur = mSupportsBlur,
                     .forceFullDamage = mForceFullDamage,
                     .parentCrop = {parentCrop},
                     .parentCrop = parentCrop,
                     .excludeLayerIds = std::move(excludeLayerIds),
                     .supportedLayerGenericMetadata =
                             getHwComposer().getSupportedLayerGenericMetadata(),
Loading