Revert "Implemented basic CPU image masking"
[platform/core/uifw/dali-core.git] / dali / internal / event / images / pixel-data-impl.h
1 #ifndef DALI_INTERNAL_PIXEL_DATA_H
2 #define DALI_INTERNAL_PIXEL_DATA_H
3
4 /*
5  * Copyright (c) 2017 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/public-api/images/pixel-data.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/devel-api/images/pixel-data-devel.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class PixelData;
33 typedef IntrusivePtr<PixelData> PixelDataPtr;
34
35 class PixelData : public BaseObject
36 {
37 public:
38
39   /**
40    * @brief Create a PixelData object.
41    *
42    * @param [in] buffer           The raw pixel data.
43    * @param [in] bufferSize       The size of the buffer in bytes
44    * @param [in] width            Buffer width in pixels
45    * @param [in] height           Buffer height in pixels
46    * @param [in] pixelFormat      The pixel format
47    * @param [in] releaseFunction  The function used to release the memory.
48    */
49   static PixelDataPtr New( unsigned char* buffer,
50                            unsigned int bufferSize,
51                            unsigned int width,
52                            unsigned int height,
53                            Pixel::Format pixelFormat,
54                            Dali::PixelData::ReleaseFunction releaseFunction);
55
56   /**
57    * @brief Constructor.
58    *
59    * @param [in] buffer           The raw pixel data.
60    * @param [in] bufferSize       The size of the buffer in bytes
61    * @param [in] width            Buffer width in pixels
62    * @param [in] height           Buffer height in pixels
63    * @param [in] pixelFormat      The pixel format
64    * @param [in] releaseFunction  The function used to release the memory.
65    */
66   PixelData( unsigned char* buffer,
67              unsigned int bufferSize,
68              unsigned int width,
69              unsigned int height,
70              Pixel::Format pixelFormat,
71              Dali::PixelData::ReleaseFunction releaseFunction );
72
73 protected:
74
75   /**
76    * @brief Destructor.
77    *
78    * Release the pixel buffer if exists.
79    */
80   ~PixelData();
81
82 public:
83
84   /**
85    * Get the width of the buffer in pixels.
86    * @return The width of the buffer in pixels
87    */
88   unsigned int GetWidth() const;
89
90   /**
91    * Get the height of the buffer in pixels
92    * @return The height of the buffer in pixels
93    */
94   unsigned int GetHeight() const;
95
96   /**
97    * Get the pixel format
98    * @return The pixel format
99    */
100   Pixel::Format GetPixelFormat() const;
101
102   /**
103    * Get the pixel buffer if it's present.
104    * @return The buffer if exists, or NULL if there is no pixel buffer.
105    */
106   unsigned char* GetBuffer() const;
107
108   /**
109    * Get the size of the buffer in bytes
110    * @return The size of the buffer
111    */
112   unsigned int GetBufferSize() const;
113
114   /**
115    * Return the buffer pointer and reset the internal buffer to zero.
116    * @return The buffer pointer and associated data.
117    */
118   DevelPixelData::PixelDataBuffer ReleaseBuffer();
119
120 private:
121
122   /*
123    * Undefined copy constructor.
124    */
125   PixelData(const PixelData& other);
126
127   /*
128    * Undefined assignment operator.
129    */
130   PixelData& operator = (const PixelData& other);
131
132 private:
133
134   unsigned char* mBuffer;           ///< The raw pixel data
135   unsigned int   mBufferSize;       ///< Buffer sized in bytes
136   unsigned int   mWidth;            ///< Buffer width in pixels
137   unsigned int   mHeight;           ///< Buffer height in pixels
138   Pixel::Format  mPixelFormat;      ///< Pixel format
139   Dali::PixelData::ReleaseFunction mReleaseFunction;  ///< Function for releasing memory
140 };
141
142 } // namespace Internal
143
144 /**
145  * Helper methods for public API
146  */
147 inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
148 {
149   DALI_ASSERT_ALWAYS( handle && "handle is empty" );
150
151   BaseObject& object = handle.GetBaseObject();
152
153   return static_cast<Internal::PixelData&>( object );
154 }
155
156 inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
157 {
158   DALI_ASSERT_ALWAYS( handle && "handle is empty" );
159
160   const BaseObject& object = handle.GetBaseObject();
161
162   return static_cast<const Internal::PixelData&>( object );
163 }
164
165 } // namespace Dali
166
167 #endif // __DALI_INTERNAL_PIXEL_DATA_H__