Support tbm_surface_queue 47/188647/4
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 7 Sep 2018 05:37:56 +0000 (14:37 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 14 Sep 2018 02:59:01 +0000 (11:59 +0900)
Change-Id: I7e689dff135d6fcb4bb5b44cf3c99fc8fb4414cd

19 files changed:
dali/devel-api/adaptor-framework/native-image-source-queue.cpp [new file with mode: 0755]
dali/devel-api/adaptor-framework/native-image-source-queue.h [new file with mode: 0755]
dali/devel-api/file.list
dali/internal/graphics/tizen/egl-image-extensions-tizen.cpp
dali/internal/imaging/common/native-image-source-factory.cpp [deleted file]
dali/internal/imaging/common/native-image-source-factory.h
dali/internal/imaging/common/native-image-source-impl.cpp [deleted file]
dali/internal/imaging/common/native-image-source-impl.h
dali/internal/imaging/common/native-image-source-queue-impl.h [new file with mode: 0755]
dali/internal/imaging/file.list
dali/internal/imaging/tizen/native-image-source-factory-tizen.cpp
dali/internal/imaging/tizen/native-image-source-factory-tizen.h [new file with mode: 0644]
dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-impl-tizen.h
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp [new file with mode: 0644]
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h [new file with mode: 0755]
dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.h [new file with mode: 0644]
dali/public-api/adaptor-framework/native-image-source.cpp

diff --git a/dali/devel-api/adaptor-framework/native-image-source-queue.cpp b/dali/devel-api/adaptor-framework/native-image-source-queue.cpp
new file mode 100755 (executable)
index 0000000..7774cf1
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2018 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/devel-api/adaptor-framework/native-image-source-queue.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
+#include <dali/internal/imaging/common/native-image-source-factory.h>
+
+namespace Dali
+{
+
+NativeImageSourceQueuePtr NativeImageSourceQueue::New( unsigned int width, unsigned int height, ColorDepth depth )
+{
+  Any empty;
+  NativeImageSourceQueuePtr image = new NativeImageSourceQueue( width, height, depth, empty );
+  return image;
+}
+
+NativeImageSourceQueuePtr NativeImageSourceQueue::New( Any nativeImageSourceQueue )
+{
+  NativeImageSourceQueuePtr image = new NativeImageSourceQueue( 0, 0, COLOR_DEPTH_DEFAULT, nativeImageSourceQueue );
+  return image;
+}
+
+Any NativeImageSourceQueue::GetNativeImageSourceQueue()
+{
+  return mImpl->GetNativeImageSourceQueue();
+}
+
+void NativeImageSourceQueue::SetSource( Any source )
+{
+  mImpl->SetSource( source );
+}
+
+bool NativeImageSourceQueue::GlExtensionCreate()
+{
+  return mImpl->GlExtensionCreate();
+}
+
+void NativeImageSourceQueue::GlExtensionDestroy()
+{
+  mImpl->GlExtensionDestroy();
+}
+
+unsigned int NativeImageSourceQueue::TargetTexture()
+{
+  return mImpl->TargetTexture();
+}
+
+void NativeImageSourceQueue::PrepareTexture()
+{
+  mImpl->PrepareTexture();
+}
+
+unsigned int NativeImageSourceQueue::GetWidth() const
+{
+  return mImpl->GetWidth();
+}
+
+unsigned int NativeImageSourceQueue::GetHeight() const
+{
+  return mImpl->GetHeight();
+}
+
+bool NativeImageSourceQueue::RequiresBlending() const
+{
+  return mImpl->RequiresBlending();
+}
+
+NativeImageInterface::Extension* NativeImageSourceQueue::GetExtension()
+{
+  return mImpl->GetNativeImageInterfaceExtension();
+}
+
+NativeImageSourceQueue::NativeImageSourceQueue( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSourceQueue )
+{
+  auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
+  mImpl = factory->CreateNativeImageSourceQueue( width, height, depth, nativeImageSourceQueue );
+}
+
+NativeImageSourceQueue::~NativeImageSourceQueue()
+{
+}
+
+} // namespace Dali
diff --git a/dali/devel-api/adaptor-framework/native-image-source-queue.h b/dali/devel-api/adaptor-framework/native-image-source-queue.h
new file mode 100755 (executable)
index 0000000..0a6f4fe
--- /dev/null
@@ -0,0 +1,194 @@
+#ifndef DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
+#define DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
+
+/*
+ * Copyright (c) 2018 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/images/native-image-interface.h>
+#include <dali/public-api/object/any.h>
+#include <memory>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class NativeImageSourceQueue;
+}
+}
+
+class NativeImageSourceQueue;
+
+/**
+ * @brief Pointer to Dali::NativeImageSourceQueue.
+ */
+typedef Dali::IntrusivePtr< Dali::NativeImageSourceQueue > NativeImageSourceQueuePtr;
+
+/**
+ * @brief Used for displaying native images.
+ *
+ * NativeImageSource can be created internally or externally by native image source.
+ * NativeImage is a platform specific way of providing pixel data to the GPU for rendering,for example via an EGL image.
+ */
+class DALI_ADAPTOR_API NativeImageSourceQueue : public NativeImageInterface
+{
+public:
+
+   /**
+    * @brief Enumeration for the instance when creating a native image, the color depth has to be specified.
+    */
+   enum ColorDepth
+   {
+     COLOR_DEPTH_DEFAULT,     ///< Uses the current screen default depth (recommended)
+     COLOR_DEPTH_24,          ///< 24 bits per pixel
+     COLOR_DEPTH_32           ///< 32 bits per pixel
+   };
+
+  /**
+   * @brief Creates a new NativeImageSourceQueue.
+   *        Depending on hardware, the width and height may have to be a power of two.
+   * @param[in] width The width of the image
+   * @param[in] height The height of the image
+   * @param[in] depth color depth of the image
+   * @return A smart-pointer to a newly allocated image
+   */
+  static NativeImageSourceQueuePtr New( unsigned int width, unsigned int height, ColorDepth depth );
+
+  /**
+   * @brief Creates a new NativeImageSourceQueue from an existing native image source.
+   *
+   * @param[in] nativeImageSourceQueue NativeImageSourceQueue must be a any handle with native image source
+   * @return A smart-pointer to a newly allocated image
+   * @see NativeImageInterface
+   */
+  static NativeImageSourceQueuePtr New( Any nativeImageSourceQueue );
+
+  /**
+   * @brief Retrieves the internal native image.
+   *
+   * @return Any object containing the internal native image source queue
+   */
+  Any GetNativeImageSourceQueue();
+
+  /**
+   * @brief Sets an existing source.
+   *
+   * @param[in] source Any handle with the source
+   */
+  void SetSource( Any source );
+
+private:   // native image
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
+   */
+  virtual bool GlExtensionCreate();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
+   */
+  virtual void GlExtensionDestroy();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
+   */
+  virtual unsigned int TargetTexture();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
+   */
+  virtual void PrepareTexture();
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetWidth()
+   */
+  virtual unsigned int GetWidth() const;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetHeight()
+   */
+  virtual unsigned int GetHeight() const;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
+   */
+  virtual bool RequiresBlending() const;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetExtension()
+   */
+  NativeImageInterface::Extension* GetExtension();
+
+private:
+
+  /// @cond internal
+  /**
+   * @brief Private constructor.
+   * @param[in] width The width of the image
+   * @param[in] height The height of the image
+   * @param[in] depth color depth of the image
+   * @param[in] nativeImageSourceQueue contains either: native image source or is empty
+   */
+  DALI_INTERNAL NativeImageSourceQueue( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSourceQueue );
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference().
+   *
+   * The implementation should destroy the NativeImage resources.
+   */
+  DALI_INTERNAL virtual ~NativeImageSourceQueue();
+
+  /**
+   * @brief Undefined copy constructor.
+   *
+   * This avoids accidental calls to a default copy constructor.
+   * @param[in] nativeImageSourceQueue A reference to the object to copy
+   */
+  DALI_INTERNAL NativeImageSourceQueue( const NativeImageSourceQueue& nativeImageSourceQueue );
+
+  /**
+   * @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 NativeImageSourceQueue& operator=(const NativeImageSourceQueue& rhs);
+  /// @endcond
+
+private:
+
+  /// @cond internal
+  std::unique_ptr< Internal::Adaptor::NativeImageSourceQueue > mImpl; ///< Implementation pointer
+  /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_NATIVE_IMAGE_SOURCE_QUEUE_H
index a98a7be..d2897d5 100755 (executable)
@@ -16,6 +16,7 @@ devel_api_src_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/gif-loading.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/input-method-context.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/input-method-options.cpp \
+  $(adaptor_devel_api_dir)/adaptor-framework/native-image-source-queue.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/orientation.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/performance-logger.cpp \
   $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.cpp \
@@ -54,6 +55,7 @@ devel_api_adaptor_framework_header_files = \
   $(adaptor_devel_api_dir)/adaptor-framework/input-method-options.h \
   $(adaptor_devel_api_dir)/adaptor-framework/keyboard.h \
   $(adaptor_devel_api_dir)/adaptor-framework/lifecycle-controller.h \
+  $(adaptor_devel_api_dir)/adaptor-framework/native-image-source-queue.h \
   $(adaptor_devel_api_dir)/adaptor-framework/orientation.h \
   $(adaptor_devel_api_dir)/adaptor-framework/performance-logger.h \
   $(adaptor_devel_api_dir)/adaptor-framework/pixel-buffer.h \
index f8d8463..781c32f 100644 (file)
@@ -97,7 +97,6 @@ void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
                                              clientBuffer,
                                              attribs );
 
-  DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
   if( EGL_NO_IMAGE_KHR == eglImage )
   {
     switch( eglGetError() )
@@ -142,6 +141,7 @@ void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer)
       }
     }
   }
+  DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "EglImageExtensions::CreateImageKHR: eglCreateImageKHR failed!\n");
 
   return eglImage;
 }
diff --git a/dali/internal/imaging/common/native-image-source-factory.cpp b/dali/internal/imaging/common/native-image-source-factory.cpp
deleted file mode 100644 (file)
index 6f77fdf..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-#include <memory>
-#include <dali/internal/imaging/common/native-image-source-impl.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-namespace NativeImageSourceFactory
-{
-
-/**
- * Dummy implementation
- * @param width
- * @param height
- * @param depth
- * @param nativeImageSource
- * @return
- */
-__attribute__((weak))
-std::unique_ptr<Dali::Internal::Adaptor::NativeImageSource> New(unsigned int width,
-                                       unsigned int height,
-                                       Dali::NativeImageSource::ColorDepth depth,
-                                       Any nativeImageSource)
-{
-  return std::unique_ptr<NativeImageSource>(nullptr);
-}
-
-}
-
-} // Adaptor
-
-} // Internal
-
-} // Dali
index 8c9d7d3..0ea3db5 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef TIZEN_ORG_NATIVE_IMAGE_SOURCE_FACTORY_H
-#define TIZEN_ORG_NATIVE_IMAGE_SOURCE_FACTORY_H
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  *
  */
 
