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

Commit f8a18312 authored by Leon Scroggins III's avatar Leon Scroggins III
Browse files

Identify a PIP window and implement hole punch

Bug: 163076219
Test: manual
Test: I53fc851eca876d44ba7cb9347f1c62d659c38932

In order to use a hole punch + device compositing to render a PIP, we
need to find a PIP that follows a CachedSet. A PIP (or, more generally,
a layer that we can render in this way in order to use device
composition more frequently) must have rounded corners and a buffer.

Add LayerFE::hasRoundedCorners (and implement in Layer) to allow
identifying whether a layer has rounded corners.

If a CachedSet has a hole punch layer, use a modified version of its
LayerSettings to draw a transparent round rect into its buffer.

Only active if caching and debug.sf.enable_hole_punch_pip are enabled
and PIPs use rounded corners (as in frameworks/base change
Ib0f61bbcbee6ead82beec2b149b0892836492b78).

Change-Id: I56e2a6debce6ede4bebfcbd32bffa01c20461542
parent 344d6a62
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -138,6 +138,9 @@ public:


    // Gets the sequence number: a serial number that uniquely identifies a Layer
    // Gets the sequence number: a serial number that uniquely identifies a Layer
    virtual int32_t getSequence() const = 0;
    virtual int32_t getSequence() const = 0;

    // Whether the layer should be rendered with rounded corners.
    virtual bool hasRoundedCorners() const = 0;
};
};


// TODO(b/121291683): Specialize std::hash<> for sp<T> so these and others can
// TODO(b/121291683): Specialize std::hash<> for sp<T> so these and others can
+11 −0
Original line number Original line Diff line number Diff line
@@ -105,12 +105,23 @@ public:


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


    // Whether this represents a single layer with a buffer and rounded corners.
    // If it is, we can draw it by placing it behind another CachedSet and
    // punching a hole.
    bool requiresHolePunch() const;

    // Add a layer that will be drawn behind this one. ::render() will render a
    // hole in this CachedSet's buffer, allowing the supplied layer to peek
    // through. Must be called before ::render().
    void addHolePunchLayer(const LayerState*);

private:
private:
    CachedSet() = default;
    CachedSet() = default;


    const NonBufferHash mFingerprint;
    const NonBufferHash mFingerprint;
    std::chrono::steady_clock::time_point mLastUpdate = std::chrono::steady_clock::now();
    std::chrono::steady_clock::time_point mLastUpdate = std::chrono::steady_clock::now();
    std::vector<Layer> mLayers;
    std::vector<Layer> mLayers;
    const LayerState* mHolePunchLayer = nullptr;
    Rect mBounds = Rect::EMPTY_RECT;
    Rect mBounds = Rect::EMPTY_RECT;
    Region mVisibleRegion;
    Region mVisibleRegion;
    size_t mAge = 0;
    size_t mAge = 0;
+3 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,8 @@ class Predictor;


class Flattener {
class Flattener {
public:
public:
    Flattener(Predictor& predictor) : mPredictor(predictor) {}
    Flattener(Predictor& predictor, bool enableHolePunch = false)
          : mEnableHolePunch(enableHolePunch), mPredictor(predictor) {}


    void setDisplaySize(ui::Size size) { mDisplaySize = size; }
    void setDisplaySize(ui::Size size) { mDisplaySize = size; }


@@ -61,6 +62,7 @@ private:


    void buildCachedSets(std::chrono::steady_clock::time_point now);
    void buildCachedSets(std::chrono::steady_clock::time_point now);


    const bool mEnableHolePunch;
    Predictor& mPredictor;
    Predictor& mPredictor;


    ui::Size mDisplaySize;
    ui::Size mDisplaySize;
+1 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ namespace compositionengine::impl::planner {
// as a more efficient representation of parts of the layer stack.
// as a more efficient representation of parts of the layer stack.
class Planner {
class Planner {
public:
public:
    Planner() : mFlattener(mPredictor) {}
    Planner();


    void setDisplaySize(ui::Size);
    void setDisplaySize(ui::Size);


+1 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ public:


    MOCK_CONST_METHOD0(getDebugName, const char*());
    MOCK_CONST_METHOD0(getDebugName, const char*());
    MOCK_CONST_METHOD0(getSequence, int32_t());
    MOCK_CONST_METHOD0(getSequence, int32_t());
    MOCK_CONST_METHOD0(hasRoundedCorners, bool());
};
};


} // namespace android::compositionengine::mock
} // namespace android::compositionengine::mock
Loading