Add release request in update buffer callback
authortaeyoon <taeyoon0.lee@samsung.com>
Thu, 22 Dec 2016 05:14:41 +0000 (14:14 +0900)
committertaeyoon <taeyoon0.lee@samsung.com>
Wed, 28 Dec 2016 08:17:48 +0000 (17:17 +0900)
  By tizen remote surface protocol version up (2),
  update buffer callback should call release request

Change-Id: I07cc06b81a2b7a76735991635c11d0535f5600eb

internal/widget_view/widget_view_impl.cpp

index 7927adc..d49aab0 100644 (file)
@@ -36,6 +36,7 @@
 #include <widget_instance.h>
 #include <tzplatform_config.h>
 #include <wayland-extension/tizen-extension-client-protocol.h>
+#include <unistd.h>
 
 namespace Dali
 {
@@ -88,6 +89,8 @@ DALI_ACTION_REGISTRATION( Dali::WidgetView, WidgetView, "activateFaultedWidget",
 
 DALI_TYPE_REGISTRATION_END()
 
+struct wl_buffer* preBuffer;
+
 static void OnBufferChanged( struct tizen_remote_surface *surface, uint32_t type, struct wl_buffer *buffer,
                               int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data)
 {
@@ -107,6 +110,15 @@ static void OnBufferChanged( struct tizen_remote_surface *surface, uint32_t type
     tbm_surface_h tbmSurface = static_cast< tbm_surface_h >( wl_buffer_get_user_data( buffer ) );
     widgetView->UpdateImageSource( tbmSurface );
   }
+
+  if( preBuffer != NULL && tizen_remote_surface_get_version( surface ) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION )
+  {
+    tizen_remote_surface_release( surface, preBuffer );
+  }
+
+  preBuffer = buffer;
+
+  close( img_file_fd );
 }
 
 static void OnBufferUpdated( struct tizen_remote_surface* surface, wl_buffer* buffer, uint32_t time, void* data )
@@ -127,6 +139,13 @@ static void OnBufferUpdated( struct tizen_remote_surface* surface, wl_buffer* bu
     tbm_surface_h tbmSurface = static_cast< tbm_surface_h >( wl_buffer_get_user_data( buffer ) );
     widgetView->UpdateImageSource( tbmSurface );
   }
+
+  if( preBuffer != NULL && tizen_remote_surface_get_version( surface ) >= TIZEN_REMOTE_SURFACE_RELEASE_SINCE_VERSION )
+  {
+    tizen_remote_surface_release( surface, preBuffer );
+  }
+
+  preBuffer = buffer;
 }
 
 static void OnSurfaceMissing( struct tizen_remote_surface* surface, void* data )