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

Commit 3250a13d authored by Francis Hart's avatar Francis Hart Committed by Steve Kondik
Browse files

Surface: Ensure synchronisation of copyBlt

The Surface::lock() function has an optimisation for copying the
previously drawn contents from the frontbuffer to the (current)
backbuffer, so that the client does not have to redraw the whole surface
contents. This logic was not using the sync fence FD from
dequeueBuffer() and so was not correctly synchronised with pending
operations on the backbuffer.

Change-Id: Ib44574d50f8bdb4a23078cd8da1c5c512c876320
parent e7e6006b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@

#include <android/native_window.h>

#include <sync/sync.h>

#include <binder/Parcel.h>

#include <utils/Log.h>
@@ -937,8 +939,14 @@ status_t Surface::lock(
                    oldDirtyRegion.orSelf(mSlots[i].dirtyRegion);
            }
            const Region copyback(oldDirtyRegion.subtract(newDirtyRegion));
            if (!copyback.isEmpty())
            if (!copyback.isEmpty()) {
                if (fenceFd >= 0) {
                    sync_wait(fenceFd, -1);
                    close(fenceFd);
                    fenceFd = -1;
                }
                copyBlt(backBuffer, frontBuffer, copyback);
            }
        } else {
            // if we can't copy-back anything, modify the user's dirty
            // region to make sure they redraw the whole buffer