[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / render / gl-resources / compressed-bitmap-texture.h
1 #ifndef __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
2 #define __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <string>
22 #include <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/images/bitmap-image.h>
26 #include <dali/internal/common/message.h>
27 #include <dali/internal/render/gl-resources/texture.h>
28 #include <dali/internal/common/bitmap-upload.h>
29 #include <dali/integration-api/bitmap.h>
30 #include <dali/internal/event/images/bitmap-compressed.h>
31 #include <dali/integration-api/debug.h>
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 class CompressedBitmapTexture;
40 typedef IntrusivePtr<CompressedBitmapTexture> CompressedBitmapTexturePointer;
41
42 /**
43  * Compressed Texture class.
44  * If you want to load a file to a CompressedBitmapTexture use
45  * TextureManager::GetTexture()
46  * Compressed textures differ from ordinary ones in that their in-memory
47  * representation cannot be inspected at a pixel level by simple pointer
48  * arithmetic and in that they cannot be partially updated.
49  */
50 class CompressedBitmapTexture : public Texture
51 {
52 public:
53   /**
54    * Constructor
55    * Creates a new texture object from a Bitmap
56    * @param[in] bitmap The Bitmap
57    * @param     context The GL context
58    */
59   CompressedBitmapTexture( Internal::BitmapCompressed* const bitmap, Context& context );
60
61   /**
62    * Destructor.
63    */
64   virtual ~CompressedBitmapTexture();
65
66 public:
67   /**
68    * @copydoc Texture::Init
69    */
70   virtual bool Init();
71
72   /**
73    * @copydoc Texture::GetWidth
74    */
75   virtual unsigned int GetWidth() const;
76
77   /**
78    * @copydoc Texture::GetHeight
79    */
80   virtual unsigned int GetHeight() const;
81
82   /**
83    * @copydoc Texture::HasAlphaChannel
84    */
85   virtual bool HasAlphaChannel() const;
86
87   /**
88    * @copydoc Texture::IsFullyOpaque
89    * Always returns false as we can't know what is going on inside the encoded pixel data. ///!Todo: Revise this decision: Paul, didn't you want the opposite assumption?
90    */
91   virtual bool IsFullyOpaque() const;
92
93   /**
94    * Bitmap has been reloaded - update the texture appropriately.
95    * @param[in] bitmap The new bitmap
96    */
97   virtual void Update( Integration::Bitmap* bitmap );
98
99   /**
100    * @return Return true if the texture should be updated on GL texture creation.
101    */
102   virtual bool UpdateOnCreate();
103
104 protected:
105   /**
106    * @copydoc Texture::CreateGlTexture
107    */
108   virtual bool CreateGlTexture();
109
110 private:
111
112   /**
113    * Assigns the bitmap data to an OpenGL texture
114    * Creates a new texture object and copies
115    * the image data held in the pixels parameter
116    * @param[in] generateTexture True if we should generate a GL texture id
117    * @param[in] pixels The pixel data
118    */
119   void AssignBitmap( bool generateTexture, const unsigned char* pixels, const size_t bufferSize );
120
121 private:
122   Internal::BitmapCompressedPtr mBitmap;      ///< The Bitmap the Texture was created from (may be NULL)
123
124   // Changes scope, should be at end of class
125   DALI_LOG_OBJECT_STRING_DECLARATION;
126 };
127 } //namespace Internal
128 } //namespace Dali
129
130 #endif //__DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__