/*
- * Copyright (c) 2020 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.
DALI_TEST_CHECK(pixelData);
DALI_TEST_CHECK(pixelData.GetWidth() == width);
DALI_TEST_CHECK(pixelData.GetHeight() == height);
+ DALI_TEST_CHECK(pixelData.GetStride() == 0);
+ DALI_TEST_CHECK(pixelData.GetPixelFormat() == Pixel::L8);
+
+ END_TEST;
+}
+
+int UtcDaliPixelData03(void)
+{
+ TestApplication application;
+
+ uint32_t width = 10u;
+ uint32_t height = 10u;
+ uint32_t stride = 12u;
+ uint32_t bufferSize = stride * height * Pixel::GetBytesPerPixel(Pixel::RGB888);
+
+ uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
+ PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, stride, Pixel::RGB888, PixelData::FREE);
+
+ DALI_TEST_CHECK(pixelData);
+ DALI_TEST_CHECK(pixelData.GetWidth() == width);
+ DALI_TEST_CHECK(pixelData.GetHeight() == height);
+ DALI_TEST_CHECK(pixelData.GetStride() == stride);
+ DALI_TEST_CHECK(pixelData.GetPixelFormat() == Pixel::RGB888);
+
+ END_TEST;
+}
+
+int UtcDaliPixelData04(void)
+{
+ TestApplication application;
+
+ uint32_t width = 10u;
+ uint32_t height = 10u;
+ uint32_t stride = 12u;
+ uint32_t bufferSize = stride * height * Pixel::GetBytesPerPixel(Pixel::L8);
+ uint8_t* buffer = new uint8_t[bufferSize];
+ buffer[0] = 'a';
+
+ PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, stride, Pixel::L8, PixelData::DELETE_ARRAY);
+
+ DALI_TEST_CHECK(pixelData);
+ DALI_TEST_CHECK(pixelData.GetWidth() == width);
+ DALI_TEST_CHECK(pixelData.GetHeight() == height);
+ DALI_TEST_CHECK(pixelData.GetStride() == stride);
DALI_TEST_CHECK(pixelData.GetPixelFormat() == Pixel::L8);
END_TEST;
#define DALI_GRAPHICS_API_TYPES
/*
- * Copyright (c) 2021 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.
Extent2D srcExtent2D{};
uint32_t srcOffset{};
uint32_t srcSize{};
+ uint32_t srcStride{};
Format srcFormat{}; ///< Should match dstTexture's format, otherwise conversion may occur
};
/*
- * Copyright (c) 2021 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.
uint32_t bufferSize,
uint32_t width,
uint32_t height,
+ uint32_t stride,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction)
: mBuffer(buffer),
mBufferSize(bufferSize),
mWidth(width),
mHeight(height),
+ mStride(stride),
mPixelFormat(pixelFormat),
mReleaseFunction(releaseFunction)
{
uint32_t bufferSize,
uint32_t width,
uint32_t height,
+ uint32_t stride,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction)
{
- return new PixelData(buffer, bufferSize, width, height, pixelFormat, releaseFunction);
+ return new PixelData(buffer, bufferSize, width, height, stride, pixelFormat, releaseFunction);
}
uint32_t PixelData::GetWidth() const
return pixelDataBuffer;
}
+uint32_t PixelData::GetStride() const
+{
+ return mStride;
+}
+
} // namespace Internal
} // namespace Dali
#define DALI_INTERNAL_PIXEL_DATA_H
/*
- * Copyright (c) 2021 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.
* @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.
*/
uint32_t bufferSize,
uint32_t width,
uint32_t height,
+ uint32_t stride,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction);
* @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.
*/
uint32_t bufferSize,
uint32_t width,
uint32_t height,
+ uint32_t stride,
Pixel::Format pixelFormat,
Dali::PixelData::ReleaseFunction releaseFunction);
*/
DevelPixelData::PixelDataBuffer ReleaseBuffer();
+ /**
+ * @copydoc PixelData::GetStride()
+ */
+ uint32_t GetStride() const;
+
private:
/*
* Undefined copy constructor.
private:
uint8_t* mBuffer; ///< The raw pixel data
- uint32_t mBufferSize; ///< Buffer sized in bytes
+ 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
};
/*
- * Copyright (c) 2021 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.
info.srcExtent2D = {params.width, params.height};
info.srcOffset = 0;
info.srcSize = pixelData->GetBufferSize();
+ info.srcStride = pixelData->GetStride();
info.srcFormat = ConvertPixelFormat(pixelData->GetPixelFormat());
Graphics::TextureUpdateSourceInfo updateSourceInfo{};
/*
- * Copyright (c) 2020 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.
Pixel::Format pixelFormat,
ReleaseFunction releaseFunction)
{
- IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New(buffer, bufferSize, width, height, pixelFormat, releaseFunction);
+ IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New(buffer, bufferSize, width, height, 0, pixelFormat, releaseFunction);
+ return PixelData(internal.Get());
+}
+
+PixelData PixelData::New(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride,
+ Pixel::Format pixelFormat,
+ ReleaseFunction releaseFunction)
+{
+ IntrusivePtr<Internal::PixelData> internal = Internal::PixelData::New(buffer, bufferSize, width, height, stride, pixelFormat, releaseFunction);
return PixelData(internal.Get());
}
return GetImplementation(*this).GetPixelFormat();
}
+uint32_t PixelData::GetStride() const
+{
+ return GetImplementation(*this).GetStride();
+}
+
} // namespace Dali
#define DALI_PIXEL_DATA_H
/*
- * Copyright (c) 2020 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.
ReleaseFunction releaseFunction);
/**
+ * @brief Creates a PixelData object.
+ *
+ * @param[in] buffer The raw pixel data
+ * @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
+ * @return A handle to the PixelData
+ */
+ static PixelData New(uint8_t* buffer,
+ uint32_t bufferSize,
+ uint32_t width,
+ uint32_t height,
+ uint32_t stride,
+ Pixel::Format pixelFormat,
+ ReleaseFunction releaseFunction);
+ /**
* @brief Creates an empty handle.
* Use PixelData::New() to create an initialized object.
*
*/
Pixel::Format GetPixelFormat() 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;
+
public:
/**
* @brief The constructor.