summaryrefslogtreecommitdiffstats
path: root/services/surfaceflinger/DispSync.cpp
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2014-04-24 16:42:35 -0700
committerRuchi Kandoi <kandoiruchi@google.com>2014-05-01 18:29:33 +0000
commitf52b3c88f18c0546526996c839fbce74172e11c7 (patch)
tree5f958cf34171b4e7bde22a933112fee4739a3e2b /services/surfaceflinger/DispSync.cpp
parent5d112a7dd60801b9993778624bcf9092a596ad62 (diff)
downloadframeworks_native-f52b3c88f18c0546526996c839fbce74172e11c7.zip
frameworks_native-f52b3c88f18c0546526996c839fbce74172e11c7.tar.gz
frameworks_native-f52b3c88f18c0546526996c839fbce74172e11c7.tar.bz2
SurfaceFlinger: Adds the functionality to reduce refresh rate to half of
the default. Feature added for the low power mode. Change-Id: I2849e5ea335c0d2509fea1c315392bce7f20451d Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Diffstat (limited to 'services/surfaceflinger/DispSync.cpp')
-rw-r--r--services/surfaceflinger/DispSync.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index 602f20a..a00ccdb 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -61,7 +61,10 @@ class DispSyncThread: public Thread {
public:
DispSyncThread():
+ mLowPowerMode(false),
mStop(false),
+ mLastVsyncSent(false),
+ mLastBufferFull(false),
mPeriod(0),
mPhase(0),
mWakeupLatency(0) {
@@ -145,7 +148,18 @@ public:
}
if (callbackInvocations.size() > 0) {
- fireCallbackInvocations(callbackInvocations);
+ if (mLowPowerMode) {
+ if (!mLastVsyncSent || !mLastBufferFull) {
+ fireCallbackInvocations(callbackInvocations);
+ mLastVsyncSent = true;
+ } else
+ mLastVsyncSent = false;
+ } else {
+ fireCallbackInvocations(callbackInvocations);
+ }
+ mLastBufferFull = true;
+ } else {
+ mLastBufferFull = false;
}
}
@@ -200,6 +214,7 @@ public:
return !mEventListeners.empty();
}
+ bool mLowPowerMode;
private:
struct EventListener {
@@ -272,6 +287,8 @@ private:
}
bool mStop;
+ bool mLastVsyncSent;
+ bool mLastBufferFull;
nsecs_t mPeriod;
nsecs_t mPhase;
@@ -395,6 +412,10 @@ status_t DispSync::addEventListener(nsecs_t phase,
return mThread->addEventListener(phase, callback);
}
+void DispSync::setLowPowerMode(bool enabled) {
+ mThread->mLowPowerMode = enabled;
+}
+
status_t DispSync::removeEventListener(const sp<Callback>& callback) {
Mutex::Autolock lock(mMutex);
return mThread->removeEventListener(callback);