[Tizen] Fix related to eglImage memory 76/259076/2
authorSunghyun Kim <scholb.kim@samsung.com>
Mon, 31 May 2021 01:22:53 +0000 (10:22 +0900)
committerSunghyun Kim <scholb.kim@samsung.com>
Tue, 1 Jun 2021 02:08:38 +0000 (11:08 +0900)
1. Create only when there is no eglImage
2. When new eglImage is prepared, the existing eglImage need to update

Change-Id: I03d4f0df913203a29bc6f3f912ddcf08072a5911

dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp

index f3b526d..816fd14 100644 (file)
@@ -401,6 +401,12 @@ bool NativeImageSourceTizen::IsColorDepthSupported(Dali::NativeImageSource::Colo
 
 bool NativeImageSourceTizen::CreateResource()
 {
+  // If an EGL image exists, use it as it is without creating it.
+  if(mEglImageKHR != NULL)
+  {
+    return true;
+  }
+
   // casting from an unsigned int to a void *, which should then be cast back
   // to an unsigned int in the driver.
   EGLClientBuffer eglBuffer = reinterpret_cast<EGLClientBuffer>(mTbmSurface);
@@ -440,15 +446,16 @@ void NativeImageSourceTizen::PrepareTexture()
   Dali::Mutex::ScopedLock lock(mMutex);
   if(mSetSource)
   {
-    void* eglImage = mEglImageKHR;
+    // Destroy previous eglImage because use for new one.
+    // if mEglImageKHR is not to be NULL here, it will not be updated with a new eglImage.
+    mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
+    mEglImageKHR = NULL;
 
     if(CreateResource())
     {
       TargetTexture();
     }
 
-    mEglImageExtensions->DestroyImageKHR(eglImage);
-
     mSetSource = false;
   }
 }