Fix wayland indicator issue
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / pixmap-image-impl.h
1 #ifndef __DALI_INTERNAL_PIXMAP_IMAGE_H__
2 #define __DALI_INTERNAL_PIXMAP_IMAGE_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <pixmap-image.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34 class EglImageExtensions;
35
36 /**
37  * Dali internal PixmapImage.
38  */
39 class PixmapImage
40 {
41 public:
42
43   /**
44    * Create a new PixmapImage internally.
45    * Depending on hardware the width and height may have to be a power of two.
46    * @param[in] width The width of the image.
47    * @param[in] height The height of the image.
48    * @param[in] depth color depth of the pixmap
49    * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
50    * @return A smart-pointer to a newly allocated image.
51    */
52   static PixmapImage* New(unsigned int width,
53                           unsigned int height,
54                           Dali::PixmapImage::ColorDepth depth,
55                           Any pixmap);
56
57   /**
58    * @copydoc Dali::PixmapImage::GetPixmap()
59    */
60   Any GetPixmap() const;
61
62   /**
63    * @copydoc Dali::PixmapImage::GetPixels()
64    */
65   bool GetPixels(std::vector<unsigned char> &pixbuf, unsigned int &width, unsigned int &height, Pixel::Format& pixelFormat ) const;
66
67   /**
68    * @copydoc Dali::PixmapImage::EncodeToFile(const std::string& )
69    */
70   bool EncodeToFile(const std::string& filename) const;
71
72   /**
73    * destructor
74    */
75   ~PixmapImage();
76
77   /**
78    * @copydoc Dali::PixmapImage::GlExtensionCreate()
79    */
80   bool GlExtensionCreate();
81
82   /**
83    * @copydoc Dali::PixmapImage::GlExtensionDestroy()
84    */
85   void GlExtensionDestroy();
86
87   /**
88    * @copydoc Dali::PixmapImage::TargetTexture()
89    */
90   unsigned int TargetTexture();
91
92   /**
93    * @copydoc Dali::PixmapImage::GetWidth()
94    */
95   unsigned int GetWidth() const
96   {
97     return mWidth;
98   }
99
100   /**
101    * @copydoc Dali::PixmapImage::GetHeight()
102    */
103   unsigned int GetHeight() const
104   {
105     return mHeight;
106   }
107
108   /**
109    * @copydoc Dali::PixmapImage::RequiresBlending()
110    */
111   bool RequiresBlending() const
112   {
113     return mBlendingRequired;
114   }
115
116 private:
117
118   /**
119    * Private constructor; @see PixmapImage::New()
120    * @param[in] width The width of the image.
121    * @param[in] height The height of the image.
122    * @param[in] colour depth of the pixmap
123    * @param[in] pixmap contains either: pixmap of type X11 Pixmap , a Ecore_X_Pixmap or is empty
124    */
125   PixmapImage(unsigned int width,
126               unsigned  int height,
127               Dali::PixmapImage::ColorDepth depth,
128               Any pixmap);
129
130   /**
131    * 2nd phase construction.
132    */
133   void Initialize();
134
135   /**
136    * Decide whether blending is required based on the color depth.
137    * @param depth the PixelImage depth enum
138    */
139   void SetBlending(Dali::PixmapImage::ColorDepth depth);
140
141   /**
142    * Given an existing pixmap, the function uses X to find out
143    * the width, heigth and depth of that pixmap.
144    */
145   void GetPixmapDetails();
146
147 private:
148
149   unsigned int mWidth;                        ///< pixmap width
150   unsigned int mHeight;                       ///< pixmap heights
151   bool mOwnPixmap;                            ///< Whether we created pixmap or not
152   bool mBlendingRequired;                      ///< Whether blending is required
153   Dali::PixmapImage::ColorDepth mColorDepth;  ///< color depth of pixmap
154   void* mEglImageKHR;                         ///< From EGL extension
155   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
156 };
157
158 } // namespace Adaptor
159
160 } // namespace Internal
161
162 } // namespace Dali
163
164 #endif // __DALI_INTERNAL_PIXMAP_IMAGE_H__