1 #ifndef __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
2 #define __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__
5 * Copyright (c) 2014 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/public-api/common/dali-vector.h>
27 #include <native-image-source.h>
37 class EglImageExtensions;
41 typedef Dali::Vector< void* > EglImageContainer;
45 * Dali internal NativeImageSource.
47 class NativeImageSource: public NativeImageInterface::Extension
52 * Create a new NativeImageSource internally.
53 * Depending on hardware the width and height may have to be a power of two.
54 * @param[in] width The width of the image.
55 * @param[in] height The height of the image.
56 * @param[in] depth color depth of the image.
57 * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
58 * @return A smart-pointer to a newly allocated image.
60 static NativeImageSource* New(unsigned int width,
62 Dali::NativeImageSource::ColorDepth depth,
63 Any nativeImageSource);
66 * @copydoc Dali::NativeImageSource::GetNativeImageSource()
68 Any GetNativeImageSource() const;
71 * @copydoc Dali::NativeImageSource::GetPixels()
73 bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
76 * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
78 bool EncodeToFile(const std::string& filename) const;
81 * @copydoc Dali::NativeImageSource::SetSource( Any source )
83 void SetSource( Any source );
86 * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
88 bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth );
96 * @copydoc Dali::NativeImageSource::GlExtensionCreate()
98 bool GlExtensionCreate();
101 * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
103 void GlExtensionDestroy();
106 * @copydoc Dali::NativeImageSource::TargetTexture()
108 unsigned int TargetTexture();
111 * @copydoc Dali::NativeImageSource::PrepareTexture()
113 void PrepareTexture();
116 * @copydoc Dali::NativeImageSource::GetWidth()
118 unsigned int GetWidth() const
124 * @copydoc Dali::NativeImageSource::GetHeight()
126 unsigned int GetHeight() const
132 * @copydoc Dali::NativeImageSource::RequiresBlending()
134 bool RequiresBlending() const
136 return mBlendingRequired;
140 * @copydoc Dali::NativeImageInterface::GetExtension()
142 NativeImageInterface::Extension* GetNativeImageInterfaceExtension()
148 * @copydoc Dali::NativeImageInterface::Extension::GetCustomFragmentPreFix()
150 const char* GetCustomFragmentPreFix();
153 * @copydoc Dali::NativeImageInterface::Extension::GetCustomSamplerTypename()
155 const char* GetCustomSamplerTypename();
160 * Private constructor; @see NativeImageSource::New()
161 * @param[in] width The width of the image.
162 * @param[in] height The height of the image.
163 * @param[in] colour depth of the image.
164 * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
166 NativeImageSource(unsigned int width,
168 Dali::NativeImageSource::ColorDepth depth,
169 Any nativeImageSource);
173 int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
175 tbm_surface_h GetSurfaceFromAny( Any source ) const;
179 unsigned int mWidth; ///< image width
180 unsigned int mHeight; ///< image heights
181 bool mOwnTbmsurface; ///< Whether we created pixmap or not
182 tbm_surface_h mTbmsurface;
183 bool mBlendingRequired; ///< Whether blending is required
184 Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
185 void* mEglImageKHR; ///< From EGL extension
186 EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
188 EglImageContainer mEglImageKHRContainer;
191 } // namespace Adaptor
193 } // namespace Internal
197 #endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__