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

Commit 2f65e97a authored by Vishnu Nair's avatar Vishnu Nair
Browse files

[layer tracing] generate composition state for non-default displays

Fixes: 264688936
Test: load multi display trace on winscope
Change-Id: Id6c07af31a3d1175b91c943e9d744a62cb9fbba5
parent f9c1b98e
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2122,7 +2122,9 @@ LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);

    if (traceFlags & LayerTracing::TRACE_COMPOSITION) {
        writeCompositionStateToProto(layerProto);
        ui::LayerStack layerStack =
                (mSnapshot) ? mSnapshot->outputFilter.layerStack : ui::INVALID_LAYER_STACK;
        writeCompositionStateToProto(layerProto, layerStack);
    }

    for (const sp<Layer>& layer : mDrawingChildren) {
@@ -2132,14 +2134,15 @@ LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    return layerProto;
}

void Layer::writeCompositionStateToProto(LayerProto* layerProto) {
void Layer::writeCompositionStateToProto(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->getDefaultDisplayDeviceLocked()) {
    if (const auto display = mFlinger->getDisplayFromLayerStack(layerStack)) {
        const auto compositionType = getCompositionType(*display);
        layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType));
        LayerProtoHelper::writeToProto(getVisibleRegion(display.get()),
        LayerProtoHelper::writeToProto(getVisibleRegion(display),
                                       [&]() { return layerProto->mutable_visible_region(); });
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -610,7 +610,7 @@ public:
    bool isRemovedFromCurrentState() const;

    LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags);
    void writeCompositionStateToProto(LayerProto* layerProto);
    void writeCompositionStateToProto(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
+1 −1
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto(
    if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) {
        auto it = mLegacyLayers.find(layer.id);
        if (it != mLegacyLayers.end()) {
            it->second->writeCompositionStateToProto(layerProto);
            it->second->writeCompositionStateToProto(layerProto, snapshot->outputFilter.layerStack);
        }
    }

+9 −0
Original line number Diff line number Diff line
@@ -8903,6 +8903,15 @@ void SurfaceFlinger::forceFutureUpdate(int delayInMs) {
    static_cast<void>(mScheduler->scheduleDelayed([&]() { scheduleRepaint(); }, ms2ns(delayInMs)));
}

const DisplayDevice* SurfaceFlinger::getDisplayFromLayerStack(ui::LayerStack layerStack) {
    for (const auto& [_, display] : mDisplays) {
        if (display->getLayerStack() == layerStack) {
            return display.get();
        }
    }
    return nullptr;
}

} // namespace android

#if defined(__gl_h_)
+2 −0
Original line number Diff line number Diff line
@@ -323,6 +323,8 @@ public:
    bool mIgnoreHwcPhysicalDisplayOrientation = false;

    void forceFutureUpdate(int delayInMs);
    const DisplayDevice* getDisplayFromLayerStack(ui::LayerStack)
            REQUIRES(mStateLock, kMainThreadContext);

protected:
    // We're reference counted, never destroy SurfaceFlinger directly