public:
DispSyncThread():
+ mLowPowerMode(false),
mStop(false),
+ mLastVsyncSent(false),
+ mLastBufferFull(false),
mPeriod(0),
mPhase(0),
mWakeupLatency(0) {
}
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;
}
}
return !mEventListeners.empty();
}
+ bool mLowPowerMode;
private:
struct EventListener {
}
bool mStop;
+ bool mLastVsyncSent;
+ bool mLastBufferFull;
nsecs_t mPeriod;
nsecs_t mPhase;
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);
// turned on. It should NOT be used after that.
void setPeriod(nsecs_t period);
+ // Setting the low power mode reduces the frame rate to half of the default
+ void setLowPowerMode(bool enabled);
+
// addEventListener registers a callback to be called repeatedly at the
// given phase offset from the hardware vsync events. The callback is
// called from a separate thread and it should return reasonably quickly
repaintEverything();
return NO_ERROR;
}
+ // This is an experimental interface
+ // Needs to be shifted to proper binder interface when we productize
+ case 1016: {
+ mPrimaryDispSync.setLowPowerMode(true);
+ return NO_ERROR;
+ }
+ case 1017: {
+ mPrimaryDispSync.setLowPowerMode(false);
+ return NO_ERROR;
+ }
}
}
return err;