Add NativeImageSurface 56/254756/26
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 15 Sep 2021 12:29:10 +0000 (21:29 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 15 Sep 2021 12:29:10 +0000 (21:29 +0900)
NativeImageSurface is a GL Rendering surface.
But it's not an actual window, it's like a pixmap.
It creates EGL resources.

Change-Id: Ib69a1dba557483e87bb05c76842cf012dc4423a5

24 files changed:
dali/integration-api/adaptor-framework/native-image-surface.cpp [new file with mode: 0644]
dali/integration-api/adaptor-framework/native-image-surface.h [new file with mode: 0644]
dali/integration-api/file.list
dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h
dali/internal/window-system/android/native-image-surface-factory-android.cpp [new file with mode: 0644]
dali/internal/window-system/android/native-image-surface-impl-android.cpp [new file with mode: 0644]
dali/internal/window-system/android/native-image-surface-impl-android.h [new file with mode: 0644]
dali/internal/window-system/common/native-image-surface-factory.h [new file with mode: 0644]
dali/internal/window-system/common/native-image-surface-impl.h [new file with mode: 0644]
dali/internal/window-system/file.list
dali/internal/window-system/macos/native-image-surface-factory-mac.cpp [new file with mode: 0644]
dali/internal/window-system/macos/native-image-surface-impl-mac.cpp [new file with mode: 0644]
dali/internal/window-system/macos/native-image-surface-impl-mac.h [new file with mode: 0644]
dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp [new file with mode: 0644]
dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.cpp [new file with mode: 0644]
dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h [new file with mode: 0644]
dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp [new file with mode: 0644]
dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp [new file with mode: 0644]
dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h [new file with mode: 0644]
dali/internal/window-system/windows/native-image-surface-factory-win.cpp [new file with mode: 0644]
dali/internal/window-system/windows/native-image-surface-impl-win.cpp [new file with mode: 0644]
dali/internal/window-system/windows/native-image-surface-impl-win.h [new file with mode: 0644]

diff --git a/dali/integration-api/adaptor-framework/native-image-surface.cpp b/dali/integration-api/adaptor-framework/native-image-surface.cpp
new file mode 100644 (file)
index 0000000..88a4d74
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/integration-api/adaptor-framework/native-image-surface.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+NativeImageSurfacePtr NativeImageSurface::New(Dali::NativeImageSourceQueuePtr queue)
+{
+  NativeImageSurfacePtr surface = new NativeImageSurface(queue);
+  if(surface->mImpl)
+  {
+    return surface;
+  }
+  return nullptr;
+}
+
+Any NativeImageSurface::GetNativeRenderable()
+{
+  return mImpl->GetNativeRenderable();
+}
+
+void NativeImageSurface::InitializeGraphics()
+{
+  mImpl->InitializeGraphics();
+}
+
+void NativeImageSurface::TerminateGraphics()
+{
+  mImpl->TerminateGraphics();
+}
+
+void NativeImageSurface::PreRender()
+{
+  mImpl->PreRender();
+}
+
+void NativeImageSurface::PostRender()
+{
+  mImpl->PostRender();
+}
+
+bool NativeImageSurface::CanRender()
+{
+  return mImpl->CanRender();
+}
+
+bool NativeImageSurface::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  return mImpl->SetGraphicsConfig(depth, stencil, msaa, version);
+}
+
+NativeImageSurface::NativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  mImpl = Dali::Internal::Adaptor::NativeImageSurfaceFactory::CreateNativeImageSurface(queue);
+}
+
+NativeImageSurface::~NativeImageSurface()
+{
+}
+
+} // namespace Dali
diff --git a/dali/integration-api/adaptor-framework/native-image-surface.h b/dali/integration-api/adaptor-framework/native-image-surface.h
new file mode 100644 (file)
index 0000000..71d23bb
--- /dev/null
@@ -0,0 +1,138 @@
+#ifndef DALI_NATIVE_IMAGE_SURFACE_H
+#define DALI_NATIVE_IMAGE_SURFACE_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurface;
+}
+} // namespace Internal
+
+class NativeImageSurface;
+
+/**
+ * @brief Pointer to Dali::NativeImageSurface.
+ */
+typedef Dali::IntrusivePtr<Dali::NativeImageSurface> NativeImageSurfacePtr;
+
+/**
+ * Native image surface is a surface that GL can render.
+ * The surface is not a window, it's like a pixmap.
+ */
+class DALI_ADAPTOR_API NativeImageSurface : public RefObject
+{
+public:
+  /**
+   * Creates a NativeImageSurface
+   *
+   * @param [in] queue the native image source queue handle
+   * @return A smart-pointer to a newly allocated native image surface
+   */
+  static NativeImageSurfacePtr New(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Gets the native renderable handle
+   * @return The native renderable handle
+   */
+  Any GetNativeRenderable();
+
+  /**
+   * @brief Initializes the graphics resources
+   */
+  void InitializeGraphics();
+
+  /**
+   * @brief Terminate the graphics resources
+   */
+  void TerminateGraphics();
+
+  /**
+   * @brief Invoked by render thread before rendering
+   */
+  void PreRender();
+
+  /**
+   * @brief Invoked by render thread after rendering
+   */
+  void PostRender();
+
+  /**
+   * @brief Checks to render
+   */
+  bool CanRender();
+
+  /**
+   * @brief Sets Graphics configuration to the surface
+   *
+   * @param[in] depth the flag of depth buffer. If true is set, 24bit depth buffer is enabled.
+   * @param[in] stencil the flag of stencil. it true is set, 8bit stencil buffer is enabled.
+   * @param[in] msaa the bit of msaa.
+   * @param[in] version the GLES version.
+   * @return True if the config exists, false otherwise.
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version);
+
+private:
+  /// @cond internal
+  /**
+   * @brief Private constructor.
+   * @param[in] queue the native image source queue handle
+   */
+  DALI_INTERNAL NativeImageSurface(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   */
+  DALI_INTERNAL ~NativeImageSurface() override;
+
+  /**
+   * @brief Undefined copy constructor.
+   *
+   * This avoids accidental calls to a default copy constructor.
+   * @param[in] nativeImageSurface A reference to the object to copy
+   */
+  DALI_INTERNAL NativeImageSurface(const NativeImageSurface& nativeImageSurface);
+
+  /**
+   * @brief Undefined assignment operator.
+   *
+   * This avoids accidental calls to a default assignment operator.
+   * @param[in] rhs A reference to the object to copy
+   */
+  DALI_INTERNAL NativeImageSurface& operator=(const NativeImageSurface& rhs);
+  /// @endcond
+
+private:
+  std::unique_ptr<Internal::Adaptor::NativeImageSurface> mImpl; ///< Implementation pointer
+};
+
+} // namespace Dali
+
+#endif // DALI_NATIVE_IMAGE_SURFACE_H
index 0a5b4df..40e11c9 100644 (file)
@@ -3,6 +3,7 @@
 SET( adaptor_integration_api_src_files
   ${adaptor_integration_api_dir}/adaptor-framework/scene-holder.cpp
   ${adaptor_integration_api_dir}/adaptor-framework/scene-holder-impl.cpp
 SET( adaptor_integration_api_src_files
   ${adaptor_integration_api_dir}/adaptor-framework/scene-holder.cpp
   ${adaptor_integration_api_dir}/adaptor-framework/scene-holder-impl.cpp
+  ${adaptor_integration_api_dir}/adaptor-framework/native-image-surface.cpp
 )
 
 
 )
 
 
@@ -18,5 +19,6 @@ SET( adaptor_integration_api_header_files
   ${adaptor_integration_api_dir}/adaptor-framework/thread-synchronization-interface.h
   ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-interface.h
   ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-factory.h
   ${adaptor_integration_api_dir}/adaptor-framework/thread-synchronization-interface.h
   ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-interface.h
   ${adaptor_integration_api_dir}/adaptor-framework/trigger-event-factory.h
+  ${adaptor_integration_api_dir}/adaptor-framework/native-image-surface.h
 )
 
 )
 
