renderlib: CB2 keep last frame on flush [1/1]

PD#SWPL-186083

Problem:
when dpi send keep last frame on flush prop,
renderlib should mute video plane but not

Solution:
when dpi send keep last frame on flush prop,
renderlib should mute video plane by
wl_surface_set_video_plane_mute set 1.
when resume playback or new playback,
renderlib should unmute video plane by
wl_surface_set_video_plane_mute set 0.

Verify:
AH212

Signed-off-by: le.han <le.han@amlogic.com>
Change-Id: I45d0ad6fb5ff02b6a48c4fda865e0070f7941cd3
Signed-off-by: le.han <le.han@amlogic.com>
diff --git a/weston/wayland_display.cpp b/weston/wayland_display.cpp
index 18151df..529e2c5 100644
--- a/weston/wayland_display.cpp
+++ b/weston/wayland_display.cpp
@@ -669,6 +669,8 @@
     mVideoSubSurface = NULL;
     mPip = 0;
     mKeepLastFrame = 0; //default is off keep last frame
+    mKeepFrameOnFlush = 1;
+    mFirstPtsAfterFlush = -1;
     mSignalFirstFramePts = false;
     mToSendKeepLastFrame = false;
     mVideoPlaneZorder = -1;
@@ -811,6 +813,7 @@
     }
     run("display queue");
     mRedrawingPending = false;
+    wl_surface_set_video_plane_mute(mVideoSurfaceWrapper, 0);
 
     DEBUG(mLogCategory,"openDisplay out");
     return NO_ERROR;
@@ -1474,6 +1477,10 @@
             wl_surface_set_pts(mVideoSurfaceWrapper, hiPts, lowPts);
         }
 
+        if (!mKeepFrameOnFlush && mFirstPtsAfterFlush == -1) {
+            mFirstPtsAfterFlush = buf->pts;
+        }
+
         wl_surface_damage (mVideoSurfaceWrapper, 0, 0, mVideoRect.w, mVideoRect.h);
         wl_surface_commit (mVideoSurfaceWrapper);
         //insert this buffer to committed weston buffer manager
@@ -1532,6 +1539,12 @@
         mWaylandPlugin->handleMsgNotify(MSG_FIRST_FRAME, (void*)&renderBuffer->pts);
     }
     mWaylandPlugin->handleFrameDisplayed(renderBuffer);
+    if (!mKeepFrameOnFlush && mFirstPtsAfterFlush == renderBuffer->pts) {
+        mKeepFrameOnFlush = 1;
+        mFirstPtsAfterFlush = -1;
+        wl_surface_set_video_plane_mute(mVideoSurfaceWrapper, 0);
+        INFO(mLogCategory,"unmute video plane");
+    }
 }
 
 void WaylandDisplay::handleFrameDropedCallback(WaylandBuffer *buf)
@@ -1786,6 +1799,16 @@
     mToSendKeepLastFrame = true;
 }
 
+void WaylandDisplay::setKeepLastFrameOnFlush(int keepOnFlush)
+{
+    mKeepFrameOnFlush = keepOnFlush;
+    INFO(mLogCategory,"keep last frame:%d",mKeepFrameOnFlush);
+    if (mVideoSurfaceWrapper && !mKeepFrameOnFlush) {
+        INFO(mLogCategory,"mute video plane");
+        wl_surface_set_video_plane_mute(mVideoSurfaceWrapper, 1);
+    }
+}
+
 void WaylandDisplay::setImmediatelyOutput(int enable)
 {
     if (mVideoSurfaceWrapper) {