Loading services/surfaceflinger/Layer.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -1687,9 +1687,9 @@ void Layer::miniDump(std::string& result, const DisplayDevice& display) const { crop.bottom); if (layerState.frameRate.rate != 0 || layerState.frameRate.type != FrameRateCompatibility::Default) { StringAppendF(&result, "% 6.2ffps %15s seamless=%d", layerState.frameRate.rate, StringAppendF(&result, "% 6.2ffps %15s seamless=%s", layerState.frameRate.rate, frameRateCompatibilityString(layerState.frameRate.type).c_str(), layerState.frameRate.shouldBeSeamless); toString(layerState.frameRate.seamlessness).c_str()); } else { StringAppendF(&result, " "); } Loading Loading @@ -2754,7 +2754,7 @@ bool Layer::getPrimaryDisplayOnly() const { std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) { return stream << "{rate=" << rate.rate << " type=" << Layer::frameRateCompatibilityString(rate.type) << " shouldBeSeamless=" << rate.shouldBeSeamless << "}"; << " seamlessness=" << toString(rate.seamlessness) << "}"; } }; // namespace android Loading services/surfaceflinger/Layer.h +24 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,9 @@ #include "LayerVector.h" #include "MonitoredProducer.h" #include "RenderArea.h" #include "Scheduler/Seamlessness.h" #include "SurfaceFlinger.h" #include "SurfaceTracing.h" #include "TransactionCompletedThread.h" using namespace android::surfaceflinger; Loading Loading @@ -151,17 +153,21 @@ public: // Encapsulates the frame rate and compatibility of the layer. This information will be used // when the display refresh rate is determined. struct FrameRate { using Seamlessness = scheduler::Seamlessness; float rate; FrameRateCompatibility type; bool shouldBeSeamless; Seamlessness seamlessness; FrameRate() : rate(0), type(FrameRateCompatibility::Default), shouldBeSeamless(true) {} FrameRate() : rate(0), type(FrameRateCompatibility::Default), seamlessness(Seamlessness::Default) {} FrameRate(float rate, FrameRateCompatibility type, bool shouldBeSeamless = true) : rate(rate), type(type), shouldBeSeamless(shouldBeSeamless) {} : rate(rate), type(type), seamlessness(getSeamlessness(rate, shouldBeSeamless)) {} bool operator==(const FrameRate& other) const { return rate == other.rate && type == other.type && shouldBeSeamless == other.shouldBeSeamless; return rate == other.rate && type == other.type && seamlessness == other.seamlessness; } bool operator!=(const FrameRate& other) const { return !(*this == other); } Loading @@ -169,6 +175,19 @@ public: // Convert an ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* value to a // Layer::FrameRateCompatibility. Logs fatal if the compatibility value is invalid. static FrameRateCompatibility convertCompatibility(int8_t compatibility); private: static Seamlessness getSeamlessness(float rate, bool shouldBeSeamless) { if (rate == 0.0f) { // Refresh rate of 0 is a special value which should reset the vote to // its default value. return Seamlessness::Default; } else if (shouldBeSeamless) { return Seamlessness::OnlySeamless; } else { return Seamlessness::SeamedAndSeamless; } } }; struct State { Loading services/surfaceflinger/Scheduler/LayerHistory.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -129,8 +129,7 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) { RefreshRateConfigs::LayerRequirement{.name = layer->getName(), .vote = voteType, .desiredRefreshRate = frameRate.rate, .shouldBeSeamless = frameRate.shouldBeSeamless, .seamlessness = frameRate.seamlessness, .weight = 1.0f, .focused = layerFocused}); } else if (recent) { Loading @@ -139,7 +138,8 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) { .vote = LayerVoteType::Heuristic, .desiredRefreshRate = info->getRefreshRate(now), .shouldBeSeamless = true, .seamlessness = Seamlessness::OnlySeamless, .weight = 1.0f, .focused = layerFocused}); } Loading services/surfaceflinger/Scheduler/LayerHistoryV2.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -144,8 +144,8 @@ LayerHistoryV2::Summary LayerHistoryV2::summarize(nsecs_t now) { const float layerArea = transformed.getWidth() * transformed.getHeight(); float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f; summary.push_back({strong->getName(), vote.type, vote.fps, vote.shouldBeSeamless, weight, layerFocused}); summary.push_back( {strong->getName(), vote.type, vote.fps, vote.seamlessness, weight, layerFocused}); if (CC_UNLIKELY(mTraceEnabled)) { trace(layer, *info, vote.type, static_cast<int>(std::round(vote.fps))); Loading Loading @@ -179,7 +179,7 @@ void LayerHistoryV2::partitionLayers(nsecs_t now) { if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) { const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote; info->setLayerVote({type, frameRate.rate, frameRate.shouldBeSeamless}); info->setLayerVote({type, frameRate.rate, frameRate.seamlessness}); } else { info->resetLayerVote(); } Loading services/surfaceflinger/Scheduler/LayerInfoV2.h +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "LayerHistory.h" #include "RefreshRateConfigs.h" #include "Scheduler/Seamlessness.h" #include "SchedulerUtils.h" namespace android { Loading Loading @@ -60,7 +61,7 @@ public: struct LayerVote { LayerHistory::LayerVoteType type = LayerHistory::LayerVoteType::Heuristic; float fps = 0.0f; bool shouldBeSeamless = true; Seamlessness seamlessness = Seamlessness::Default; }; static void setTraceEnabled(bool enabled) { sTraceEnabled = enabled; } Loading Loading @@ -91,7 +92,7 @@ public: void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; } // Resets the layer vote to its default. void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, true}; } void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, Seamlessness::Default}; } LayerVote getRefreshRateVote(nsecs_t now); Loading Loading
services/surfaceflinger/Layer.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -1687,9 +1687,9 @@ void Layer::miniDump(std::string& result, const DisplayDevice& display) const { crop.bottom); if (layerState.frameRate.rate != 0 || layerState.frameRate.type != FrameRateCompatibility::Default) { StringAppendF(&result, "% 6.2ffps %15s seamless=%d", layerState.frameRate.rate, StringAppendF(&result, "% 6.2ffps %15s seamless=%s", layerState.frameRate.rate, frameRateCompatibilityString(layerState.frameRate.type).c_str(), layerState.frameRate.shouldBeSeamless); toString(layerState.frameRate.seamlessness).c_str()); } else { StringAppendF(&result, " "); } Loading Loading @@ -2754,7 +2754,7 @@ bool Layer::getPrimaryDisplayOnly() const { std::ostream& operator<<(std::ostream& stream, const Layer::FrameRate& rate) { return stream << "{rate=" << rate.rate << " type=" << Layer::frameRateCompatibilityString(rate.type) << " shouldBeSeamless=" << rate.shouldBeSeamless << "}"; << " seamlessness=" << toString(rate.seamlessness) << "}"; } }; // namespace android Loading
services/surfaceflinger/Layer.h +24 −5 Original line number Diff line number Diff line Loading @@ -49,7 +49,9 @@ #include "LayerVector.h" #include "MonitoredProducer.h" #include "RenderArea.h" #include "Scheduler/Seamlessness.h" #include "SurfaceFlinger.h" #include "SurfaceTracing.h" #include "TransactionCompletedThread.h" using namespace android::surfaceflinger; Loading Loading @@ -151,17 +153,21 @@ public: // Encapsulates the frame rate and compatibility of the layer. This information will be used // when the display refresh rate is determined. struct FrameRate { using Seamlessness = scheduler::Seamlessness; float rate; FrameRateCompatibility type; bool shouldBeSeamless; Seamlessness seamlessness; FrameRate() : rate(0), type(FrameRateCompatibility::Default), shouldBeSeamless(true) {} FrameRate() : rate(0), type(FrameRateCompatibility::Default), seamlessness(Seamlessness::Default) {} FrameRate(float rate, FrameRateCompatibility type, bool shouldBeSeamless = true) : rate(rate), type(type), shouldBeSeamless(shouldBeSeamless) {} : rate(rate), type(type), seamlessness(getSeamlessness(rate, shouldBeSeamless)) {} bool operator==(const FrameRate& other) const { return rate == other.rate && type == other.type && shouldBeSeamless == other.shouldBeSeamless; return rate == other.rate && type == other.type && seamlessness == other.seamlessness; } bool operator!=(const FrameRate& other) const { return !(*this == other); } Loading @@ -169,6 +175,19 @@ public: // Convert an ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* value to a // Layer::FrameRateCompatibility. Logs fatal if the compatibility value is invalid. static FrameRateCompatibility convertCompatibility(int8_t compatibility); private: static Seamlessness getSeamlessness(float rate, bool shouldBeSeamless) { if (rate == 0.0f) { // Refresh rate of 0 is a special value which should reset the vote to // its default value. return Seamlessness::Default; } else if (shouldBeSeamless) { return Seamlessness::OnlySeamless; } else { return Seamlessness::SeamedAndSeamless; } } }; struct State { Loading
services/surfaceflinger/Scheduler/LayerHistory.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -129,8 +129,7 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) { RefreshRateConfigs::LayerRequirement{.name = layer->getName(), .vote = voteType, .desiredRefreshRate = frameRate.rate, .shouldBeSeamless = frameRate.shouldBeSeamless, .seamlessness = frameRate.seamlessness, .weight = 1.0f, .focused = layerFocused}); } else if (recent) { Loading @@ -139,7 +138,8 @@ LayerHistory::Summary LayerHistory::summarize(nsecs_t now) { .vote = LayerVoteType::Heuristic, .desiredRefreshRate = info->getRefreshRate(now), .shouldBeSeamless = true, .seamlessness = Seamlessness::OnlySeamless, .weight = 1.0f, .focused = layerFocused}); } Loading
services/surfaceflinger/Scheduler/LayerHistoryV2.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -144,8 +144,8 @@ LayerHistoryV2::Summary LayerHistoryV2::summarize(nsecs_t now) { const float layerArea = transformed.getWidth() * transformed.getHeight(); float weight = mDisplayArea ? layerArea / mDisplayArea : 0.0f; summary.push_back({strong->getName(), vote.type, vote.fps, vote.shouldBeSeamless, weight, layerFocused}); summary.push_back( {strong->getName(), vote.type, vote.fps, vote.seamlessness, weight, layerFocused}); if (CC_UNLIKELY(mTraceEnabled)) { trace(layer, *info, vote.type, static_cast<int>(std::round(vote.fps))); Loading Loading @@ -179,7 +179,7 @@ void LayerHistoryV2::partitionLayers(nsecs_t now) { if (frameRate.rate > 0 || voteType == LayerVoteType::NoVote) { const auto type = layer->isVisible() ? voteType : LayerVoteType::NoVote; info->setLayerVote({type, frameRate.rate, frameRate.shouldBeSeamless}); info->setLayerVote({type, frameRate.rate, frameRate.seamlessness}); } else { info->resetLayerVote(); } Loading
services/surfaceflinger/Scheduler/LayerInfoV2.h +3 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "LayerHistory.h" #include "RefreshRateConfigs.h" #include "Scheduler/Seamlessness.h" #include "SchedulerUtils.h" namespace android { Loading Loading @@ -60,7 +61,7 @@ public: struct LayerVote { LayerHistory::LayerVoteType type = LayerHistory::LayerVoteType::Heuristic; float fps = 0.0f; bool shouldBeSeamless = true; Seamlessness seamlessness = Seamlessness::Default; }; static void setTraceEnabled(bool enabled) { sTraceEnabled = enabled; } Loading Loading @@ -91,7 +92,7 @@ public: void setDefaultLayerVote(LayerHistory::LayerVoteType type) { mDefaultVote = type; } // Resets the layer vote to its default. void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, true}; } void resetLayerVote() { mLayerVote = {mDefaultVote, 0.0f, Seamlessness::Default}; } LayerVote getRefreshRateVote(nsecs_t now); Loading