From 276d901d67437710f59c5b0b250e63bcc0b1a72f Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Fri, 16 Aug 2024 14:47:50 +0900 Subject: [PATCH] Support TBM_FORMAT_ABGR8888 and simliar friends support alpha 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 --- .../native-image-surface-impl-ecore-wl.cpp | 39 ++++++++++++++++++++-- .../native-render-surface-ecore-wl.cpp | 34 +++++++++++++++++-- 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp index 67933f1..994a88e 100644 --- a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp @@ -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(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 graphicsFactoryPtr = Utils::MakeUnique(*(new EnvironmentOptions())); auto graphicsFactory = *graphicsFactoryPtr.get(); - mGraphics = std::unique_ptr(&graphicsFactory.Create()); - auto graphics = mGraphics.get(); + mGraphics = std::unique_ptr(&graphicsFactory.Create()); + auto graphics = mGraphics.get(); auto eglGraphics = static_cast(graphics); mDisplayConnection = std::unique_ptr(Dali::DisplayConnection::New(Dali::Integration::RenderSurfaceInterface::Type::NATIVE_RENDER_SURFACE)); diff --git a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp index ad8b75c..c409919 100644 --- a/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp +++ b/dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp @@ -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(); -- 2.7.4