X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fimages%2Fpixel-data-impl.h;h=746d3471e61ee6569c1dd2fb02b792bbde9bf909;hb=c8e0d2807617b0ba441ae67e735512bf6f3c1c68;hp=838403650e5b491183f17fb5a8ac59e699831b76;hpb=e6175d8b3554f4e6a3f7e3c308c73bc6aa26ded2;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/pixel-data-impl.h b/dali/internal/event/images/pixel-data-impl.h index 8384036..746d347 100644 --- a/dali/internal/event/images/pixel-data-impl.h +++ b/dali/internal/event/images/pixel-data-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_PIXEL_DATA_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,23 +19,21 @@ */ // INTERNAL INCLUDES +#include +#include #include #include -#include namespace Dali { - namespace Internal { - class PixelData; using PixelDataPtr = IntrusivePtr; class PixelData : public BaseObject { public: - /** * @brief Create a PixelData object. * @@ -43,15 +41,17 @@ public: * @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 PixelDataPtr New( uint8_t* buffer, - uint32_t bufferSize, - uint32_t width, - uint32_t height, - Pixel::Format pixelFormat, - Dali::PixelData::ReleaseFunction releaseFunction); + static PixelDataPtr New(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, + Pixel::Format pixelFormat, + Dali::PixelData::ReleaseFunction releaseFunction); /** * @brief Constructor. @@ -60,18 +60,19 @@ public: * @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. */ - PixelData( uint8_t* buffer, - uint32_t bufferSize, - uint32_t width, - uint32_t height, - Pixel::Format pixelFormat, - Dali::PixelData::ReleaseFunction releaseFunction ); + PixelData(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t stride, + Pixel::Format pixelFormat, + Dali::PixelData::ReleaseFunction releaseFunction); protected: - /** * @brief Destructor. * @@ -80,7 +81,6 @@ protected: ~PixelData() override; public: - /** * Get the width of the buffer in pixels. * @return The width of the buffer in pixels @@ -117,8 +117,24 @@ public: */ DevelPixelData::PixelDataBuffer ReleaseBuffer(); -private: + /** + * @copydoc PixelData::GetStride() + */ + uint32_t GetStride() const; + /** + * Class method to get the total currently allocated size of pixel buffers + */ + static uint32_t GetTotalAllocatedSize() + { +#if defined(DEBUG_ENABLED) + return gPixelDataAllocationTotal; +#else + return 0; +#endif + } + +private: /* * Undefined copy constructor. */ @@ -127,16 +143,20 @@ private: /* * Undefined assignment operator. */ - PixelData& operator = (const PixelData& other); + PixelData& operator=(const PixelData& other); private: - - 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 - Pixel::Format mPixelFormat; ///< Pixel format - Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory + uint8_t* mBuffer; ///< The raw pixel data + uint32_t mBufferSize; ///< Buffer size in bytes + uint32_t mWidth; ///< Buffer width in pixels + uint32_t mHeight; ///< Buffer height in pixels + uint32_t mStride; ///< Buffer stride in pixels, 0 means the buffer is tightly packed + Pixel::Format mPixelFormat; ///< Pixel format + Dali::PixelData::ReleaseFunction mReleaseFunction; ///< Function for releasing memory + +#if defined(DEBUG_ENABLED) + static uint32_t gPixelDataAllocationTotal; +#endif }; } // namespace Internal @@ -144,22 +164,22 @@ private: /** * Helper methods for public API */ -inline Internal::PixelData& GetImplementation( Dali::PixelData& handle ) +inline Internal::PixelData& GetImplementation(Dali::PixelData& handle) { - DALI_ASSERT_ALWAYS( handle && "handle is empty" ); + DALI_ASSERT_ALWAYS(handle && "handle is empty"); BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); + return static_cast(object); } -inline const Internal::PixelData& GetImplementation( const Dali::PixelData& handle ) +inline const Internal::PixelData& GetImplementation(const Dali::PixelData& handle) { - DALI_ASSERT_ALWAYS( handle && "handle is empty" ); + DALI_ASSERT_ALWAYS(handle && "handle is empty"); const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); + return static_cast(object); } } // namespace Dali