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

Commit 734f288a authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Trace critical workloads

Create a new trace track and trace all important work that happens on
the main thread. Keep track of changes in workload as transaction are
queued and committed to infer when the CPU load will increase from
the last frame. This CL only logs the workload.

Flag: EXEMPT logs
Bug: 333623207
Test: perfetto
Change-Id: Ib423d1968545adc89172bd0e40fbde2a31b46ddf
parent a1635a6f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -302,6 +302,11 @@ struct layer_state_t {
    static constexpr uint64_t VISIBLE_REGION_CHANGES = layer_state_t::GEOMETRY_CHANGES |
            layer_state_t::HIERARCHY_CHANGES | layer_state_t::eAlphaChanged;

    // Changes that force GPU composition.
    static constexpr uint64_t COMPOSITION_EFFECTS = layer_state_t::eBackgroundBlurRadiusChanged |
            layer_state_t::eBlurRegionsChanged | layer_state_t::eCornerRadiusChanged |
            layer_state_t::eShadowRadiusChanged | layer_state_t::eStretchChanged;

    bool hasValidBuffer() const;
    void sanitize(int32_t permissions);

+9 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@
#include <utils/RefBase.h>
#include <utils/Timers.h>

namespace aidl::android::hardware::graphics::composer3 {
enum class Composition;
}

namespace android {

class Fence;
@@ -176,6 +180,11 @@ public:
    // Whether the layer should be rendered with rounded corners.
    virtual bool hasRoundedCorners() const = 0;
    virtual void setWasClientComposed(const sp<Fence>&) {}
    virtual void setHwcCompositionType(
            aidl::android::hardware::graphics::composer3::Composition) = 0;
    virtual aidl::android::hardware::graphics::composer3::Composition getHwcCompositionType()
            const = 0;

    virtual const gui::LayerMetadata* getMetadata() const = 0;
    virtual const gui::LayerMetadata* getRelativeMetadata() const = 0;
};
+4 −0
Original line number Diff line number Diff line
@@ -59,6 +59,10 @@ public:
    MOCK_CONST_METHOD0(getMetadata, gui::LayerMetadata*());
    MOCK_CONST_METHOD0(getRelativeMetadata, gui::LayerMetadata*());
    MOCK_METHOD0(onPictureProfileCommitted, void());
    MOCK_METHOD(void, setHwcCompositionType,
                (aidl::android::hardware::graphics::composer3::Composition), (override));
    MOCK_METHOD(aidl::android::hardware::graphics::composer3::Composition, getHwcCompositionType,
                (), (const, override));
};

} // namespace android::compositionengine::mock
+2 −0
Original line number Diff line number Diff line
@@ -867,6 +867,7 @@ void OutputLayer::writeCompositionTypeToHWC(HWC2::Layer* hwcLayer,
    if (outputDependentState.hwc->hwcCompositionType != requestedCompositionType ||
        (outputDependentState.hwc->layerSkipped && !skipLayer)) {
        outputDependentState.hwc->hwcCompositionType = requestedCompositionType;
        getLayerFE().setHwcCompositionType(requestedCompositionType);

        if (auto error = hwcLayer->setCompositionType(requestedCompositionType);
            error != hal::Error::NONE) {
@@ -964,6 +965,7 @@ void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType)
    }

    hwcState.hwcCompositionType = compositionType;
    getLayerFE().setHwcCompositionType(compositionType);
}

void OutputLayer::prepareForDeviceLayerRequests() {
+51 −1
Original line number Diff line number Diff line
@@ -18,12 +18,17 @@
#undef LOG_TAG
#define LOG_TAG "SurfaceFlinger"

#include "LayerSnapshot.h"
#include <PowerAdvisor/Workload.h>
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <gui/LayerState.h>

#include "Layer.h"
#include "LayerSnapshot.h"

namespace android::surfaceflinger::frontend {

using namespace ftl::flag_operators;
using namespace aidl::android::hardware::graphics::composer3;

namespace {

@@ -532,4 +537,49 @@ void LayerSnapshot::merge(const RequestedLayerState& requested, bool forceUpdate
    }
}

char LayerSnapshot::classifyCompositionForDebug(Composition compositionType) const {
    if (!isVisible) {
        return '.';
    }

    switch (compositionType) {
        case Composition::INVALID:
            return 'i';
        case Composition::SOLID_COLOR:
            return 'c';
        case Composition::CURSOR:
            return 'u';
        case Composition::SIDEBAND:
            return 'd';
        case Composition::DISPLAY_DECORATION:
            return 'a';
        case Composition::REFRESH_RATE_INDICATOR:
            return 'r';
        case Composition::CLIENT:
        case Composition::DEVICE:
            break;
    }

    char code = '.'; // Default to invisible
    if (hasBufferOrSidebandStream()) {
        code = 'b';
    } else if (fillsColor()) {
        code = 'c'; // Solid color
    } else if (hasBlur()) {
        code = 'l'; // Blur
    } else if (hasProtectedContent) {
        code = 'p'; // Protected content
    } else if (drawShadows()) {
        code = 's'; // Shadow
    } else if (roundedCorner.hasRoundedCorners()) {
        code = 'r'; // Rounded corners
    }

    if (compositionType == Composition::CLIENT) {
        return static_cast<char>(std::toupper(code));
    } else {
        return code;
    }
}

} // namespace android::surfaceflinger::frontend
Loading