1 #ifndef DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
2 #define DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H
5 * Copyright (c) 2017 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 <tbm_surface.h>
23 #include <dali/devel-api/images/native-image-interface-extension.h>
24 #include <dali/devel-api/threading/mutex.h>
25 #include <dali/public-api/common/dali-vector.h>
28 #include <dali/public-api/adaptor-framework/native-image-source.h>
29 #include <dali/internal/imaging/common/native-image-source-impl.h>
41 class EglImageExtensions;
44 * Dali internal NativeImageSource.
46 class NativeImageSourceTizen: public Internal::Adaptor::NativeImageSource, public NativeImageInterface::Extension
51 * Create a new NativeImageSource 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] nativeImageSource contains tbm_surface_h or is empty
57 * @return A smart-pointer to a newly allocated image.
59 static NativeImageSourceTizen* New(uint32_t width,
61 Dali::NativeImageSource::ColorDepth depth,
62 Any nativeImageSource);
65 * @copydoc Dali::NativeImageSource::GetNativeImageSource()
67 Any GetNativeImageSource() const override;
70 * @copydoc Dali::NativeImageSource::GetPixels()
72 bool GetPixels(std::vector<unsigned char> &pixbuf, uint32_t &width, uint32_t &height, Pixel::Format& pixelFormat ) const override;
75 * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
77 bool EncodeToFile(const std::string& filename) const override;
80 * @copydoc Dali::NativeImageSource::SetSource( Any source )
82 void SetSource( Any source ) override;
85 * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
87 bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
92 ~NativeImageSourceTizen() override;
95 * @copydoc Dali::NativeImageSource::GlExtensionCreate()
97 bool GlExtensionCreate() override;
100 * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
102 void GlExtensionDestroy() override;
105 * @copydoc Dali::NativeImageSource::TargetTexture()
107 uint32_t TargetTexture() override;
110 * @copydoc Dali::NativeImageSource::PrepareTexture()
112 void PrepareTexture() override;
115 * @copydoc Dali::NativeImageSource::GetWidth()
117 uint32_t GetWidth() const override
123 * @copydoc Dali::NativeImageSource::GetHeight()
125 uint32_t GetHeight() const override
131 * @copydoc Dali::NativeImageSource::RequiresBlending()
133 bool RequiresBlending() const override
135 return mBlendingRequired;
139 * @copydoc Dali::NativeImageInterface::GetExtension()
141 NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
147 * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
149 const char* GetCustomFragmentPreFix() override;
152 * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
154 const char* GetCustomSamplerTypename() override;
157 * @copydoc Dali::NativeImageInterface::Extension::GetEglImageTextureTarget()
159 int GetEglImageTextureTarget() override;
164 * Private constructor; @see NativeImageSource::New()
165 * @param[in] width The width of the image.
166 * @param[in] height The height of the image.
167 * @param[in] colour depth of the image.
168 * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
170 NativeImageSourceTizen(uint32_t width,
172 Dali::NativeImageSource::ColorDepth depth,
173 Any nativeImageSource);
177 tbm_surface_h GetSurfaceFromAny( Any source ) const;
179 bool CheckBlending( tbm_format format );
183 uint32_t mWidth; ///< image width
184 uint32_t mHeight; ///< image height
185 bool mOwnTbmSurface; ///< Whether we created pixmap or not
186 tbm_surface_h mTbmSurface;
187 tbm_format mTbmFormat;
188 bool mBlendingRequired; ///< Whether blending is required
189 Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
190 void* mEglImageKHR; ///< From EGL extension
191 EglGraphics* mEglGraphics; ///< EGL Graphics
192 EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
194 mutable Dali::Mutex mMutex;
197 } // namespace Adaptor
199 } // namespace Internal
203 #endif // DALI_INTERNAL_NATIVE_IMAGE_SOURCE_IMPL_TIZEN_H