/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
END_TEST;
}
+int UtcDaliEncodedImageBufferNew03(void)
+{
+ // invoke default handle constructor
+ EncodedImageBuffer buffer;
+
+ DALI_TEST_CHECK(!buffer);
+
+ // initialise handle by move operator
+ buffer = EncodedImageBuffer::New(std::move(tinybuffer()), Dali::EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE);
+
+ DALI_TEST_CHECK(buffer);
+ END_TEST;
+}
+
int UtcDaliEncodedImageBufferCopyConstructor(void)
{
EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer());
END_TEST;
}
-
int UtcDaliEncodedImageBufferSetGetType(void)
{
EncodedImageBuffer buffer1 = EncodedImageBuffer::New(tinybuffer());
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
mBufferHash = CalculateHash(mBuffer);
}
+EncodedImageBuffer::EncodedImageBuffer(RawBufferType&& buffer, ImageType type)
+: mBuffer(std::move(buffer)),
+ mType(type)
+{
+ mBufferHash = CalculateHash(mBuffer);
+}
+
EncodedImageBuffer::~EncodedImageBuffer()
{
}
return internal;
}
+IntrusivePtr<EncodedImageBuffer> EncodedImageBuffer::New(RawBufferType&& buffer, ImageType type)
+{
+ IntrusivePtr<EncodedImageBuffer> internal = new EncodedImageBuffer(std::move(buffer), type);
+
+ return internal;
+}
+
const EncodedImageBuffer::RawBufferType& EncodedImageBuffer::GetRawBuffer() const
{
return mBuffer;
using ImageType = Dali::EncodedImageBuffer::ImageType;
/**
- * Constructor
- * @param[in] buffer The raw buffer of image.
- * @param[in] type The type of image.
+ * @copydoc Dali::EncodedImageBuffer::New
*/
- EncodedImageBuffer(const RawBufferType& buffer, ImageType type);
+ static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer, ImageType type);
/**
* @copydoc Dali::EncodedImageBuffer::New
*/
- static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer, ImageType type);
+ static IntrusivePtr<EncodedImageBuffer> New(RawBufferType&& buffer, ImageType type);
/**
* @copydoc Dali::EncodedImageBuffer::GetRawBuffer
protected:
/**
+ * Constructor
+ * @param[in] buffer The raw buffer of image.
+ * @param[in] type The type of image.
+ */
+ EncodedImageBuffer(const RawBufferType& buffer, ImageType type);
+
+ /**
+ * Constructor as moved buffer
+ * @param[in] buffer The raw buffer of image as moved.
+ * @param[in] type The type of image.
+ */
+ EncodedImageBuffer(RawBufferType&& buffer, ImageType type);
+
+ /**
* Destructor
*/
~EncodedImageBuffer();
return EncodedImageBuffer::New(buffer, ImageType::DEFAULT);
}
+EncodedImageBuffer EncodedImageBuffer::New(RawBufferType&& buffer)
+{
+ return EncodedImageBuffer::New(std::move(buffer), ImageType::DEFAULT);
+}
+
EncodedImageBuffer EncodedImageBuffer::New(const RawBufferType& buffer, ImageType type)
{
IntrusivePtr<Internal::EncodedImageBuffer> internal = Internal::EncodedImageBuffer::New(buffer, type);
return EncodedImageBuffer(internal.Get());
}
+EncodedImageBuffer EncodedImageBuffer::New(RawBufferType&& buffer, ImageType type)
+{
+ IntrusivePtr<Internal::EncodedImageBuffer> internal = Internal::EncodedImageBuffer::New(std::move(buffer), type);
+ return EncodedImageBuffer(internal.Get());
+}
+
} // namespace Dali
enum class ImageType
{
REGULAR_IMAGE,
- VECTOR_IMAGE, ///< svg format.
+ VECTOR_IMAGE, ///< svg format.
ANIMATED_VECTOR_IMAGE, ///< lottie format.
DEFAULT = REGULAR_IMAGE,
static EncodedImageBuffer New(const RawBufferType& buffer);
/**
+ * @brief Create a new EncodedImageBuffer. ImageType will be setted as DEFAULT.
+ *
+ * @SINCE_2_0.34
+ * @param [in] buffer The encoded raw buffer as moved
+ * @return A handle to a new EncodedImageBuffer.
+ */
+ static EncodedImageBuffer New(RawBufferType&& buffer);
+
+ /**
* @brief Create a new EncodedImageBuffer with ImageType.
*
* @SINCE_2_2.51
static EncodedImageBuffer New(const RawBufferType& buffer, ImageType type);
/**
+ * @brief Create a new EncodedImageBuffer with ImageType.
+ *
+ * @SINCE_2_2.51
+ * @param [in] buffer The encoded raw buffer as moved
+ * @param [in] type The type hint of encoded raw buffer
+ * @return A handle to a new EncodedImageBuffer.
+ */
+ static EncodedImageBuffer New(RawBufferType&& buffer, ImageType type);
+
+ /**
* @brief Create an empty handle.
*
* @SINCE_2_0.34