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

Commit 08f3cb2b authored by chaviw's avatar chaviw
Browse files

Add layers to proto by traversing children

There are currently some layers that end up missing from the proto dumps
since their relativeOf layer has been deleted. That means the layers are
still in memory, but not traversable since we skip layers that have a
relativeOf when traversing. Instead, we can traverse the children
directly.

Test: Layers will missing relativeOf are adding to proto
Change-Id: I571ef677de0544dfe7459080cf97ff193e8666e6
parent 838817f1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1893,6 +1893,16 @@ void Layer::setInputInfo(const InputWindowInfo& info) {
    setTransactionFlags(eTransactionNeeded);
}

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

    for (const sp<Layer>& layer : mDrawingChildren) {
        layer->writeToProto(layersProto, traceFlags);
    }
}

void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags) const {
    ui::Transform transform = getTransform();

@@ -2014,6 +2024,8 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
        } else {
            layerInfo->set_z_order_relative_of(-1);
        }

        layerInfo->set_is_relative_of(state.isRelativeOf);
    }

    if (traceFlags & SurfaceTracing::TRACE_INPUT) {
+3 −0
Original line number Diff line number Diff line
@@ -453,6 +453,9 @@ public:

    bool isRemovedFromCurrentState() const;

    void writeToProto(LayersProto& layersProto,
                      uint32_t traceFlags = SurfaceTracing::TRACE_ALL) const;

    // 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.
+4 −15
Original line number Diff line number Diff line
@@ -4270,12 +4270,9 @@ void SurfaceFlinger::dumpWideColorInfo(std::string& result) const {

LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const {
    LayersProto layersProto;
    mDrawingState.traverseInZOrder([&](Layer* layer) {
        LayerProto* layerProto = layersProto.add_layers();
        layer->writeToProtoDrawingState(layerProto, traceFlags);
        layer->writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);
    });

    for (const sp<Layer>& layer : mDrawingState.layersSortedByZ) {
        layer->writeToProto(layersProto, traceFlags);
    }
    return layersProto;
}

@@ -4299,15 +4296,7 @@ void SurfaceFlinger::dumpOffscreenLayersProto(LayersProto& layersProto, uint32_t
                                                traceFlags);
        layerProto->set_parent(offscreenRootLayerId);

        // Add children
        offscreenLayer->traverseInZOrder(LayerVector::StateSet::Drawing, [&](Layer* layer) {
            if (layer == offscreenLayer) {
                return;
            }
            LayerProto* childProto = layersProto.add_layers();
            layer->writeToProtoDrawingState(childProto, traceFlags);
            layer->writeToProtoCommonState(childProto, LayerVector::StateSet::Drawing, traceFlags);
        });
        offscreenLayer->writeToProto(layersProto, traceFlags);
    }
}

+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ message LayerProto {
  // layer or set by a parent layer.
  float shadow_radius = 49;
  ColorTransformProto color_transform = 50;

  bool is_relative_of = 51;
}

message PositionProto {