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

Commit 3701f0d8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I74d970ba,I86e47539

* changes:
  [sf] propagate FrameRateSelectionPriority to child layers
  [sf] add debug dump for new front end
parents ea37cba3 3d8565aa
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -267,7 +267,8 @@ struct layer_state_t {
            layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged |
            layer_state_t::eColorTransformChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eFlagsChanged | layer_state_t::eTrustedOverlayChanged |
            layer_state_t::eFrameRateChanged | layer_state_t::eFixedTransformHintChanged;
            layer_state_t::eFrameRateChanged | layer_state_t::eFrameRateSelectionPriority |
            layer_state_t::eFixedTransformHintChanged;

    // Changes affecting data sent to input.
    static constexpr uint64_t INPUT_CHANGES = layer_state_t::eInputInfoChanged |
+26 −6
Original line number Diff line number Diff line
@@ -149,13 +149,33 @@ std::string LayerHierarchy::getDebugStringShort() const {
    return debug + "}";
}

std::string LayerHierarchy::getDebugString(const char* prefix) const {
    std::string debug = prefix + getDebugStringShort();
    for (auto& [child, childVariant] : mChildren) {
        std::string childPrefix = "  " + std::string(prefix) + " " + std::to_string(childVariant);
        debug += "\n" + child->getDebugString(childPrefix.c_str());
void LayerHierarchy::dump(std::ostream& out, const std::string& prefix,
                          LayerHierarchy::Variant variant, bool isLastChild) const {
    if (!mLayer) {
        out << " ROOT";
    } else {
        out << prefix + (isLastChild ? "└─ " : "├─ ");
        if (variant == LayerHierarchy::Variant::Relative) {
            out << "(Relative) ";
        } else if (variant == LayerHierarchy::Variant::Mirror) {
            out << "(Mirroring) " << *mLayer << "\n" + prefix + "   └─ ...";
            return;
        }
    return debug;
        out << *mLayer;
    }

    for (size_t i = 0; i < mChildren.size(); i++) {
        auto& [child, childVariant] = mChildren[i];
        if (childVariant == LayerHierarchy::Variant::Detached) continue;
        const bool lastChild = i == (mChildren.size() - 1);
        std::string childPrefix = prefix;
        if (mLayer) {
            childPrefix += (isLastChild ? "   " : "│  ");
        }
        out << "\n";
        child->dump(out, childPrefix, childVariant, lastChild);
    }
    return;
}

bool LayerHierarchy::hasRelZLoop(uint32_t& outInvalidRelativeRoot) const {
+8 −1
Original line number Diff line number Diff line
@@ -156,7 +156,12 @@ public:
    const RequestedLayerState* getLayer() const;
    const LayerHierarchy* getRelativeParent() const;
    const LayerHierarchy* getParent() const;
    std::string getDebugString(const char* prefix = "") const;
    friend std::ostream& operator<<(std::ostream& os, const LayerHierarchy& obj) {
        std::string prefix = " ";
        obj.dump(os, prefix, LayerHierarchy::Variant::Attached, /*isLastChild=*/false);
        return os;
    }

    std::string getDebugStringShort() const;
    // Traverse the hierarchy and return true if loops are found. The outInvalidRelativeRoot
    // will contain the first relative root that was visited twice in a traversal.
@@ -172,6 +177,8 @@ private:
    void updateChild(LayerHierarchy*, LayerHierarchy::Variant);
    void traverseInZOrder(const Visitor& visitor, LayerHierarchy::TraversalPath& parent) const;
    void traverse(const Visitor& visitor, LayerHierarchy::TraversalPath& parent) const;
    void dump(std::ostream& out, const std::string& prefix, LayerHierarchy::Variant variant,
              bool isLastChild) const;

    const RequestedLayerState* mLayer;
    LayerHierarchy* mParent = nullptr;
+92 −2
Original line number Diff line number Diff line
@@ -39,6 +39,63 @@ void updateSurfaceDamage(const RequestedLayerState& requested, bool hasReadyFram
    }
}

std::ostream& operator<<(std::ostream& os, const ui::Transform& transform) {
    const uint32_t type = transform.getType();
    const uint32_t orientation = transform.getOrientation();
    if (type == ui::Transform::IDENTITY) {
        return os;
    }

    if (type & ui::Transform::UNKNOWN) {
        std::string out;
        transform.dump(out, "", "");
        os << out;
        return os;
    }

    if (type & ui::Transform::ROTATE) {
        switch (orientation) {
            case ui::Transform::ROT_0:
                os << "ROT_0";
                break;
            case ui::Transform::FLIP_H:
                os << "FLIP_H";
                break;
            case ui::Transform::FLIP_V:
                os << "FLIP_V";
                break;
            case ui::Transform::ROT_90:
                os << "ROT_90";
                break;
            case ui::Transform::ROT_180:
                os << "ROT_180";
                break;
            case ui::Transform::ROT_270:
                os << "ROT_270";
                break;
            case ui::Transform::ROT_INVALID:
            default:
                os << "ROT_INVALID";
                break;
        }
    }

    if (type & ui::Transform::SCALE) {
        std::string out;
        android::base::StringAppendF(&out, " scale x=%.4f y=%.4f ", transform.getScaleX(),
                                     transform.getScaleY());
        os << out;
    }

    if (type & ui::Transform::TRANSLATE) {
        std::string out;
        android::base::StringAppendF(&out, " tx=%.4f ty=%.4f ", transform.tx(), transform.ty());
        os << out;
    }

    return os;
}

} // namespace

LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
@@ -59,6 +116,7 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
    }
    sequence = static_cast<int32_t>(state.id);
    name = state.name;
    debugName = state.debugName;
    textureName = state.textureName;
    premultipliedAlpha = state.premultipliedAlpha;
    inputInfo.name = state.name;
@@ -73,6 +131,8 @@ LayerSnapshot::LayerSnapshot(const RequestedLayerState& state,
            ? path
            : LayerHierarchy::TraversalPath::ROOT;
    reachablilty = LayerSnapshot::Reachablilty::Unreachable;
    frameRateSelectionPriority = state.frameRateSelectionPriority;
    layerMetadata = state.metadata;
}

// As documented in libhardware header, formats in the range
@@ -180,13 +240,13 @@ std::string LayerSnapshot::getIsVisibleReason() const {
    if (handleSkipScreenshotFlag & outputFilter.toInternalDisplay) return "eLayerSkipScreenshot";
    if (invalidTransform) return "invalidTransform";
    if (color.a == 0.0f && !hasBlur()) return "alpha = 0 and no blur";
    if (!hasSomethingToDraw()) return "!hasSomethingToDraw";
    if (!hasSomethingToDraw()) return "nothing to draw";

    // visible
    std::stringstream reason;
    if (sidebandStream != nullptr) reason << " sidebandStream";
    if (externalTexture != nullptr)
        reason << " buffer:" << externalTexture->getId() << " frame:" << frameNumber;
        reason << " buffer=" << externalTexture->getId() << " frame=" << frameNumber;
    if (fillsColor() || color.a > 0.0f) reason << " color{" << color << "}";
    if (drawShadows()) reason << " shadowSettings.length=" << shadowSettings.length;
    if (backgroundBlurRadius > 0) reason << " backgroundBlurRadius=" << backgroundBlurRadius;
@@ -232,6 +292,36 @@ std::string LayerSnapshot::getDebugString() const {
    return debug.str();
}

std::ostream& operator<<(std::ostream& out, const LayerSnapshot& obj) {
    out << "Layer [" << obj.path.id;
    if (obj.path.mirrorRootId != UNASSIGNED_LAYER_ID) {
        out << " mirrored from " << obj.path.mirrorRootId;
    }
    out << "] " << obj.name << "\n    " << (obj.isVisible ? "visible" : "invisible")
        << " reason=" << obj.getIsVisibleReason();

    if (!obj.geomLayerBounds.isEmpty()) {
        out << "\n    bounds={" << obj.transformedBounds.left << "," << obj.transformedBounds.top
            << "," << obj.transformedBounds.bottom << "," << obj.transformedBounds.right << "}";
    }

    if (obj.geomLayerTransform.getType() != ui::Transform::IDENTITY) {
        out << " toDisplayTransform={" << obj.geomLayerTransform << "}";
    }

    if (obj.hasInputInfo()) {
        out << "\n    input{"
            << "(" << obj.inputInfo.inputConfig.string() << ")";
        if (obj.touchCropId != UNASSIGNED_LAYER_ID) out << " touchCropId=" << obj.touchCropId;
        if (obj.inputInfo.replaceTouchableRegionWithCrop) out << " replaceTouchableRegionWithCrop";
        auto touchableRegion = obj.inputInfo.touchableRegion.getBounds();
        out << " touchableRegion={" << touchableRegion.left << "," << touchableRegion.top << ","
            << touchableRegion.bottom << "," << touchableRegion.right << "}"
            << "}";
    }
    return out;
}

FloatRect LayerSnapshot::sourceBounds() const {
    if (!externalTexture) {
        return geomLayerBounds;
+3 −2
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    // generated from the same layer, for example when mirroring.
    int32_t sequence;
    std::string name;
    std::string debugName;
    uint32_t textureName;
    bool contentOpaque;
    bool layerOpaqueFlagSet;
@@ -93,7 +94,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    ui::Transform::RotationFlags fixedTransformHint;
    std::optional<ui::Transform::RotationFlags> transformHint;
    bool handleSkipScreenshotFlag = false;
    int32_t frameRateSelectionPriority;
    int32_t frameRateSelectionPriority = -1;
    LayerHierarchy::TraversalPath mirrorRootPath;
    uint32_t touchCropId;
    gui::Uid uid = gui::Uid::INVALID;
@@ -145,7 +146,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
    bool hasInputInfo() const;
    FloatRect sourceBounds() const;
    Hwc2::IComposerClient::BlendMode getBlendMode(const RequestedLayerState& requested) const;

    friend std::ostream& operator<<(std::ostream& os, const LayerSnapshot& obj);
    void merge(const RequestedLayerState& requested, bool forceUpdate, bool displayChanges,
               bool forceFullDamage, uint32_t displayRotationFlags);
};
Loading