Create render pass for surface rendering
[platform/core/uifw/dali-core.git] / dali / internal / common / message-buffer.h
index 6fe0159..5c791f0 100644 (file)
@@ -1,44 +1,45 @@
-#ifndef __DALI_INTERNAL_MESSAGE_BUFFER_H__
-#define __DALI_INTERNAL_MESSAGE_BUFFER_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_INTERNAL_MESSAGE_BUFFER_H
+#define DALI_INTERNAL_MESSAGE_BUFFER_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // EXTERNAL INCLUDES
-#include <cstddef>
+#include <cstddef> // size_t
+#include <cstdint> // uint32_t
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 /**
  * Utility class to reserve a buffer for storing messages.
  */
 class MessageBuffer
 {
 public:
+  using WordType = std::ptrdiff_t;
 
   /**
    * Create a new MessageBuffer
    * @param[in] The smallest capacity which the buffer will allocate, with respect to the size of type "char".
    * @note The buffer will not allocate memory until the first call to ReserveMessageSlot().
    */
-  MessageBuffer( std::size_t initialCapacity );
+  MessageBuffer(std::size_t initialCapacity);
 
   /**
    * Non-virtual destructor; not suitable as a base class
@@ -48,10 +49,10 @@ public:
   /**
    * Reserve space for another message in the buffer.
    * @pre size is greater than zero.
-   * @param[in] The message size with respect to the size of type "char".
-   * @return A pointer to the address allocated for the message.
+   * @param[in] size The message size with respect to the size of type "char".
+   * @return A pointer to the address allocated for the message, aligned to a word boundary
    */
-  unsigned int* ReserveMessageSlot( std::size_t size );
+  uint32_t* ReserveMessageSlot(std::size_t size);
 
   /**
    * Query the capacity of the message buffer.
@@ -65,9 +66,8 @@ public:
   class Iterator
   {
   public:
-
     // Constructor
-    Iterator(unsigned int* current);
+    Iterator(WordType* current);
 
     // Inlined for performance
     bool IsValid()
@@ -77,9 +77,9 @@ public:
     }
 
     // Inlined for performance
-    unsigned int* Get()
+    WordType* Get()
     {
-      return ( 0 != mMessageSize ) ? mCurrent : NULL;
+      return (0 != mMessageSize) ? mCurrent : nullptr;
     }
 
     // Inlined for performance
@@ -94,14 +94,12 @@ public:
     Iterator(const Iterator& copy);
 
   private:
-
     // Undefined
     Iterator& operator=(const Iterator& rhs);
 
   private:
-
-    unsigned int* mCurrent;
-    unsigned int mMessageSize;
+    WordType*   mCurrent;
+    std::size_t mMessageSize;
   };
 
   /**
@@ -118,7 +116,6 @@ public:
   void Reset();
 
 private:
-
   // Undefined
   MessageBuffer(const MessageBuffer&);
 
@@ -130,21 +127,20 @@ private:
    * @pre The newCapacity is greater than mCapacity.
    * @param[in] The newCapacity
    */
-  void IncreaseCapacity( std::size_t newCapacity );
+  void IncreaseCapacity(std::size_t newCapacity);
 
 private:
-
   std::size_t mInitialCapacity; ///< The capacity to allocate during first call to ReserveMessageSlot
 
-  unsigned int* mData;     ///< The data allocated for the message buffer
-  unsigned int* mNextSlot; ///< The next free location in the buffer
+  WordType* mData;     ///< The data allocated for the message buffer
+  WordType* mNextSlot; ///< The next free location in the buffer
 
-  std::size_t mCapacity; ///< The memory allocated with respect to sizeof(unsigned int)
-  std::size_t mSize;     ///< The memory reserved for messages with respect to sizeof(unsigned int)
+  std::size_t mCapacity; ///< The memory allocated with respect to sizeof(WordType)
+  std::size_t mSize;     ///< The memory reserved for messages with respect to sizeof(WordType)
 };
 
 } // namespace Internal
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_MESSAGE_BUFFER_H__
+#endif // DALI_INTERNAL_MESSAGE_BUFFER_H