[dali_1.0.46] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / images / bitmap-compressed.h
1 #ifndef __DALI_INTERNAL_COMPRESSED_BITMAP_H__
2 #define __DALI_INTERNAL_COMPRESSED_BITMAP_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 <dali/integration-api/bitmap.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30
31 class BitmapCompressed;
32 typedef IntrusivePtr<BitmapCompressed>        BitmapCompressedPtr;
33
34 /**
35  * BitmapCompressed class.
36  * A container for image data that remains in compresssed form as an opaque blob
37  * in memory rather than being decompressed at load time.
38  * Used for formats that are supported as GLES texture data directly.
39  * \sa{Bitmap BitmapPackedPixel BitmapExternal}
40  */
41 class BitmapCompressed : public Dali::Integration::Bitmap, Dali::Integration::Bitmap::CompressedProfile
42 {
43 public:
44   /**
45    * Constructor
46    * @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
47    */
48   BitmapCompressed( ResourcePolicy::Discardable discardable = ResourcePolicy::RETAIN );
49
50   virtual const Bitmap::CompressedProfile* GetCompressedProfile() const { return this; }
51   virtual Bitmap::CompressedProfile* GetCompressedProfile() { return this; }
52
53 private:
54   /**
55    * Initializes internal class members
56    * @param[in] pixelFormat   pixel format
57    * @param[in] width         Image width in pixels
58    * @param[in] height        Image height in pixels
59    * @param[in] bufferSize    Buffer cpacity in pixels
60    */
61   void Initialize(Pixel::Format pixelFormat,
62                            unsigned int width,
63                            unsigned int height,
64                            const std::size_t bufferSize);
65 public:
66   /**
67    * (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer
68    * is deleted.
69    * Dali has ownership of the buffer, and contents are opaque and immutable.
70    * Bitmap stores given size information about the image which the client is assumed
71    * to have retrieved from out-of-band image metadata.
72    * @param[in] pixelFormat   pixel format
73    * @param[in] width         Image width in pixels
74    * @param[in] height        Image height in pixels
75    * @param[in] bufferSize    Buffer size in bytes
76    * @return pixel buffer pointer
77    */
78   virtual Dali::Integration::PixelBuffer* ReserveBufferOfSize( Pixel::Format pixelFormat,
79                                      const unsigned width,
80                                      const unsigned height,
81                                      const std::size_t numBytes );
82
83   /**
84    * Get the pixel buffer size in bytes
85    * @return The buffer size in bytes.
86    */
87   virtual std::size_t GetBufferSize() const
88   {
89     return mBufferSize;
90   }
91
92 protected:
93
94   /**
95    * A reference counted object may only be deleted by calling Unreference()
96    */
97   virtual ~BitmapCompressed();
98
99 private:
100
101   std::size_t mBufferSize;
102
103   BitmapCompressed(const BitmapCompressed& other);  ///< defined private to prevent use
104   BitmapCompressed& operator = (const BitmapCompressed& other); ///< defined private to prevent use
105
106   // Changes scope, should be at end of class
107   DALI_LOG_OBJECT_STRING_DECLARATION;
108 };
109
110 } // namespace Integration
111
112 } // namespace Dali
113
114 #endif // __DALI_INTERNAL_COMPRESSED_BITMAP_H__