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

Commit 0a398994 authored by chaviw's avatar chaviw Committed by Nataniel Borges
Browse files

Add display proto info

Currently display bounds are calculated in to layer bounds so when proto
files are uploaded, the display bounds are set at the root layer.
However, once display bounds are removed from layer bounds calculation,
the proto information will be missing display info and will be hard to
show a correct visual representation.

Add display proto info so winscope can properly show the display area.

Test: winscope works
Bug: 188792659
Change-Id: I445a892a855c302ab617a9c79bfbf5f217ac5349
parent 04c093a6
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2016,7 +2016,7 @@ void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags,
        if (buffer != nullptr) {
            LayerProtoHelper::writeToProto(buffer,
                                           [&]() { return layerInfo->mutable_active_buffer(); });
            LayerProtoHelper::writeToProto(ui::Transform(getBufferTransform()),
            LayerProtoHelper::writeToProtoDeprecated(ui::Transform(getBufferTransform()),
                                                     layerInfo->mutable_buffer_transform());
        }
        layerInfo->set_invalidate(contentDirty);
@@ -2031,7 +2031,7 @@ void Layer::writeToProtoDrawingState(LayerProto* layerInfo, uint32_t traceFlags,
        layerInfo->set_corner_radius(getRoundedCornerState().radius);
        layerInfo->set_background_blur_radius(getBackgroundBlurRadius());
        layerInfo->set_is_trusted_overlay(isTrustedOverlay());
        LayerProtoHelper::writeToProto(transform, layerInfo->mutable_transform());
        LayerProtoHelper::writeToProtoDeprecated(transform, layerInfo->mutable_transform());
        LayerProtoHelper::writePositionToProto(transform.tx(), transform.ty(),
                                               [&]() { return layerInfo->mutable_position(); });
        LayerProtoHelper::writeToProto(mBounds, [&]() { return layerInfo->mutable_bounds(); });
@@ -2106,7 +2106,7 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
                                       [&]() { return layerInfo->mutable_requested_color(); });
        layerInfo->set_flags(state.flags);

        LayerProtoHelper::writeToProto(requestedTransform,
        LayerProtoHelper::writeToProtoDeprecated(requestedTransform,
                                                 layerInfo->mutable_requested_transform());

        auto parent = useDrawing ? mDrawingParent.promote() : mCurrentParent.promote();
+19 −3
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ void LayerProtoHelper::writeToProto(const half4 color, std::function<ColorProto*
    }
}

void LayerProtoHelper::writeToProto(const ui::Transform& transform,
void LayerProtoHelper::writeToProtoDeprecated(const ui::Transform& transform,
                                              TransformProto* transformProto) {
    const uint32_t type = transform.getType() | (transform.getOrientation() << 8);
    transformProto->set_type(type);
@@ -114,6 +114,22 @@ void LayerProtoHelper::writeToProto(const ui::Transform& transform,
    }
}

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

    // Rotations that are 90/180/270 have their own type so the transform matrix can be
    // reconstructed later. All other rotation have the type UNKNOWN so we need to save the
    // transform values in that case.
    if (type & (ui::Transform::SCALE | ui::Transform::UNKNOWN)) {
        transformProto->set_dsdx(transform.dsdx());
        transformProto->set_dtdx(transform.dtdx());
        transformProto->set_dtdy(transform.dtdy());
        transformProto->set_dsdy(transform.dsdy());
    }
}

void LayerProtoHelper::writeToProto(const sp<GraphicBuffer>& buffer,
                                    std::function<ActiveBufferProto*()> getActiveBufferProto) {
    if (buffer->getWidth() != 0 || buffer->getHeight() != 0 || buffer->getStride() != 0 ||
@@ -154,7 +170,7 @@ void LayerProtoHelper::writeToProto(
    proto->set_has_wallpaper(inputInfo.hasWallpaper);

    proto->set_global_scale_factor(inputInfo.globalScaleFactor);
    LayerProtoHelper::writeToProto(inputInfo.transform, proto->mutable_transform());
    LayerProtoHelper::writeToProtoDeprecated(inputInfo.transform, proto->mutable_transform());
    proto->set_replace_touchable_region_with_crop(inputInfo.replaceTouchableRegionWithCrop);
    auto cropLayer = touchableRegionBounds.promote();
    if (cropLayer != nullptr) {
+6 −1
Original line number Diff line number Diff line
@@ -37,7 +37,12 @@ public:
                             std::function<FloatRectProto*()> getFloatRectProto);
    static void writeToProto(const Region& region, std::function<RegionProto*()> getRegionProto);
    static void writeToProto(const half4 color, std::function<ColorProto*()> getColorProto);
    static void writeToProto(const ui::Transform& transform, TransformProto* transformProto);
    // 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);
    static void writeTransformToProto(const ui::Transform& transform,
                                      TransformProto* transformProto);
    static void writeToProto(const sp<GraphicBuffer>& buffer,
                             std::function<ActiveBufferProto*()> getActiveBufferProto);
    static void writeToProto(const gui::WindowInfo& inputInfo,
+24 −2
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@
#include "FrameTracer/FrameTracer.h"
#include "HdrLayerInfoReporter.h"
#include "Layer.h"
#include "LayerProtoHelper.h"
#include "LayerRenderArea.h"
#include "LayerVector.h"
#include "MonitoredProducer.h"
@@ -4636,9 +4637,14 @@ status_t SurfaceFlinger::doDump(int fd, const DumpArgs& args, bool asProto) {
        }

        if (dumpLayers) {
            const LayersProto layersProto = dumpProtoFromMainThread();
            LayersTraceFileProto traceFileProto = SurfaceTracing::createLayersTraceFileProto();
            LayersTraceProto* layersTrace = traceFileProto.add_entry();
            LayersProto layersProto = dumpProtoFromMainThread();
            layersTrace->mutable_layers()->Swap(&layersProto);
            dumpDisplayProto(*layersTrace);

            if (asProto) {
                result.append(layersProto.SerializeAsString());
                result.append(traceFileProto.SerializeAsString());
            } else {
                // Dump info that we need to access from the main thread
                const auto layerTree = LayerProtoParser::generateLayerTree(layersProto);
@@ -4910,6 +4916,22 @@ LayersProto SurfaceFlinger::dumpDrawingStateProto(uint32_t traceFlags) const {
    return layersProto;
}

void SurfaceFlinger::dumpDisplayProto(LayersTraceProto& layersTraceProto) const {
    for (const auto& [_, display] : ON_MAIN_THREAD(mDisplays)) {
        DisplayProto* displayProto = layersTraceProto.add_displays();
        displayProto->set_id(display->getId().value);
        displayProto->set_name(display->getDisplayName());
        displayProto->set_layer_stack(display->getLayerStack().id);
        LayerProtoHelper::writeSizeToProto(display->getWidth(), display->getHeight(),
                                           [&]() { return displayProto->mutable_size(); });
        LayerProtoHelper::writeToProto(display->getLayerStackSpaceRect(), [&]() {
            return displayProto->mutable_layer_stack_space_rect();
        });
        LayerProtoHelper::writeTransformToProto(display->getTransform(),
                                                displayProto->mutable_transform());
    }
}

void SurfaceFlinger::dumpHwc(std::string& result) const {
    getHwComposer().dump(result);
}
+2 −0
Original line number Diff line number Diff line
@@ -1174,6 +1174,8 @@ private:
    LayersProto dumpDrawingStateProto(uint32_t traceFlags) const;
    void dumpOffscreenLayersProto(LayersProto& layersProto,
                                  uint32_t traceFlags = SurfaceTracing::TRACE_ALL) const;
    void dumpDisplayProto(LayersTraceProto& layersTraceProto) const;

    // Dumps state from HW Composer
    void dumpHwc(std::string& result) const;
    LayersProto dumpProtoFromMainThread(uint32_t traceFlags = SurfaceTracing::TRACE_ALL)
Loading