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

Commit 4fa5e4a0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I63f2a34e,I3e95be93

* changes:
  [sf] Pass metadata to layer during composition
  [sf] Add support for generic layer metadata to HWComposer and HWC2
parents 6617ad5c 8d9f836d
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -40,6 +40,29 @@

namespace android::compositionengine {

// More complex metadata for this layer
struct GenericLayerMetadataEntry {
    // True if the metadata may affect the composed result.
    // See setLayerGenericMetadata in IComposerClient.hal
    bool mandatory;

    // Byte blob or parcel
    std::vector<uint8_t> value;

    std::string dumpAsString() const;
};

inline bool operator==(const GenericLayerMetadataEntry& lhs, const GenericLayerMetadataEntry& rhs) {
    return lhs.mandatory == rhs.mandatory && lhs.value == rhs.value;
}

// Defining PrintTo helps with Google Tests.
inline void PrintTo(const GenericLayerMetadataEntry& v, ::std::ostream* os) {
    *os << v.dumpAsString();
}

using GenericLayerMetadataMap = std::unordered_map<std::string, GenericLayerMetadataEntry>;

/*
 * Used by LayerFE::getCompositionState
 */
@@ -115,6 +138,8 @@ struct LayerFECompositionState {
    // The appId for this layer
    int appId{0};

    GenericLayerMetadataMap metadata;

    /*
     * Per-frame content
     */
+25 −0
Original line number Diff line number Diff line
@@ -32,6 +32,20 @@ void dumpVal(std::string& out, const char* name, half4 value) {

} // namespace

std::string GenericLayerMetadataEntry::dumpAsString() const {
    using android::base::StringAppendF;
    std::string out;

    out.append("GenericLayerMetadataEntry{mandatory: ");
    StringAppendF(&out, "%d", mandatory);
    out.append(" value: ");
    for (uint8_t byte : value) {
        StringAppendF(&out, "0x08%" PRIx8 " ", byte);
    }
    out.append("]}");
    return out;
}

LayerFECompositionState::~LayerFECompositionState() = default;

void LayerFECompositionState::dump(std::string& out) const {
@@ -65,6 +79,17 @@ void LayerFECompositionState::dump(std::string& out) const {
    dumpVal(out, "type", type);
    dumpVal(out, "appId", appId);

    if (!metadata.empty()) {
        out.append("\n      metadata {");
        for (const auto& [key, entry] : metadata) {
            out.append("\n           ");
            out.append(key);
            out.append("=");
            out.append(entry.dumpAsString());
        }
        out.append("\n      }\n      ");
    }

    dumpVal(out, "composition type", toString(compositionType), compositionType);

    out.append("\n      buffer: ");
+8 −1
Original line number Diff line number Diff line
@@ -406,6 +406,14 @@ void OutputLayer::writeOutputIndependentGeometryStateToHWC(
        ALOGE("[%s] Failed to set info %s (%d)", getLayerFE().getDebugName(),
              to_string(error).c_str(), static_cast<int32_t>(error));
    }

    for (const auto& [name, entry] : outputIndependentState.metadata) {
        if (auto error = hwcLayer->setLayerGenericMetadata(name, entry.mandatory, entry.value);
            error != HWC2::Error::None) {
            ALOGE("[%s] Failed to set generic metadata %s %s (%d)", getLayerFE().getDebugName(),
                  name.c_str(), to_string(error).c_str(), static_cast<int32_t>(error));
        }
    }
}

void OutputLayer::writeOutputDependentPerFrameStateToHWC(HWC2::Layer* hwcLayer) {
@@ -661,4 +669,3 @@ void OutputLayer::dump(std::string& out) const {

} // namespace impl
} // namespace android::compositionengine
+2 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ public:
    MOCK_METHOD2(setInfo, Error(uint32_t, uint32_t));

    MOCK_METHOD1(setColorTransform, Error(const android::mat4&));
    MOCK_METHOD3(setLayerGenericMetadata,
                 Error(const std::string&, bool, const std::vector<uint8_t>&));
};

} // namespace mock
+3 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public:
    HWComposer();
    ~HWComposer() override;

    MOCK_METHOD2(registerCallback, void(HWC2::ComposerCallback*, int32_t));
    MOCK_METHOD2(setConfiguration, void(HWC2::ComposerCallback*, int32_t));
    MOCK_CONST_METHOD3(getDisplayIdentificationData,
                       bool(hwc2_display_t, uint8_t*, DisplayIdentificationData*));
    MOCK_CONST_METHOD1(hasCapability, bool(HWC2::Capability));
@@ -96,6 +96,8 @@ public:
    MOCK_METHOD2(setAutoLowLatencyMode, status_t(DisplayId, bool));
    MOCK_METHOD2(getSupportedContentTypes, status_t(DisplayId, std::vector<HWC2::ContentType>*));
    MOCK_METHOD2(setContentType, status_t(DisplayId, HWC2::ContentType));
    MOCK_CONST_METHOD0(getSupportedLayerGenericMetadata,
                       const std::unordered_map<std::string, bool>&());

    MOCK_CONST_METHOD1(dump, void(std::string&));
    MOCK_CONST_METHOD0(getComposer, android::Hwc2::Composer*());
Loading