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

Commit d5e8e276 authored by Ady Abraham's avatar Ady Abraham
Browse files

libnativedisplay: plumb setFrameRate to SurfaceTexure

Bug: 281695725
Test: manual using a test app
Change-Id: I2d18c843d9e0771cef4378f58f1197f974163fa0
parent 1926052e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <android/hardware_buffer.h>
#include <gui/BufferQueueDefs.h>
#include <gui/ConsumerBase.h>
#include <gui/Flags.h>
#include <gui/IGraphicBufferProducer.h>
#include <sys/cdefs.h>
#include <system/graphics.h>
@@ -295,6 +296,8 @@ public:
     */
    struct SurfaceTextureListener : public RefBase {
        virtual void onFrameAvailable(const BufferItem& item) = 0;
        virtual void onSetFrameRate(float frameRate, int8_t compatibility,
                                    int8_t changeFrameRateStrategy) = 0;
    };

    /**
@@ -346,6 +349,14 @@ protected:
     */
    void computeCurrentTransformMatrixLocked();

    /**
     * onSetFrameRate Notifies the consumer of a setFrameRate call from the producer side.
     */
#if FLAG_BQ_SET_FRAME_RATE
    void onSetFrameRate(float frameRate, int8_t compatibility,
                        int8_t changeFrameRateStrategy) override;
#endif

    /**
     * The default consumer usage flags that SurfaceTexture always sets on its
     * BufferQueue instance; these will be OR:d with any additional flags passed
+16 −0
Original line number Diff line number Diff line
@@ -515,4 +515,20 @@ void SurfaceTexture::FrameAvailableListenerProxy::onFrameAvailable(const BufferI
    }
}

#if FLAG_BQ_SET_FRAME_RATE
void SurfaceTexture::onSetFrameRate(float frameRate, int8_t compatibility,
                                    int8_t changeFrameRateStrategy) {
    SFT_LOGV("onSetFrameRate: %.2f", frameRate);

    auto listener = [&] {
        Mutex::Autolock _l(mMutex);
        return mSurfaceTextureListener;
    }();

    if (listener) {
        listener->onSetFrameRate(frameRate, compatibility, changeFrameRateStrategy);
    }
}
#endif

} // namespace android