Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ec3e074 authored by Jamie Gennis's avatar Jamie Gennis
Browse files

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
parent 1493a397
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -419,6 +419,11 @@ nsecs_t HWComposer::getRefreshTimestamp(int disp) const {
    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 @@ status_t HWComposer::commit() {

        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;
+8 −1
Original line number Diff line number Diff line
@@ -22,13 +22,15 @@

#include <hardware/hwcomposer_defs.h>

#include <ui/Fence.h>

#include <utils/BitSet.h>
#include <utils/Condition.h>
#include <utils/Mutex.h>
#include <utils/StrongPointer.h>
#include <utils/Thread.h>
#include <utils/Timers.h>
#include <utils/Vector.h>
#include <utils/BitSet.h>

extern "C" int clock_nanosleep(clockid_t clock_id, int flags,
                           const struct timespec *request,
@@ -232,6 +234,7 @@ public:
    // HWC_DISPLAY_PRIMARY).
    nsecs_t getRefreshPeriod(int disp) const;
    nsecs_t getRefreshTimestamp(int disp) const;
    sp<Fence> getDisplayFence(int disp) const;
    uint32_t getWidth(int disp) const;
    uint32_t getHeight(int disp) const;
    uint32_t getFormat(int disp) const;
@@ -305,6 +308,10 @@ private:
        hwc_display_contents_1* list;
        hwc_layer_1* framebufferTarget;
        buffer_handle_t fbTargetHandle;
        sp<Fence> lastRetireFence;  // signals when the last set op retires
        sp<Fence> lastDisplayFence; // signals when the last set op takes
                                    // effect on screen

        // protected by mEventControlLock
        int32_t events;
    };