/*
- * 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.
*
*/
-#include <stdlib.h>
-#include <unistd.h>
-#include <dali/dali.h>
#include <dali-test-suite-utils.h>
+#include <dali/dali.h>
#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
+#include <stdlib.h>
+#include <unistd.h>
using namespace Dali;
EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer());
EncodedImageBuffer bufferCopy(buffer);
- DALI_TEST_EQUALS( (bool)bufferCopy, true, TEST_LOCATION );
+ DALI_TEST_EQUALS((bool)bufferCopy, true, TEST_LOCATION);
END_TEST;
}
EncodedImageBuffer buffer = EncodedImageBuffer::New(tinybuffer());
EncodedImageBuffer buffer2;
- DALI_TEST_EQUALS( (bool)buffer2, false, TEST_LOCATION );
+ DALI_TEST_EQUALS((bool)buffer2, false, TEST_LOCATION);
buffer2 = buffer;
- DALI_TEST_EQUALS( (bool)buffer2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS((bool)buffer2, true, TEST_LOCATION);
END_TEST;
}
EncodedImageBuffer::RawBufferType::Iterator jter = getBuffer.Begin();
for(; iter != originBuffer.End(); ++iter, ++jter)
{
- DALI_TEST_EQUALS(*iter, *jter, TEST_LOCATION );
+ DALI_TEST_EQUALS(*iter, *jter, TEST_LOCATION);
}
END_TEST;
}
+
+int UtcDaliEncodedImageBufferGetHash(void)
+{
+ EncodedImageBuffer buffer1 = EncodedImageBuffer::New(tinybuffer());
+ EncodedImageBuffer buffer2 = EncodedImageBuffer::New(tinybuffer());
+ EncodedImageBuffer buffer3 = EncodedImageBuffer::New(EncodedImageBuffer::RawBufferType()); //< EmptyBuffer
+
+ tet_infoline("Test different encoded buffer with same data has same hash value.");
+ DALI_TEST_CHECK(buffer1 != buffer2);
+ DALI_TEST_CHECK(buffer1.GetHash() == buffer2.GetHash());
+
+ tet_infoline("Test hash with empty buffer.");
+ DALI_TEST_CHECK(buffer1.GetHash() != buffer3.GetHash());
+ DALI_TEST_CHECK(buffer2.GetHash() != buffer3.GetHash());
+
+ END_TEST;
+}
\ No newline at end of file
/*
- * 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.
// CLASS HEADER
#include "encoded-image-buffer-impl.h"
+// EXTERNAL INCLUDE
+#include <dali/devel-api/common/hash.h>
+
namespace Dali
{
namespace Internal
{
-
EncodedImageBuffer::EncodedImageBuffer(const RawBufferType& buffer)
: mBuffer(buffer)
{
+ mBufferHash = CalculateHash(mBuffer);
}
EncodedImageBuffer::~EncodedImageBuffer()
return mBuffer;
}
+const std::size_t EncodedImageBuffer::GetHash() const
+{
+ return mBufferHash;
+}
+
} // namespace Internal
} // namespace Dali
#define DALI_ENCODED_IMAGE_BUFFER_IMPL_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.
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/intrusive-ptr.h>
#include <dali/public-api/object/base-object.h>
-#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
*/
const RawBufferType& GetRawBuffer() const;
+ /**
+ * @copydoc Dali::EncodedImageBuffer::GetHash
+ */
+ const std::size_t GetHash() const;
+
protected:
/**
* Destructor
private:
Dali::Vector<uint8_t> mBuffer;
+ std::size_t mBufferHash;
};
} // namespace Internal
/*
- * 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.
return GetImplementation(*this).GetRawBuffer();
}
+const std::size_t EncodedImageBuffer::GetHash() const
+{
+ return GetImplementation(*this).GetHash();
+}
+
EncodedImageBuffer& EncodedImageBuffer::operator=(const EncodedImageBuffer& handle)
{
BaseHandle::operator=(handle);
#ifndef DALI_ENCODED_IMAGE_BUFFER_H
#define DALI_ENCODED_IMAGE_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.
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
#include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/object/base-handle.h>
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
*/
const RawBufferType& GetRawBuffer() const;
+ /**
+ * @brief Get the hash value of raw buffer
+ *
+ * @return A hash value of raw buffer.
+ */
+ const std::size_t GetHash() const;
+
public: // Not intended for developer use
explicit DALI_INTERNAL EncodedImageBuffer(Internal::EncodedImageBuffer* impl);
};