--- /dev/null
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_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 <memory>
+
+// INTERNAL INCLUDES
+#include <native-image-source.h>
+#include <native-image-source-queue.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+class NativeImageSource;
+class NativeImageSourceQueue;
+
+class NativeImageSourceFactory
+{
+public:
+
+ NativeImageSourceFactory() = default;
+ virtual ~NativeImageSourceFactory() = default;
+
+ virtual std::unique_ptr< NativeImageSource > CreateNativeImageSource( unsigned int width, unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource ) = 0;
+
+ virtual std::unique_ptr< NativeImageSourceQueue > CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+ Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue ) = 0;
+
+};
+
+extern std::unique_ptr< NativeImageSourceFactory > GetNativeImageSourceFactory();
+
+} // Adaptor
+} // Internal
+} // Dali
+
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_FACTORY_H
--- /dev/null
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_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 <native-image-source.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Dali internal NativeImageSource.
+ */
+class NativeImageSource
+{
+public:
+
+ /**
+ * Create a new NativeImageSource 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] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
+ * @return A smart-pointer to a newly allocated image.
+ */
+ static NativeImageSource* New(unsigned int width,
+ unsigned int height,
+ Dali::NativeImageSource::ColorDepth depth,
+ Any nativeImageSource);
+ /**
+ * @copydoc Dali::NativeImageSource::GetNativeImageSource()
+ */
+ 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 = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
+ */
+ virtual bool EncodeToFile(const std::string& filename) const = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::SetSource( Any source )
+ */
+ virtual void SetSource( Any source ) = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
+ */
+ virtual bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) = 0;
+
+ /**
+ * destructor
+ */
+ virtual ~NativeImageSource() = default;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GlExtensionCreate()
+ */
+ virtual bool GlExtensionCreate() = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
+ */
+ virtual void GlExtensionDestroy() = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::TargetTexture()
+ */
+ virtual unsigned int TargetTexture() = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::PrepareTexture()
+ */
+ virtual void PrepareTexture() = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetWidth()
+ */
+ virtual unsigned int GetWidth() const = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::GetHeight()
+ */
+ virtual unsigned int GetHeight() const = 0;
+
+ /**
+ * @copydoc Dali::NativeImageSource::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_IMPL_H
--- /dev/null
+#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 <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
--- /dev/null
+/*
+ * 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 <native-image-source-queue.h>
+
+// INTERNAL INCLUDES
+#include <native-image-source-queue-impl.h>
+#include <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
--- /dev/null
+#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>
+
+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_IMPORT_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
$(adaptor_devel_api_dir)/adaptor-framework/gif-loading.cpp \
$(adaptor_devel_api_dir)/adaptor-framework/imf-manager.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 \
$(adaptor_devel_api_dir)/adaptor-framework/input-method-devel.h \
$(adaptor_devel_api_dir)/adaptor-framework/input-method-options.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 \
/*
- * 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.
// INTERNAL INCLUDES
#include <native-image-source-impl.h>
+#include <native-image-source-factory.h>
namespace Dali
{
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()
adaptor_tizen_internal_native_image_src_files = \
$(adaptor_tizen_dir)/display-connection-impl-tizen.cpp \
$(adaptor_tizen_dir)/native-render-surface-tizen.cpp \
+ $(adaptor_tizen_dir)/native-image-source-factory-tizen.cpp \
$(adaptor_tizen_dir)/native-image-source-impl-tizen.cpp
public_api_adaptor_tizen_header_files = \
$(adaptor_tizen_dir)/display-connection-impl-tizen.cpp \
$(adaptor_tizen_dir)/native-render-surface-tizen.cpp \
$(adaptor_tizen_dir)/native-render-surface-factory-tizen.cpp \
- $(adaptor_tizen_dir)/native-image-source-impl-tizen.cpp
+ $(adaptor_tizen_dir)/native-image-source-factory-tizen.cpp \
+ $(adaptor_tizen_dir)/native-image-source-impl-tizen.cpp \
+ $(adaptor_tizen_dir)/native-image-source-queue-impl-tizen.cpp
public_api_adaptor_tizen_header_files = \
$(adaptor_tizen_dir)/key-grab.h
clientBuffer,
attribs );
- DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "X11Image::GlExtensionCreate eglCreateImageKHR failed!\n");
if( EGL_NO_IMAGE_KHR == eglImage )
{
switch( eglGetError() )
}
}
}
+ DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "EglImageExtensions::CreateImageKHR: eglCreateImageKHR failed!\n");
return eglImage;
}
--- /dev/null
+/*
+ * 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 <native-image-source-factory-tizen.h>
+
+// INTERNAL HEADERS
+#include <native-image-source-impl-tizen.h>
+#include <native-image-source-queue-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+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 ) );
+}
+
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryTizen::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+ Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+{
+ 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
--- /dev/null
+#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 <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
*/
// CLASS HEADER
-#include "native-image-source-impl.h"
+#include <native-image-source-impl-tizen.h>
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <render-surface.h>
#include <trigger-event-factory.h>
-
// Allow this to be encoded and saved:
#include <bitmap-saver.h>
using Dali::Integration::PixelBuffer;
-NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen* NativeImageSourceTizen::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
{
- NativeImageSource* image = new NativeImageSource( width, height, depth, nativeImageSource );
+ NativeImageSourceTizen* image = new NativeImageSourceTizen( width, height, depth, nativeImageSource );
DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
if( image )
return image;
}
-NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
: mWidth( width ),
mHeight( height ),
mOwnTbmSurface( false ),
}
}
-void NativeImageSource::Initialize()
+void NativeImageSourceTizen::Initialize()
{
if( mTbmSurface != NULL || mWidth == 0 || mHeight == 0 )
{
mOwnTbmSurface = true;
}
-tbm_surface_h NativeImageSource::GetSurfaceFromAny( Any source ) const
+tbm_surface_h NativeImageSourceTizen::GetSurfaceFromAny( Any source ) const
{
if( source.Empty() )
{
}
}
-NativeImageSource::~NativeImageSource()
+NativeImageSourceTizen::~NativeImageSourceTizen()
{
if( mOwnTbmSurface )
{
}
}
-Any NativeImageSource::GetNativeImageSource() const
+Any NativeImageSourceTizen::GetNativeImageSource() const
{
return Any( mTbmSurface );
}
-void NativeImageSource::SetDestructorNotification(void* notification)
+void NativeImageSourceTizen::SetDestructorNotification(void* notification)
{
mNotification = notification;
}
-bool NativeImageSource::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
if( mTbmSurface != NULL )
{
return false;
}
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
+bool NativeImageSourceTizen::EncodeToFile(const std::string& filename) const
{
std::vector< unsigned char > pixbuf;
unsigned int width(0), height(0);
return false;
}
-void NativeImageSource::SetSource( Any source )
+void NativeImageSourceTizen::SetSource( Any source )
{
if( mOwnTbmSurface )
{
}
}
-bool NativeImageSource::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceTizen::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
{
uint32_t* formats;
uint32_t formatNum;
return false;
}
-bool NativeImageSource::GlExtensionCreate()
+bool NativeImageSourceTizen::GlExtensionCreate()
{
// casting from an unsigned int to a void *, which should then be cast back
// to an unsigned int in the driver.
return mEglImageKHR != NULL;
}
-void NativeImageSource::GlExtensionDestroy()
+void NativeImageSourceTizen::GlExtensionDestroy()
{
if( mEglImageKHR )
{
}
}
-unsigned int NativeImageSource::TargetTexture()
+unsigned int NativeImageSourceTizen::TargetTexture()
{
mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
return 0;
}
-void NativeImageSource::PrepareTexture()
+void NativeImageSourceTizen::PrepareTexture()
{
if( mSetSource )
{
}
}
-int NativeImageSource::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* NativeImageSource::GetCustomFragmentPreFix()
+const char* NativeImageSourceTizen::GetCustomFragmentPreFix()
{
return FRAGMENT_PREFIX;
}
-const char* NativeImageSource::GetCustomSamplerTypename()
+const char* NativeImageSourceTizen::GetCustomSamplerTypename()
{
return SAMPLER_TYPE;
}
-int NativeImageSource::GetEglImageTextureTarget()
+int NativeImageSourceTizen::GetEglImageTextureTarget()
{
return GL_TEXTURE_EXTERNAL_OES;
}
-bool NativeImageSource::CheckBlending( tbm_format format )
+bool NativeImageSourceTizen::CheckBlending( tbm_format format )
{
if( mTbmFormat != format )
{
-#ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
-#define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+#ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
+#define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_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.
// INTERNAL INCLUDES
#include <native-image-source.h>
+#include <native-image-source-impl.h>
namespace Dali
{
/**
* Dali internal NativeImageSource.
*/
-class NativeImageSource: public NativeImageInterface::Extension
+class NativeImageSourceTizen: public Internal::Adaptor::NativeImageSource, public NativeImageInterface::Extension
{
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 NativeImageSource* New(unsigned int width,
+ static NativeImageSourceTizen* New(unsigned int width,
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
- Any GetNativeImageSource() const;
-
+ Any GetNativeImageSource() const override;
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+ bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
/**
* @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
*/
- bool EncodeToFile(const std::string& filename) const;
+ bool EncodeToFile(const std::string& filename) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source );
+ void SetSource( Any source ) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth );
+ bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
/**
* destructor
*/
- ~NativeImageSource();
+ ~NativeImageSourceTizen() override;
/**
* @copydoc Dali::NativeImageSource::GlExtensionCreate()
*/
- bool GlExtensionCreate();
+ bool GlExtensionCreate() override;
/**
* @copydoc Dali::NativeImageSource::GlExtensionDestroy()
*/
- void GlExtensionDestroy();
+ void GlExtensionDestroy() override;
/**
* @copydoc Dali::NativeImageSource::TargetTexture()
*/
- unsigned int TargetTexture();
+ unsigned int TargetTexture() override;
/**
* @copydoc Dali::NativeImageSource::PrepareTexture()
*/
- void PrepareTexture();
+ void PrepareTexture() override;
/**
* @copydoc Dali::NativeImageSource::GetWidth()
*/
- unsigned int GetWidth() const
+ unsigned int GetWidth() const override
{
return mWidth;
}
/**
* @copydoc Dali::NativeImageSource::GetHeight()
*/
- unsigned int GetHeight() const
+ unsigned int GetHeight() const override
{
return mHeight;
}
/**
* @copydoc Dali::NativeImageSource::RequiresBlending()
*/
- bool RequiresBlending() const
+ bool RequiresBlending() const override
{
return mBlendingRequired;
}
/**
* @copydoc Dali::NativeImageInterface::GetExtension()
*/
- NativeImageInterface::Extension* GetNativeImageInterfaceExtension()
+ NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
{
return this;
}
/**
* @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
*/
- const char* GetCustomFragmentPreFix();
+ const char* GetCustomFragmentPreFix() override;
/**
* @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
*/
- const char* GetCustomSamplerTypename();
+ const char* GetCustomSamplerTypename() override;
/**
* @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
*/
- int GetEglImageTextureTarget();
+ int GetEglImageTextureTarget() override;
/**
* @copydoc Dali::NativeImageInterface::Extension::SetDestructorNotification((void *notification)
*/
- void SetDestructorNotification(void* notification);
+ void SetDestructorNotification(void* notification) override;
private:
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSource(unsigned int width,
+ NativeImageSourceTizen(unsigned int width,
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);
void Initialize();
- int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
-
tbm_surface_h GetSurfaceFromAny( Any source ) const;
bool CheckBlending( tbm_format format );
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
} // namespace Dali
-#endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
+#endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
--- /dev/null
+/*
+ * 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 <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 <gl/egl-image-extensions.h>
+#include <gl/egl-factory.h>
+#include <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::SetDestructorNotification(void* notification)
+{
+}
+
+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
--- /dev/null
+#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 <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;
+
+ /**
+ * @copydoc Dali::NativeImageInterface::Extension::SetDestructorNotification((void *notification)
+ */
+ void SetDestructorNotification(void* notification) 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
$(adaptor_x11_dir)/clipboard-impl-x.cpp \
$(adaptor_x11_dir)/display-connection-impl-x.cpp \
$(adaptor_x11_dir)/imf-manager-impl-x.cpp \
+ $(adaptor_x11_dir)/native-image-source-factory-x.cpp \
$(adaptor_x11_dir)/native-image-source-impl-x.cpp \
$(adaptor_x11_dir)/virtual-keyboard-impl-x.cpp \
$(adaptor_x11_dir)/window-impl-x.cpp \
--- /dev/null
+/*
+ * 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 <native-image-source-factory-x.h>
+
+// INTERNAL HEADERS
+#include <native-image-source-impl-x.h>
+#include <native-image-source-queue-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+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 ) );
+}
+
+std::unique_ptr< NativeImageSourceQueue > NativeImageSourceFactoryX::CreateNativeImageSourceQueue( unsigned int width, unsigned int height,
+ Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue )
+{
+ 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
--- /dev/null
+#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 <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
/*
- * 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.
*/
// CLASS HEADER
-#include "native-image-source-impl.h"
+#include <native-image-source-impl-x.h>
// EXTERNAL INCLUDES
#include <Ecore_X.h>
};
}
-NativeImageSource* NativeImageSource::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceX* NativeImageSourceX::New(unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
{
- NativeImageSource* image = new NativeImageSource( width, height, depth, nativeImageSource );
+ NativeImageSourceX* image = new NativeImageSourceX( width, height, depth, nativeImageSource );
DALI_ASSERT_DEBUG( image && "NativeImageSource allocation failed." );
// 2nd phase construction
return image;
}
-NativeImageSource::NativeImageSource( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
+NativeImageSourceX::NativeImageSourceX( unsigned int width, unsigned int height, Dali::NativeImageSource::ColorDepth depth, Any nativeImageSource )
: mWidth( width ),
mHeight( height ),
mOwnPixmap( true ),
mPixmap = GetPixmapFromAny(nativeImageSource);
}
-void NativeImageSource::Initialize()
+void NativeImageSourceX::Initialize()
{
// if pixmap has been created outside of X11 Image we can return
if (mPixmap)
ecore_x_sync();
}
-NativeImageSource::~NativeImageSource()
+NativeImageSourceX::~NativeImageSourceX()
{
if (mOwnPixmap && mPixmap)
{
}
}
-Any NativeImageSource::GetNativeImageSource() const
+Any NativeImageSourceX::GetNativeImageSource() const
{
// return ecore x11 type
return Any(mPixmap);
}
-bool NativeImageSource::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
+bool NativeImageSourceX::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
{
DALI_ASSERT_DEBUG(sizeof(unsigned) == 4);
bool success = false;
XImageJanitor xImageJanitor( XGetImage( displayConnection,
mPixmap,
0, 0, // x,y of subregion to extract.
- width, height, // of suregion to extract.
+ width, height, // of subregion to extract.
0xFFFFFFFF,
ZPixmap ) );
XImage* const pXImage = xImageJanitor.mXImage;
return success;
}
-bool NativeImageSource::EncodeToFile(const std::string& filename) const
+bool NativeImageSourceX::EncodeToFile(const std::string& filename) const
{
std::vector< unsigned char > pixbuf;
unsigned int width(0), height(0);
return false;
}
-void NativeImageSource::SetSource( Any source )
+void NativeImageSourceX::SetSource( Any source )
{
mPixmap = GetPixmapFromAny( source );
}
}
-bool NativeImageSource::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
+bool NativeImageSourceX::IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth )
{
return true;
}
-bool NativeImageSource::GlExtensionCreate()
+bool NativeImageSourceX::GlExtensionCreate()
{
// if the image existed previously delete it.
if (mEglImageKHR != NULL)
return mEglImageKHR != NULL;
}
-void NativeImageSource::GlExtensionDestroy()
+void NativeImageSourceX::GlExtensionDestroy()
{
mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
mEglImageKHR = NULL;
}
-unsigned int NativeImageSource::TargetTexture()
+unsigned int NativeImageSourceX::TargetTexture()
{
mEglImageExtensions->TargetTextureKHR(mEglImageKHR);
return 0;
}
-void NativeImageSource::PrepareTexture()
+void NativeImageSourceX::PrepareTexture()
{
}
-int NativeImageSource::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
+int NativeImageSourceX::GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const
{
switch (depth)
{
}
}
-Ecore_X_Pixmap NativeImageSource::GetPixmapFromAny(Any pixmap) const
+Ecore_X_Pixmap NativeImageSourceX::GetPixmapFromAny(Any pixmap) const
{
if (pixmap.Empty())
{
}
}
-void NativeImageSource::GetPixmapDetails()
+void NativeImageSourceX::GetPixmapDetails()
{
int x, y;
// INTERNAL INCLUDES
#include <native-image-source.h>
+#include <native-image-source-impl.h>
namespace Dali
{
/**
* Dali internal NativeImageSource.
*/
-class NativeImageSource
+class NativeImageSourceX : public Internal::Adaptor::NativeImageSource
{
public:
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
* @return A smart-pointer to a newly allocated image.
*/
- static NativeImageSource* New(unsigned int width,
+ static NativeImageSourceX* New(unsigned int width,
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);
/**
* @copydoc Dali::NativeImageSource::GetNativeImageSource()
*/
- Any GetNativeImageSource() const;
+ Any GetNativeImageSource() const override;
/**
* @copydoc Dali::NativeImageSource::GetPixels()
*/
- bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
+ bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
/**
* @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
*/
- bool EncodeToFile(const std::string& filename) const;
+ bool EncodeToFile(const std::string& filename) const override;
/**
* @copydoc Dali::NativeImageSource::SetSource( Any source )
*/
- void SetSource( Any source );
+ void SetSource( Any source ) override;
/**
* @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
*/
- bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth );
+ bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
/**
* destructor
*/
- ~NativeImageSource();
+ ~NativeImageSourceX() override;
/**
* @copydoc Dali::NativeImageSource::GlExtensionCreate()
*/
- bool GlExtensionCreate();
+ bool GlExtensionCreate() override;
/**
* @copydoc Dali::NativeImageSource::GlExtensionDestroy()
*/
- void GlExtensionDestroy();
+ void GlExtensionDestroy() override;
/**
* @copydoc Dali::NativeImageSource::TargetTexture()
*/
- unsigned int TargetTexture();
+ unsigned int TargetTexture() override;
/**
* @copydoc Dali::NativeImageSource::PrepareTexture()
*/
- void PrepareTexture();
+ void PrepareTexture() override;
/**
* @copydoc Dali::NativeImageSource::GetWidth()
*/
- unsigned int GetWidth() const
+ unsigned int GetWidth() const override
{
return mWidth;
}
/**
* @copydoc Dali::NativeImageSource::GetHeight()
*/
- unsigned int GetHeight() const
+ unsigned int GetHeight() const override
{
return mHeight;
}
/**
* @copydoc Dali::NativeImageSource::RequiresBlending()
*/
- bool RequiresBlending() const
+ bool RequiresBlending() const override
{
return mBlendingRequired;
}
/**
* @copydoc Dali::NativeImageInterface::GetExtension()
*/
- NativeImageInterface::Extension* GetNativeImageInterfaceExtension()
+ NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
{
- return NULL;
+ return nullptr;
}
private:
* @param[in] colour depth of the image.
* @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
*/
- NativeImageSource(unsigned int width,
+ NativeImageSourceX(unsigned int width,
unsigned int height,
Dali::NativeImageSource::ColorDepth depth,
Any nativeImageSource);