#define DALI_INTERNAL_ADAPTOR_PIXEL_BUFFER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/integration-api/debug.h>
#include <dali/public-api/images/image-operations.h> // For ImageDimensions
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/base-object.h>
* @param [in] height Buffer height in pixels
* @param [in] pixelFormat The pixel format
*/
- static PixelBufferPtr New(unsigned int width,
- unsigned int height,
+ static PixelBufferPtr New(uint32_t width,
+ uint32_t height,
Pixel::Format pixelFormat);
/**
* @param [in] bufferSize The size of the buffer in bytes
* @param [in] width Buffer width in pixels
* @param [in] height Buffer height in pixels
+ * @param [in] stride Buffer stride in pixels, 0 means the buffer is tightly packed
* @param [in] pixelFormat The pixel format
- * @param [in] releaseFunction The function used to release the memory.
*/
- static PixelBufferPtr New(unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat);
+ static PixelBufferPtr New(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride,
+ Pixel::Format pixelFormat);
/**
* Convert a pixelBuffer object into a PixelData object.
* The new object takes ownership of the buffer data, and the
* mBuffer pointer is reset to NULL.
* @param[in] pixelBuffer The buffer to convert
+ * @param[in] releaseAfterUpload Whether converted PixelData released after upload or not.
* @return the pixelData
*/
- static Dali::PixelData Convert(PixelBuffer& pixelBuffer);
+ static Dali::PixelData Convert(PixelBuffer& pixelBuffer, bool releaseAfterUpload);
/**
* @brief Constructor.
* @param [in] bufferSize The size of the buffer in bytes
* @param [in] width Buffer width in pixels
* @param [in] height Buffer height in pixels
+ * @param [in] stride Buffer stride in pixels, 0 means the buffer is tightly packed
* @param [in] pixelFormat The pixel format
*/
- PixelBuffer(unsigned char* buffer,
- unsigned int bufferSize,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat);
+ PixelBuffer(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride,
+ Pixel::Format pixelFormat);
protected:
/**
public:
/**
+ * Get the total allocated size of current pixel buffers
+ */
+ static uint32_t GetTotalAllocatedSize()
+ {
+#if defined(DEBUG_ENABLED)
+ return gPixelBufferAllocationTotal;
+#else
+ return 0;
+#endif
+ }
+
+ /**
* Get the width of the buffer in pixels.
* @return The width of the buffer in pixels
*/
- unsigned int GetWidth() const;
+ uint32_t GetWidth() const;
/**
* Get the height of the buffer in pixels
* @return The height of the buffer in pixels
*/
- unsigned int GetHeight() const;
+ uint32_t GetHeight() const;
+
+ /**
+ * @brief Gets the stride of the buffer in pixels.
+ * @return The stride of the buffer in pixels. 0 means the buffer is tightly packed.
+ */
+ uint32_t GetStride() const;
/**
* Get the pixel format
* Get the pixel buffer if it's present.
* @return The buffer if exists, or NULL if there is no pixel buffer.
*/
- unsigned char* GetBuffer() const;
+ uint8_t* GetBuffer() const;
/**
* @copydoc Devel::PixelBuffer::GetBuffer()
*/
- const unsigned char* const GetConstBuffer() const;
+ const uint8_t* GetConstBuffer() const;
/**
* Get the size of the buffer in bytes
* @return The size of the buffer
*/
- unsigned int GetBufferSize() const;
+ uint32_t GetBufferSize() const;
/**
* Copy the buffer into a new PixelData
private:
std::unique_ptr<Property::Map> mMetadata; ///< Metadata fields
- unsigned char* mBuffer; ///< The raw pixel data
- unsigned int mBufferSize; ///< Buffer sized in bytes
- unsigned int mWidth; ///< Buffer width in pixels
- unsigned int mHeight; ///< Buffer height in pixels
+ uint8_t* mBuffer; ///< The raw pixel data
+ uint32_t mBufferSize; ///< Buffer sized in bytes
+ uint32_t mWidth; ///< Buffer width in pixels
+ uint32_t mHeight; ///< Buffer height in pixels
+ uint32_t mStride; ///< Buffer stride in bytes, 0 means the buffer is tightly packed
Pixel::Format mPixelFormat; ///< Pixel format
bool mPreMultiplied; ///< PreMultiplied
+
+#if defined(DEBUG_ENABLED)
+ static uint32_t gPixelBufferAllocationTotal;
+#endif
};
} // namespace Adaptor