Fix EGL initialization issue 17/283317/1
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 24 Oct 2022 06:12:19 +0000 (15:12 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 24 Oct 2022 06:12:19 +0000 (15:12 +0900)
Sometimes EGL image extensions are initialized after NativeImageSource is created.

Change-Id: I424c451a336ca4b9b7e85fae0785c8bf4f20a553

dali/internal/imaging/android/native-image-source-impl-android.cpp
dali/internal/imaging/android/native-image-source-impl-android.h
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h
dali/internal/imaging/windows/native-image-source-impl-win.cpp
dali/internal/imaging/windows/native-image-source-impl-win.h

index bb6693f..bb25e3f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,25 +56,22 @@ NativeImageSourceAndroid* NativeImageSourceAndroid::New(uint32_t width, uint32_t
   return image;
 }
 
-NativeImageSourceAndroid::NativeImageSourceAndroid( uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceAndroid::NativeImageSourceAndroid(uint32_t width, uint32_t height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource)
 : mWidth(width),
-  mHeight(height ),
+  mHeight(height),
   mOwnPixmap(true),
   mPixmap(NULL),
   mBlendingRequired(false),
   mColorDepth(depth),
   mEglImageKHR(NULL),
+  mEglGraphics(NULL),
   mEglImageExtensions(NULL),
   mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
-  GraphicsInterface* graphics    = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
-  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
-
-  mEglImageExtensions = eglGraphics->GetImageExtensions();
-
-  DALI_ASSERT_DEBUG(mEglImageExtensions);
+  GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+  mEglGraphics                = static_cast<EglGraphics*>(graphics);
 
   // assign the pixmap
   mPixmap = static_cast<AHardwareBuffer*>(GetPixmapFromAny(nativeImageSource));
@@ -239,6 +236,9 @@ bool NativeImageSourceAndroid::IsColorDepthSupported(Dali::NativeImageSource::Co
 
 bool NativeImageSourceAndroid::CreateResource()
 {
+  mEglImageExtensions = mEglGraphics->GetImageExtensions();
+  DALI_ASSERT_DEBUG(mEglImageExtensions);
+
   // if the image existed previously delete it.
   if(mEglImageKHR != NULL)
   {
index 65397d6..feaaa2b 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ namespace Internal
 {
 namespace Adaptor
 {
+class EglGraphics;
 class EglImageExtensions;
 
 /**
@@ -210,15 +211,16 @@ private:
   void GetPixmapDetails();
 
 private:
-  uint32_t                             mWidth;                        ///< image width
-  uint32_t                             mHeight;                       ///< image heights
-  bool                                 mOwnPixmap;                    ///< Whether we created pixmap or not
-  AHardwareBuffer*                     mPixmap;                       ///<
-  bool                                 mBlendingRequired;             ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth  mColorDepth;                   ///< color depth of image
-  void*                                mEglImageKHR;                  ///< From EGL extension
-  EglImageExtensions*                  mEglImageExtensions;           ///< The EGL Image Extensions
-  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
+  uint32_t                             mWidth;                       ///< image width
+  uint32_t                             mHeight;                      ///< image heights
+  bool                                 mOwnPixmap;                   ///< Whether we created pixmap or not
+  AHardwareBuffer*                     mPixmap;                      ///<
+  bool                                 mBlendingRequired;            ///< Whether blending is required
+  Dali::NativeImageSource::ColorDepth  mColorDepth;                  ///< color depth of image
+  void*                                mEglImageKHR;                 ///< From EGL extension
+  EglGraphics*                         mEglGraphics;                 ///< EGL Graphics
+  EglImageExtensions*                  mEglImageExtensions;          ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
 };
 
 } // namespace Adaptor
index 5ae65a1..7c4f911 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,17 +92,14 @@ NativeImageSourceX::NativeImageSourceX(uint32_t width, uint32_t height, Dali::Na
   mBlendingRequired(false),
   mColorDepth(depth),
   mEglImageKHR(NULL),
+  mEglGraphics(NULL),
   mEglImageExtensions(NULL),
   mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
-  GraphicsInterface* graphics    = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
-  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
-
-  mEglImageExtensions = eglGraphics->GetImageExtensions();
-
-  DALI_ASSERT_DEBUG(mEglImageExtensions);
+  GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+  mEglGraphics                = static_cast<EglGraphics*>(graphics);
 
   // assign the pixmap
   mPixmap = GetPixmapFromAny(nativeImageSource);
@@ -287,6 +284,9 @@ bool NativeImageSourceX::IsColorDepthSupported(Dali::NativeImageSource::ColorDep
 
 bool NativeImageSourceX::CreateResource()
 {
+  mEglImageExtensions = mEglGraphics->GetImageExtensions();
+  DALI_ASSERT_DEBUG(mEglImageExtensions);
+
   // if the image existed previously delete it.
   if(mEglImageKHR != NULL)
   {
index 6f49953..38b5dac 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
 #include <memory>
 
 // INTERNAL INCLUDES
-#include <dali/public-api/adaptor-framework/native-image-source.h>
 #include <dali/internal/imaging/common/native-image-source-impl.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
 
 namespace Dali
 {
@@ -32,6 +32,7 @@ namespace Internal
 {
 namespace Adaptor
 {
+class EglGraphics;
 class EglImageExtensions;
 
 /**
@@ -209,15 +210,16 @@ private:
   void GetPixmapDetails();
 
 private:
-  uint32_t                             mWidth;                        ///< image width
-  uint32_t                             mHeight;                       ///< image heights
-  bool                                 mOwnPixmap;                    ///< Whether we created pixmap or not
-  Ecore_X_Pixmap                       mPixmap;                       ///< From Xlib
-  bool                                 mBlendingRequired;             ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth  mColorDepth;                   ///< color depth of image
-  void*                                mEglImageKHR;                  ///< From EGL extension
-  EglImageExtensions*                  mEglImageExtensions;           ///< The EGL Image Extensions
-  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
+  uint32_t                             mWidth;                       ///< image width
+  uint32_t                             mHeight;                      ///< image heights
+  bool                                 mOwnPixmap;                   ///< Whether we created pixmap or not
+  Ecore_X_Pixmap                       mPixmap;                      ///< From Xlib
+  bool                                 mBlendingRequired;            ///< Whether blending is required
+  Dali::NativeImageSource::ColorDepth  mColorDepth;                  ///< color depth of image
+  void*                                mEglImageKHR;                 ///< From EGL extension
+  EglGraphics*                         mEglGraphics;                 ///< EGL Graphics
+  EglImageExtensions*                  mEglImageExtensions;          ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
 };
 
 } // namespace Adaptor
index 44742ee..c234e03 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,17 +58,14 @@ NativeImageSourceWin::NativeImageSourceWin(unsigned int width, unsigned int heig
   mBlendingRequired(false),
   mColorDepth(depth),
   mEglImageKHR(NULL),
+  mEglGraphics(NULL),
   mEglImageExtensions(NULL),
   mResourceDestructionCallback()
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
-  GraphicsInterface* graphics    = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
-  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
-
-  mEglImageExtensions = eglGraphics->GetImageExtensions();
-
-  DALI_ASSERT_DEBUG(mEglImageExtensions);
+  GraphicsInterface* graphics = &(Adaptor::GetImplementation(Adaptor::Get()).GetGraphicsInterface());
+  mEglGraphics                = static_cast<EglGraphics*>(graphics);
 
   // assign the pixmap
   mPixmap = GetPixmapFromAny(nativeImageSource);
@@ -138,6 +135,9 @@ bool NativeImageSourceWin::IsColorDepthSupported(Dali::NativeImageSource::ColorD
 
 bool NativeImageSourceWin::CreateResource()
 {
+  mEglImageExtensions = mEglGraphics->GetImageExtensions();
+  DALI_ASSERT_DEBUG(mEglImageExtensions);
+
   // if the image existed previously delete it.
   if(mEglImageKHR != NULL)
   {
index 81e2ab2..eb05a9e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ namespace Internal
 {
 namespace Adaptor
 {
+class EglGraphics;
 class EglImageExtensions;
 
 /**
@@ -206,15 +207,16 @@ private:
   void GetPixmapDetails();
 
 private:
-  unsigned int                        mWidth;                         ///< image width
-  unsigned int                        mHeight;                        ///< image heights
-  bool                                mOwnPixmap;                     ///< Whether we created pixmap or not
-  unsigned int                        mPixmap;                        ///< From Windows
-  bool                                mBlendingRequired;              ///< Whether blending is required
-  Dali::NativeImageSource::ColorDepth mColorDepth;                    ///< color depth of image
-  void*                               mEglImageKHR;                   ///< From EGL extension
-  EglImageExtensions*                 mEglImageExtensions;            ///< The EGL Image Extensions
-  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback;  ///< The Resource Destruction Callback
+  unsigned int                         mWidth;                       ///< image width
+  unsigned int                         mHeight;                      ///< image heights
+  bool                                 mOwnPixmap;                   ///< Whether we created pixmap or not
+  unsigned int                         mPixmap;                      ///< From Windows
+  bool                                 mBlendingRequired;            ///< Whether blending is required
+  Dali::NativeImageSource::ColorDepth  mColorDepth;                  ///< color depth of image
+  void*                                mEglImageKHR;                 ///< From EGL extension
+  EglGraphics*                         mEglGraphics;                 ///< EGL Graphics
+  EglImageExtensions*                  mEglImageExtensions;          ///< The EGL Image Extensions
+  std::unique_ptr<EventThreadCallback> mResourceDestructionCallback; ///< The Resource Destruction Callback
 };
 
 } // namespace Adaptor