1 #ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
2 #define __DALI_INTERNAL_PIXMAP_IMAGE_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.
23 #include <pixmap-image.h>
36 class EglImageExtensions;
39 * Dali internal PixmapImage.
46 * Create a new PixmapImage internally.
47 * Depending on hardware the width and height may have to be a power of two.
48 * @param[in] width The width of the image.
49 * @param[in] height The height of the image.
50 * @param[in] depth color depth of the pixmap
51 * @param[in] adaptor reference to dali adaptor
52 * @param[in] pixmap 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 PixmapImage* New(unsigned int width,
57 Dali::PixmapImage::ColorDepth depth,
58 Dali::Adaptor& adaptor,
62 * @copydoc Dali::PixmapImage::GetPixmap()
64 Any GetPixmap(Dali::PixmapImage::PixmapAPI api) const;
67 * @copydoc Dali::PixmapImage::GetDisplay()
69 Any GetDisplay() const;
72 * @copydoc Dali::PixmapImage::GetPixels()
74 bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
77 * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
79 bool EncodeToFile(const std::string& filename) const;
87 * @copydoc Dali::PixmapImage::GlExtensionCreate()
89 bool GlExtensionCreate();
92 * @copydoc Dali::PixmapImage::GlExtensionDestroy()
94 void GlExtensionDestroy();
97 * @copydoc Dali::PixmapImage::TargetTexture()
99 unsigned int TargetTexture();
102 * @copydoc Dali::PixmapImage::GetWidth()
104 unsigned int GetWidth() const
110 * @copydoc Dali::PixmapImage::GetHeight()
112 unsigned int GetHeight() const
118 * @copydoc Dali::PixmapImage::GetPixelFormat()
120 Pixel::Format GetPixelFormat() const
128 * Private constructor; @see PixmapImage::New()
129 * @param[in] width The width of the image.
130 * @param[in] height The height of the image.
131 * @param[in] colour depth of the pixmap
132 * @param[in] adaptor a reference to Dali adaptor
133 * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
135 PixmapImage(unsigned int width,
137 Dali::PixmapImage::ColorDepth depth,
138 Dali::Adaptor &adaptor,
142 * 2nd phase construction.
147 * Uses X11 to get the default depth.
148 * @param depth the PixelImage depth enum
149 * @return default x11 pixel depth
151 int GetPixelDepth(Dali::PixmapImage::ColorDepth depth) const;
154 * Sets the pixel format based on the bit depth
155 * @param depth depth in bytes
157 void SetPixelFormat(int depth);
160 * Gets the pixmap from the Any parameter
161 * @param pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
162 * @return pixmap x11 pixmap
164 Ecore_X_Pixmap GetPixmapFromAny(Any pixmap) const;
167 * Given an existing pixmap, the function uses X to find out
168 * the width, heigth and depth of that pixmap.
170 void GetPixmapDetails();
173 * Returns the egl image extensions class from the adaptor
174 * @return reference to egl image extensionsa
176 EglImageExtensions* GetEglImageExtensions() const;
180 unsigned int mWidth; ///< pixmap width
181 unsigned int mHeight; ///< pixmap heights
182 bool mOwnPixmap; ///< Whether we created pixmap or not
183 Ecore_X_Pixmap mPixmap; ///< From Xlib
184 Ecore_X_Display* mDisplay; ///< x-connection used to create pixmap (if it was not created outside of PixmapImage)
185 Pixel::Format mPixelFormat; ///< pixmap pixel format
186 Dali::PixmapImage::ColorDepth mColorDepth; ///< color depth of pixmap
187 Adaptor& mAdaptor; ///< adaptor
188 void* mEglImageKHR; ///< From EGL extension
191 } // namespace Adaptor
193 } // namespace Internal
197 #endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__