+// EXTERNAL INCLUDES
 #include <memory>
+
+// INTERNAL INCLUDES
 #include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
 
 namespace Dali
 {
@@ -29,20 +33,27 @@ namespace Adaptor
 {
 
 class NativeImageSource;
-namespace NativeImageSourceFactory
+class NativeImageSourceQueue;
+
+class NativeImageSourceFactory
 {
+public:
 
-std::unique_ptr<Internal::Adaptor::NativeImageSource> New(unsigned int width,
-                                       unsigned int height,
-                                       Dali::NativeImageSource::ColorDepth depth,
-                                       Any nativeImageSource);
+  NativeImageSourceFactory() = default;
+  virtual ~NativeImageSourceFactory() = default;
 
-}
+  virtual std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                        Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) = 0;
 
-} // Adaptor
+  virtual std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                                  Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) = 0;
 
-} // Internal
+};
 
+extern std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory();
+
+} // Adaptor
+} // Internal
 } // Dali
 
-#endif //TIZEN_ORG_NATIVE_IMAGE_SOURCE_FACTORY_H
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
diff --git a/dali/internal/imaging/common/native-image-source-impl.cpp b/dali/internal/imaging/common/native-image-source-impl.cpp
deleted file mode 100644 (file)
index 20b770c..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2017 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/imaging/common/native-image-source-impl.h>
-#include <dali/internal/imaging/common/native-image-source-factory.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-NativeImageSource::~NativeImageSource() = default;
-
-NativeImageSource* NativeImageSource::New(unsigned int width,
-                              unsigned int height,
-                              Dali::NativeImageSource::ColorDepth depth,
-                              Any nativeImageSource)
-{
-  return Internal::Adaptor::NativeImageSourceFactory::New( width, height, depth, nativeImageSource ).release();
-}
-
-
-Any NativeImageSource::GetNativeImageSource() const
-{
-  return nullptr;
-}
-
-
-bool NativeImageSource::GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const
-{
-  return false;
-}
-
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
-{
-  return false;
-}
-
-void NativeImageSource::SetSource( Any source )
-{
-
-}
-
-bool NativeImageSource::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
-{
-  return false;
-}
-
-bool NativeImageSource::GlExtensionCreate()
-{
-  return false;
-}
-
-void NativeImageSource::GlExtensionDestroy()
-{
-
-}
-
-unsigned int NativeImageSource::TargetTexture()
-{
-  return 0u;
-}
-
-void NativeImageSource::PrepareTexture()
-{
-
-}
-
-unsigned int NativeImageSource::GetWidth() const
-{
-  return 0u;
-}
-
-unsigned int NativeImageSource::GetHeight() const
-{
-  return 0u;
-}
-
-bool NativeImageSource::RequiresBlending() const
-{
-  return false;
-}
-
-
-NativeImageInterface::Extension* NativeImageSource::GetNativeImageInterfaceExtension()
-{
-  return nullptr;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
index 03031ee..ada807f 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -53,72 +53,72 @@ public:
   /**
    * @copydoc Dali::NativeImageSource::GetNativeImageSource()
    */
-  virtual Any GetNativeImageSource() const;
+  virtual Any GetNativeImageSource() const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::GetPixels()
    */
-  virtual bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+  virtual bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
    */
-  virtual bool EncodeToFile(const std::string& filename) const;
+  virtual bool EncodeToFile(const std::string& filename) const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::SetSource( Any source )
    */
-  virtual void SetSource( Any source );
+  virtual void SetSource( Any source ) = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
    */
-  virtual bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth );
+  virtual bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) = 0;
 
   /**
    * destructor
    */