index 8168b72..976fab8 100644 (file)
@@ -530,6 +530,7 @@ bool EglImplementation::ChooseConfig(bool isWindowType, ColorDepth depth)
   configAttribs.PushBack(8);
 
   //  For underlay video playback, we also need to set the alpha value of the 24/32bit window.
   configAttribs.PushBack(8);
 
   //  For underlay video playback, we also need to set the alpha value of the 24/32bit window.
+  // TODO: When the tbm queue of GlView is 24bit, do we have to set the alpha size??
   configAttribs.PushBack(EGL_ALPHA_SIZE);
   configAttribs.PushBack(8);
 
   configAttribs.PushBack(EGL_ALPHA_SIZE);
   configAttribs.PushBack(8);
 
index fab4a53..107f4cd 100644 (file)
@@ -82,7 +82,8 @@ NativeImageSourceQueueTizen::NativeImageSourceQueueTizen(uint32_t width, uint32_
   mEglGraphics(NULL),
   mEglImageExtensions(NULL),
   mOwnTbmQueue(false),
   mEglGraphics(NULL),
   mEglImageExtensions(NULL),
   mOwnTbmQueue(false),
-  mBlendingRequired(false)
+  mBlendingRequired(false),
+  mIsResized(false)
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
 {
   DALI_ASSERT_ALWAYS(Adaptor::IsAvailable());
 
@@ -185,12 +186,16 @@ void NativeImageSourceQueueTizen::SetSize(uint32_t width, uint32_t height)
 {
   Dali::Mutex::ScopedLock lock(mMutex);
 
 {
   Dali::Mutex::ScopedLock lock(mMutex);
 
-  tbm_surface_queue_reset(mTbmQueue, width, height, tbm_surface_queue_get_format(mTbmQueue));
+  if(mWidth == width && mHeight == height)
+  {
+    return;
+  }
 
 
-  mWidth  = width;
-  mHeight = height;
+  tbm_surface_queue_reset(mTbmQueue, width, height, tbm_surface_queue_get_format(mTbmQueue));
 
 
-  ResetEglImageList();
+  mWidth     = width;
+  mHeight    = height;
+  mIsResized = true;
 }
 
 void NativeImageSourceQueueTizen::IgnoreSourceImage()
 }
 
 void NativeImageSourceQueueTizen::IgnoreSourceImage()
@@ -297,7 +302,7 @@ void NativeImageSourceQueueTizen::DestroyResource()
 {
   Dali::Mutex::ScopedLock lock(mMutex);
 
 {
   Dali::Mutex::ScopedLock lock(mMutex);
 
-  ResetEglImageList();
+  ResetEglImageList(true);
 }
 
 uint32_t NativeImageSourceQueueTizen::TargetTexture()
 }
 
 uint32_t NativeImageSourceQueueTizen::TargetTexture()
@@ -327,6 +332,12 @@ void NativeImageSourceQueueTizen::PrepareTexture()
       }
     }
 
       }
     }
 
