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

Commit cc01a45a authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Intro CE::OutputLayer

Introduce compositionengine::OutputLayer, for representing the
composition state of a layer on an output (display)

This change just introduces the OutputLayer class, and modifies
SurfaceFlinger.cpp to create them properly. The new class does not yet
have any state.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: Ic8fe0fee61470b36539287883d4901b25208b634
parent feb73d79
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ cc_library {
        "src/Layer.cpp",
        "src/Output.cpp",
        "src/OutputCompositionState.cpp",
        "src/OutputLayer.cpp",
        "src/RenderSurface.cpp",
    ],
    local_include_dirs: ["include"],
@@ -61,6 +62,7 @@ cc_library {
        "mock/Layer.cpp",
        "mock/LayerFE.cpp",
        "mock/Output.cpp",
        "mock/OutputLayer.cpp",
        "mock/RenderSurface.cpp",
    ],
    static_libs: [
@@ -83,6 +85,7 @@ cc_test {
        "tests/LayerTest.cpp",
        "tests/MockHWComposer.cpp",
        "tests/OutputTest.cpp",
        "tests/OutputLayerTest.cpp",
        "tests/RenderSurfaceTest.cpp",
    ],
    static_libs: [
+22 −0
Original line number Diff line number Diff line
@@ -23,11 +23,15 @@
#include <ui/GraphicTypes.h>
#include <ui/Region.h>
#include <ui/Transform.h>
#include <utils/StrongPointer.h>

namespace android::compositionengine {

class DisplayColorProfile;
class Layer;
class LayerFE;
class RenderSurface;
class OutputLayer;

namespace impl {
struct OutputCompositionState;
@@ -38,6 +42,8 @@ struct OutputCompositionState;
 */
class Output {
public:
    using OutputLayers = std::vector<std::unique_ptr<compositionengine::OutputLayer>>;

    virtual ~Output();

    // Returns true if the output is valid. This is meant to be checked post-
@@ -104,6 +110,22 @@ public:
    // this output allows that.
    virtual bool belongsInOutput(uint32_t layerStackId, bool internalOnly) const = 0;

    // Returns a pointer to the output layer corresponding to the given layer on
    // this output, or nullptr if the layer does not have one
    virtual OutputLayer* getOutputLayerForLayer(Layer*) const = 0;

    // Gets the OutputLayer corresponding to the input Layer instance from the
    // current ordered set of output layers. If there is no such layer, a new
    // one is created and returned.
    virtual std::unique_ptr<OutputLayer> getOrCreateOutputLayer(std::shared_ptr<Layer>,
                                                                sp<LayerFE>) = 0;

    // Sets the new ordered set of output layers for this output
    virtual void setOutputLayersOrderedByZ(OutputLayers&&) = 0;

    // Gets the ordered set of output layers for this output
    virtual const OutputLayers& getOutputLayersOrderedByZ() const = 0;

protected:
    virtual void setDisplayColorProfile(std::unique_ptr<DisplayColorProfile>) = 0;
    virtual void setRenderSurface(std::unique_ptr<RenderSurface>) = 0;
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <utils/StrongPointer.h>

namespace android::compositionengine {

class Output;
class Layer;
class LayerFE;

/**
 * An output layer contains the output-dependent composition state for a layer
 */
class OutputLayer {
public:
    virtual ~OutputLayer();

    // Gets the output which owns this output layer
    virtual const Output& getOutput() const = 0;

    // Gets the display-independent layer which this output layer represents
    virtual Layer& getLayer() const = 0;

    // Gets the front-end layer interface this output layer represents
    virtual LayerFE& getLayerFE() const = 0;
};

} // namespace android::compositionengine
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#pragma once

#include <memory>
#include <utility>
#include <vector>

#include <compositionengine/Output.h>
#include <compositionengine/impl/OutputCompositionState.h>
@@ -24,6 +26,8 @@
namespace android::compositionengine {

class CompositionEngine;
class Layer;
class OutputLayer;

namespace impl {

@@ -60,6 +64,13 @@ public:
    Region getDirtyRegion(bool repaintEverything) const override;
    bool belongsInOutput(uint32_t, bool) const override;

    compositionengine::OutputLayer* getOutputLayerForLayer(
            compositionengine::Layer*) const override;
    std::unique_ptr<compositionengine::OutputLayer> getOrCreateOutputLayer(
            std::shared_ptr<compositionengine::Layer>, sp<LayerFE>) override;
    void setOutputLayersOrderedByZ(OutputLayers&&) override;
    const OutputLayers& getOutputLayersOrderedByZ() const override;

    // Testing
    void setDisplayColorProfileForTest(std::unique_ptr<compositionengine::DisplayColorProfile>);
    void setRenderSurfaceForTest(std::unique_ptr<compositionengine::RenderSurface>);
@@ -79,6 +90,8 @@ private:

    std::unique_ptr<compositionengine::DisplayColorProfile> mDisplayColorProfile;
    std::unique_ptr<compositionengine::RenderSurface> mRenderSurface;

    OutputLayers mOutputLayersOrderedByZ;
};

} // namespace impl
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <memory>

#include <compositionengine/OutputLayer.h>

namespace android::compositionengine::impl {

class OutputLayer : public compositionengine::OutputLayer {
public:
    OutputLayer(const compositionengine::Output&, std::shared_ptr<compositionengine::Layer>,
                sp<compositionengine::LayerFE>);
    ~OutputLayer() override;

    const compositionengine::Output& getOutput() const override;
    compositionengine::Layer& getLayer() const override;
    compositionengine::LayerFE& getLayerFE() const override;

private:
    const compositionengine::Output& mOutput;
    std::shared_ptr<compositionengine::Layer> mLayer;
    sp<compositionengine::LayerFE> mLayerFE;
};

std::unique_ptr<compositionengine::OutputLayer> createOutputLayer(
        const compositionengine::Output&, std::shared_ptr<compositionengine::Layer>,
        sp<compositionengine::LayerFE>);

} // namespace android::compositionengine::impl
Loading