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

Commit 6166c312 authored by Dan Stoza's avatar Dan Stoza Committed by Ady Abraham
Browse files

SF: Add Planner flattener

Adds the Planner flattener, which detects when layers are inactive and
flattens them using GPU composition in order to reduce the workload on
the display processor.

Bug: 158790260
Test: atest libcompositionengine_test libsurfaceflinger_unittest
Change-Id: Idc5c2927c8af6fe85653404a7d94c9e68ffc329b
parent 47437bb9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ cc_library {
    name: "libcompositionengine",
    defaults: ["libcompositionengine_defaults"],
    srcs: [
        "src/planner/CachedSet.cpp",
        "src/planner/Flattener.cpp",
        "src/planner/LayerState.cpp",
        "src/planner/Planner.cpp",
        "src/planner/Predictor.cpp",
+1 −0
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ protected:
    virtual std::optional<base::unique_fd> composeSurfaces(
            const Region&, const compositionengine::CompositionRefreshArgs& refreshArgs) = 0;
    virtual void postFramebuffer() = 0;
    virtual void renderCachedSets() = 0;
    virtual void chooseCompositionStrategy() = 0;
    virtual bool getSkipColorTransform() const = 0;
    virtual FrameFences presentAndGetFrameFences() = 0;
+9 −3
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include "DisplayHardware/ComposerHal.h"
#include "DisplayHardware/DisplayIdentification.h"

#include "LayerFE.h"

// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion -Wextra"

@@ -43,7 +45,6 @@ namespace compositionengine {

class CompositionEngine;
class Output;
class LayerFE;

namespace impl {
struct OutputLayerCompositionState;
@@ -88,8 +89,9 @@ public:

    // Writes the geometry state to the HWC, or does nothing if this layer does
    // not use the HWC. If includeGeometry is false, the geometry state can be
    // skipped.
    virtual void writeStateToHWC(bool includeGeometry) = 0;
    // skipped. If skipLayer is true, then the alpha of the layer is forced to
    // 0 so that HWC will ignore it.
    virtual void writeStateToHWC(bool includeGeometry, bool skipLayer) = 0;

    // Updates the cursor position with the HWC
    virtual void writeCursorPositionToHWC() const = 0;
@@ -115,6 +117,10 @@ public:
    // Returns true if the composition settings scale pixels
    virtual bool needsFiltering() const = 0;

    // Returns a composition list to be used by RenderEngine if the layer has been overridden
    // during the composition process
    virtual std::vector<LayerFE::LayerSettings> getOverrideCompositionList() const = 0;

    // Debugging
    virtual void dump(std::string& result) const = 0;
};
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ public:
    std::optional<base::unique_fd> composeSurfaces(
            const Region&, const compositionengine::CompositionRefreshArgs& refreshArgs) override;
    void postFramebuffer() override;
    void renderCachedSets() override;
    void cacheClientCompositionRequests(uint32_t) override;

    // Testing
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <memory>
#include <string>

#include <compositionengine/LayerFE.h>
#include <compositionengine/OutputLayer.h>
#include <ui/FloatRect.h>
#include <ui/Rect.h>
@@ -41,7 +42,7 @@ public:

    void updateCompositionState(bool includeGeometry, bool forceClientComposition,
                                ui::Transform::RotationFlags) override;
    void writeStateToHWC(bool) override;
    void writeStateToHWC(bool includeGeometry, bool skipLayer) override;
    void writeCursorPositionToHWC() const override;

    HWC2::Layer* getHwcLayer() const override;
@@ -51,6 +52,7 @@ public:
    void prepareForDeviceLayerRequests() override;
    void applyDeviceLayerRequest(Hwc2::IComposerClient::LayerRequest request) override;
    bool needsFiltering() const override;
    std::vector<LayerFE::LayerSettings> getOverrideCompositionList() const override;

    void dump(std::string&) const override;

@@ -66,7 +68,8 @@ protected:
private:
    Rect calculateInitialCrop() const;
    void writeOutputDependentGeometryStateToHWC(HWC2::Layer*, Hwc2::IComposerClient::Composition);
    void writeOutputIndependentGeometryStateToHWC(HWC2::Layer*, const LayerFECompositionState&);
    void writeOutputIndependentGeometryStateToHWC(HWC2::Layer*, const LayerFECompositionState&,
                                                  bool skipLayer);
    void writeOutputDependentPerFrameStateToHWC(HWC2::Layer*);
    void writeOutputIndependentPerFrameStateToHWC(HWC2::Layer*, const LayerFECompositionState&);
    void writeSolidColorStateToHWC(HWC2::Layer*, const LayerFECompositionState&);
Loading