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

Commit 0e1c05e6 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Refactor onPreComposition

Adds LayerFE::onPreComposition call, and adjusts the existing
implementation inside SurfaceFlinger to use it, in preparation to moving
the loop over to CompositionEngine.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: Ibc0fb1e87d37fabba753f265e70982b5ce70f9f2
parent f527548d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once
#pragma once


#include <utils/RefBase.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>


namespace android {
namespace android {


@@ -30,6 +31,11 @@ struct LayerFECompositionState;
// of the front-end layer
// of the front-end layer
class LayerFE : public virtual RefBase {
class LayerFE : public virtual RefBase {
public:
public:
    // Called before composition starts. Should return true if this layer has
    // pending updates which would require an extra display refresh cycle to
    // process.
    virtual bool onPreComposition(nsecs_t refreshStartTime) = 0;

    // Latches the output-independent state. If includeGeometry is false, the
    // Latches the output-independent state. If includeGeometry is false, the
    // geometry state can be skipped.
    // geometry state can be skipped.
    virtual void latchCompositionState(LayerFECompositionState&, bool includeGeometry) const = 0;
    virtual void latchCompositionState(LayerFECompositionState&, bool includeGeometry) const = 0;
+2 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,8 @@ public:
    LayerFE();
    LayerFE();
    virtual ~LayerFE();
    virtual ~LayerFE();


    MOCK_METHOD1(onPreComposition, bool(nsecs_t));

    MOCK_CONST_METHOD2(latchCompositionState, void(LayerFECompositionState&, bool));
    MOCK_CONST_METHOD2(latchCompositionState, void(LayerFECompositionState&, bool));
    MOCK_METHOD1(onLayerDisplayed, void(const sp<Fence>&));
    MOCK_METHOD1(onLayerDisplayed, void(const sp<Fence>&));


+0 −6
Original line number Original line Diff line number Diff line
@@ -484,12 +484,6 @@ public:
    virtual bool shouldPresentNow(nsecs_t /*expectedPresentTime*/) const { return false; }
    virtual bool shouldPresentNow(nsecs_t /*expectedPresentTime*/) const { return false; }
    virtual void setTransformHint(uint32_t /*orientation*/) const { }
    virtual void setTransformHint(uint32_t /*orientation*/) const { }


    /*
     * called before composition.
     * returns true if the layer has pending updates.
     */
    virtual bool onPreComposition(nsecs_t refreshStartTime) = 0;

    /*
    /*
     * called after composition.
     * called after composition.
     * returns true if the layer latched a new buffer this frame.
     * returns true if the layer latched a new buffer this frame.
+7 −2
Original line number Original line Diff line number Diff line
@@ -1962,9 +1962,14 @@ void SurfaceFlinger::preComposition()


    bool needExtraInvalidate = false;
    bool needExtraInvalidate = false;
    mDrawingState.traverseInZOrder([&](Layer* layer) {
    mDrawingState.traverseInZOrder([&](Layer* layer) {
        if (layer->onPreComposition(mRefreshStartTime)) {
        auto compositionLayer = layer->getCompositionLayer();
        if (compositionLayer) {
            auto layerFE = compositionLayer->getLayerFE();

            if (layerFE && layerFE->onPreComposition(mRefreshStartTime)) {
                needExtraInvalidate = true;
                needExtraInvalidate = true;
            }
            }
        }
    });
    });


    if (needExtraInvalidate) {
    if (needExtraInvalidate) {