Fix related to eglImage memory 41/259441/2
authorSunghyun Kim <scholb.kim@samsung.com>
Tue, 8 Jun 2021 05:29:59 +0000 (14:29 +0900)
committerSunghyun Kim <scholb.kim@samsung.com>
Wed, 9 Jun 2021 07:33:16 +0000 (16:33 +0900)
1. Create only when there is no eglImage
2. When new eglImage is prepared, the existing eglImage need to update

Change-Id: I8a292c5744b1605b464c45ef12c2b871624c0e5e

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

index 75417e4..16a5720 100644 (file)
@@ -403,6 +403,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);
@@ -414,9 +420,6 @@ bool NativeImageSourceTizen::CreateResource()
   mEglImageExtensions = mEglGraphics->GetImageExtensions();
   DALI_ASSERT_DEBUG(mEglImageExtensions);
 
-  // if resource of egl was not destroyed, destroy it first
-  DestroyResource();
-
   mEglImageKHR = mEglImageExtensions->CreateImageKHR(eglBuffer);
 
   return mEglImageKHR != NULL;
@@ -445,15 +448,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;
   }
 }