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

Commit 7124ad30 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

Implement Display Layer Stats

Try to collect data for analyzing how many display controller layers we
need and what we use them for. Also part of a bug fixing for potential
memory leak of existing layer tracing work of winscope.

Test: adb shell dumpsys SurfaceFlinger --enable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --disable-layer-stats
Test: adb shell dumpsys SurfaceFlinger --clear-layer-stats
Test: adb shell dumpsys SurfaceFlinger --dump-layer-stats
Bug: b/73668062
Bug: b/74071380
Change-Id: Ie08aa85d34db2c2c767b8e27eb5aad6f7c3fb975
parent efd3cb0b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ filegroup {
        "Layer.cpp",
        "LayerProtoHelper.cpp",
        "LayerRejecter.cpp",
        "LayerStats.cpp",
        "LayerVector.cpp",
        "MessageQueue.cpp",
        "MonitoredProducer.cpp",
+16 −0
Original line number Diff line number Diff line
@@ -639,6 +639,7 @@ void Layer::setGeometry(const sp<const DisplayDevice>& displayDevice, uint32_t z
        hwcInfo.forceClientComposition = true;
    } else {
        auto transform = static_cast<HWC2::Transform>(orientation);
        hwcInfo.transform = transform;
        auto error = hwcLayer->setTransform(transform);
        ALOGE_IF(error != HWC2::Error::None,
                 "[%s] Failed to set transform %s: "
@@ -1915,6 +1916,21 @@ void Layer::writeToProto(LayerProto* layerInfo, LayerVector::StateSet stateSet)
    layerInfo->set_refresh_pending(isBufferLatched());
}

void Layer::writeToProto(LayerProto* layerInfo, int32_t hwcId) {
    writeToProto(layerInfo, LayerVector::StateSet::Drawing);

    const auto& hwcInfo = getBE().mHwcLayers.at(hwcId);

    const Rect& frame = hwcInfo.displayFrame;
    LayerProtoHelper::writeToProto(frame, layerInfo->mutable_hwc_frame());

    const FloatRect& crop = hwcInfo.sourceCrop;
    LayerProtoHelper::writeToProto(crop, layerInfo->mutable_hwc_crop());

    const int32_t transform = static_cast<int32_t>(hwcInfo.transform);
    layerInfo->set_hwc_transform(transform);
}

// ---------------------------------------------------------------------------

}; // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -290,6 +290,8 @@ public:
    void writeToProto(LayerProto* layerInfo,
                      LayerVector::StateSet stateSet = LayerVector::StateSet::Drawing);

    void writeToProto(LayerProto* layerInfo, int32_t hwcId);

protected:
    /*
     * onDraw - draws the surface.
+3 −1
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ public:
                layer(nullptr),
                forceClientComposition(false),
                compositionType(HWC2::Composition::Invalid),
                clearClientTarget(false) {}
                clearClientTarget(false),
                transform(HWC2::Transform::None) {}

        HWComposer* hwc;
        HWC2::Layer* layer;
@@ -80,6 +81,7 @@ public:
        Rect displayFrame;
        FloatRect sourceCrop;
        HWComposerBufferCache bufferCache;
        HWC2::Transform transform;
    };


+7 −0
Original line number Diff line number Diff line
@@ -37,6 +37,13 @@ void LayerProtoHelper::writeToProto(const Rect& rect, RectProto* rectProto) {
    rectProto->set_right(rect.right);
}

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

void LayerProtoHelper::writeToProto(const half4 color, ColorProto* colorProto) {
    colorProto->set_r(color.r);
    colorProto->set_g(color.g);
Loading