-  virtual ~NativeImageSource();
+  virtual ~NativeImageSource() = default;
 
   /**
    * @copydoc Dali::NativeImageSource::GlExtensionCreate()
    */
-  virtual bool GlExtensionCreate();
+  virtual bool GlExtensionCreate() = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
    */
-  virtual void GlExtensionDestroy();
+  virtual void GlExtensionDestroy() = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::TargetTexture()
    */
-  virtual unsigned int TargetTexture();
+  virtual unsigned int TargetTexture() = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::PrepareTexture()
    */
-  virtual void PrepareTexture();
+  virtual void PrepareTexture() = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::GetWidth()
    */
-  virtual unsigned int GetWidth() const;
+  virtual unsigned int GetWidth() const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::GetHeight()
    */
-  virtual unsigned int GetHeight() const;
+  virtual unsigned int GetHeight() const = 0;
 
   /**
    * @copydoc Dali::NativeImageSource::RequiresBlending()
    */
-  virtual bool RequiresBlending() const;
+  virtual bool RequiresBlending() const = 0;
 
   /**
    * @copydoc Dali::NativeImageInterface::GetExtension()
    */
-  virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension();
+  virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension() = 0;
 };
 
 } // namespace Adaptor
diff --git a/dali/internal/imaging/common/native-image-source-queue-impl.h b/dali/internal/imaging/common/native-image-source-queue-impl.h
new file mode 100755 (executable)
index 0000000..3caf002
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
+
+/*
+ * Copyright (c) 2018 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
+{
+
+/**
+ * Dali internal NativeImageSourceQueue.
+ */
+class NativeImageSourceQueue
+{
+public:
+
+  /**
+   * @copydoc Dali::NativeImageSourceQueue::New()
+   */
+  static NativeImageSourceQueue* New( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+
+  /**
+   * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
+   */
+  virtual Any GetNativeImageSourceQueue() const = 0;
+
+  /**
+   * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
+   */
+  virtual void SetSource( Any source ) = 0;
+
+  /**
+   * destructor
+   */
+  virtual ~NativeImageSourceQueue() = default;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
+   */
+  virtual bool GlExtensionCreate() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
+   */
+  virtual void GlExtensionDestroy() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
+   */
+  virtual unsigned int TargetTexture() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
+   */
+  virtual void PrepareTexture() = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetWidth()
+   */
+  virtual unsigned int GetWidth() const = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetHeight()
+   */
+  virtual unsigned int GetHeight() const = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
+   */
+  virtual bool RequiresBlending() const = 0;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetExtension()
+   */
+  virtual NativeImageInterface::Extension* GetNativeImageInterfaceExtension() = 0;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_H
index 34735f8..88ad0cb 100644 (file)
@@ -3,8 +3,6 @@
 # module: imaging, backend: common
 adaptor_imaging_common_src_files=\
     ${adaptor_imaging_dir}/common/native-bitmap-buffer-impl.cpp \
-    ${adaptor_imaging_dir}/common/native-image-source-factory.cpp \
-    ${adaptor_imaging_dir}/common/native-image-source-impl.cpp \
     ${adaptor_imaging_dir}/common/pixel-buffer-impl.cpp \
     ${adaptor_imaging_dir}/common/alpha-mask.cpp \
     ${adaptor_imaging_dir}/common/file-download.cpp \
@@ -25,9 +23,10 @@ adaptor_imaging_common_src_files=\
 # module: imaging, backend: tizen
 adaptor_imaging_tizen_src_files=\
     ${adaptor_imaging_dir}/tizen/native-image-source-factory-tizen.cpp \
-    ${adaptor_imaging_dir}/tizen/native-image-source-impl-tizen.cpp
+    ${adaptor_imaging_dir}/tizen/native-image-source-impl-tizen.cpp \
+    ${adaptor_imaging_dir}/tizen/native-image-source-queue-impl-tizen.cpp
 
 # module: imaging, backend: ubuntu-x11
 adaptor_imaging_ubuntu_x11_src_files=\
     ${adaptor_imaging_dir}/ubuntu-x11/native-image-source-factory-x.cpp \
-    ${adaptor_imaging_dir}/ubuntu-x11/native-image-source-impl-x.cpp
\ No newline at end of file
+    ${adaptor_imaging_dir}/ubuntu-x11/native-image-source-impl-x.cpp
index 95ff081..66f1d36 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  *
  */
 
-#include <memory>
+// CLASS HEADER
+#include <dali/internal/imaging/tizen/native-image-source-factory-tizen.h>
+
+// INTERNAL HEADERS
 #include <dali/internal/imaging/tizen/native-image-source-impl-tizen.h>
+#include <dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h>
 
 namespace Dali
 {
@@ -25,29 +29,25 @@ namespace Internal
 namespace Adaptor
 {
 
-namespace NativeImageSourceFactory
+std::unique_ptr< NativeImageSource > NativeImageSourceFactoryTizen::CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                                             Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
+  return std::unique_ptr< NativeImageSource >( NativeImageSourceTizen::New( width, height, depth, nativeImageSource ) );
+}
 
-/**
- * Dummy implementation
- * @param width
- * @param height
- * @param depth
- * @param nativeImageSource
- * @return
- */
-std::unique_ptr<Dali::Internal::Adaptor::NativeImageSource> New(unsigned int width,
-                                       unsigned int height,
-                                       Dali::NativeImageSource::ColorDepth depth,
-                                       Any nativeImageSource)
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                                                       Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
-  return std::unique_ptr<NativeImageSourceTizen>( NativeImageSourceTizen::New( width, height, depth, nativeImageSource ) );
+  return std::unique_ptr< NativeImageSourceQueue >( NativeImageSourceQueueTizen::New( width, height, depth, nativeImageSourceQueue ) );
 }
 
+// this should be created from somewhere
+std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+{
+  // returns native image source factory
+  return std::unique_ptr< NativeImageSourceFactoryTizen >( new NativeImageSourceFactoryTizen() );
 }
 
 } // Adaptor
-
 } // Internal
