From ea223bd69a8f3e8eeeb283b419bddbff537ae825 Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Tue, 17 Sep 2013 18:00:31 -0400
Subject: [PATCH] #30253: video: cleanup mixer background when resized.

---
 daemon/src/video/video_base.cpp  | 8 ++++++++
 daemon/src/video/video_base.h    | 1 +
 daemon/src/video/video_mixer.cpp | 5 +++++
 3 files changed, 14 insertions(+)

diff --git a/daemon/src/video/video_base.cpp b/daemon/src/video/video_base.cpp
index 81cb094954..1ce59e5bf5 100644
--- a/daemon/src/video/video_base.cpp
+++ b/daemon/src/video/video_base.cpp
@@ -202,6 +202,14 @@ void VideoFrame::copy(VideoFrame &dst)
                     frame_->height);
 }
 
+void VideoFrame::clear()
+{
+    // FIXME: beurk!!!!
+    memset(frame_->data[0], 0, frame_->linesize[0]*frame_->height);
+    memset(frame_->data[1], 0, frame_->linesize[1]*frame_->height/2);
+    memset(frame_->data[2], 0, frame_->linesize[2]*frame_->height/2);
+}
+
 void VideoFrame::test()
 {
     memset(frame_->data[0], 0xaa, frame_->linesize[0]*frame_->height/2);
diff --git a/daemon/src/video/video_base.h b/daemon/src/video/video_base.h
index 4969a30364..be4b46d264 100644
--- a/daemon/src/video/video_base.h
+++ b/daemon/src/video/video_base.h
@@ -203,6 +203,7 @@ public:
     bool allocBuffer(int width, int height, int pix_fmt);
     int blit(VideoFrame& src, int xoff, int yoff);
     void copy(VideoFrame &src);
+    void clear();
     void test();
 
 private:
diff --git a/daemon/src/video/video_mixer.cpp b/daemon/src/video/video_mixer.cpp
index 6c11d4ae4c..afeb500874 100644
--- a/daemon/src/video/video_mixer.cpp
+++ b/daemon/src/video/video_mixer.cpp
@@ -136,6 +136,11 @@ void VideoMixer::setDimensions(int width, int height)
     width_ = width;
     height_ = height;
 
+    // cleanup the previous frame to have a nice copy in rendering method
+    VideoFrameSP previous_p=obtainLastFrame();
+    if (previous_p)
+        previous_p->clear();
+
     stop_sink();
     start_sink();
 }
-- 
GitLab