SurfaceFlinger: track the HWC retire fences
This change adds functionality to the HWComposer class to track the retire
fences returned by each hwc set call. It adds the HWComposer::getDisplayFence
method to allow other parts of SurfaceFlinger to get a fence that will signal
when the most recent flip takes effect on a display.
Change-Id: I676e0f98440fc58ed70908aa1a1e2ee3e7bf9eb2
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 31d731e..be0af6a 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -419,6 +419,11 @@
return now - ((now - mLastHwVSync) % mDisplayData[disp].refresh);
}
+sp<Fence> HWComposer::getDisplayFence(int disp) const {
+ return mDisplayData[disp].lastDisplayFence;
+}
+
+
uint32_t HWComposer::getWidth(int disp) const {
return mDisplayData[disp].width;
}
@@ -663,9 +668,11 @@
for (size_t i=0 ; i<mNumDisplays ; i++) {
DisplayData& disp(mDisplayData[i]);
+ disp.lastDisplayFence = disp.lastRetireFence;
+ disp.lastRetireFence = NULL;
if (disp.list) {
if (disp.list->retireFenceFd != -1) {
- close(disp.list->retireFenceFd);
+ disp.lastRetireFence = new Fence(disp.list->retireFenceFd);
disp.list->retireFenceFd = -1;
}
disp.list->flags &= ~HWC_GEOMETRY_CHANGED;