Merge "Disable hardware vsync when blanking the screen" into klp-dev
This commit is contained in:
commit
247423751f
@ -147,6 +147,7 @@ SurfaceFlinger::SurfaceFlinger()
|
|||||||
mLastTransactionTime(0),
|
mLastTransactionTime(0),
|
||||||
mBootFinished(false),
|
mBootFinished(false),
|
||||||
mPrimaryHWVsyncEnabled(false),
|
mPrimaryHWVsyncEnabled(false),
|
||||||
|
mHWVsyncAvailable(false),
|
||||||
mDaltonize(false)
|
mDaltonize(false)
|
||||||
{
|
{
|
||||||
ALOGI("SurfaceFlinger is starting");
|
ALOGI("SurfaceFlinger is starting");
|
||||||
@ -752,16 +753,23 @@ void SurfaceFlinger::run() {
|
|||||||
|
|
||||||
void SurfaceFlinger::enableHardwareVsync() {
|
void SurfaceFlinger::enableHardwareVsync() {
|
||||||
Mutex::Autolock _l(mHWVsyncLock);
|
Mutex::Autolock _l(mHWVsyncLock);
|
||||||
if (!mPrimaryHWVsyncEnabled) {
|
if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) {
|
||||||
mPrimaryDispSync.beginResync();
|
mPrimaryDispSync.beginResync();
|
||||||
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true);
|
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true);
|
||||||
mPrimaryHWVsyncEnabled = true;
|
mPrimaryHWVsyncEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::resyncToHardwareVsync() {
|
void SurfaceFlinger::resyncToHardwareVsync(bool makeAvailable) {
|
||||||
Mutex::Autolock _l(mHWVsyncLock);
|
Mutex::Autolock _l(mHWVsyncLock);
|
||||||
|
|
||||||
|
if (makeAvailable) {
|
||||||
|
mHWVsyncAvailable = true;
|
||||||
|
} else if (!mHWVsyncAvailable) {
|
||||||
|
ALOGE("resyncToHardwareVsync called when HW vsync unavailable");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const nsecs_t period =
|
const nsecs_t period =
|
||||||
getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
|
getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
|
||||||
|
|
||||||
@ -775,13 +783,16 @@ void SurfaceFlinger::resyncToHardwareVsync() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::disableHardwareVsync() {
|
void SurfaceFlinger::disableHardwareVsync(bool makeUnavailable) {
|
||||||
Mutex::Autolock _l(mHWVsyncLock);
|
Mutex::Autolock _l(mHWVsyncLock);
|
||||||
if (mPrimaryHWVsyncEnabled) {
|
if (mPrimaryHWVsyncEnabled) {
|
||||||
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false);
|
eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false);
|
||||||
mPrimaryDispSync.endResync();
|
mPrimaryDispSync.endResync();
|
||||||
mPrimaryHWVsyncEnabled = false;
|
mPrimaryHWVsyncEnabled = false;
|
||||||
}
|
}
|
||||||
|
if (makeUnavailable) {
|
||||||
|
mHWVsyncAvailable = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceFlinger::onVSyncReceived(int type, nsecs_t timestamp) {
|
void SurfaceFlinger::onVSyncReceived(int type, nsecs_t timestamp) {
|
||||||
@ -791,7 +802,7 @@ void SurfaceFlinger::onVSyncReceived(int type, nsecs_t timestamp) {
|
|||||||
if (needsHwVsync) {
|
if (needsHwVsync) {
|
||||||
enableHardwareVsync();
|
enableHardwareVsync();
|
||||||
} else {
|
} else {
|
||||||
disableHardwareVsync();
|
disableHardwareVsync(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,7 +944,7 @@ void SurfaceFlinger::postComposition()
|
|||||||
if (mPrimaryDispSync.addPresentFence(presentFence)) {
|
if (mPrimaryDispSync.addPresentFence(presentFence)) {
|
||||||
enableHardwareVsync();
|
enableHardwareVsync();
|
||||||
} else {
|
} else {
|
||||||
disableHardwareVsync();
|
disableHardwareVsync(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2178,7 +2189,7 @@ void SurfaceFlinger::onScreenAcquired(const sp<const DisplayDevice>& hw) {
|
|||||||
// FIXME: eventthread only knows about the main display right now
|
// FIXME: eventthread only knows about the main display right now
|
||||||
mEventThread->onScreenAcquired();
|
mEventThread->onScreenAcquired();
|
||||||
|
|
||||||
resyncToHardwareVsync();
|
resyncToHardwareVsync(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mVisibleRegionsDirty = true;
|
mVisibleRegionsDirty = true;
|
||||||
@ -2196,6 +2207,8 @@ void SurfaceFlinger::onScreenReleased(const sp<const DisplayDevice>& hw) {
|
|||||||
int32_t type = hw->getDisplayType();
|
int32_t type = hw->getDisplayType();
|
||||||
if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
|
if (type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
|
||||||
if (type == DisplayDevice::DISPLAY_PRIMARY) {
|
if (type == DisplayDevice::DISPLAY_PRIMARY) {
|
||||||
|
disableHardwareVsync(true); // also cancels any in-progress resync
|
||||||
|
|
||||||
// FIXME: eventthread only knows about the main display right now
|
// FIXME: eventthread only knows about the main display right now
|
||||||
mEventThread->onScreenReleased();
|
mEventThread->onScreenReleased();
|
||||||
}
|
}
|
||||||
|
@ -383,8 +383,8 @@ private:
|
|||||||
* VSync
|
* VSync
|
||||||
*/
|
*/
|
||||||
void enableHardwareVsync();
|
void enableHardwareVsync();
|
||||||
void disableHardwareVsync();
|
void disableHardwareVsync(bool makeUnavailable);
|
||||||
void resyncToHardwareVsync();
|
void resyncToHardwareVsync(bool makeAvailable);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
* Debugging & dumpsys
|
* Debugging & dumpsys
|
||||||
@ -467,6 +467,7 @@ private:
|
|||||||
// protected by mHWVsyncLock
|
// protected by mHWVsyncLock
|
||||||
Mutex mHWVsyncLock;
|
Mutex mHWVsyncLock;
|
||||||
bool mPrimaryHWVsyncEnabled;
|
bool mPrimaryHWVsyncEnabled;
|
||||||
|
bool mHWVsyncAvailable;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
* Feature prototyping
|
* Feature prototyping
|
||||||
|
Loading…
Reference in New Issue
Block a user