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

Commit 63241c3c authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "[layer tracing] generate composition state for non-default displays" into udc-dev

parents 4038250f 2f65e97a
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -2127,7 +2127,9 @@ LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);
    writeToProtoCommonState(layerProto, LayerVector::StateSet::Drawing, traceFlags);


    if (traceFlags & LayerTracing::TRACE_COMPOSITION) {
    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) {
    for (const sp<Layer>& layer : mDrawingChildren) {
@@ -2137,14 +2139,15 @@ LayerProto* Layer::writeToProto(LayersProto& layersProto, uint32_t traceFlags) {
    return layerProto;
    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 guard(mFlinger->mStateLock); // Called from the main thread.
    ftl::FakeGuard mainThreadGuard(kMainThreadContext);


    // Only populate for the primary display.
    // Only populate for the primary display.
    if (const auto display = mFlinger->getDefaultDisplayDeviceLocked()) {
    if (const auto display = mFlinger->getDisplayFromLayerStack(layerStack)) {
        const auto compositionType = getCompositionType(*display);
        const auto compositionType = getCompositionType(*display);
        layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType));
        layerProto->set_hwc_composition_type(static_cast<HwcCompositionType>(compositionType));
        LayerProtoHelper::writeToProto(getVisibleRegion(display.get()),
        LayerProtoHelper::writeToProto(getVisibleRegion(display),
                                       [&]() { return layerProto->mutable_visible_region(); });
                                       [&]() { return layerProto->mutable_visible_region(); });
    }
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -611,7 +611,7 @@ public:
    bool isRemovedFromCurrentState() const;
    bool isRemovedFromCurrentState() const;


    LayerProto* writeToProto(LayersProto& layersProto, uint32_t traceFlags);
    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
    // 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
    // state as well as buffer data. This should be called in the main or tracing
+1 −1
Original line number Original line Diff line number Diff line
@@ -332,7 +332,7 @@ void LayerProtoFromSnapshotGenerator::writeHierarchyToProto(
    if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) {
    if (mTraceFlags & LayerTracing::TRACE_COMPOSITION) {
        auto it = mLegacyLayers.find(layer.id);
        auto it = mLegacyLayers.find(layer.id);
        if (it != mLegacyLayers.end()) {
        if (it != mLegacyLayers.end()) {
            it->second->writeCompositionStateToProto(layerProto);
            it->second->writeCompositionStateToProto(layerProto, snapshot->outputFilter.layerStack);
        }
        }
    }
    }


+9 −0
Original line number Original line Diff line number Diff line
@@ -8968,6 +8968,15 @@ void SurfaceFlinger::forceFutureUpdate(int delayInMs) {
    static_cast<void>(mScheduler->scheduleDelayed([&]() { scheduleRepaint(); }, ms2ns(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
} // namespace android


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


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


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