mLastTransactionTime(0),
mBootFinished(false),
mPrimaryHWVsyncEnabled(false),
+ mHWVsyncAvailable(false),
mDaltonize(false)
{
ALOGI("SurfaceFlinger is starting");
void SurfaceFlinger::enableHardwareVsync() {
Mutex::Autolock _l(mHWVsyncLock);
- if (!mPrimaryHWVsyncEnabled) {
+ if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) {
mPrimaryDispSync.beginResync();
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true);
mPrimaryHWVsyncEnabled = true;
}
}
-void SurfaceFlinger::resyncToHardwareVsync() {
+void SurfaceFlinger::resyncToHardwareVsync(bool makeAvailable) {
Mutex::Autolock _l(mHWVsyncLock);
+ if (makeAvailable) {
+ mHWVsyncAvailable = true;
+ } else if (!mHWVsyncAvailable) {
+ ALOGE("resyncToHardwareVsync called when HW vsync unavailable");
+ return;
+ }
+
const nsecs_t period =
getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
}
}
-void SurfaceFlinger::disableHardwareVsync() {
+void SurfaceFlinger::disableHardwareVsync(bool makeUnavailable) {
Mutex::Autolock _l(mHWVsyncLock);
if (mPrimaryHWVsyncEnabled) {
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false);
mPrimaryDispSync.endResync();
mPrimaryHWVsyncEnabled = false;
}
+ if (makeUnavailable) {
+ mHWVsyncAvailable = false;
+ }
}
void SurfaceFlinger::onVSyncReceived(int type, nsecs_t timestamp) {
if (needsHwVsync) {
enableHardwareVsync();
} else {
- disableHardwareVsync();
+ disableHardwareVsync(false);
}
}
}
if (mPrimaryDispSync.addPresentFence(presentFence)) {
enableHardwareVsync();
} else {
- disableHardwareVsync();
+ disableHardwareVsync(false);
}
}
// FIXME: eventthread only knows about the main display right now
mEventThread->onScreenAcquired();
- resyncToHardwareVsync();
+ resyncToHardwareVsync(true);
}
}
mVisibleRegionsDirty = true;
int32_t type = hw->getDisplayType();
if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
if (type == DisplayDevice::DISPLAY_PRIMARY) {
+ disableHardwareVsync(true); // also cancels any in-progress resync
+
// FIXME: eventthread only knows about the main display right now
mEventThread->onScreenReleased();
}
* VSync
*/
void enableHardwareVsync();
- void disableHardwareVsync();
- void resyncToHardwareVsync();
+ void disableHardwareVsync(bool makeUnavailable);
+ void resyncToHardwareVsync(bool makeAvailable);
/* ------------------------------------------------------------------------
* Debugging & dumpsys
// protected by mHWVsyncLock
Mutex mHWVsyncLock;
bool mPrimaryHWVsyncEnabled;
+ bool mHWVsyncAvailable;
/* ------------------------------------------------------------------------
* Feature prototyping