-
 } // Dali
diff --git a/dali/internal/imaging/tizen/native-image-source-factory-tizen.h b/dali/internal/imaging/tizen/native-image-source-factory-tizen.h
new file mode 100644 (file)
index 0000000..2ca3658
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_TIZEN_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_TIZEN_H
+
+/*
+ * Copyright (c) 2018 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/imaging/common/native-image-source-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class NativeImageSourceFactoryTizen : public NativeImageSourceFactory
+{
+public:
+
+  std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
+
+  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                          Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
+
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_TIZEN_H
index 79a77cc..3cd791f 100644 (file)
@@ -445,39 +445,6 @@ void NativeImageSourceTizen::PrepareTexture()
   }
 }
 
-int NativeImageSourceTizen::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
-{
-  switch (depth)
-  {
-    case Dali::NativeImageSource::COLOR_DEPTH_DEFAULT:
-    {
-      // ToDo: Get the default screen depth
-      return 32;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_8:
-    {
-      return 8;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_16:
-    {
-      return 16;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_24:
-    {
-      return 24;
-    }
-    case Dali::NativeImageSource::COLOR_DEPTH_32:
-    {
-      return 32;
-    }
-    default:
-    {
-      DALI_ASSERT_DEBUG(0 && "unknown color enum");
-      return 0;
-    }
-  }
-}
-
 const char* NativeImageSourceTizen::GetCustomFragmentPreFix()
 {
   return FRAGMENT_PREFIX;
index 18930cc..8578d69 100755 (executable)
@@ -51,7 +51,7 @@ public:
    * @param[in] width The width of the image.
    * @param[in] height The height of the image.
    * @param[in] depth color depth of the image.
-   * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+   * @param[in] nativeImageSource contains tbm_surface_h or is empty
    * @return A smart-pointer to a newly allocated image.
    */
   static NativeImageSourceTizen* New(unsigned int width,
@@ -172,8 +172,6 @@ private:
 
   void Initialize();
 
-  int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
-
   tbm_surface_h GetSurfaceFromAny( Any source ) const;
 
   bool CheckBlending( tbm_format format );
@@ -181,8 +179,8 @@ private:
 private:
 
   unsigned int mWidth;                        ///< image width
-  unsigned int mHeight;                       ///< image heights
-  bool mOwnTbmSurface;                            ///< Whether we created pixmap or not
+  unsigned int mHeight;                       ///< image height
+  bool mOwnTbmSurface;                        ///< Whether we created pixmap or not
   tbm_surface_h mTbmSurface;
   tbm_format mTbmFormat;
   bool mBlendingRequired;                      ///< Whether blending is required
diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp
new file mode 100644 (file)
index 0000000..157d3b8
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * Copyright (c) 2018 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/imaging/tizen/native-image-source-queue-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/integration-api/gl-defines.h>
+#include <tbm_surface_internal.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+#include <dali/internal/graphics/gles20/egl-factory.h>
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+namespace
+{
+#define TBM_SURFACE_QUEUE_SIZE  3
+
+const char* FRAGMENT_PREFIX = "#extension GL_OES_EGL_image_external:require\n";
+const char* SAMPLER_TYPE = "samplerExternalOES";
+
+int FORMATS_BLENDING_REQUIRED[] = {
+  TBM_FORMAT_ARGB4444, TBM_FORMAT_ABGR4444,
+  TBM_FORMAT_RGBA4444, TBM_FORMAT_BGRA4444,
+  TBM_FORMAT_RGBX5551, TBM_FORMAT_BGRX5551,
+  TBM_FORMAT_ARGB1555, TBM_FORMAT_ABGR1555,
+  TBM_FORMAT_RGBA5551, TBM_FORMAT_BGRA5551,
+  TBM_FORMAT_ARGB8888, TBM_FORMAT_ABGR8888,
+  TBM_FORMAT_RGBA8888, TBM_FORMAT_BGRA8888,
+  TBM_FORMAT_ARGB2101010, TBM_FORMAT_ABGR2101010,
+  TBM_FORMAT_RGBA1010102, TBM_FORMAT_BGRA1010102
+};
+
+const int NUM_FORMATS_BLENDING_REQUIRED = 18;
+
+}
+
+NativeImageSourceQueueTizen* NativeImageSourceQueueTizen::New( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+{
+  NativeImageSourceQueueTizen* image = new NativeImageSourceQueueTizen( width, height, depth, nativeImageSourceQueue );
+  DALI_ASSERT_DEBUG( image && "NativeImageSourceQueueTizen allocation failed." );
+
+  if( image )
+  {
+    image->Initialize( depth );
+  }
+
+  return image;
+}
+
+NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+: mWidth( width ),
+  mHeight( height ),
+  mTbmQueue( NULL ),
+  mConsumeSurface( NULL ),
+  mEglImages(),
+  mEglImageExtensions( NULL ),
+  mOwnTbmQueue( false ),
+  mBlendingRequired( false )
+{
+  DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
+  EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
+  mEglImageExtensions = eglFactory.GetImageExtensions();
+  DALI_ASSERT_DEBUG( mEglImageExtensions );
+
+  mTbmQueue = GetSurfaceFromAny( nativeImageSourceQueue );
+
+  if( mTbmQueue != NULL )
+  {
+    mBlendingRequired = CheckBlending( tbm_surface_queue_get_format( mTbmQueue ) );
+    mWidth = tbm_surface_queue_get_width( mTbmQueue );
+    mHeight = tbm_surface_queue_get_height( mTbmQueue );
+  }
+}
+
+NativeImageSourceQueueTizen::~NativeImageSourceQueueTizen()
+{
+  if( mOwnTbmQueue )
+  {
+    DestroyQueue();
+  }
+}
+
+void NativeImageSourceQueueTizen::Initialize( Dali::NativeImageSourceQueue::ColorDepth depth )
+{
+  if( mTbmQueue != NULL || mWidth == 0 || mHeight == 0 )
+  {
+    return;
+  }
+
+  int format = TBM_FORMAT_ARGB8888;
+
+  switch( depth )
+  {
+    case Dali::NativeImageSourceQueue::COLOR_DEPTH_DEFAULT:
+    case Dali::NativeImageSourceQueue::COLOR_DEPTH_32:
+    {
+      format = TBM_FORMAT_ARGB8888;
+      mBlendingRequired = true;
+      break;
+    }
+    case Dali::NativeImageSourceQueue::COLOR_DEPTH_24:
+    {
+      format = TBM_FORMAT_RGB888;
+      mBlendingRequired = false;
+      break;
+    }
+    default:
+    {
+      DALI_LOG_WARNING( "Wrong color depth.\n" );
+      return;
+    }
+  }
+
+  mTbmQueue = tbm_surface_queue_create( TBM_SURFACE_QUEUE_SIZE, mWidth, mHeight, format, 0 );
+
+  mOwnTbmQueue = true;
+}
+
+tbm_surface_queue_h NativeImageSourceQueueTizen::GetSurfaceFromAny( Any source ) const
+{
+  if( source.Empty() )
+  {
+    return NULL;
+  }
+
+  if( source.GetType() == typeid( tbm_surface_queue_h ) )
+  {
+    return AnyCast< tbm_surface_queue_h >( source );
+  }
+  else
+  {
+    return NULL;
+  }
+}
+
+Any NativeImageSourceQueueTizen::GetNativeImageSourceQueue() const
+{
+  return Any( mTbmQueue );
+}
+
+void NativeImageSourceQueueTizen::SetSource( Any source )
+{
+  if( mOwnTbmQueue )
+  {
+    DestroyQueue();
+  }
+
+  mTbmQueue = GetSurfaceFromAny( source );
+
+  if( mTbmQueue != NULL )
+  {
+    mBlendingRequired = CheckBlending( tbm_surface_queue_get_format( mTbmQueue ) );
+    mWidth = tbm_surface_queue_get_width( mTbmQueue );
+    mHeight = tbm_surface_queue_get_height( mTbmQueue );
+  }
+}
+
+bool NativeImageSourceQueueTizen::GlExtensionCreate()
+{
+  return true;
+}
+
+void NativeImageSourceQueueTizen::GlExtensionDestroy()
+{
+  for( auto&& iter : mEglImages )
+  {
+    mEglImageExtensions->DestroyImageKHR( iter.second );
+
+    tbm_surface_internal_unref( iter.first );
+  }
+  mEglImages.clear();
+}
+
+unsigned int NativeImageSourceQueueTizen::TargetTexture()
+{
+  return 0;
+}
+
+void NativeImageSourceQueueTizen::PrepareTexture()
+{
+  tbm_surface_h oldSurface = mConsumeSurface;
+
+  bool needToWait = ( mConsumeSurface == NULL ) ? true : false;
+
+  if( tbm_surface_queue_can_acquire( mTbmQueue, needToWait ) )
+  {
+    if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
+    {
+      DALI_LOG_ERROR( "Failed to aquire a tbm_surface\n" );
+      return;
+    }
+  }
+
+  if( oldSurface && oldSurface != mConsumeSurface )
+  {
+    if( tbm_surface_internal_is_valid( oldSurface ) )
+    {
+      tbm_surface_queue_release( mTbmQueue, oldSurface );
+    }
+  }
+
+  if( mConsumeSurface )
+  {
+    bool existing = false;
+    for( auto&& iter : mEglImages )
+    {
+      if( iter.first == mConsumeSurface )
+      {
+        // Find the surface in the existing list
+        existing = true;
+        mEglImageExtensions->TargetTextureKHR( iter.second );
+        break;
+      }
+    }
+
+    if( !existing )
+    {
+      // Push the surface
+      tbm_surface_internal_ref( mConsumeSurface );
+
+      void* eglImageKHR = mEglImageExtensions->CreateImageKHR( reinterpret_cast< EGLClientBuffer >( mConsumeSurface ) );
+      mEglImageExtensions->TargetTextureKHR( eglImageKHR );
+
+      mEglImages.push_back( EglImagePair( mConsumeSurface, eglImageKHR) );
+    }
+  }
+}
+
+const char* NativeImageSourceQueueTizen::GetCustomFragmentPreFix()
+{
+  return FRAGMENT_PREFIX;
+}
+
+const char* NativeImageSourceQueueTizen::GetCustomSamplerTypename()
+{
+  return SAMPLER_TYPE;
+}
+
+int NativeImageSourceQueueTizen::GetEglImageTextureTarget()
+{
+  return GL_TEXTURE_EXTERNAL_OES;
+}
+
+void NativeImageSourceQueueTizen::DestroyQueue()
+{
+  if( mConsumeSurface )
+  {
+    tbm_surface_internal_unref( mConsumeSurface );
+
+    if( tbm_surface_internal_is_valid( mConsumeSurface ) )
+    {
+      tbm_surface_queue_release( mTbmQueue, mConsumeSurface );
+    }
+  }
+
+  if( mTbmQueue != NULL )
+  {
+    tbm_surface_queue_destroy( mTbmQueue );
+  }
+
+  mTbmQueue = NULL;
+  mOwnTbmQueue = false;
+}
+
+bool NativeImageSourceQueueTizen::CheckBlending( int format )
+{
+  for( int i = 0; i < NUM_FORMATS_BLENDING_REQUIRED; ++i )
+  {
+    if( format == FORMATS_BLENDING_REQUIRED[i] )
+    {
+      return true;
+    }
+  }
+
+  return false;
+}
+
+} // namespace Adaptor
+
+} // namespace internal
+
+} // namespace Dali
diff --git a/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.h
new file mode 100755 (executable)
index 0000000..8d25513
--- /dev/null
@@ -0,0 +1,180 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
+
+/*
+ * Copyright (c) 2018 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/devel-api/images/native-image-interface-extension.h>
+#include <dali/public-api/common/vector-wrapper.h>
+#include <tbm_surface.h>
+#include <tbm_surface_queue.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class EglImageExtensions;
+
+/**
+ * Dali internal NativeImageSource.
+ */
+class NativeImageSourceQueueTizen: public Internal::Adaptor::NativeImageSourceQueue, public NativeImageInterface::Extension
+{
+public:
+
+  /**
+   * Create a new NativeImageSourceQueueTizen internally.
+   * Depending on hardware the width and height may have to be a power of two.
+   * @param[in] width The width of the image.
+   * @param[in] height The height of the image.
+   * @param[in] depth color depth of the image.
+   * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
+   * @return A smart-pointer to a newly allocated image.
+   */
+  static NativeImageSourceQueueTizen* New(unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+
+  /**
+   * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
+   */
+  Any GetNativeImageSourceQueue() const override;
+
+  /**
+   * @copydoc Dali::NativeImageSourceQueue::SetSource( Any source )
+   */
+  void SetSource( Any source ) override;
+
+  /**
+   * destructor
+   */
+  ~NativeImageSourceQueueTizen() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
+   */
+  bool GlExtensionCreate() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
+   */
+  void GlExtensionDestroy() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::TargetTexture()
+   */
+  unsigned int TargetTexture() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::PrepareTexture()
+   */
+  void PrepareTexture() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetWidth()
+   */
+  unsigned int GetWidth() const override
+  {
+    return mWidth;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetHeight()
+   */
+  unsigned int GetHeight() const override
+  {
+    return mHeight;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::RequiresBlending()
+   */
+  bool RequiresBlending() const override
+  {
+    return mBlendingRequired;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::GetExtension()
+   */
+  NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
+  {
+    return this;
+  }
+
+  /**
+   * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
+   */
+  const char* GetCustomFragmentPreFix() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
+   */
+  const char* GetCustomSamplerTypename() override;
+
+  /**
+   * @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
+   */
+  int GetEglImageTextureTarget() override;
+
+private:
+
+  /**
+   * Private constructor; @see NativeImageSourceQueue::New()
+   * @param[in] width The width of the image.
+   * @param[in] height The height of the image.
+   * @param[in] colour depth of the image.
+   * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
+   */
+  NativeImageSourceQueueTizen( unsigned int width, unsigned int height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
+
+  void Initialize( Dali::NativeImageSourceQueue::ColorDepth depth );
+
+  void DestroyQueue();
+
+  tbm_surface_queue_h GetSurfaceFromAny( Any source ) const;
+
+  bool CheckBlending( int format );
+
+private:
+
+  typedef std::pair< tbm_surface_h, void* > EglImagePair;
+
+  unsigned int                     mWidth;                ///< image width
+  unsigned int                     mHeight;               ///< image height
+  tbm_surface_queue_h              mTbmQueue;             ///< Tbm surface queue handle
+  tbm_surface_h                    mConsumeSurface;       ///< The current tbm surface
+  std::vector< EglImagePair >      mEglImages;            ///< EGL Image vector
+  EglImageExtensions*              mEglImageExtensions;   ///< The EGL Image Extensions
+  bool                             mOwnTbmQueue;          ///< Whether we created tbm queue
+  bool                             mBlendingRequired;     ///< Whether blending is required
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
index 47d6595..b072c67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  *
  */
 
-#include <memory>
+// CLASS HEADER
+#include <dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.h>
+
+// INTERNAL HEADERS
 #include <dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h>
+#include <dali/internal/imaging/common/native-image-source-queue-impl.h>
 
 namespace Dali
 {
@@ -25,29 +29,25 @@ namespace Internal
 namespace Adaptor
 {
 
-namespace NativeImageSourceFactory
+std::unique_ptr< NativeImageSource > NativeImageSourceFactoryX::CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                                         Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
 {
+  return std::unique_ptr< NativeImageSource >( NativeImageSourceX::New( width, height, depth, nativeImageSource ) );
+}
 
-/**
- * Dummy implementation
- * @param width
- * @param height
- * @param depth
- * @param nativeImageSource
- * @return
- */
-std::unique_ptr<Dali::Internal::Adaptor::NativeImageSource> New(unsigned int width,
-                                       unsigned int height,
-                                       Dali::NativeImageSource::ColorDepth depth,
-                                       Any nativeImageSource)
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryX::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                                                   Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
 {
-  return std::unique_ptr<NativeImageSourceX>( NativeImageSourceX::New( width, height, depth, nativeImageSource ) );
+  return std::unique_ptr< NativeImageSourceQueue >( nullptr );
 }
 
+// this should be created from somewhere
+std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory()
+{
+  // returns native image source factory
+  return std::unique_ptr< NativeImageSourceFactoryX >( new NativeImageSourceFactoryX() );
 }
 
 } // Adaptor
-
 } // Internal
-
 } // Dali
diff --git a/dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.h b/dali/internal/imaging/ubuntu-x11/native-image-source-factory-x.h
new file mode 100644 (file)
index 0000000..6c35f9a
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
+
+/*
+ * Copyright (c) 2018 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/imaging/common/native-image-source-factory.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class NativeImageSourceFactoryX : public NativeImageSourceFactory
+{
+public:
+
+  std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+                                                                Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) override;
+
+  std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+                                                                          Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) override;
+
+};
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_X_H
index 24f8a7a..9672c60 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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,6 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/imaging/common/native-image-source-impl.h>
+#include <dali/internal/imaging/common/native-image-source-factory.h>
 
 namespace Dali
 {
@@ -107,7 +108,8 @@ NativeImageInterface::Extension* NativeImageSource::GetExtension()
 
 NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, ColorDepth depth, Any nativeImageSource )
 {
-   mImpl = Internal::Adaptor::NativeImageSource::New( width, height, depth, nativeImageSource );
+  auto factory = Dali::Internal::Adaptor::GetNativeImageSourceFactory();
+  mImpl = factory->CreateNativeImageSource( width, height, depth, nativeImageSource ).release();
 }
 
 NativeImageSource::~NativeImageSource()