Merge "Sync UTC harness" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / render / queue / render-queue.h
index 7d7cf9b..0df8060 100644 (file)
@@ -1,44 +1,43 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_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_SCENE_GRAPH_RENDER_QUEUE_H
+#define DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H
+
+/*
+ * 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.
+ * 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.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/internal/common/buffer-index.h>
 #include <dali/internal/common/message-buffer.h>
+#include <atomic>
+#include <cstddef>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 class MessageBase;
 
 namespace SceneGraph
 {
-
 /**
  * Allows messages to be queued for RenderManager, during the scene-graph Update.
  */
 class RenderQueue
 {
 public:
-
   /**
    * Create a new RenderQueue.
    */
@@ -57,41 +56,49 @@ public:
    * @param[in] size The message size with respect to the size of type "char".
    * @return A pointer to the first char allocated for the message.
    */
-  unsigned int* ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size );
+  uint32_t* ReserveMessageSlot(BufferIndex updateBufferIndex, std::size_t size);
 
   /**
    * Process the batch of messages, which were queued in the previous update.
    * @pre This message should only be called by RenderManager from within the render-thread.
    * @param[in] bufferIndex The previous update buffer index.
    */
-  void ProcessMessages( BufferIndex bufferIndex );
+  void ProcessMessages(BufferIndex bufferIndex);
 
-private:
+  /**
+   * Return the current capacity total of both buffers.
+   */
+  std::size_t GetCapacity() const
+  {
+    return mCapacity;
+  }
 
+private:
   /**
    * Helper to retrieve the current container.
    * The update-thread queues messages with one container, whilst the render-thread is processing the other.
    * @param[in] bufferIndex The current buffer index.
    * @return The container.
    */
-  MessageBuffer* GetCurrentContainer( BufferIndex bufferIndex );
+  MessageBuffer* GetCurrentContainer(BufferIndex bufferIndex);
 
   /**
    * Helper to limit the buffer capacity i.e. after a frame when an extreme number of messages have been sent.
    * @param[in] bufferIndex The current buffer index.
    */
-  void LimitBufferCapacity( BufferIndex bufferIndex );
+  void LimitBufferCapacity(BufferIndex bufferIndex);
 
   // Undefined
-  RenderQueue( const RenderQueue& );
+  RenderQueue(const RenderQueue&);
 
   // Undefined
-  RenderQueue& operator=( const RenderQueue& rhs );
+  RenderQueue& operator=(const RenderQueue& rhs);
 
 private:
-
   MessageBuffer* container0; ///< Messages are queued here when the update buffer index == 0
   MessageBuffer* container1; ///< Messages are queued here when the update buffer index == 1
+
+  std::atomic<std::size_t> mCapacity{0u}; // Current total capacity of both buffers.
 };
 
 } // namespace SceneGraph
@@ -100,4 +107,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H