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

Commit 8f28a1d2 authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Add GPU protected content support.

Switch to protected context when a layer with protected contents presents.
Previously we black out layers with protected contents, now that we add support
of protected contents in GPU composition, we can turn it on. In screenshot
cases for Recents, we still black out layers with protected contents.

BUG: 35315015
Test: Build, flash and boot
Test: Watch Youtube movie, verifed by force GPU composition.
Change-Id: I556bdd6f82c06c3d54ce62fab06a8c6f47599dcf
parent 1aaff311
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -125,9 +125,11 @@ static constexpr mat4 inverseOrientation(uint32_t transform) {

bool BufferLayer::prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                                     bool useIdentityTransform, Region& clearRegion,
                                     const bool supportProtectedContent,
                                     renderengine::LayerSettings& layer) {
    ATRACE_CALL();
    Layer::prepareClientLayer(renderArea, clip, useIdentityTransform, clearRegion, layer);
    Layer::prepareClientLayer(renderArea, clip, useIdentityTransform, clearRegion,
                              supportProtectedContent, layer);
    if (CC_UNLIKELY(mActiveBuffer == 0)) {
        // the texture has not been created yet, this Layer has
        // in fact never been drawn into. This happens frequently with
@@ -154,7 +156,8 @@ bool BufferLayer::prepareClientLayer(const RenderArea& renderArea, const Region&
        }
        return false;
    }
    bool blackOutLayer = isProtected() || (isSecure() && !renderArea.isSecure());
    bool blackOutLayer =
            (isProtected() && !supportProtectedContent) || (isSecure() && !renderArea.isSecure());
    const State& s(getDrawingState());
    if (!blackOutLayer) {
        layer.source.buffer.buffer = mActiveBuffer;
+2 −1
Original line number Diff line number Diff line
@@ -168,7 +168,8 @@ protected:
    // prepareClientLayer - constructs a RenderEngine layer for GPU composition.
    bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                            bool useIdentityTransform, Region& clearRegion,
                            renderengine::LayerSettings& layer);
                            const bool supportProtectedContent,
                            renderengine::LayerSettings& layer) override;

private:
    // Returns true if this layer requires filtering
+3 −1
Original line number Diff line number Diff line
@@ -50,8 +50,10 @@ ColorLayer::~ColorLayer() = default;

bool ColorLayer::prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                                    bool useIdentityTransform, Region& clearRegion,
                                    const bool supportProtectedContent,
                                    renderengine::LayerSettings& layer) {
    Layer::prepareClientLayer(renderArea, clip, useIdentityTransform, clearRegion, layer);
    Layer::prepareClientLayer(renderArea, clip, useIdentityTransform, clearRegion,
                              supportProtectedContent, layer);
    half4 color(getColor());
    half3 solidColor(color.r, color.g, color.b);
    layer.source.solidColor = solidColor;
+4 −3
Original line number Diff line number Diff line
@@ -42,9 +42,10 @@ public:

protected:
    FloatRect computeCrop(const sp<const DisplayDevice>& /*display*/) const override { return {}; }
    virtual bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
    bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                            bool useIdentityTransform, Region& clearRegion,
                                    renderengine::LayerSettings& layer);
                            const bool supportProtectedContent,
                            renderengine::LayerSettings& layer) override;

private:
    std::shared_ptr<compositionengine::Layer> mCompositionLayer;
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ ContainerLayer::ContainerLayer(const LayerCreationArgs& args) : Layer(args) {}

ContainerLayer::~ContainerLayer() = default;

bool ContainerLayer::prepareClientLayer(const RenderArea&, const Region&, bool, Region&,
bool ContainerLayer::prepareClientLayer(const RenderArea&, const Region&, bool, Region&, const bool,
                                        renderengine::LayerSettings&) {
    return false;
}
Loading