X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Flockless-buffer.h;h=026372699d94e66cb8282c2b16f0bd8758ae65d5;hb=HEAD;hp=8c0530d2aea24183cc2af3664b4c4af0de107ea1;hpb=8bccadc96b3773fb10c562a5ccdf1b071b2efe8e;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/integration-api/lockless-buffer.h b/dali/integration-api/lockless-buffer.h index 8c0530d..0263726 100644 --- a/dali/integration-api/lockless-buffer.h +++ b/dali/integration-api/lockless-buffer.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTEGRATION_LOCKLESS_BUFFER_H__ -#define __DALI_INTEGRATION_LOCKLESS_BUFFER_H__ +#ifndef DALI_INTEGRATION_LOCKLESS_BUFFER_H +#define DALI_INTEGRATION_LOCKLESS_BUFFER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,18 +19,17 @@ */ // EXTERNAL INCLUDES +#include // uint32_t, uint8_t // INTERNAL INCLUDES -#include -#include #include +#include +#include namespace Dali { - namespace Integration { - /** * The LocklessBuffer class implements double buffering eligible for multi-(two) threaded use, * where it's possible to read from one thread and write from another @@ -46,13 +45,12 @@ namespace Integration */ class DALI_CORE_API LocklessBuffer { - public: /** * Constructor. * @param[in] size The size of buffers in bytes. */ - LocklessBuffer( size_t size ); + LocklessBuffer(uint32_t size); /** * Destructor. @@ -64,19 +62,19 @@ public: * @param[in] src data source * @param[in] size size of data in bytes */ - void Write( const unsigned char *src, size_t size ); + void Write(const uint8_t* src, uint32_t size); /** * Try to swap buffers and read data. * @note returned value only valid until Read() is called again or object is destroyed * @return current read buffer contents */ - const unsigned char* Read(); + const uint8_t* Read(); /** * @return the buffer size in bytes */ - unsigned int GetSize() const; + uint32_t GetSize() const; private: /** @@ -86,28 +84,28 @@ private: */ enum BufferState { - R0W1 = 0, ///< Read from buffer 0 write to buffer 1 - R1W0 = 1, ///< Read from buffer 1 write to buffer 0 - WRITING = 2, ///< Currently writing to buffer - UPDATED = 4, ///< Swapping buffer required; there is new data available + R0W1 = 0, ///< Read from buffer 0 write to buffer 1 + R1W0 = 1, ///< Read from buffer 1 write to buffer 0 + WRITING = 2, ///< Currently writing to buffer + UPDATED = 4, ///< Swapping buffer required; there is new data available WRITE_BUFFER_MASK = 1, ///< indicates which buffer to write to WRITING_MASK = 2, ///< indicates whether currently writing UPDATED_MASK = 4 ///< indicates whether new data is available }; private: - LocklessBuffer(); ///< undefined default constructor, need to give size on construction - LocklessBuffer( const LocklessBuffer& ); ///< undefined copy constructor - LocklessBuffer& operator=( const LocklessBuffer& ); ///< undefined assignment operator + LocklessBuffer(); ///< undefined default constructor, need to give size on construction + LocklessBuffer(const LocklessBuffer&); ///< undefined copy constructor + LocklessBuffer& operator=(const LocklessBuffer&); ///< undefined assignment operator private: - unsigned char* mBuffer[2]; ///< bitmap buffers - BufferState volatile mState; ///< readbuffer number and whether we're currently writing into writebuffer or not - size_t mSize; ///< size of buffers + uint8_t* mBuffer[2]; ///< bitmap buffers + BufferState volatile mState; ///< readbuffer number and whether we're currently writing into writebuffer or not + uint32_t mSize; ///< size of buffers }; -} // Internal +} // namespace Integration -} // Dali +} // namespace Dali -#endif // __DALI_INTEGRATION_LOCKLESS_H__ +#endif // DALI_INTEGRATION_LOCKLESS_BUFFER_H