Fix the issue that short black glitch when switching bandwidth.
authorYongGeol Jung <yg48.jung@samsung.com>
Fri, 29 Mar 2013 05:49:49 +0000 (14:49 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 29 Mar 2013 10:52:48 +0000 (19:52 +0900)
[Title] Fix the issue that short black glitch when switching bandwidth.
[Issue#] N/A
[Problem] Short black glitch when switching bandwidth.
[Cause] After changing video size, new buffer which is not drawn was used for compositing.
[Solution] If current buffer is not updated yet, copy previous buffer.

Change-Id: I6977e59cf402b28748d368a3a79493972d1ec473

Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp
Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h
Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp

index dc7536f..bb9aaff 100644 (file)
@@ -50,6 +50,7 @@ public:
 
     int id() const { return m_platformSurface; }
     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
+    void copySurface(VideoPlatformSurface* other);
     bool hasAlpha() { return m_hasAlpha; }
 
 private:
@@ -122,6 +123,16 @@ void VideoPlatformSurface::paintCurrentFrameInContext(GraphicsContext* context,
     cairo_surface_destroy(surface);
 }
 
+void VideoPlatformSurface::copySurface(VideoPlatformSurface* other)
+{
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_xlib_surface_create(m_nativeDisplay, m_platformSurface, DefaultVisual(m_nativeDisplay, DefaultScreen(m_nativeDisplay)), m_size.width(), m_size.height()));
+    RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
+    OwnPtr<WebCore::GraphicsContext> graphicsContext = adoptPtr(new GraphicsContext(context.get()));
+
+    graphicsContext->scale(FloatSize((float)m_size.width() / other->m_size.width(), (float)m_size.height() / other->m_size.height()));
+    other->paintCurrentFrameInContext(graphicsContext.get(), IntRect());
+}
+
 bool VideoPlatformSurface::initialize(IntSize size)
 {
     if (!createPlatformSurface(size))
@@ -324,6 +335,12 @@ void SharedVideoPlatformSurfaceTizen::paintCurrentFrameInContext(GraphicsContext
         m_platformSurface->paintCurrentFrameInContext(context, rect);
 }
 
+void SharedVideoPlatformSurfaceTizen::copySurface(SharedVideoPlatformSurfaceTizen* other)
+{
+    if (m_platformSurface)
+        m_platformSurface->copySurface(other->m_platformSurface.get());
+}
+
 void SharedVideoPlatformSurfaceTizen::registerDamageHandler()
 {
     if (!m_platformSurface)
index d763e6c..604739c 100644 (file)
@@ -48,6 +48,7 @@ public:
     void platformSurfaceUpdated();
     void setVideoPlatformSurfaceUpdateListener(VideoPlatformSurfaceUpdateListener* listener);
     void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
+    void copySurface(SharedVideoPlatformSurfaceTizen*);
     int graphicsSurfaceFlags() const;
 
 private:
index 401497f..94a719d 100644 (file)
@@ -179,6 +179,9 @@ void VideoLayerTizen::setOverlay(IntSize size)
     m_platformSurface = SharedVideoPlatformSurfaceTizen::create(size);
     m_platformSurface->setVideoPlatformSurfaceUpdateListener(this);
 
+    if (m_platformSurfaceToBeRemoved)
+        m_platformSurface->copySurface(m_platformSurfaceToBeRemoved.get());
+
     gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), m_platformSurface->id());
 #if !USE(ACCELERATED_VIDEO_VAAPI)
     g_object_set(m_videoSink, "rotate", 0, NULL);