Ignore callbacks from the non-active hardware composer
Ignore callbacks from the non-active hardware composer so we don't get
e.g. duplicate vsync callbacks, one from each composer.
Bug: None
Test: Manually confirmed with logs we're now ignoring callbacks on the
non-active composer.
Change-Id: I8b475d6283d86c64ff96b41e78528bce8c6ff1d3
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 30bce55..cbc209d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -579,7 +579,7 @@
// the lock because on creation, it will call back into SurfaceFlinger to
// initialize the primary display.
LOG_ALWAYS_FATAL_IF(mEnterVrMode, "Starting in vr mode is not currently supported.");
- mRealHwc = new HWComposer(this, false);
+ mRealHwc = new HWComposer(false);
mHwc = mRealHwc;
mHwc->setEventHandler(static_cast<HWComposer::EventHandler*>(this));
@@ -1102,7 +1102,14 @@
}
}
-void SurfaceFlinger::onVSyncReceived(int32_t type, nsecs_t timestamp) {
+void SurfaceFlinger::onVSyncReceived(HWComposer* composer, int32_t type,
+ nsecs_t timestamp) {
+ Mutex::Autolock lock(mStateLock);
+ // Ignore any vsyncs from the non-active hardware composer.
+ if (composer != mHwc) {
+ return;
+ }
+
bool needsHwVsync = false;
{ // Scope for the lock
@@ -1163,6 +1170,20 @@
}
}
+void SurfaceFlinger::onInvalidateReceived(HWComposer* composer) {
+ Mutex::Autolock lock(mStateLock);
+ if (composer == mHwc) {
+ repaintEverything();
+ } else {
+ // This isn't from our current hardware composer. If it's a callback
+ // from the real composer, forward the refresh request to vr
+ // flinger. Otherwise ignore it.
+ if (!composer->isUsingVrComposer()) {
+ mVrFlinger->OnHardwareComposerRefresh();
+ }
+ }
+}
+
void SurfaceFlinger::setVsyncEnabled(int disp, int enabled) {
ATRACE_CALL();
getHwComposer().setVsyncEnabled(disp,
@@ -1209,7 +1230,7 @@
}
if (!mVrHwc) {
- mVrHwc = new HWComposer(this, true);
+ mVrHwc = new HWComposer(true);
ALOGV("Vr HWC created");
}