Use modern construct 'using' instead of typedef.
[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) 2019 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 using BitmapCompressedPtr = IntrusivePtr<BitmapCompressed>;
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  */
40 class BitmapCompressed : public Dali::Integration::Bitmap, Dali::Integration::Bitmap::CompressedProfile
41 {
42 public:
43   /**
44    * Constructor
45    * @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data.
46    */
47   BitmapCompressed( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN );
48
49   virtual const Bitmap::CompressedProfile* GetCompressedProfile() const { return this; }
50   virtual Bitmap::CompressedProfile* GetCompressedProfile() { return this; }
51
52 private:
53   /**
54    * Initializes internal class members
55    * @param[in] pixelFormat   pixel format
56    * @param[in] width         Image width in pixels
57    * @param[in] height        Image height in pixels
58    * @param[in] bufferSize    Buffer cpacity in pixels
59    */
60   void Initialize(Pixel::Format pixelFormat,
61                            uint32_t width,
62                            uint32_t height,
63                            uint32_t bufferSize);
64 public:
65   /**
66    * (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer
67    * is deleted.
68    * Dali has ownership of the buffer, and contents are opaque and immutable.
69    * Bitmap stores given size information about the image which the client is assumed
70    * to have retrieved from out-of-band image metadata.
71    * @param[in] pixelFormat   pixel format
72    * @param[in] width         Image width in pixels
73    * @param[in] height        Image height in pixels
74    * @param[in] bufferSize    Buffer size in bytes
75    * @return pixel buffer pointer
76    */
77   virtual Dali::Integration::PixelBuffer* ReserveBufferOfSize( Pixel::Format pixelFormat,
78                                      const uint32_t width,
79                                      const uint32_t height,
80                                      const uint32_t numBytes );
81
82   /**
83    * Get the pixel buffer size in bytes
84    * @return The buffer size in bytes.
85    */
86   virtual uint32_t GetBufferSize() const
87   {
88     return mBufferSize;
89   }
90
91   /**
92    * See Dali::Integration::Bitmap::GetReleaseFunction()
93    */
94   ReleaseFunction GetReleaseFunction(){ return FREE; }
95
96 protected:
97
98   /**
99    * A reference counted object may only be deleted by calling Unreference()
100    */
101   virtual ~BitmapCompressed();
102
103 private:
104
105   uint32_t mBufferSize;
106
107   BitmapCompressed(const BitmapCompressed& other);  ///< defined private to prevent use
108   BitmapCompressed& operator = (const BitmapCompressed& other); ///< defined private to prevent use
109
110   // Changes scope, should be at end of class
111   DALI_LOG_OBJECT_STRING_DECLARATION;
112 };
113
114 } // namespace Integration
115
116 } // namespace Dali
117
118 #endif // DALI_INTERNAL_COMPRESSED_BITMAP_H