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

Commit 2f96ee9c authored by Kean Mariotti's avatar Kean Mariotti Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sf-perfetto-integration-2" into main

* changes:
  Revert^2 Integrate transaction tracing with perfetto
  Revert^2 Integrate layer tracing with perfetto
  Revert^2 Revert layer proto format back to proto2
  Revert^2 Move proto definitions to external/perfetto
parents 5855f5a0 3e68a203
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -198,9 +198,12 @@ filegroup {
        "StartPropertySetThread.cpp",
        "SurfaceFlinger.cpp",
        "SurfaceFlingerDefaultFactory.cpp",
        "Tracing/LayerDataSource.cpp",
        "Tracing/LayerTracing.cpp",
        "Tracing/TransactionDataSource.cpp",
        "Tracing/TransactionTracing.cpp",
        "Tracing/TransactionProtoParser.cpp",
        "Tracing/tools/LayerTraceGenerator.cpp",
        "TransactionCallbackInvoker.cpp",
        "TunnelModeEnabledReporter.cpp",
    ],
+15 −15
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ using gui::WindowInfo;

using PresentState = frametimeline::SurfaceFrame::PresentState;

Layer::Layer(const LayerCreationArgs& args)
Layer::Layer(const surfaceflinger::LayerCreationArgs& args)
      : sequence(args.sequence),
        mFlinger(sp<SurfaceFlinger>::fromExisting(args.flinger)),
        mName(base::StringPrintf("%s#%d", args.name.c_str(), sequence)),
@@ -1000,7 +1000,7 @@ bool Layer::setBackgroundColor(const half3& color, float alpha, ui::Dataspace da
        uint32_t flags = ISurfaceComposerClient::eFXSurfaceEffect;
        std::string name = mName + "BackgroundColorLayer";
        mDrawingState.bgColorLayer = mFlinger->getFactory().createEffectLayer(
                LayerCreationArgs(mFlinger.get(), nullptr, std::move(name), flags,
                surfaceflinger::LayerCreationArgs(mFlinger.get(), nullptr, std::move(name), flags,
                                                  LayerMetadata()));

        // add to child list
@@ -2203,8 +2203,9 @@ void Layer::setInputInfo(const WindowInfo& info) {
    setTransactionFlags(eTransactionNeeded);
}

LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    LayerProto* layerProto = layersProto.add_layers();
perfetto::protos::LayerProto* Layer::writeToProto(perfetto::protos::LayersProto& layersProto,
                                                  uint32_t traceFlags) {
    perfetto::protos::LayerProto* layerProto = layersProto.add_layers();
    writeToProtoDrawingState(layerProto);
    writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);

@@ -2221,20 +2222,22 @@ LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    return layerProto;
}

void Layer::writeCompositionStateToProto(LayerProto* layerProto, ui::LayerStack layerStack) {
void Layer::writeCompositionStateToProto(perfetto::protos::LayerProto* layerProto,
                                         ui::LayerStack layerStack) {
    ftl::FakeGuard guard(mFlinger->mStateLock); // Called from the main thread.
    ftl::FakeGuard mainThreadGuard(kMainThreadContext);

    // Only populate for the primary display.
    if (const auto display = mFlinger->getDisplayFromLayerStack(layerStack)) {
        const auto compositionType = getCompositionType(*display);
        layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType));
        layerProto->set_hwc_composition_type(
                static_cast<perfetto::protos::HwcCompositionType>(compositionType));
        LayerProtoHelper::writeToProto(getVisibleRegion(display),
                                       [&]() { return layerProto->mutable_visible_region(); });
    }
}