+    if(mIsResized)
+    {
+      ResetEglImageList(false);
+      mIsResized = false;
+    }
+
     if(mConsumeSurface)
     {
       bool existing = false;
     if(mConsumeSurface)
     {
       bool existing = false;
@@ -380,9 +391,11 @@ bool NativeImageSourceQueueTizen::SourceChanged() const
   return false;
 }
 
   return false;
 }
 
-void NativeImageSourceQueueTizen::ResetEglImageList()
+void NativeImageSourceQueueTizen::ResetEglImageList(bool releaseConsumeSurface)
 {
 {
-  if(mConsumeSurface)
+  // When Tbm surface queue is reset(resized), the surface acquired before reset() is still valid, not the others.
+  // We can still use the acquired surface so that we will release it as the oldSurface in PrepareTexture() when the next surface is ready.
+  if(releaseConsumeSurface && mConsumeSurface)
   {
     if(tbm_surface_internal_is_valid(mConsumeSurface))
     {
   {
     if(tbm_surface_internal_is_valid(mConsumeSurface))
     {
index 347f60a..3556448 100644 (file)
@@ -177,7 +177,7 @@ private:
 
   void Initialize(Dali::NativeImageSourceQueue::ColorFormat colorFormat);
 
 
   void Initialize(Dali::NativeImageSourceQueue::ColorFormat colorFormat);
 
-  void ResetEglImageList();
+  void ResetEglImageList(bool releaseConsumeSurface);
 
   tbm_surface_queue_h GetSurfaceFromAny(Any source) const;
 
 
   tbm_surface_queue_h GetSurfaceFromAny(Any source) const;
 
@@ -198,6 +198,7 @@ private:
   EglImageExtensions*       mEglImageExtensions; ///< The EGL Image Extensions
   bool                      mOwnTbmQueue;        ///< Whether we created tbm queue
   bool                      mBlendingRequired;   ///< Whether blending is required
   EglImageExtensions*       mEglImageExtensions; ///< The EGL Image Extensions
   bool                      mOwnTbmQueue;        ///< Whether we created tbm queue
   bool                      mBlendingRequired;   ///< Whether blending is required
+  bool                      mIsResized;          ///< Whether the size has changed
 };
 
 } // namespace Adaptor
 };
 
 } // namespace Adaptor
diff --git a/dali/internal/window-system/android/native-image-surface-factory-android.cpp b/dali/internal/window-system/android/native-image-surface-factory-android.cpp
new file mode 100644 (file)
index 0000000..6b05a06
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/android/native-image-surface-impl-android.h>
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  return std::make_unique<Internal::Adaptor::NativeImageSurfaceAndroid>(queue);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/android/native-image-surface-impl-android.cpp b/dali/internal/window-system/android/native-image-surface-impl-android.cpp
new file mode 100644 (file)
index 0000000..29c53e5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/android/native-image-surface-impl-android.h>
+
+using namespace Dali::Internal::Adaptor;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+NativeImageSurfaceAndroid::NativeImageSurfaceAndroid(Dali::NativeImageSourceQueuePtr queue)
+{
+}
+
+NativeImageSurfaceAndroid::~NativeImageSurfaceAndroid()
+{
+}
+
+Any NativeImageSurfaceAndroid::GetNativeRenderable()
+{
+  return Any();
+}
+
+void NativeImageSurfaceAndroid::InitializeGraphics()
+{
+}
+
+void NativeImageSurfaceAndroid::TerminateGraphics()
+{
+}
+
+void NativeImageSurfaceAndroid::PreRender()
+{
+}
+
+void NativeImageSurfaceAndroid::PostRender()
+{
+}
+
+bool NativeImageSurfaceAndroid::CanRender()
+{
+  return false;
+}
+
+bool NativeImageSurfaceAndroid::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  return false;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/android/native-image-surface-impl-android.h b/dali/internal/window-system/android/native-image-surface-impl-android.h
new file mode 100644 (file)
index 0000000..941140b
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H
+#define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurfaceAndroid : public Dali::Internal::Adaptor::NativeImageSurface
+{
+public:
+  /**
+    * @param [in] queue the NativeImageSourceQueue pointer
+    */
+  NativeImageSurfaceAndroid(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Destructor
+   */
+  ~NativeImageSurfaceAndroid();
+
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  Any GetNativeRenderable() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::TerminateGraphics()
+   */
+  void TerminateGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  void PreRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  bool CanRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_NATIVE_IMAGE_SURFACE_IMPL_ANDROID_H
diff --git a/dali/internal/window-system/common/native-image-surface-factory.h b/dali/internal/window-system/common/native-image-surface-factory.h
new file mode 100644 (file)
index 0000000..1e6eb50
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurface;
+
+class NativeImageSurfaceFactory
+{
+public:
+  /**
+   * Factory function for native image surface
+   * A native image surface is created.
+   *
+   * @param [in] queue the native image surface handle
+   * @return A pointer to a newly allocated surface
+   */
+  static std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue);
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SURFACE_FACTORY_H
diff --git a/dali/internal/window-system/common/native-image-surface-impl.h b/dali/internal/window-system/common/native-image-surface-impl.h
new file mode 100644 (file)
index 0000000..2151917
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H
+#define DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+
+namespace Dali
+{
+class NativeImageSurface;
+
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurface
+{
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  virtual Any GetNativeRenderable() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  virtual void InitializeGraphics() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::TerminateGraphics()
+   */
+  virtual void TerminateGraphics() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  virtual void PreRender() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  virtual void PostRender() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  virtual bool CanRender() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  virtual bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) = 0;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_NATIVE_IMAGE_SURFACE_IMPL_H
index 101958f..a3b290f 100644 (file)
@@ -16,6 +16,8 @@ SET( adaptor_window_system_common_src_files
 SET( adaptor_window_system_tizen_wayland_src_files
     ${adaptor_window_system_dir}/tizen-wayland/display-connection-factory-ecore-wl.cpp
     ${adaptor_window_system_dir}/tizen-wayland/display-connection-impl-ecore-wl.cpp
 SET( adaptor_window_system_tizen_wayland_src_files
     ${adaptor_window_system_dir}/tizen-wayland/display-connection-factory-ecore-wl.cpp
     ${adaptor_window_system_dir}/tizen-wayland/display-connection-impl-ecore-wl.cpp
+    ${adaptor_window_system_dir}/tizen-wayland/native-image-surface-factory-ecore-wl.cpp
+    ${adaptor_window_system_dir}/tizen-wayland/native-image-surface-impl-ecore-wl.cpp
     ${adaptor_window_system_dir}/tizen-wayland/native-render-surface-ecore-wl.cpp
 )
 
     ${adaptor_window_system_dir}/tizen-wayland/native-render-surface-ecore-wl.cpp
 )
 
@@ -45,6 +47,8 @@ SET( adaptor_window_system_ubuntu_x11_src_files
     ${adaptor_window_system_dir}/ubuntu-x11/window-base-ecore-x.cpp
     ${adaptor_window_system_dir}/ubuntu-x11/window-factory-ecore-x.cpp
     ${adaptor_window_system_dir}/ubuntu-x11/window-system-ecore-x.cpp
     ${adaptor_window_system_dir}/ubuntu-x11/window-base-ecore-x.cpp
     ${adaptor_window_system_dir}/ubuntu-x11/window-factory-ecore-x.cpp
     ${adaptor_window_system_dir}/ubuntu-x11/window-system-ecore-x.cpp
+    ${adaptor_window_system_dir}/ubuntu-x11/native-image-surface-factory-x.cpp
+    ${adaptor_window_system_dir}/ubuntu-x11/native-image-surface-impl-x.cpp
 )
 
 # module: window-system, backend: android
 )
 
 # module: window-system, backend: android
@@ -55,6 +59,8 @@ SET( adaptor_window_system_android_src_files
     ${adaptor_window_system_dir}/android/window-base-android.cpp
     ${adaptor_window_system_dir}/android/window-factory-android.cpp
     ${adaptor_window_system_dir}/android/window-system-android.cpp
     ${adaptor_window_system_dir}/android/window-base-android.cpp
     ${adaptor_window_system_dir}/android/window-factory-android.cpp
     ${adaptor_window_system_dir}/android/window-system-android.cpp
+    ${adaptor_window_system_dir}/android/native-image-surface-factory-android.cpp
+    ${adaptor_window_system_dir}/android/native-image-surface-impl-android.cpp
 )
 
 # module: window-system, backend: windows
 )
 
 # module: window-system, backend: windows
@@ -66,6 +72,8 @@ SET( adaptor_window_system_windows_src_files
     ${adaptor_window_system_dir}/windows/window-base-win.cpp
     ${adaptor_window_system_dir}/windows/window-factory-win.cpp
     ${adaptor_window_system_dir}/windows/window-system-win.cpp
     ${adaptor_window_system_dir}/windows/window-base-win.cpp
     ${adaptor_window_system_dir}/windows/window-factory-win.cpp
     ${adaptor_window_system_dir}/windows/window-system-win.cpp
+    ${adaptor_window_system_dir}/windows/native-image-surface-factory-win.cpp
+    ${adaptor_window_system_dir}/windows/native-image-surface-impl-win.cpp
 )
 
 # module: window-system, backend: macos
 )
 
 # module: window-system, backend: macos
@@ -77,4 +85,6 @@ SET( adaptor_window_system_macos_src_files
     ${adaptor_window_system_dir}/macos/window-base-mac.mm
     ${adaptor_window_system_dir}/macos/window-factory-mac.cpp
     ${adaptor_window_system_dir}/macos/render-surface-factory-mac.cpp
     ${adaptor_window_system_dir}/macos/window-base-mac.mm
     ${adaptor_window_system_dir}/macos/window-factory-mac.cpp
     ${adaptor_window_system_dir}/macos/render-surface-factory-mac.cpp
+    ${adaptor_window_system_dir}/macos/native-image-surface-factory-mac.cpp
+    ${adaptor_window_system_dir}/macos/native-image-surface-impl-mac.cpp
 )
 )
diff --git a/dali/internal/window-system/macos/native-image-surface-factory-mac.cpp b/dali/internal/window-system/macos/native-image-surface-factory-mac.cpp
new file mode 100644 (file)
index 0000000..d50dd1b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+#include <dali/internal/window-system/macos/native-image-surface-impl-mac.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  return std::make_unique<Internal::Adaptor::NativeImageSurfaceCocoa>(queue);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/macos/native-image-surface-impl-mac.cpp b/dali/internal/window-system/macos/native-image-surface-impl-mac.cpp
new file mode 100644 (file)
index 0000000..86eaaf0
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/macos/native-image-surface-impl-mac.h>
+
+using namespace Dali::Internal::Adaptor;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+NativeImageSurfaceCocoa::NativeImageSurfaceCocoa(Dali::NativeImageSourceQueuePtr queue)
+{
+}
+
+NativeImageSurfaceCocoa::~NativeImageSurfaceCocoa()
+{
+}
+
+Any NativeImageSurfaceCocoa::GetNativeRenderable()
+{
+  return Any();
+}
+
+void NativeImageSurfaceCocoa::InitializeGraphics()
+{
+}
+
+void NativeImageSurfaceCocoa::TerminateGraphics()
+{
+}
+
+void NativeImageSurfaceCocoa::PreRender()
+{
+}
+
+void NativeImageSurfaceCocoa::PostRender()
+{
+}
+
+bool NativeImageSurfaceCocoa::CanRender()
+{
+  return false;
+}
+
+bool NativeImageSurfaceCocoa::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  return false;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/macos/native-image-surface-impl-mac.h b/dali/internal/window-system/macos/native-image-surface-impl-mac.h
new file mode 100644 (file)
index 0000000..21275ba
--- /dev/null
@@ -0,0 +1,85 @@
+#pragma once
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurfaceCocoa : public Dali::Internal::Adaptor::NativeImageSurface
+{
+public:
+  /**
+    * @param [in] queue the NativeImageSourceQueue pointer
+    */
+  NativeImageSurfaceCocoa(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Destructor
+   */
+  ~NativeImageSurfaceCocoa();
+
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  Any GetNativeRenderable() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::TerminateGraphics()
+   */
+  void TerminateGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  void PreRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  bool CanRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp b/dali/internal/window-system/tizen-wayland/native-image-surface-factory-ecore-wl.cpp
new file mode 100644 (file)
index 0000000..2999e10
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+#include <dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  return std::make_unique<Internal::Adaptor::NativeImageSurfaceEcoreWl>(queue);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
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
new file mode 100644 (file)
index 0000000..c4b68f9
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <system_info.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/gles/egl-graphics-factory.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
+#include <dali/internal/graphics/gles/egl-implementation.h>
+#include <dali/internal/system/common/environment-options.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+using namespace Dali::Internal::Adaptor;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+NativeImageSurfaceEcoreWl::NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueuePtr queue)
+: mDisplayConnection(nullptr),
+  mGraphics(nullptr),
+  mEGL(nullptr),
+  mEGLSurface(nullptr),
+  mEGLContext(nullptr),
+  mColorDepth(COLOR_DEPTH_32),
+  mTbmQueue(nullptr),
+  mDepth(false),
+  mStencil(false),
+  mGLESVersion(30),
+  mMSAA(0)
+{
+  if(queue)
+  {
+    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;
+  }
+  else
+  {
+    DALI_LOG_ERROR("NativeImageSourceQueue is null.");
+  }
+}
+
+bool NativeImageSurfaceEcoreWl::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  bool featureFlag = false;
+  int  error       = SYSTEM_INFO_ERROR_NONE;
+
+  if(version == 30)
+  {
+    error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.3_0", &featureFlag);
+  }
+  else if(version == 20)
+  {
+    error = system_info_get_platform_bool("http://tizen.org/feature/opengles.version.2_0", &featureFlag);
+  }
+  else
+  {
+    DALI_LOG_ERROR("version is not valid");
+    return false;
+  }
+
+  if(error != SYSTEM_INFO_ERROR_NONE)
+  {
+    DALI_LOG_ERROR("Can't check platform feature.\n");
+    return false;
+  }
+
+  if(featureFlag)
+  {
+    mDepth   = depth;
+    mStencil = stencil;
+    if(mMSAA == 0)
+    {
+      //EGL_DONT_CARE is -1
+      mMSAA = -1;
+    }
+    else
+    {
+      mMSAA = msaa;
+    }
+    mGLESVersion = version;
+  }
+
+  return featureFlag;
+}
+
+Any NativeImageSurfaceEcoreWl::GetNativeRenderable()
+{
+  return mTbmQueue;
+}
+
+void NativeImageSurfaceEcoreWl::InitializeGraphics()
+{
+  std::unique_ptr<GraphicsFactory> graphicsFactoryPtr = Utils::MakeUnique<GraphicsFactory>(*(new EnvironmentOptions()));
+  auto                             graphicsFactory    = *graphicsFactoryPtr.get();
+
+  mGraphics                      = std::unique_ptr<GraphicsInterface>(&graphicsFactory.Create());
+  GraphicsInterface* graphics    = mGraphics.get();
+  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
+  eglGraphics->Initialize(mDepth, mStencil, false, mMSAA);
+
+  mDisplayConnection = std::unique_ptr<Dali::DisplayConnection>(Dali::DisplayConnection::New(*mGraphics, Dali::RenderSurfaceInterface::Type::NATIVE_RENDER_SURFACE));
+  mDisplayConnection->Initialize();
+
+  mEGL = &eglGraphics->GetEglInterface();
+
+  if(mEGLContext == NULL)
+  {
+    Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
+    eglImpl.SetGlesVersion(mGLESVersion);
+
+    if(eglImpl.ChooseConfig(true, mColorDepth) == false)
+    {
+      DALI_LOG_ERROR("InitializeGraphics: Fail to choose config. Version:%d, ColorDepth:%d, depth:%d, stencil:%d, MSAA:%d",
+                     mGLESVersion,
+                     mColorDepth == COLOR_DEPTH_32 ? 32 : 24,
+                     mDepth ? 24 : 0,
+                     mStencil ? 8 : 0,
+                     mMSAA);
+      return;
+    }
+
+    // Create the OpenGL Surface & Context
+    eglImpl.CreateWindowContext(mEGLContext);
+    mEGLSurface = eglImpl.CreateSurfaceWindow(reinterpret_cast<EGLNativeWindowType>(mTbmQueue), mColorDepth);
+
+    MakeContextCurrent();
+  }
+}
+
+void NativeImageSurfaceEcoreWl::TerminateGraphics()
+{
+  GraphicsInterface* graphics    = mGraphics.get();
+  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+  if(mEGLSurface)
+  {
+    eglImpl.DestroySurface(mEGLSurface);
+  }
+
+  if(mEGLContext)
+  {
+    eglImpl.DestroyContext(mEGLContext);
+  }
+}
+
+void NativeImageSurfaceEcoreWl::PreRender()
+{
+  MakeContextCurrent();
+}
+
+void NativeImageSurfaceEcoreWl::PostRender()
+{
+  GraphicsInterface* graphics    = mGraphics.get();
+  auto               eglGraphics = static_cast<EglGraphics*>(graphics);
+  if(eglGraphics)
+  {
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    eglImpl.SwapBuffers(mEGLSurface);
+  }
+}
+
+void NativeImageSurfaceEcoreWl::MakeContextCurrent()
+{
+  if(mEGL != nullptr)
+  {
+    if(mEGLSurface && mEGLContext)
+    {
+      mEGL->MakeContextCurrent(mEGLSurface, mEGLContext);
+    }
+    else
+    {
+      DALI_LOG_ERROR("EGLSurface(%p) or mEGLContext(%p) is null\n", mEGLSurface, mEGLContext);
+    }
+  }
+}
+
+bool NativeImageSurfaceEcoreWl::CanRender()
+{
+  return tbm_surface_queue_can_dequeue(mTbmQueue, 0);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h b/dali/internal/window-system/tizen-wayland/native-image-surface-impl-ecore-wl.h
new file mode 100644 (file)
index 0000000..f78ea90
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H
+#define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+#include <tbm_surface.h>
+#include <tbm_surface_queue.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/integration-api/adaptor-framework/egl-interface.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
+#include <dali/internal/window-system/common/display-connection.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurfaceEcoreWl : public Dali::Internal::Adaptor::NativeImageSurface
+{
+public:
+  /**
+    * @param [in] queue the NativeImageSourceQueue pointer
+    */
+  NativeImageSurfaceEcoreWl(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Destructor
+   */
+  ~NativeImageSurfaceEcoreWl() = default;
+
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  Any GetNativeRenderable() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::TerminateGraphics()
+   */
+  void TerminateGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  void PreRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  bool CanRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override;
+
+private:
+  void MakeContextCurrent();
+
+private:                                                       // Data
+  std::unique_ptr<Dali::DisplayConnection> mDisplayConnection; ///< The native display connection
+  std::unique_ptr<GraphicsInterface>       mGraphics;          ///< Graphics interface
+  EglInterface*                            mEGL;
+  EGLSurface                               mEGLSurface;
+  EGLContext                               mEGLContext;
+  ColorDepth                               mColorDepth;
+  tbm_format                               mTbmFormat;
+  tbm_surface_queue_h                      mTbmQueue;
+
+  bool mDepth : 1;
+  bool mStencil : 1;
+  int  mGLESVersion;
+  int  mMSAA;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_IMAGE_SURFACE_IMPL_ECORE_WL_H
diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp b/dali/internal/window-system/ubuntu-x11/native-image-surface-factory-x.cpp
new file mode 100644 (file)
index 0000000..b053f46
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+#include <dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  return std::make_unique<Internal::Adaptor::NativeImageSurfaceX>(queue);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.cpp
new file mode 100644 (file)
index 0000000..a953e6e
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h>
+
+using namespace Dali::Internal::Adaptor;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+NativeImageSurfaceX::NativeImageSurfaceX(Dali::NativeImageSourceQueuePtr queue)
+{
+}
+
+NativeImageSurfaceX::~NativeImageSurfaceX()
+{
+}
+
+Any NativeImageSurfaceX::GetNativeRenderable()
+{
+  return Any();
+}
+
+void NativeImageSurfaceX::InitializeGraphics()
+{
+}
+
+void NativeImageSurfaceX::TerminateGraphics()
+{
+}
+
+void NativeImageSurfaceX::PreRender()
+{
+}
+
+void NativeImageSurfaceX::PostRender()
+{
+}
+
+bool NativeImageSurfaceX::CanRender()
+{
+  return false;
+}
+
+bool NativeImageSurfaceX::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  return false;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h b/dali/internal/window-system/ubuntu-x11/native-image-surface-impl-x.h
new file mode 100644 (file)
index 0000000..b5d597e
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H
+#define DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurfaceX : public Dali::Internal::Adaptor::NativeImageSurface
+{
+public:
+  /**
+    * @param [in] queue the NativeImageSourceQueue pointer
+    */
+  NativeImageSurfaceX(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Destructor
+   */
+  ~NativeImageSurfaceX();
+
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  Any GetNativeRenderable() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void TerminateGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  void PreRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  bool CanRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_X_NATIVE_IMAGE_SURFACE_IMPL_X_H
diff --git a/dali/internal/window-system/windows/native-image-surface-factory-win.cpp b/dali/internal/window-system/windows/native-image-surface-factory-win.cpp
new file mode 100644 (file)
index 0000000..a66836f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/native-image-surface-factory.h>
+#include <dali/internal/window-system/windows/native-image-surface-impl-win.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+std::unique_ptr<Dali::Internal::Adaptor::NativeImageSurface> NativeImageSurfaceFactory::CreateNativeImageSurface(Dali::NativeImageSourceQueuePtr queue)
+{
+  return std::make_unique<Internal::Adaptor::NativeImageSurfaceWin>(queue);
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/windows/native-image-surface-impl-win.cpp b/dali/internal/window-system/windows/native-image-surface-impl-win.cpp
new file mode 100644 (file)
index 0000000..1caa790
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/window-system/windows/native-image-surface-impl-win.cpp>
+
+using namespace Dali::Internal::Adaptor;
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+NativeImageSurfaceWin::NativeImageSurfaceWin(Dali::NativeImageSourceQueuePtr queue)
+{
+}
+
+NativeImageSurfaceWin::~NativeImageSurfaceWin()
+{
+}
+
+Any NativeImageSurfaceWin::GetNativeRenderable()
+{
+  return Any();
+}
+
+void NativeImageSurfaceWin::InitializeGraphics()
+{
+}
+
+void NativeImageSurfaceWin::TerminateGraphics()
+{
+}
+
+void NativeImageSurfaceWin::PreRender()
+{
+}
+
+void NativeImageSurfaceWin::PostRender()
+{
+}
+
+bool NativeImageSurfaceWin::CanRender()
+{
+  return false;
+}
+
+bool NativeImageSurfaceWin::SetGraphicsConfig(bool depth, bool stencil, int msaa, int version)
+{
+  return false;
+}
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/window-system/windows/native-image-surface-impl-win.h b/dali/internal/window-system/windows/native-image-surface-impl-win.h
new file mode 100644 (file)
index 0000000..d79e04b
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H
+#define DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/any.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
+#include <dali/internal/window-system/common/native-image-surface-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class NativeImageSurfaceWin : public Dali::Internal::Adaptor::NativeImageSurface
+{
+public:
+  /**
+    * @param [in] queue the NativeImageSourceQueue pointer
+    */
+  NativeImageSurfaceWin(Dali::NativeImageSourceQueuePtr queue);
+
+  /**
+   * @brief Destructor
+   */
+  ~NativeImageSurfaceWin();
+
+public:
+  /**
+   * @copydoc Dali::NativeImageSurface::GetNativeRenderable()
+   */
+  Any GetNativeRenderable() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::InitializeGraphics()
+   */
+  void InitializeGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::TerminateGraphics()
+   */
+  void TerminateGraphics() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PreRender()
+   */
+  void PreRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::PostRender()
+   */
+  void PostRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::CanRender()
+   */
+  bool CanRender() override;
+
+  /**
+   * @copydoc Dali::NativeImageSurface::SetGraphicsConfig()
+   */
+  bool SetGraphicsConfig(bool depth, bool stencil, int msaa, int version) override;
+};
+
+} // namespace Adaptor
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_NATIVE_IMAGE_SURFACE_IMPL_WIN_H