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.
25 #include <dali/public-api/adaptor-framework/native-image-source.h>
27 #include <dali/internal/imaging/common/native-image-source-impl.h>
37 class EglImageExtensions;
40 * Dali internal NativeImageSource.
42 class NativeImageSourceX : public Internal::Adaptor::NativeImageSource
47 * Create a new NativeImageSource internally.
48 * Depending on hardware the width and height may have to be a power of two.
49 * @param[in] width The width of the image.
50 * @param[in] height The height of the image.
51 * @param[in] depth color depth of the image.
52 * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
53 * @return A smart-pointer to a newly allocated image.
55 static NativeImageSourceX* New(unsigned int width,
57 Dali::NativeImageSource::ColorDepth depth,
58 Any nativeImageSource);
60 * @copydoc Dali::NativeImageSource::GetNativeImageSource()
62 Any GetNativeImageSource() const override;
65 * @copydoc Dali::NativeImageSource::GetPixels()
67 bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const override;
70 * @copydoc Dali::NativeImageSource::EncodeToFile(const std::string& )
72 bool EncodeToFile(const std::string& filename) const override;
75 * @copydoc Dali::NativeImageSource::SetSource( Any source )
77 void SetSource( Any source ) override;
80 * @copydoc Dali::NativeImageSource::IsColorDepthSupported( ColorDepth colorDepth )
82 bool IsColorDepthSupported( Dali::NativeImageSource::ColorDepth colorDepth ) override;
87 ~NativeImageSourceX() override;
90 * @copydoc Dali::NativeImageSource::GlExtensionCreate()
92 bool GlExtensionCreate() override;
95 * @copydoc Dali::NativeImageSource::GlExtensionDestroy()
97 void GlExtensionDestroy() override;
100 * @copydoc Dali::NativeImageSource::TargetTexture()
102 unsigned int TargetTexture() override;
105 * @copydoc Dali::NativeImageSource::PrepareTexture()
107 void PrepareTexture() override;
110 * @copydoc Dali::NativeImageSource::GetWidth()
112 unsigned int GetWidth() const override
118 * @copydoc Dali::NativeImageSource::GetHeight()
120 unsigned int GetHeight() const override
126 * @copydoc Dali::NativeImageSource::RequiresBlending()
128 bool RequiresBlending() const override
130 return mBlendingRequired;
134 * @copydoc Dali::NativeImageInterface::GetExtension()
136 NativeImageInterface::Extension* GetNativeImageInterfaceExtension() override
144 * Private constructor; @see NativeImageSource::New()
145 * @param[in] width The width of the image.
146 * @param[in] height The height of the image.
147 * @param[in] colour depth of the image.
148 * @param[in] nativeImageSource contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
150 NativeImageSourceX(unsigned int width,
152 Dali::NativeImageSource::ColorDepth depth,
153 Any nativeImageSource);
156 * 2nd phase construction.
161 * Uses X11 to get the default depth.
162 * @param depth the PixelImage depth enum
163 * @return default x11 pixel depth
165 int GetPixelDepth(Dali::NativeImageSource::ColorDepth depth) const;
168 * Gets the pixmap from the Any parameter
169 * @param pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
170 * @return pixmap x11 pixmap
172 Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
175 * Given an existing pixmap, the function uses X to find out
176 * the width, heigth and depth of that pixmap.
178 void GetPixmapDetails();
182 unsigned int mWidth; ///< image width
183 unsigned int mHeight; ///< image heights
184 bool mOwnPixmap; ///< Whether we created pixmap or not
185 Ecore_X_Pixmap mPixmap; ///< From Xlib
186 bool mBlendingRequired; ///< Whether blending is required
187 Dali::NativeImageSource::ColorDepth mColorDepth; ///< color depth of image
188 void* mEglImageKHR; ///< From EGL extension
189 EglImageExtensions* mEglImageExtensions; ///< The EGL Image Extensions
192 } // namespace Adaptor
194 } // namespace Internal
198 #endif // __DALI_INTERNAL_NATIVE_IMAGE_SOURCE_H__