Support TBM_FORMAT_ABGR8888 and simliar friends support alpha 34/316234/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 16 Aug 2024 05:47:50 +0000 (14:47 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 20 Aug 2024 01:18:57 +0000 (10:18 +0900)
Until now, we only consider TBM_FORMAT_ARGB8888 Format as NativeImageSurface and NativeRenderSurface.
(Since it was default, and only surported format at DALi until now)

Their is no reason to non-support TBM_FORMAT_ABGR8888 format what user created
outside of DALi engine.

Change-Id: If08ccbdb7fe43a6b90c05169405a6e1bc24db093
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp

index 67933f1..994a88e 100644 (file)
@@ -37,6 +37,39 @@ namespace Internal
 {
 namespace Adaptor
 {
+namespace
+{
+inline bool IsColorDepth32Required(const tbm_format format)
+{
+  switch(format)
+  {
+    case TBM_FORMAT_ARGB8888:
+    case TBM_FORMAT_ABGR8888:
+    case TBM_FORMAT_RGBA8888:
+    case TBM_FORMAT_BGRA8888:
+    case TBM_FORMAT_XRGB8888:
+    case TBM_FORMAT_XBGR8888:
+    case TBM_FORMAT_RGBX8888:
+    case TBM_FORMAT_BGRX8888:
+    case TBM_FORMAT_XRGB2101010:
+    case TBM_FORMAT_XBGR2101010:
+    case TBM_FORMAT_RGBX1010102:
+    case TBM_FORMAT_BGRX1010102:
+    case TBM_FORMAT_ARGB2101010:
+    case TBM_FORMAT_ABGR2101010:
+    case TBM_FORMAT_RGBA1010102:
+    case TBM_FORMAT_BGRA1010102:
+    {
+      return true;
+    }
+    default:
+    {
+      return false;
+    }
+  }
+}
+} // namespace
+
 NativeImageSurfaceEcoreWl::NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueuePtr queue)
 : mDisplayConnection(nullptr),
   mGraphics(nullptr),
@@ -55,7 +88,7 @@ NativeImageSurfaceEcoreWl::NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueu
   {
     mTbmQueue   = AnyCast<tbm_surface_queue_h>(queue->GetNativeImageSourceQueue());
     mTbmFormat  = tbm_surface_queue_get_format(mTbmQueue);
-    mColorDepth = (mTbmFormat == TBM_FORMAT_ARGB8888) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
+    mColorDepth = IsColorDepth32Required(mTbmFormat) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
   }
   else
   {
@@ -93,8 +126,8 @@ void NativeImageSurfaceEcoreWl::InitializeGraphics()
   std::unique_ptr<GraphicsFactory> graphicsFactoryPtr = Utils::MakeUnique<GraphicsFactory>(*(new EnvironmentOptions()));
   auto                             graphicsFactory    = *graphicsFactoryPtr.get();
 
-  mGraphics = std::unique_ptr<Graphics::GraphicsInterface>(&graphicsFactory.Create());
-  auto graphics = mGraphics.get();
+  mGraphics        = std::unique_ptr<Graphics::GraphicsInterface>(&graphicsFactory.Create());
+  auto graphics    = mGraphics.get();
   auto eglGraphics = static_cast<EglGraphics*>(graphics);
 
   mDisplayConnection = std::unique_ptr<Dali::DisplayConnection>(Dali::DisplayConnection::New(Dali::Integration::RenderSurfaceInterface::Type::NATIVE_RENDER_SURFACE));
index ad8b75c..c409919 100644 (file)
@@ -52,6 +52,36 @@ static void TbmAcquirableCallback(tbm_surface_queue_h queue, void* data)
   }
 }
 
+inline bool IsColorDepth32Required(const tbm_format format)
+{
+  switch(format)
+  {
+    case TBM_FORMAT_ARGB8888:
+    case TBM_FORMAT_ABGR8888:
+    case TBM_FORMAT_RGBA8888:
+    case TBM_FORMAT_BGRA8888:
+    case TBM_FORMAT_XRGB8888:
+    case TBM_FORMAT_XBGR8888:
+    case TBM_FORMAT_RGBX8888:
+    case TBM_FORMAT_BGRX8888:
+    case TBM_FORMAT_XRGB2101010:
+    case TBM_FORMAT_XBGR2101010:
+    case TBM_FORMAT_RGBX1010102:
+    case TBM_FORMAT_BGRX1010102:
+    case TBM_FORMAT_ARGB2101010:
+    case TBM_FORMAT_ABGR2101010:
+    case TBM_FORMAT_RGBA1010102:
+    case TBM_FORMAT_BGRA1010102:
+    {
+      return true;
+    }
+    default:
+    {
+      return false;
+    }
+  }
+}
+
 } // unnamed namespace
 
 NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent)
@@ -81,7 +111,7 @@ NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize,
 
     mTbmFormat = tbm_surface_queue_get_format(mTbmQueue);
 
-    mColorDepth = (mTbmFormat == TBM_FORMAT_ARGB8888) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
+    mColorDepth = IsColorDepth32Required(mTbmFormat) ? COLOR_DEPTH_32 : COLOR_DEPTH_24;
   }
 }
 
@@ -180,7 +210,7 @@ void NativeRenderSurfaceEcoreWl::InitializeGraphics()
     CreateContext();
   }
 
-    // Create the OpenGL surface
+  // Create the OpenGL surface
   if(mEGLSurface == NULL)
   {
     CreateSurface();