test_return_value = TET_PASS;
}
-int UtcDaliEncodedImageBufferNew(void)
+int UtcDaliEncodedImageBufferNew01(void)
{
// invoke default handle constructor
EncodedImageBuffer buffer;
END_TEST;
}
+int UtcDaliEncodedImageBufferNew02(void)
+{
+ // invoke default handle constructor
+ EncodedImageBuffer buffer;
+
+ DALI_TEST_CHECK(!buffer);
+
+ // initialise handle
+ buffer = EncodedImageBuffer::New(tinybuffer(), Dali::EncodedImageBuffer::ImageType::VECTOR_IMAGE);
+
+ DALI_TEST_CHECK(buffer);
+ END_TEST;
+}
+
int UtcDaliEncodedImageBufferCopyConstructor(void)
{
EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer());
DALI_TEST_CHECK(buffer1.GetHash() != buffer3.GetHash());
DALI_TEST_CHECK(buffer2.GetHash() != buffer3.GetHash());
+ END_TEST;
+}
+
+
+int UtcDaliEncodedImageBufferSetGetType(void)
+{
+ EncodedImageBuffer buffer1 = EncodedImageBuffer::New(tinybuffer());
+ EncodedImageBuffer buffer2 = buffer1; ///< Copy handle
+
+ DALI_TEST_CHECK(buffer1);
+ DALI_TEST_CHECK(buffer2);
+ DALI_TEST_CHECK(buffer1 == buffer2);
+ DALI_TEST_CHECK(buffer1.GetHash() == buffer2.GetHash());
+
+ DALI_TEST_EQUALS(buffer1.GetImageType(), Dali::EncodedImageBuffer::ImageType::DEFAULT, TEST_LOCATION);
+ DALI_TEST_EQUALS(buffer2.GetImageType(), Dali::EncodedImageBuffer::ImageType::DEFAULT, TEST_LOCATION);
+
+ buffer1.SetImageType(Dali::EncodedImageBuffer::ImageType::VECTOR_IMAGE);
+
+ DALI_TEST_EQUALS(buffer1.GetImageType(), Dali::EncodedImageBuffer::ImageType::VECTOR_IMAGE, TEST_LOCATION);
+ DALI_TEST_EQUALS(buffer2.GetImageType(), Dali::EncodedImageBuffer::ImageType::VECTOR_IMAGE, TEST_LOCATION);
+
+ buffer2.SetImageType(Dali::EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE);
+
+ DALI_TEST_EQUALS(buffer1.GetImageType(), Dali::EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE, TEST_LOCATION);
+ DALI_TEST_EQUALS(buffer2.GetImageType(), Dali::EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE, TEST_LOCATION);
+
END_TEST;
}
\ No newline at end of file
*/
// CLASS HEADER
-#include "encoded-image-buffer-impl.h"
+#include <dali/internal/imaging/common/encoded-image-buffer-impl.h>
// EXTERNAL INCLUDE
#include <dali/devel-api/common/hash.h>
{
namespace Internal
{
-EncodedImageBuffer::EncodedImageBuffer(const RawBufferType& buffer)
-: mBuffer(buffer)
+EncodedImageBuffer::EncodedImageBuffer(const RawBufferType& buffer, ImageType type)
+: mBuffer(buffer),
+ mType(type)
{
mBufferHash = CalculateHash(mBuffer);
}
{
}
-IntrusivePtr<EncodedImageBuffer> EncodedImageBuffer::New(const RawBufferType& buffer)
+IntrusivePtr<EncodedImageBuffer> EncodedImageBuffer::New(const RawBufferType& buffer, ImageType type)
{
- IntrusivePtr<EncodedImageBuffer> internal = new EncodedImageBuffer(buffer);
+ IntrusivePtr<EncodedImageBuffer> internal = new EncodedImageBuffer(buffer, type);
return internal;
}
return mBuffer;
}
-const std::size_t EncodedImageBuffer::GetHash() const
+std::size_t EncodedImageBuffer::GetHash() const
{
return mBufferHash;
}
+void EncodedImageBuffer::SetImageType(Dali::EncodedImageBuffer::ImageType type)
+{
+ mType = type;
+}
+
+Dali::EncodedImageBuffer::ImageType EncodedImageBuffer::GetImageType() const
+{
+ return mType;
+}
+
} // namespace Internal
} // namespace Dali
#define DALI_ENCODED_IMAGE_BUFFER_IMPL_H
/*
- * 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.
{
public:
using RawBufferType = Dali::EncodedImageBuffer::RawBufferType;
+ using ImageType = Dali::EncodedImageBuffer::ImageType;
/**
* Constructor
- * @param [in] buffer The raw buffer of image.
+ * @param[in] buffer The raw buffer of image.
+ * @param[in] type The type of image.
*/
- EncodedImageBuffer(const RawBufferType& buffer);
+ EncodedImageBuffer(const RawBufferType& buffer, ImageType type);
/**
* @copydoc Dali::EncodedImageBuffer::New
*/
- static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer);
+ static IntrusivePtr<EncodedImageBuffer> New(const RawBufferType& buffer, ImageType type);
/**
* @copydoc Dali::EncodedImageBuffer::GetRawBuffer
/**
* @copydoc Dali::EncodedImageBuffer::GetHash
*/
- const std::size_t GetHash() const;
+ std::size_t GetHash() const;
+
+ /**
+ * @copydoc Dali::EncodedImageBuffer::SetImageType
+ */
+ void SetImageType(ImageType type);
+
+ /**
+ * @copydoc Dali::EncodedImageBuffer::GetImageType
+ */
+ ImageType GetImageType() const;
protected:
/**
private:
Dali::Vector<uint8_t> mBuffer;
std::size_t mBufferHash;
+ ImageType mType;
};
} // namespace Internal
/*
- * 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.
return GetImplementation(*this).GetRawBuffer();
}
-const std::size_t EncodedImageBuffer::GetHash() const
+std::size_t EncodedImageBuffer::GetHash() const
{
return GetImplementation(*this).GetHash();
}
+void EncodedImageBuffer::SetImageType(ImageType type)
+{
+ GetImplementation(*this).SetImageType(type);
+}
+
+EncodedImageBuffer::ImageType EncodedImageBuffer::GetImageType() const
+{
+ return GetImplementation(*this).GetImageType();
+}
+
EncodedImageBuffer EncodedImageBuffer::New(const RawBufferType& buffer)
{
- IntrusivePtr<Internal::EncodedImageBuffer> internal = Internal::EncodedImageBuffer::New(buffer);
+ return EncodedImageBuffer::New(buffer, ImageType::DEFAULT);
+}
+
+EncodedImageBuffer EncodedImageBuffer::New(const RawBufferType& buffer, ImageType type)
+{
+ IntrusivePtr<Internal::EncodedImageBuffer> internal = Internal::EncodedImageBuffer::New(buffer, type);
return EncodedImageBuffer(internal.Get());
}
public:
using RawBufferType = Dali::Vector<uint8_t>;
+ /**
+ * @brief The list of type of encoded image buffer.
+ *
+ * @SINCE_2_2.51
+ */
+ enum class ImageType
+ {
+ REGULAR_IMAGE,
+ VECTOR_IMAGE, ///< svg format.
+ ANIMATED_VECTOR_IMAGE, ///< lottie format.
+
+ DEFAULT = REGULAR_IMAGE,
+ };
+
public:
/**
- * @brief Create a new EncodedImageBuffer.
+ * @brief Create a new EncodedImageBuffer. ImageType will be setted as DEFAULT.
*
* @SINCE_2_0.34
* @param [in] buffer The encoded raw buffer
*/
static EncodedImageBuffer New(const RawBufferType& buffer);
+ /**
+ * @brief Create a new EncodedImageBuffer with ImageType.
+ *
+ * @SINCE_2_2.51
+ * @param [in] buffer The encoded raw buffer
+ * @param [in] type The type hint of encoded raw buffer
+ * @return A handle to a new EncodedImageBuffer.
+ */
+ static EncodedImageBuffer New(const RawBufferType& buffer, ImageType type);
+
/**
* @brief Create an empty handle.
*
* @SINCE_2_1.20
* @return A hash value of raw buffer.
*/
- const std::size_t GetHash() const;
+ std::size_t GetHash() const;
+
+ /**
+ * @brief Set type of raw buffer.
+ *
+ * @SINCE_2_2.51
+ * @param[in] type A ImageType for this buffer
+ */
+ void SetImageType(ImageType type);
+
+ /**
+ * @brief Get type of raw buffer.
+ *
+ * @SINCE_2_2.51
+ * @return A ImageType this buffer have
+ */
+ ImageType GetImageType() const;
public: // Not intended for developer use
explicit DALI_INTERNAL EncodedImageBuffer(Internal::EncodedImageBuffer* impl);