/*
- * 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.
}
mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ mGlAbstraction->PixelStorei(GL_UNPACK_ROW_LENGTH, info.srcStride);
+
mCurrentContext->BindTexture(bindTarget, texture->GetTextureTypeId(), texture->GetGLTexture());
if(!isSubImage)
/*
- * 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.
unsigned int bufferSize,
unsigned int width,
unsigned int height,
+ unsigned int stride,
Dali::Pixel::Format pixelFormat)
: mMetadata(),
mBuffer(buffer),
mBufferSize(bufferSize),
mWidth(width),
mHeight(height),
+ mStride(stride ? stride : width),
mPixelFormat(pixelFormat),
mPreMultiplied(false)
{
{
buffer = static_cast<unsigned char*>(malloc(bufferSize));
}
- return new PixelBuffer(buffer, bufferSize, width, height, pixelFormat);
+ return new PixelBuffer(buffer, bufferSize, width, height, width, pixelFormat);
}
PixelBufferPtr PixelBuffer::New(unsigned char* buffer,
unsigned int bufferSize,
unsigned int width,
unsigned int height,
+ unsigned int stride,
Dali::Pixel::Format pixelFormat)
{
- return new PixelBuffer(buffer, bufferSize, width, height, pixelFormat);
+ return new PixelBuffer(buffer, bufferSize, width, height, stride, pixelFormat);
}
Dali::PixelData PixelBuffer::Convert(PixelBuffer& pixelBuffer)
pixelBuffer.mBufferSize,
pixelBuffer.mWidth,
pixelBuffer.mHeight,
+ pixelBuffer.mStride,
pixelBuffer.mPixelFormat,
Dali::PixelData::FREE);
pixelBuffer.mBuffer = NULL;
pixelBuffer.mWidth = 0;
pixelBuffer.mHeight = 0;
pixelBuffer.mBufferSize = 0;
+ pixelBuffer.mStride = 0;
return pixelData;
}
return mHeight;
}
+uint32_t PixelBuffer::GetStride() const
+{
+ return mStride;
+}
+
Dali::Pixel::Format PixelBuffer::GetPixelFormat() const
{
return mPixelFormat;
memcpy(destBuffer, mBuffer, mBufferSize);
}
- Dali::PixelData pixelData = Dali::PixelData::New(destBuffer, mBufferSize, mWidth, mHeight, mPixelFormat, Dali::PixelData::FREE);
+ Dali::PixelData pixelData = Dali::PixelData::New(destBuffer, mBufferSize, mWidth, mHeight, mStride, mPixelFormat, Dali::PixelData::FREE);
return pixelData;
}
mBufferSize = pixelBuffer.mBufferSize;
mWidth = pixelBuffer.mWidth;
mHeight = pixelBuffer.mHeight;
+ mStride = pixelBuffer.mStride;
mPixelFormat = pixelBuffer.mPixelFormat;
}
#define DALI_INTERNAL_ADAPTOR_PIXEL_BUFFER_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.
*/
static PixelBufferPtr New(unsigned char* buffer,
unsigned int bufferSize,
unsigned int width,
unsigned int height,
+ unsigned int stride,
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
*/
PixelBuffer(unsigned char* buffer,
unsigned int bufferSize,
unsigned int width,
unsigned int height,
+ unsigned int stride,
Pixel::Format pixelFormat);
protected:
unsigned int 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.
+ */
+ unsigned int GetStride() const;
+
+ /**
* Get the pixel format
* @return The pixel format
*/
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
};