Loading services/surfaceflinger/BufferQueueLayer.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -125,21 +125,16 @@ bool BufferQueueLayer::shouldPresentNow(nsecs_t expectedPresentTime) const { return isDue || !isPlausible; } bool BufferQueueLayer::setFrameRate(float frameRate) { bool BufferQueueLayer::setFrameRate(FrameRate frameRate) { float oldFrameRate = 0.f; status_t result = mConsumer->getFrameRate(&oldFrameRate); bool frameRateChanged = result < 0 || frameRate != oldFrameRate; mConsumer->setFrameRate(frameRate); bool frameRateChanged = result < 0 || frameRate.rate != oldFrameRate; mConsumer->setFrameRate(frameRate.rate); return frameRateChanged; } std::optional<float> BufferQueueLayer::getFrameRate() const { const auto frameRate = mLatchedFrameRate.load(); if (frameRate > 0.f || frameRate == FRAME_RATE_NO_VOTE) { return frameRate; } return {}; Layer::FrameRate BufferQueueLayer::getFrameRate() const { return FrameRate(mLatchedFrameRate, Layer::FrameRateCompatibility::Default); } // ----------------------------------------------------------------------- Loading services/surfaceflinger/BufferQueueLayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -56,8 +56,8 @@ public: bool shouldPresentNow(nsecs_t expectedPresentTime) const override; bool setFrameRate(float frameRate) override; std::optional<float> getFrameRate() const override; bool setFrameRate(FrameRate frameRate) override; FrameRate getFrameRate() const override; // ----------------------------------------------------------------------- Loading services/surfaceflinger/Layer.cpp +3 −7 Original line number Diff line number Diff line Loading @@ -117,7 +117,6 @@ Layer::Layer(const LayerCreationArgs& args) mCurrentState.frameRateSelectionPriority = PRIORITY_UNSET; mCurrentState.metadata = args.metadata; mCurrentState.shadowRadius = 0.f; mCurrentState.frameRate = 0.f; // drawing state & current state are identical mDrawingState = mCurrentState; Loading Loading @@ -1245,7 +1244,7 @@ bool Layer::setShadowRadius(float shadowRadius) { return true; } bool Layer::setFrameRate(float frameRate) { bool Layer::setFrameRate(FrameRate frameRate) { if (mCurrentState.frameRate == frameRate) { return false; } Loading @@ -1257,11 +1256,8 @@ bool Layer::setFrameRate(float frameRate) { return true; } std::optional<float> Layer::getFrameRate() const { const auto frameRate = getDrawingState().frameRate; if (frameRate > 0.f || frameRate == FRAME_RATE_NO_VOTE) return frameRate; return {}; Layer::FrameRate Layer::getFrameRate() const { return getDrawingState().frameRate; } void Layer::deferTransactionUntil_legacy(const sp<Layer>& barrierLayer, uint64_t frameNumber) { Loading services/surfaceflinger/Layer.h +31 −4 Original line number Diff line number Diff line Loading @@ -136,6 +136,34 @@ public: float radius = 0.0f; }; // FrameRateCompatibility specifies how we should interpret the frame rate associated with // the layer. enum class FrameRateCompatibility { Default, // Layer didn't specify any specific handling strategy ExactOrMultiple, // Layer needs the exact frame rate (or a multiple of it) to present the // content properly. Any other value will result in a pull down. NoVote, // Layer doesn't have any requirements for the refresh rate and // should not be considered when the display refresh rate is determined. }; // Encapsulates the frame rate and compatibility of the layer. This information will be used // when the display refresh rate is determined. struct FrameRate { float rate; FrameRateCompatibility type; FrameRate() : rate(0), type(FrameRateCompatibility::Default) {} FrameRate(float rate, FrameRateCompatibility type) : rate(rate), type(type) {} bool operator==(const FrameRate& other) const { return rate == other.rate && type == other.type; } bool operator!=(const FrameRate& other) const { return !(*this == other); } }; struct State { Geometry active_legacy; Geometry requested_legacy; Loading Loading @@ -227,7 +255,7 @@ public: // Priority of the layer assigned by Window Manager. int32_t frameRateSelectionPriority; float frameRate; FrameRate frameRate; }; explicit Layer(const LayerCreationArgs& args); Loading Loading @@ -754,9 +782,8 @@ public: */ Rect getCroppedBufferSize(const Layer::State& s) const; constexpr static auto FRAME_RATE_NO_VOTE = -1.0f; virtual bool setFrameRate(float frameRate); virtual std::optional<float> getFrameRate() const; virtual bool setFrameRate(FrameRate frameRate); virtual FrameRate getFrameRate() const; protected: // constant Loading services/surfaceflinger/RefreshRateOverlay.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ bool RefreshRateOverlay::createLayer() { Mutex::Autolock _l(mFlinger.mStateLock); mLayer = mClient->getLayerUser(mIBinder); mLayer->setFrameRate(Layer::FRAME_RATE_NO_VOTE); mLayer->setFrameRate(Layer::FrameRate(0, Layer::FrameRateCompatibility::NoVote)); // setting Layer's Z requires resorting layersSortedByZ ssize_t idx = mFlinger.mCurrentState.layersSortedByZ.indexOf(mLayer); Loading Loading
services/surfaceflinger/BufferQueueLayer.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -125,21 +125,16 @@ bool BufferQueueLayer::shouldPresentNow(nsecs_t expectedPresentTime) const { return isDue || !isPlausible; } bool BufferQueueLayer::setFrameRate(float frameRate) { bool BufferQueueLayer::setFrameRate(FrameRate frameRate) { float oldFrameRate = 0.f; status_t result = mConsumer->getFrameRate(&oldFrameRate); bool frameRateChanged = result < 0 || frameRate != oldFrameRate; mConsumer->setFrameRate(frameRate); bool frameRateChanged = result < 0 || frameRate.rate != oldFrameRate; mConsumer->setFrameRate(frameRate.rate); return frameRateChanged; } std::optional<float> BufferQueueLayer::getFrameRate() const { const auto frameRate = mLatchedFrameRate.load(); if (frameRate > 0.f || frameRate == FRAME_RATE_NO_VOTE) { return frameRate; } return {}; Layer::FrameRate BufferQueueLayer::getFrameRate() const { return FrameRate(mLatchedFrameRate, Layer::FrameRateCompatibility::Default); } // ----------------------------------------------------------------------- Loading
services/surfaceflinger/BufferQueueLayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -56,8 +56,8 @@ public: bool shouldPresentNow(nsecs_t expectedPresentTime) const override; bool setFrameRate(float frameRate) override; std::optional<float> getFrameRate() const override; bool setFrameRate(FrameRate frameRate) override; FrameRate getFrameRate() const override; // ----------------------------------------------------------------------- Loading
services/surfaceflinger/Layer.cpp +3 −7 Original line number Diff line number Diff line Loading @@ -117,7 +117,6 @@ Layer::Layer(const LayerCreationArgs& args) mCurrentState.frameRateSelectionPriority = PRIORITY_UNSET; mCurrentState.metadata = args.metadata; mCurrentState.shadowRadius = 0.f; mCurrentState.frameRate = 0.f; // drawing state & current state are identical mDrawingState = mCurrentState; Loading Loading @@ -1245,7 +1244,7 @@ bool Layer::setShadowRadius(float shadowRadius) { return true; } bool Layer::setFrameRate(float frameRate) { bool Layer::setFrameRate(FrameRate frameRate) { if (mCurrentState.frameRate == frameRate) { return false; } Loading @@ -1257,11 +1256,8 @@ bool Layer::setFrameRate(float frameRate) { return true; } std::optional<float> Layer::getFrameRate() const { const auto frameRate = getDrawingState().frameRate; if (frameRate > 0.f || frameRate == FRAME_RATE_NO_VOTE) return frameRate; return {}; Layer::FrameRate Layer::getFrameRate() const { return getDrawingState().frameRate; } void Layer::deferTransactionUntil_legacy(const sp<Layer>& barrierLayer, uint64_t frameNumber) { Loading
services/surfaceflinger/Layer.h +31 −4 Original line number Diff line number Diff line Loading @@ -136,6 +136,34 @@ public: float radius = 0.0f; }; // FrameRateCompatibility specifies how we should interpret the frame rate associated with // the layer. enum class FrameRateCompatibility { Default, // Layer didn't specify any specific handling strategy ExactOrMultiple, // Layer needs the exact frame rate (or a multiple of it) to present the // content properly. Any other value will result in a pull down. NoVote, // Layer doesn't have any requirements for the refresh rate and // should not be considered when the display refresh rate is determined. }; // Encapsulates the frame rate and compatibility of the layer. This information will be used // when the display refresh rate is determined. struct FrameRate { float rate; FrameRateCompatibility type; FrameRate() : rate(0), type(FrameRateCompatibility::Default) {} FrameRate(float rate, FrameRateCompatibility type) : rate(rate), type(type) {} bool operator==(const FrameRate& other) const { return rate == other.rate && type == other.type; } bool operator!=(const FrameRate& other) const { return !(*this == other); } }; struct State { Geometry active_legacy; Geometry requested_legacy; Loading Loading @@ -227,7 +255,7 @@ public: // Priority of the layer assigned by Window Manager. int32_t frameRateSelectionPriority; float frameRate; FrameRate frameRate; }; explicit Layer(const LayerCreationArgs& args); Loading Loading @@ -754,9 +782,8 @@ public: */ Rect getCroppedBufferSize(const Layer::State& s) const; constexpr static auto FRAME_RATE_NO_VOTE = -1.0f; virtual bool setFrameRate(float frameRate); virtual std::optional<float> getFrameRate() const; virtual bool setFrameRate(FrameRate frameRate); virtual FrameRate getFrameRate() const; protected: // constant Loading
services/surfaceflinger/RefreshRateOverlay.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ bool RefreshRateOverlay::createLayer() { Mutex::Autolock _l(mFlinger.mStateLock); mLayer = mClient->getLayerUser(mIBinder); mLayer->setFrameRate(Layer::FRAME_RATE_NO_VOTE); mLayer->setFrameRate(Layer::FrameRate(0, Layer::FrameRateCompatibility::NoVote)); // setting Layer's Z requires resorting layersSortedByZ ssize_t idx = mFlinger.mCurrentState.layersSortedByZ.indexOf(mLayer); Loading