[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-list.h
old mode 100644 (file)
new mode 100755 (executable)
index f435628..90925eb
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
+#define DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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 <cstdint>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/math/rect.h>
+#include <dali/devel-api/common/owner-container.h>
 #include <dali/internal/render/common/render-item.h>
-#include <dali/internal/common/owner-container.h>
 
 namespace Dali
 {
@@ -31,53 +34,37 @@ typedef Rect<int> ClippingBox;
 namespace Internal
 {
 
+namespace Render
+{
+class Renderer;
+}
+
 namespace SceneGraph
 {
 
 class Layer;
-class Renderer;
 
-class RenderItem;
 typedef OwnerContainer< RenderItem* > RenderItemContainer;
 
 struct RenderList;
 typedef OwnerContainer< RenderList* > RenderListContainer;
 
 /**
- * The RenderList structure provides the renderer with a list of renderers and
- * a set of flags to tell it what depth buffering is required.
+ * The RenderList structure provides the renderer with a list of renderers.
  */
 struct RenderList
 {
 public:
 
   /**
-   * The RenderFlags describe how the objects are rendered using the depth and stencil buffer.
-   *
-   * The flags which relate to GL_DEPTH_TEST and GL_STENCIL_TEST are called
-   * DEPTH_BUFFER_ENABLED and STENCIL_BUFFER_ENABLED to avoid any confusion.
-   * E.g. if GL_DEPTH_TEST is not enabled you can't write to the depth buffer, which can cause confusion.
-   *
-   */
-  enum RenderFlags
-  {
-    DEPTH_BUFFER_ENABLED   = 1 << 0, ///< If depth buffer should be used for writing / test operations
-    DEPTH_WRITE            = 1 << 1, ///< If the depth buffer is writable
-    DEPTH_CLEAR            = 1 << 2, ///< If the depth buffer should first be cleared
-    STENCIL_BUFFER_ENABLED = 1 << 3, ///< If stencil buffer should be used for writing / test operation
-    STENCIL_WRITE          = 1 << 4, ///< If the stencil buffer is writable
-    STENCIL_CLEAR          = 1 << 5, ///< If the stencil buffer should first be cleared
-
-  };
-
-  /**
    * Constructor
    */
   RenderList()
   : mNextFree( 0 ),
-    mRenderFlags( 0u ),
     mClippingBox( NULL ),
-    mSourceLayer( NULL )
+    mSourceLayer( NULL ),
+    mHasColorRenderItems( false ),
+    mPartialUpdateEnabled( false )
   {
   }
 
@@ -86,44 +73,17 @@ public:
    */
   ~RenderList()
   {
-    // pointer container deletes the render items
+    // Pointer container deletes the render items
     delete mClippingBox;
   }
 
   /**
-   * Clear the render flags
-   */
-  void ClearFlags()
-  {
-    mRenderFlags = 0u;
-  }
-
-  /**
-   * Set particular render flags
-   * @param[in] flags The set of flags to bitwise or with existing flags
-   */
-  void SetFlags( unsigned int flags )
-  {
-    mRenderFlags |= flags;
-  }
-
-  /**
-   * Retrieve the render flags.
-   * @return the render flags.
-   */
-  unsigned int GetFlags() const
-  {
-    return mRenderFlags;
-  }
-
-  /**
    * Reset the render list for next frame
    */
   void Reset()
   {
-    // we dont want to delete and re-create the render items every frame
+    // We don't want to delete and re-create the render items every frame
     mNextFree = 0;
-    mRenderFlags = 0u;
 
     delete mClippingBox;
     mClippingBox = NULL;
@@ -156,18 +116,17 @@ public:
     // check if we have enough items, we can only be one behind at worst
     if( mItems.Count() <= mNextFree )
     {
-      mItems.PushBack( new RenderItem ); // Push a new empty render item
+      mItems.PushBack( RenderItem::New() ); // Push a new empty render item
     }
     // get the item mNextFree points to and increase by one
     RenderItem& item = *mItems[ mNextFree++ ];
-    item.Reset();
     return item;
   }
 
   /**
    * Get item at a given position in the list
    */
-  RenderItem& GetItem( RenderItemContainer::SizeType index ) const
+  RenderItem& GetItem( uint32_t index ) const
   {
     DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
     return *mItems[ index ];
@@ -176,10 +135,10 @@ public:
   /**
    * Get renderer from an item in the list
    */
-  const Renderer* GetRenderer( RenderItemContainer::SizeType index ) const
+  const Render::Renderer& GetRenderer( uint32_t index ) const
   {
     DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
-    return mItems[ index ]->GetRenderer();
+    return *mItems[ index ]->mRenderer;
   }
 
   /**
@@ -187,7 +146,7 @@ public:
    * Because of caching, the actual size may be bit more
    * @return The number of items
    */
-  RenderItemContainer::SizeType Count() const
+  uint32_t Count() const
   {
     return mNextFree;
   }
@@ -195,9 +154,9 @@ public:
   /**
    * @return the number of items cached by the list
    */
-  RenderItemContainer::SizeType GetCachedItemCount() const
+  uint32_t GetCachedItemCount() const
   {
-    return mItems.Count();
+    return static_cast<uint32_t>( mItems.Count() );
   }
 
   /**
@@ -205,7 +164,7 @@ public:
    */
   void ReuseCachedItems()
   {
-    mNextFree = mItems.Count();
+    mNextFree = static_cast<uint32_t>( mItems.Count() );
   }
 
   /**
@@ -213,7 +172,7 @@ public:
    */
   bool IsEmpty() const
   {
-    return (mNextFree == 0);
+    return ( mNextFree == 0 );
   }
 
   /**
@@ -225,9 +184,8 @@ public:
   {
     if( clipping )
     {
-      ClippingBox* newBox = new ClippingBox( box );
       delete mClippingBox;
-      mClippingBox = newBox;
+      mClippingBox = new ClippingBox( box );;
     }
   }
 
@@ -236,7 +194,7 @@ public:
    */
   bool IsClipping() const
   {
-    return (NULL != mClippingBox);
+    return ( NULL != mClippingBox );
   }
 
   /**
@@ -270,19 +228,55 @@ public:
   /**
    * @return the source layer these renderitems originate from
    */
-  Layer* GetSourceLayer()
+  Layer* GetSourceLayer() const
   {
     return mSourceLayer;
   }
 
   /**
-   * @param layer these renderitems originate from
+   * @param layer The layer these RenderItems originate from
    */
   void SetSourceLayer( Layer* layer )
   {
     mSourceLayer = layer;
   }
 
+  /**
+   * Set if the RenderList contains color RenderItems
+   * @param[in] hasColorRenderItems True if it contains color RenderItems, false otherwise
+   */
+  void SetHasColorRenderItems( bool hasColorRenderItems )
+  {
+    mHasColorRenderItems = hasColorRenderItems;
+  }
+
+  /**
+   * Check if the RenderList contains color RenderItems
+   * @return true if the RenderList contains color RenderItems, false otherwise
+   */
+  bool HasColorRenderItems() const
+  {
+    return mHasColorRenderItems;
+  }
+
+  /**
+   * Enable/Disable Partial update dirty flag
+   * @param[in] true to mark dirty else false
+   */
+  void SetPartialUpdateEnabled( bool value )
+  {
+    mPartialUpdateEnabled = value;
+  }
+
+  /**
+   * Get Partial update dirty flag
+   * @return true if dirty else false
+   */
+  bool IsPartialUpdateEnabled() const
+  {
+    return mPartialUpdateEnabled;
+  }
+
 private:
 
   /*
@@ -292,19 +286,20 @@ private:
   const RenderList& operator=( const RenderList& rhs );
 
   RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
-  RenderItemContainer::SizeType mNextFree;              ///< index for the next free item to use
+  uint32_t mNextFree;         ///< index for the next free item to use
 
-  unsigned int mRenderFlags; ///< The render flags
-
-  ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
-  Layer* mSourceLayer;       ///< The originating layer where the renderers are from
+  ClippingBox* mClippingBox;               ///< The clipping box, in window coordinates, when clipping is enabled
+  Layer*       mSourceLayer;              ///< The originating layer where the renderers are from
+  bool         mHasColorRenderItems : 1;  ///< True if list contains color render items
+  bool         mPartialUpdateEnabled : 1; //< True if partial update is needed.
 
 };
 
+
 } // namespace SceneGraph
 
 } // namespace Internal
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H