summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Salido <salidoa@google.com>2019-09-09 16:15:58 -0700
committerAdrian Salido <salidoa@google.com>2019-09-10 01:07:02 +0000
commite0aedc2e744cb983dd2a3373d8bd114a4e1061f3 (patch)
treeaf2230311e0f0e0c8424402d76519f3aac7331da
parentb419fa8686633b112b3fa153e29528cb8821ee6c (diff)
parentd916d941d89ec8fdcbc2bbe0bfdf0b0db1ad08b5 (diff)
downloadnative-e0aedc2e744cb983dd2a3373d8bd114a4e1061f3.tar.gz
resolve merge conflicts of d916d941d89ec8fdcbc2bbe0bfdf0b0db1ad08b5 to qt-qpr1-dev
Test: I solemnly swear I tested this conflict resolution. Bug: 139557239 Change-Id: I4966f630b0e980e17cbbbcf9b280e034eaeb651e Merged-In: Ia85a60fde55afaed5106462942e0bb77652ec737
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.cpp5
-rw-r--r--services/surfaceflinger/Scheduler/Scheduler.h3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp30
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h3
4 files changed, 31 insertions, 10 deletions
diff --git a/services/surfaceflinger/Scheduler/Scheduler.cpp b/services/surfaceflinger/Scheduler/Scheduler.cpp
index baa677ee2a..ad106326a1 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.cpp
+++ b/services/surfaceflinger/Scheduler/Scheduler.cpp
@@ -601,6 +601,11 @@ Scheduler::RefreshRateType Scheduler::calculateRefreshRateType() {
return currRefreshRateType;
}
+Scheduler::RefreshRateType Scheduler::getPreferredRefreshRateType() {
+ std::lock_guard<std::mutex> lock(mFeatureStateLock);
+ return mRefreshRateType;
+}
+
void Scheduler::changeRefreshRate(RefreshRateType refreshRateType, ConfigEvent configEvent) {
std::lock_guard<std::mutex> lock(mCallbackLock);
if (mChangeRefreshRateCallback) {
diff --git a/services/surfaceflinger/Scheduler/Scheduler.h b/services/surfaceflinger/Scheduler/Scheduler.h
index 5d8bb4cd2f..38184570c1 100644
--- a/services/surfaceflinger/Scheduler/Scheduler.h
+++ b/services/surfaceflinger/Scheduler/Scheduler.h
@@ -189,6 +189,9 @@ public:
// calls DispSync::dump() on primary disp sync
void dumpPrimaryDispSync(std::string& result) const;
+ // Get the appropriate refresh type for current conditions.
+ RefreshRateType getPreferredRefreshRateType();
+
protected:
virtual std::unique_ptr<EventThread> makeEventThread(
const char* connectionName, DispSync* dispSync, nsecs_t phaseOffsetNs,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index ab22cd9016..ffb7012bb3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -6169,6 +6169,25 @@ void SurfaceFlinger::traverseLayersInDisplay(const sp<const DisplayDevice>& disp
}
}
+void SurfaceFlinger::setPreferredDisplayConfig() {
+ const auto& type = mScheduler->getPreferredRefreshRateType();
+ const auto& config = mRefreshRateConfigs.getRefreshRate(type);
+ if (config && isDisplayConfigAllowed(config->configId)) {
+ ALOGV("switching to Scheduler preferred config %d", config->configId);
+ setDesiredActiveConfig({type, config->configId, Scheduler::ConfigEvent::Changed});
+ } else {
+ // Set the highest allowed config by iterating backwards on available refresh rates
+ const auto& refreshRates = mRefreshRateConfigs.getRefreshRates();
+ for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) {
+ if (iter->second && isDisplayConfigAllowed(iter->second->configId)) {
+ ALOGV("switching to allowed config %d", iter->second->configId);
+ setDesiredActiveConfig({iter->first, iter->second->configId,
+ Scheduler::ConfigEvent::Changed});
+ }
+ }
+ }
+}
+
void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
const std::vector<int32_t>& allowedConfigs) {
if (!display->isPrimary()) {
@@ -6190,16 +6209,7 @@ void SurfaceFlinger::setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& d
mScheduler->onConfigChanged(mAppConnectionHandle, display->getId()->value,
display->getActiveConfig());
- // Set the highest allowed config by iterating backwards on available refresh rates
- const auto& refreshRates = mRefreshRateConfigs.getRefreshRates();
- for (auto iter = refreshRates.crbegin(); iter != refreshRates.crend(); ++iter) {
- if (iter->second && isDisplayConfigAllowed(iter->second->configId)) {
- ALOGV("switching to config %d", iter->second->configId);
- setDesiredActiveConfig(
- {iter->first, iter->second->configId, Scheduler::ConfigEvent::Changed});
- break;
- }
- }
+ setPreferredDisplayConfig();
}
status_t SurfaceFlinger::setAllowedDisplayConfigs(const sp<IBinder>& displayToken,
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 0c6da0077f..a59a1e0086 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -534,6 +534,9 @@ private:
// called on the main thread in response to setPowerMode()
void setPowerModeInternal(const sp<DisplayDevice>& display, int mode) REQUIRES(mStateLock);
+ // Query the Scheduler or allowed display configs list for a matching config, and set it
+ void setPreferredDisplayConfig() REQUIRES(mStateLock);
+
// called on the main thread in response to setAllowedDisplayConfigs()
void setAllowedDisplayConfigsInternal(const sp<DisplayDevice>& display,
const std::vector<int32_t>& allowedConfigs)