SurfaceFlinger: fix deferred transactions for buffers with timestamps

A deferred transaction needs to wait until the buffer is ready
to be latched. This means that the buffer needs to be:
	1. Done with rendering (fence has signaled)
	2. Present timestamp is within the boundary of the next vsync

Test: Screen rotation with Chrome
Bug: 130785247
Change-Id: I8def1f10ea3d5c253ab14fa3aa4445588fc2ba8b
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index dabc683..30848d6 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -374,6 +374,14 @@
     return getDrawingState().acquireFence->getStatus() == Fence::Status::Signaled;
 }
 
+bool BufferStateLayer::framePresentTimeIsCurrent() const {
+    if (!hasFrameUpdate() || isRemovedFromCurrentState()) {
+        return true;
+    }
+
+    return mDesiredPresentTime <= mFlinger->mScheduler->expectedPresentTime();
+}
+
 nsecs_t BufferStateLayer::getDesiredPresentTime() {
     return mDesiredPresentTime;
 }