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

Commit 18fa7c60 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Add isProtected flag to Output

Allow outputs to decide if they want to render protected content, not
just if they support it. The current code checks if the Output is secure
when deciding whether to render protected content. By adding a new flag,
it will allow displays to decide if they want to render secure,
protected, or both.

This code doesn't have a way to create displays with only protected and
will still rely on the isSecure flag to ensure backwards compatibility.

Test: presubmit
Fixes: 285553970
Fixes: 300492271
Change-Id: If5e65388825d37f4ddaea5190259a136cfa89264
parent a4326c9f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ struct DisplayCreationArgs {
    // True if this display should be considered secure
    bool isSecure = false;

    // True if this display should be considered protected, as in this display should render DRM
    // content.
    bool isProtected = false;

    // Optional pointer to the power advisor interface, if one is needed for
    // this display.
    Hwc2::PowerAdvisor* powerAdvisor = nullptr;
@@ -73,6 +77,11 @@ public:
        return *this;
    }

    DisplayCreationArgsBuilder& setIsProtected(bool isProtected) {
        mArgs.isProtected = isProtected;
        return *this;
    }

    DisplayCreationArgsBuilder& setPowerAdvisor(Hwc2::PowerAdvisor* powerAdvisor) {
        mArgs.powerAdvisor = powerAdvisor;
        return *this;
+3 −4
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public:
        const bool isSecure;

        // If set to true, the target buffer has protected content support.
        const bool supportsProtectedContent;
        const bool isProtected;

        // Viewport of the target being rendered to. This is used to determine
        // the shadow light position.
@@ -167,8 +167,7 @@ using LayerFESet = std::unordered_set<sp<LayerFE>, LayerFESpHash>;
static inline bool operator==(const LayerFE::ClientCompositionTargetSettings& lhs,
                              const LayerFE::ClientCompositionTargetSettings& rhs) {
    return lhs.clip.hasSameRects(rhs.clip) && lhs.needsFiltering == rhs.needsFiltering &&
            lhs.isSecure == rhs.isSecure &&
            lhs.supportsProtectedContent == rhs.supportsProtectedContent &&
            lhs.isSecure == rhs.isSecure && lhs.isProtected == rhs.isProtected &&
            lhs.viewport == rhs.viewport && lhs.dataspace == rhs.dataspace &&
            lhs.realContentIsVisible == rhs.realContentIsVisible &&
            lhs.clearContent == rhs.clearContent;
@@ -189,7 +188,7 @@ static inline void PrintTo(const LayerFE::ClientCompositionTargetSettings& setti
    PrintTo(settings.clip, os);
    *os << "\n    .needsFiltering = " << settings.needsFiltering;
    *os << "\n    .isSecure = " << settings.isSecure;
    *os << "\n    .supportsProtectedContent = " << settings.supportsProtectedContent;
    *os << "\n    .isProtected = " << settings.isProtected;
    *os << "\n    .viewport = ";
    PrintTo(settings.viewport, os);
    *os << "\n    .dataspace = ";
+3 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@ struct OutputCompositionState {
    // If false, this output is not considered secure
    bool isSecure{false};

    // If false, this output is not considered protected
    bool isProtected{false};

    // If true, the current frame on this output uses client composition
    bool usesClientComposition{false};

+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ void Display::setConfiguration(const compositionengine::DisplayCreationArgs& arg
    mId = args.id;
    mPowerAdvisor = args.powerAdvisor;
    editState().isSecure = args.isSecure;
    editState().isProtected = args.isProtected;
    editState().displaySpace.setBounds(args.pixels);
    setName(args.name);
}
+17 −5
Original line number Diff line number Diff line
@@ -1232,10 +1232,18 @@ void Output::updateProtectedContentState() {
    auto& renderEngine = getCompositionEngine().getRenderEngine();
    const bool supportsProtectedContent = renderEngine.supportsProtectedContent();

    // If we the display is secure, protected content support is enabled, and at
    // least one layer has protected content, we need to use a secure back
    // buffer.
    if (outputState.isSecure && supportsProtectedContent) {
    bool isProtected;
    if (FlagManager::getInstance().display_protected()) {
        isProtected = outputState.isProtected;
    } else {
        isProtected = outputState.isSecure;
    }

    // We need to set the render surface as protected (DRM) if all the following conditions are met:
    // 1. The display is protected (in legacy, check if the display is secure)
    // 2. Protected content is supported
    // 3. At least one layer has protected content.
    if (isProtected && supportsProtectedContent) {
        auto layers = getOutputLayersOrderedByZ();
        bool needsProtected = std::any_of(layers.begin(), layers.end(), [](auto* layer) {
            return layer->getLayerFE().getCompositionState()->hasProtectedContent;
@@ -1475,12 +1483,16 @@ std::vector<LayerFE::LayerSettings> Output::generateClientCompositionRequests(
                                             BlurRegionsOnly
                                   : LayerFE::ClientCompositionTargetSettings::BlurSetting::
                                             Enabled);
                bool isProtected = supportsProtectedContent;
                if (FlagManager::getInstance().display_protected()) {
                    isProtected = outputState.isProtected && supportsProtectedContent;
                }
                compositionengine::LayerFE::ClientCompositionTargetSettings
                        targetSettings{.clip = clip,
                                       .needsFiltering = layer->needsFiltering() ||
                                               outputState.needsFiltering,
                                       .isSecure = outputState.isSecure,
                                       .supportsProtectedContent = supportsProtectedContent,
                                       .isProtected = isProtected,
                                       .viewport = outputState.layerStackSpace.getContent(),
                                       .dataspace = outputDataspace,
                                       .realContentIsVisible = realContentIsVisible,
Loading