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

Commit f52f4700 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF: Refactor onPreComposition"

parents d932dc73 0e1c05e6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

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

namespace android {

@@ -30,6 +31,11 @@ struct LayerFECompositionState;
// of the front-end layer
class LayerFE : public virtual RefBase {
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
    // geometry state can be skipped.
    virtual void latchCompositionState(LayerFECompositionState&, bool includeGeometry) const = 0;
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ public:
    LayerFE();
    virtual ~LayerFE();

    MOCK_METHOD1(onPreComposition, bool(nsecs_t));

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

+0 −6
Original line number Diff line number Diff line
@@ -484,12 +484,6 @@ public:
    virtual bool shouldPresentNow(nsecs_t /*expectedPresentTime*/) const { return false; }
    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.
     * returns true if the layer latched a new buffer this frame.
+7 −2
Original line number Diff line number Diff line
@@ -1966,9 +1966,14 @@ void SurfaceFlinger::preComposition()

    bool needExtraInvalidate = false;
    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;
            }
        }
    });

    if (needExtraInvalidate) {