/*
- * Copyright (c) 2023 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.
uint32_t byteSize = bytesPerPixel * xFaceSize * yFaceSize;
uint8_t* destBuffer = reinterpret_cast<uint8_t*>(malloc(byteSize + 4u));
- int32_t srcStride = width * bytesPerPixel;
- int32_t destStride = xFaceSize * bytesPerPixel;
- int32_t srcOffset = xOffset * bytesPerPixel + yOffset * srcStride;
- int32_t destOffset = 0;
- for(uint16_t row = yOffset; row < yOffset + yFaceSize; ++row)
+ if(DALI_LIKELY(destBuffer))
{
- memcpy(destBuffer + destOffset, sourceBuffer + srcOffset, destStride);
- srcOffset += srcStride;
- destOffset += destStride;
+ int32_t srcStride = width * bytesPerPixel;
+ int32_t destStride = xFaceSize * bytesPerPixel;
+ int32_t srcOffset = xOffset * bytesPerPixel + yOffset * srcStride;
+ int32_t destOffset = 0;
+ for(uint16_t row = yOffset; row < yOffset + yFaceSize; ++row)
+ {
+ memcpy(destBuffer + destOffset, sourceBuffer + srcOffset, destStride);
+ srcOffset += srcStride;
+ destOffset += destStride;
+ }
+ }
+ else
+ {
+ DALI_LOG_ERROR("malloc is failed. request malloc size : %u\n", byteSize + 4u);
}
return destBuffer;
uint32_t finalFaceWidth = (xOffset + static_cast<uint32_t>(faceWidth) < imageWidth) ? static_cast<uint32_t>(faceWidth) : imageWidth - xOffset;
uint32_t finalFaceHeight = (yOffset + static_cast<uint32_t>(faceHeight) < imageHeight) ? static_cast<uint32_t>(faceHeight) : imageHeight - yOffset;
uint8_t* tempImageBuffer = GetCroppedBuffer(imageBuffer, bytesPerPixel, imageWidth, imageHeight, xOffset, yOffset, finalFaceWidth, finalFaceHeight);
- cubeFacePixelData = PixelData::New(tempImageBuffer, finalFaceWidth * finalFaceHeight * bytesPerPixel, finalFaceWidth, finalFaceHeight, imagePixelFormat, PixelData::FREE);
+
+ if(DALI_LIKELY(tempImageBuffer))
+ {
+ cubeFacePixelData = Dali::Integration::NewPixelDataWithReleaseAfterUpload(tempImageBuffer, finalFaceWidth * finalFaceHeight * bytesPerPixel, finalFaceWidth, finalFaceHeight, 0u, imagePixelFormat, PixelData::FREE);
+ }
}
}
return cubeFacePixelData;