1 #ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
2 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/devel-api/images/native-image-interface-extension.h>
23 #include <dali/devel-api/threading/mutex.h>
24 #include <dali/public-api/common/vector-wrapper.h>
25 #include <tbm_surface.h>
26 #include <tbm_surface_queue.h>
29 #include <dali/internal/imaging/common/native-image-source-queue-impl.h>
41 class EglImageExtensions;
44 * Dali internal NativeImageSource.
46 class NativeImageSourceQueueTizen: public Internal::Adaptor::NativeImageSourceQueue, public NativeImageInterface::Extension
51 * Create a new NativeImageSourceQueueTizen internally.
52 * Depending on hardware the width and height may have to be a power of two.
53 * @param[in] width The width of the image.
54 * @param[in] height The height of the image.
55 * @param[in] depth color depth of the image.
56 * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
57 * @return A smart-pointer to a newly allocated image.
59 static NativeImageSourceQueueTizen* New( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
62 * @copydoc Dali::NativeImageSourceQueue::GetNativeImageSourceQueue()
64 Any GetNativeImageSourceQueue() const override;
67 * @copydoc Dali::NativeImageSourceQueue::SetSize
69 void SetSize( uint32_t width, uint32_t height ) override;
74 ~NativeImageSourceQueueTizen() override;
77 * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
79 bool GlExtensionCreate() override;
82 * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
84 void GlExtensionDestroy() override;
87 * @copydoc Dali::NativeImageInterface::TargetTexture()
89 uint32_t TargetTexture() override;
92 * @copydoc Dali::NativeImageInterface::PrepareTexture()
94 void PrepareTexture() override;
97 * @copydoc Dali::NativeImageInterface::GetWidth()
99 uint32_t GetWidth() const override
105 * @copydoc Dali::NativeImageInterface::GetHeight()
107 uint32_t GetHeight() const override
113 * @copydoc Dali::NativeImageInterface::RequiresBlending()
115 bool RequiresBlending() const override
117 return mBlendingRequired;
121 * @copydoc Dali::NativeImageInterface::GetExtension()
123 NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
129 * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
131 const char* GetCustomFragmentPreFix() override;
134 * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
136 const char* GetCustomSamplerTypename() override;
139 * @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
141 int GetEglImageTextureTarget() override;
146 * Private constructor; @see NativeImageSourceQueue::New()
147 * @param[in] width The width of the image.
148 * @param[in] height The height of the image.
149 * @param[in] colour depth of the image.
150 * @param[in] nativeImageSourceQueue contains tbm_surface_queue_h or is empty
152 NativeImageSourceQueueTizen( uint32_t width, uint32_t height, Dali::NativeImageSourceQueue::ColorDepth depth, Any nativeImageSourceQueue );
154 void Initialize( Dali::NativeImageSourceQueue::ColorDepth depth );
156 void ResetEglImageList();
158 tbm_surface_queue_h GetSurfaceFromAny( Any source ) const;
160 bool CheckBlending( int format );
164 typedef std::pair< tbm_surface_h, void* > EglImagePair;
166 Dali::Mutex mMutex; ///< Mutex
167 uint32_t mWidth; ///< image width
168 uint32_t mHeight; ///< image height
169 tbm_surface_queue_h mTbmQueue; ///< Tbm surface queue handle
170 tbm_surface_h mConsumeSurface; ///< The current tbm surface
171 std::vector< EglImagePair > mEglImages; ///< EGL Image vector
172 EglGraphics* mEglGraphics; ///< EGL Graphics
173 EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
174 bool mOwnTbmQueue; ///< Whether we created tbm queue
175 bool mBlendingRequired; ///< Whether blending is required
178 } // namespace Adaptor
180 } // namespace Internal
184 #endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_QUEUE_IMPL_TIZEN_H