Distinguish NativeImage from Image & Clean PixelFormat from ImageAttribute and Texture
[platform/core/uifw/dali-core.git] / dali / internal / update / resources / bitmap-metadata.h
1 #ifndef __DALI_BITMAP_METADATA_H__
2 #define  __DALI_BITMAP_METADATA_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 // INTERNAL INCLUDES
22 #include <dali/integration-api/bitmap.h>
23 #include <dali/public-api/images/pixel.h>
24 #include <dali/public-api/images/native-image-interface.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30
31 /**
32  * Texture class.
33  */
34 class BitmapMetadata
35 {
36 public:
37   /**
38    * Creates a BitmapMetadata object from a native image (eg.: EGLImage).
39    * @param[in] nativeImage The native image to load
40    * @return A newly allocated BitmapMetadata
41    */
42   static BitmapMetadata New(NativeImageInterfacePtr nativeImage);
43
44   /**
45    * Creates a new BitmapMetadata object from a Bitmap
46    * @param[in] bitmap The bitmap
47    * @return A newly allocated BitmapMetadata
48    */
49   static BitmapMetadata New(Integration::Bitmap* const bitmap);
50
51   /**
52    * Creates a new BitmapMetadata object from framebuffer metadata
53    * @return A newly allocated BitmapMetadata
54    */
55   static BitmapMetadata New(unsigned int width, unsigned int height, bool hasAlphaChannel);
56
57   /**
58    * Constructor
59    */
60   BitmapMetadata( unsigned int width, unsigned int height, bool hasAlphaChanne, bool opaqueness );
61
62   /**
63    * Copy constructor
64    */
65   BitmapMetadata( const BitmapMetadata& rhs );
66
67   /**
68    * Assignment operator
69    */
70   BitmapMetadata& operator=( const BitmapMetadata& rhs );
71
72   /**
73    * Default Constructor
74    */
75   BitmapMetadata();
76
77   /**
78    * Updates the metadata with information from the native image
79    * @param[in] nativeImage The native image that was updated
80    */
81   void Update(NativeImageInterfacePtr nativeImage);
82
83   /**
84    * Updates the metadata with information from the bitmap
85    * @param[in] bitmap The bitmap that was updated
86    */
87   void Update(Integration::Bitmap* const bitmap);
88
89   /**
90    * Return the width of image in pixels.
91    * @return width
92    */
93   unsigned int GetWidth() const;
94
95   /**
96    * Return the height of image in pixels.
97    * @return height
98    */
99   unsigned int GetHeight() const;
100
101   /**
102    * Query whether the texture data has an alpha channel.
103    * @return True if the texture data has an alpha channel.
104    */
105   bool HasAlphaChannel() const;
106
107   /**
108    * Query whether the texture is completely opaque
109    * @return True if all pixels of the texture data are opaque
110    */
111   bool IsFullyOpaque() const;
112
113   /**
114    * Set the width of image
115    * @param[in] width The width of the image
116    */
117   void SetWidth(unsigned int width);
118
119   /**
120    * Set the height of image
121    * @param[in] height The height of the image in pixels
122    */
123   void SetHeight(unsigned int height);
124
125   /**
126    * Set whether the texture has alpha channel
127    * @param[in] hasAlphaChannel whether the texture has alpha channel
128    */
129   void SetHasAlphaChannel( bool hasAlphaChannel );
130
131   /**
132    * Set whether the texture is completely opaque, i.e.
133    * true if all pixels of the texture data are opaque.
134    * @param[in] opaqueness If the alpha channel is set to fully opaque.
135    */
136   void SetOpaqueness(bool opaqueness);
137
138   void SetIsNativeImage( bool isNativeImage );
139   bool GetIsNativeImage( );
140   void SetIsFramebuffer( bool isFramebuffer );
141   bool GetIsFramebuffer( );
142
143 private:
144   unsigned int  mImageWidth;      ///< width of the original image
145   unsigned int  mImageHeight;     ///< height of the original image
146   bool          mHasAlphaChannel:1; ///< Pixel format of the contained image data.
147   bool          mOpaqueness:1;    ///< Whether the bitmap was fully opaque when loaded / updated
148   bool          mIsNativeImage:1; ///< Whether the image is native or not
149   bool          mIsFramebuffer:1; ///< Whether the image is an FBO
150 };
151
152 } // namespace Internal
153
154 } // namespace Dali
155
156 #endif // __DALI_BITMAP_METADATA_H__