void Layer::writeToProtoDrawingState(LayerProto* layerInfo) {
void Layer::writeToProtoDrawingState(perfetto::protos::LayerProto* layerInfo) {
    const ui::Transform transform = getTransform();
    auto buffer = getExternalTexture();
    if (buffer != nullptr) {
@@ -2273,8 +2276,8 @@ void Layer::writeToProtoDrawingState(LayerProto* layerInfo) {
    layerInfo->set_shadow_radius(mEffectiveShadowRadius);
}

void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet stateSet,
                                    uint32_t traceFlags) {
void Layer::writeToProtoCommonState(perfetto::protos::LayerProto* layerInfo,
                                    LayerVector::StateSet stateSet, uint32_t traceFlags) {
    const bool useDrawing = stateSet == LayerVector::StateSet::Drawing;
    const LayerVector& children = useDrawing ? mDrawingChildren : mCurrentChildren;
    const State& state = useDrawing ? mDrawingState : mDrawingState;
@@ -2322,15 +2325,11 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
    auto parent = useDrawing ? mDrawingParent.promote() : mCurrentParent.promote();
    if (parent != nullptr) {
        layerInfo->set_parent(parent->sequence);
    } else {
        layerInfo->set_parent(-1);
    }

    auto zOrderRelativeOf = state.zOrderRelativeOf.promote();
    if (zOrderRelativeOf != nullptr) {
        layerInfo->set_z_order_relative_of(zOrderRelativeOf->sequence);
    } else {
        layerInfo->set_z_order_relative_of(-1);
    }

    layerInfo->set_is_relative_of(state.isRelativeOf);
@@ -3630,7 +3629,8 @@ Rect Layer::computeBufferCrop(const State& s) {
}

sp<Layer> Layer::createClone(uint32_t mirrorRootId) {
    LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, LayerMetadata());
    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;
+7 −5
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ public:
        bool useVsyncIdForRefreshRateSelection = false;
    };

    explicit Layer(const LayerCreationArgs& args);
    explicit Layer(const surfaceflinger::LayerCreationArgs& args);
    virtual ~Layer();

    static bool isLayerFocusedBasedOnPriority(int32_t priority);
@@ -634,17 +634,19 @@ public:

    bool isRemovedFromCurrentState() const;

    LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags);
    void writeCompositionStateToProto(LayerProto* layerProto, ui::LayerStack layerStack);
    perfetto::protos::LayerProto* writeToProto(perfetto::protos::LayersProto& layersProto,
                                               uint32_t traceFlags);
    void writeCompositionStateToProto(perfetto::protos::LayerProto* layerProto,
                                      ui::LayerStack layerStack);

    // Write states that are modified by the main thread. This includes drawing
    // state as well as buffer data. This should be called in the main or tracing
    // thread.
    void writeToProtoDrawingState(LayerProto* layerInfo);
    void writeToProtoDrawingState(perfetto::protos::LayerProto* layerInfo);
    // Write drawing or current state. If writing current state, the caller should hold the
    // external mStateLock. If writing drawing state, this function should be called on the
    // main or tracing thread.
    void writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet,
    void writeToProtoCommonState(perfetto::protos::LayerProto* layerInfo, LayerVector::StateSet,
                                 uint32_t traceFlags = LayerTracing::TRACE_ALL);

    gui::WindowInfo::Type getWindowType() const { return mWindowType; }
+48 −35
Original line number Diff line number Diff line
@@ -29,28 +29,30 @@ using gui::WindowInfo;

namespace surfaceflinger {

void LayerProtoHelper::writePositionToProto(const float x, const float y,
                                            std::function<PositionProto*()> getPositionProto) {
void LayerProtoHelper::writePositionToProto(
        const float x, const float y,
        std::function<perfetto::protos::PositionProto*()> getPositionProto) {
    if (x != 0 || y != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        PositionProto* position = getPositionProto();
        perfetto::protos::PositionProto* position = getPositionProto();
        position->set_x(x);
        position->set_y(y);
    }
}

void LayerProtoHelper::writeSizeToProto(const uint32_t w, const uint32_t h,
                                        std::function<SizeProto*()> getSizeProto) {
void LayerProtoHelper::writeSizeToProto(
        const uint32_t w, const uint32_t h,
        std::function<perfetto::protos::SizeProto*()> getSizeProto) {
    if (w != 0 || h != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        SizeProto* size = getSizeProto();
        perfetto::protos::SizeProto* size = getSizeProto();
        size->set_w(w);
        size->set_h(h);
    }
}

void LayerProtoHelper::writeToProto(const Region& region,
                                    std::function<RegionProto*()> getRegionProto) {
void LayerProtoHelper::writeToProto(
        const Region& region, std::function<perfetto::protos::RegionProto*()> getRegionProto) {
    if (region.isEmpty()) {
        return;
    }
@@ -58,7 +60,8 @@ void LayerProtoHelper::writeToProto(const Region& region,
    writeToProto(region, getRegionProto());
}

void LayerProtoHelper::writeToProto(const Region& region, RegionProto* regionProto) {
void LayerProtoHelper::writeToProto(const Region& region,
                                    perfetto::protos::RegionProto* regionProto) {
    if (region.isEmpty()) {
        return;
    }
@@ -72,7 +75,8 @@ void LayerProtoHelper::writeToProto(const Region& region, RegionProto* regionPro
    }
}

void LayerProtoHelper::readFromProto(const RegionProto& regionProto, Region& outRegion) {
void LayerProtoHelper::readFromProto(const perfetto::protos::RegionProto& regionProto,
                                     Region& outRegion) {
    for (int i = 0; i < regionProto.rect_size(); i++) {
        Rect rect;
        readFromProto(regionProto.rect(i), rect);
@@ -80,32 +84,34 @@ void LayerProtoHelper::readFromProto(const RegionProto& regionProto, Region& out
    }
}

void LayerProtoHelper::writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto) {
void LayerProtoHelper::writeToProto(const Rect& rect,
                                    std::function<perfetto::protos::RectProto*()> getRectProto) {
    if (rect.left != 0 || rect.right != 0 || rect.top != 0 || rect.bottom != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        writeToProto(rect, getRectProto());
    }
}

void LayerProtoHelper::writeToProto(const Rect& rect, RectProto* rectProto) {
void LayerProtoHelper::writeToProto(const Rect& rect, perfetto::protos::RectProto* rectProto) {
    rectProto->set_left(rect.left);
    rectProto->set_top(rect.top);
    rectProto->set_bottom(rect.bottom);
    rectProto->set_right(rect.right);
}

void LayerProtoHelper::readFromProto(const RectProto& proto, Rect& outRect) {
void LayerProtoHelper::readFromProto(const perfetto::protos::RectProto& proto, Rect& outRect) {
    outRect.left = proto.left();
    outRect.top = proto.top();
    outRect.bottom = proto.bottom();
    outRect.right = proto.right();
}

void LayerProtoHelper::writeToProto(const FloatRect& rect,
                                    std::function<FloatRectProto*()> getFloatRectProto) {
void LayerProtoHelper::writeToProto(
        const FloatRect& rect,
        std::function<perfetto::protos::FloatRectProto*()> getFloatRectProto) {
    if (rect.left != 0 || rect.right != 0 || rect.top != 0 || rect.bottom != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        FloatRectProto* rectProto = getFloatRectProto();
        perfetto::protos::FloatRectProto* rectProto = getFloatRectProto();
        rectProto->set_left(rect.left);
        rectProto->set_top(rect.top);
        rectProto->set_bottom(rect.bottom);
@@ -113,10 +119,11 @@ void LayerProtoHelper::writeToProto(const FloatRect& rect,
    }
}

void LayerProtoHelper::writeToProto(const half4 color, std::function<ColorProto*()> getColorProto) {
void LayerProtoHelper::writeToProto(const half4 color,
                                    std::function<perfetto::protos::ColorProto*()> getColorProto) {
    if (color.r != 0 || color.g != 0 || color.b != 0 || color.a != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        ColorProto* colorProto = getColorProto();
        perfetto::protos::ColorProto* colorProto = getColorProto();
        colorProto->set_r(color.r);
        colorProto->set_g(color.g);
        colorProto->set_b(color.b);
@@ -125,7 +132,7 @@ void LayerProtoHelper::writeToProto(const half4 color, std::function<ColorProto*
}

void LayerProtoHelper::writeToProtoDeprecated(const ui::Transform& transform,
                                              TransformProto* transformProto) {
                                              perfetto::protos::TransformProto* transformProto) {
    const uint32_t type = transform.getType() | (transform.getOrientation() << 8);
    transformProto->set_type(type);

@@ -141,7 +148,7 @@ void LayerProtoHelper::writeToProtoDeprecated(const ui::Transform& transform,
}

void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform,
                                             TransformProto* transformProto) {
                                             perfetto::protos::TransformProto* transformProto) {
    const uint32_t type = transform.getType() | (transform.getOrientation() << 8);
    transformProto->set_type(type);

@@ -156,12 +163,13 @@ void LayerProtoHelper::writeTransformToProto(const ui::Transform& transform,
    }
}

void LayerProtoHelper::writeToProto(const renderengine::ExternalTexture& buffer,
                                    std::function<ActiveBufferProto*()> getActiveBufferProto) {
void LayerProtoHelper::writeToProto(
        const renderengine::ExternalTexture& buffer,
        std::function<perfetto::protos::ActiveBufferProto*()> getActiveBufferProto) {
    if (buffer.getWidth() != 0 || buffer.getHeight() != 0 || buffer.getUsage() != 0 ||
        buffer.getPixelFormat() != 0) {
        // Use a lambda do avoid writing the object header when the object is empty
        ActiveBufferProto* activeBufferProto = getActiveBufferProto();
        auto* activeBufferProto = getActiveBufferProto();
        activeBufferProto->set_width(buffer.getWidth());
        activeBufferProto->set_height(buffer.getHeight());
        activeBufferProto->set_stride(buffer.getUsage());
@@ -171,12 +179,12 @@ void LayerProtoHelper::writeToProto(const renderengine::ExternalTexture& buffer,

void LayerProtoHelper::writeToProto(
        const WindowInfo& inputInfo, const wp<Layer>& touchableRegionBounds,
        std::function<InputWindowInfoProto*()> getInputWindowInfoProto) {
        std::function<perfetto::protos::InputWindowInfoProto*()> getInputWindowInfoProto) {
    if (inputInfo.token == nullptr) {
        return;
    }

    InputWindowInfoProto* proto = getInputWindowInfoProto();
    perfetto::protos::InputWindowInfoProto* proto = getInputWindowInfoProto();
    proto->set_layout_params_flags(inputInfo.layoutParamsFlags.get());
    proto->set_input_config(inputInfo.inputConfig.get());
    using U = std::underlying_type_t<WindowInfo::Type>;
@@ -209,7 +217,8 @@ void LayerProtoHelper::writeToProto(
    }
}

void LayerProtoHelper::writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto) {
void LayerProtoHelper::writeToProto(const mat4 matrix,
                                    perfetto::protos::ColorTransformProto* colorTransformProto) {
    for (int i = 0; i < mat4::ROW_SIZE; i++) {
        for (int j = 0; j < mat4::COL_SIZE; j++) {
            colorTransformProto->add_val(matrix[i][j]);
@@ -217,7 +226,8 @@ void LayerProtoHelper::writeToProto(const mat4 matrix, ColorTransformProto* colo
    }
}

void LayerProtoHelper::readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix) {
void LayerProtoHelper::readFromProto(
        const perfetto::protos::ColorTransformProto& colorTransformProto, mat4& matrix) {
    for (int i = 0; i < mat4::ROW_SIZE; i++) {
        for (int j = 0; j < mat4::COL_SIZE; j++) {
            matrix[i][j] = colorTransformProto.val(i * mat4::COL_SIZE + j);
@@ -225,7 +235,8 @@ void LayerProtoHelper::readFromProto(const ColorTransformProto& colorTransformPr
    }
}

void LayerProtoHelper::writeToProto(const android::BlurRegion region, BlurRegion* proto) {
void LayerProtoHelper::writeToProto(const android::BlurRegion region,
                                    perfetto::protos::BlurRegion* proto) {
    proto->set_blur_radius(region.blurRadius);
    proto->set_corner_radius_tl(region.cornerRadiusTL);
    proto->set_corner_radius_tr(region.cornerRadiusTR);
@@ -238,7 +249,8 @@ void LayerProtoHelper::writeToProto(const android::BlurRegion region, BlurRegion
    proto->set_bottom(region.bottom);
}

void LayerProtoHelper::readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion) {
void LayerProtoHelper::readFromProto(const perfetto::protos::BlurRegion& proto,
                                     android::BlurRegion& outRegion) {
    outRegion.blurRadius = proto.blur_radius();
    outRegion.cornerRadiusTL = proto.corner_radius_tl();
    outRegion.cornerRadiusTR = proto.corner_radius_tr();
@@ -251,7 +263,8 @@ void LayerProtoHelper::readFromProto(const BlurRegion& proto, android::BlurRegio
    outRegion.bottom = proto.bottom();
}

LayersProto LayerProtoFromSnapshotGenerator::generate(const frontend::LayerHierarchy& root) {
perfetto::protos::LayersProto LayerProtoFromSnapshotGenerator::generate(
        const frontend::LayerHierarchy& root) {
    mLayersProto.clear_layers();
    std::unordered_set<uint64_t> stackIdsToSkip;
    if ((mTraceFlags & LayerTracing::TRACE_VIRTUAL_DISPLAYS) == 0) {
@@ -310,7 +323,7 @@ frontend::LayerSnapshot* LayerProtoFromSnapshotGenerator::getSnapshot(
void LayerProtoFromSnapshotGenerator::writeHierarchyToProto(
        const frontend::LayerHierarchy& root, frontend::LayerHierarchy::TraversalPath& path) {
    using Variant = frontend::LayerHierarchy::Variant;
    LayerProto* layerProto = mLayersProto.add_layers();
    perfetto::protos::LayerProto* layerProto = mLayersProto.add_layers();
    const frontend::RequestedLayerState& layer = *root.getLayer();
    frontend::LayerSnapshot* snapshot = getSnapshot(path, layer);
    LayerProtoHelper::writeSnapshotToProto(layerProto, layer, *snapshot, mTraceFlags);
@@ -349,7 +362,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto(
    }
}

void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo,
void LayerProtoHelper::writeSnapshotToProto(perfetto::protos::LayerProto* layerInfo,
                                            const frontend::RequestedLayerState& requestedState,
                                            const frontend::LayerSnapshot& snapshot,
                                            uint32_t traceFlags) {
@@ -446,9 +459,9 @@ void LayerProtoHelper::writeSnapshotToProto(LayerProto* layerInfo,
                                   [&]() { return layerInfo->mutable_destination_frame(); });
}

google::protobuf::RepeatedPtrField<DisplayProto> LayerProtoHelper::writeDisplayInfoToProto(
        const frontend::DisplayInfos& displayInfos) {
    google::protobuf::RepeatedPtrField<DisplayProto> displays;
google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto>
LayerProtoHelper::writeDisplayInfoToProto(const frontend::DisplayInfos& displayInfos) {
    google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto> displays;
    displays.Reserve(displayInfos.size());
    for (const auto& [layerStack, displayInfo] : displayInfos) {
        auto displayProto = displays.Add();
+35 −27
Original line number Diff line number Diff line
@@ -35,39 +35,47 @@ namespace android {
namespace surfaceflinger {
class LayerProtoHelper {
public:
    static void writePositionToProto(const float x, const float y,
                                     std::function<PositionProto*()> getPositionProto);
    static void writePositionToProto(
            const float x, const float y,
            std::function<perfetto::protos::PositionProto*()> getPositionProto);
    static void writeSizeToProto(const uint32_t w, const uint32_t h,
                                 std::function<SizeProto*()> getSizeProto);
    static void writeToProto(const Rect& rect, std::function<RectProto*()> getRectProto);
    static void writeToProto(const Rect& rect, RectProto* rectProto);
    static void readFromProto(const RectProto& proto, Rect& outRect);
                                 std::function<perfetto::protos::SizeProto*()> getSizeProto);
    static void writeToProto(const Rect& rect,
                             std::function<perfetto::protos::RectProto*()> getRectProto);
    static void writeToProto(const Rect& rect, perfetto::protos::RectProto* rectProto);
    static void readFromProto(const perfetto::protos::RectProto& proto, Rect& outRect);
    static void writeToProto(const FloatRect& rect,
                             std::function<FloatRectProto*()> getFloatRectProto);
    static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto);
    static void writeToProto(const Region& region, RegionProto* regionProto);
    static void readFromProto(const RegionProto& regionProto, Region& outRegion);
    static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto);
                             std::function<perfetto::protos::FloatRectProto*()> getFloatRectProto);
    static void writeToProto(const Region& region,
                             std::function<perfetto::protos::RegionProto*()> getRegionProto);
    static void writeToProto(const Region& region, perfetto::protos::RegionProto* regionProto);
    static void readFromProto(const perfetto::protos::RegionProto& regionProto, Region& outRegion);
    static void writeToProto(const half4 color,
                             std::function<perfetto::protos::ColorProto*()> getColorProto);
    // This writeToProto for transform is incorrect, but due to backwards compatibility, we can't
    // update Layers to use it. Use writeTransformToProto for any new transform proto data.
    static void writeToProtoDeprecated(const ui::Transform& transform,
                                       TransformProto* transformProto);
                                       perfetto::protos::TransformProto* transformProto);
    static void writeTransformToProto(const ui::Transform& transform,
                                      TransformProto* transformProto);
    static void writeToProto(const renderengine::ExternalTexture& buffer,
                             std::function<ActiveBufferProto*()> getActiveBufferProto);
    static void writeToProto(const gui::WindowInfo& inputInfo,
                             const wp<Layer>& touchableRegionBounds,
                             std::function<InputWindowInfoProto*()> getInputWindowInfoProto);
    static void writeToProto(const mat4 matrix, ColorTransformProto* colorTransformProto);
    static void readFromProto(const ColorTransformProto& colorTransformProto, mat4& matrix);
    static void writeToProto(const android::BlurRegion region, BlurRegion*);
    static void readFromProto(const BlurRegion& proto, android::BlurRegion& outRegion);
    static void writeSnapshotToProto(LayerProto* outProto,
                                      perfetto::protos::TransformProto* transformProto);
    static void writeToProto(
            const renderengine::ExternalTexture& buffer,
            std::function<perfetto::protos::ActiveBufferProto*()> getActiveBufferProto);
    static void writeToProto(
            const gui::WindowInfo& inputInfo, const wp<Layer>& touchableRegionBounds,
            std::function<perfetto::protos::InputWindowInfoProto*()> getInputWindowInfoProto);
    static void writeToProto(const mat4 matrix,
                             perfetto::protos::ColorTransformProto* colorTransformProto);
    static void readFromProto(const perfetto::protos::ColorTransformProto& colorTransformProto,
                              mat4& matrix);
    static void writeToProto(const android::BlurRegion region, perfetto::protos::BlurRegion*);
    static void readFromProto(const perfetto::protos::BlurRegion& proto,
                              android::BlurRegion& outRegion);
    static void writeSnapshotToProto(perfetto::protos::LayerProto* outProto,
                                     const frontend::RequestedLayerState& requestedState,
                                     const frontend::LayerSnapshot& snapshot, uint32_t traceFlags);
    static google::protobuf::RepeatedPtrField<DisplayProto> writeDisplayInfoToProto(
            const frontend::DisplayInfos&);
    static google::protobuf::RepeatedPtrField<perfetto::protos::DisplayProto>
    writeDisplayInfoToProto(const frontend::DisplayInfos&);
};

class LayerProtoFromSnapshotGenerator {
@@ -80,7 +88,7 @@ public:
            mLegacyLayers(legacyLayers),
            mDisplayInfos(displayInfos),
            mTraceFlags(traceFlags) {}
    LayersProto generate(const frontend::LayerHierarchy& root);
    perfetto::protos::LayersProto generate(const frontend::LayerHierarchy& root);

private:
    void writeHierarchyToProto(const frontend::LayerHierarchy& root,
@@ -92,7 +100,7 @@ private:
    const std::unordered_map<uint32_t, sp<Layer>>& mLegacyLayers;
    const frontend::DisplayInfos& mDisplayInfos;
    uint32_t mTraceFlags;
    LayersProto mLayersProto;
    perfetto::protos::LayersProto mLayersProto;
    // winscope expects all the layers, so provide a snapshot even if it not currently drawing
    std::unordered_map<frontend::LayerHierarchy::TraversalPath, frontend::LayerSnapshot,
                       frontend::LayerHierarchy::TraversalPathHash>
Loading