1 #ifndef DALI_INTERNAL_PIXEL_DATA_H
2 #define DALI_INTERNAL_PIXEL_DATA_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
33 typedef IntrusivePtr<PixelData> PixelDataPtr;
35 class PixelData : public BaseObject
40 * @brief Create a PixelData object.
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.
49 static PixelDataPtr New( uint8_t* buffer,
53 Pixel::Format pixelFormat,
54 Dali::PixelData::ReleaseFunction releaseFunction);
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.
66 PixelData( uint8_t* buffer,
70 Pixel::Format pixelFormat,
71 Dali::PixelData::ReleaseFunction releaseFunction );
78 * Release the pixel buffer if exists.
85 * Get the width of the buffer in pixels.
86 * @return The width of the buffer in pixels
88 uint32_t GetWidth() const;
91 * Get the height of the buffer in pixels
92 * @return The height of the buffer in pixels
94 uint32_t GetHeight() const;
97 * Get the pixel format
98 * @return The pixel format
100 Pixel::Format GetPixelFormat() const;
103 * Get the pixel buffer if it's present.
104 * @return The buffer if exists, or NULL if there is no pixel buffer.
106 uint8_t* GetBuffer() const;
109 * Get the size of the buffer in bytes
110 * @return The size of the buffer
112 uint32_t GetBufferSize() const;
115 * Return the buffer pointer and reset the internal buffer to zero.
116 * @return The buffer pointer and associated data.
118 DevelPixelData::PixelDataBuffer ReleaseBuffer();
123 * Undefined copy constructor.
125 PixelData(const PixelData& other);
128 * Undefined assignment operator.
130 PixelData& operator = (const PixelData& other);
134 uint8_t* mBuffer; ///< The raw pixel data
135 uint32_t mBufferSize; ///< Buffer sized in bytes
136 uint32_t mWidth; ///< Buffer width in pixels
137 uint32_t mHeight; ///< Buffer height in pixels
138 Pixel::Format mPixelFormat; ///< Pixel format
139 Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory
142 } // namespace Internal
145 * Helper methods for public API
147 inline Internal::PixelData& GetImplementation( Dali::PixelData& handle )
149 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
151 BaseObject& object = handle.GetBaseObject();
153 return static_cast<Internal::PixelData&>( object );
156 inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle )
158 DALI_ASSERT_ALWAYS( handle && "handle is empty" );
160 const BaseObject& object = handle.GetBaseObject();
162 return static_cast<const Internal::PixelData&>( object );
167 #endif // __DALI_INTERNAL_PIXEL_DATA_H__