[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-data-impl.h
index 3c8f072..e54c3ae 100644 (file)
@@ -20,7 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/math/vector2.h>
-#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/rendering/visual-renderer.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
@@ -53,10 +53,10 @@ struct Base::Impl
 
   enum Flags
   {
-    IS_ON_SCENE                     = 1,
-    IS_ATLASING_APPLIED             = 1 << 1,
-    IS_PREMULTIPLIED_ALPHA          = 1 << 2,
-    IS_SYNCHRONOUS_RESOURCE_LOADING = 1 << 3
+    IS_ON_SCENE                        = 1,
+    IS_ATLASING_APPLIED                = 1 << 1,
+    IS_PREMULTIPLIED_ALPHA             = 1 << 2,
+    IS_SYNCHRONOUS_RESOURCE_LOADING    = 1 << 3,
   };
 
   struct CustomShader
@@ -96,14 +96,9 @@ struct Base::Impl
     void UpdatePropertyMap(const Property::Map& map);
 
     /**
-     * Register the uniform properties onto the renderer
-     */
-    void RegisterUniforms(Renderer renderer, Toolkit::Direction::Type direction);
-
-    /**
      * Set the uniform properties onto the renderer
      */
-    void SetUniforms(Renderer renderer, Toolkit::Direction::Type direction);
+    void SetUniforms(VisualRenderer renderer, Toolkit::Direction::Type direction);
 
     /**
      * Convert the control size and the transform attributes into the actual
@@ -117,34 +112,150 @@ struct Base::Impl
     Vector4              mOffsetSizeMode;
     Toolkit::Align::Type mOrigin;
     Toolkit::Align::Type mAnchorPoint;
-    Property::Index      mOffsetIndex{Property::INVALID_INDEX};
-    Property::Index      mSizeIndex{Property::INVALID_INDEX};
   };
 
-  Renderer                        mRenderer;
+  struct DecorationData
+  {
+    // Default constructor
+    DecorationData()
+    : mBorderlineColor(Color::BLACK),
+      mCornerRadius(Vector4::ZERO),
+      mBorderlineWidth(0.0f),
+      mBorderlineOffset(0.0f),
+      mCornerRadiusPolicy(static_cast<int>(Toolkit::Visual::Transform::Policy::ABSOLUTE))
+    {
+    }
+    Vector4 mBorderlineColor;
+    Vector4 mCornerRadius;
+    float   mBorderlineWidth;
+    float   mBorderlineOffset;
+    int     mCornerRadiusPolicy;
+  };
+
+  DecorationData* EnsureDecorationData()
+  {
+    if(mDecorationData == nullptr)
+    {
+      mDecorationData = new DecorationData();
+    }
+    return mDecorationData;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline width
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  float GetBorderlineWidth()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineWidth : 0.0f;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline width
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineWidth(float value)
+  {
+    EnsureDecorationData()->mBorderlineWidth = value;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline color
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  Vector4 GetBorderlineColor()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineColor : Color::BLACK;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline color
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineColor(Vector4 value)
+  {
+    EnsureDecorationData()->mBorderlineColor = value;
+  }
+
+  /**
+   * @brief Get decoration data value : borderline offset
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  float GetBorderlineOffset()
+  {
+    return mDecorationData ? mDecorationData->mBorderlineOffset : 0.0f;
+  }
+
+  /**
+   * @brief Set decoration data value : borderline offset
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetBorderlineOffset(float value)
+  {
+    EnsureDecorationData()->mBorderlineOffset = value;
+  }
+
+  /**
+   * @brief Get decoration data value : corner radius
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  Vector4 GetCornerRadius()
+  {
+    return mDecorationData ? mDecorationData->mCornerRadius : Vector4::ZERO;
+  }
+
+  /**
+   * @brief Set decoration data value : corner radius
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetCornerRadius(Vector4 value)
+  {
+    EnsureDecorationData()->mCornerRadius = value;
+  }
+
+  /**
+   * @brief Get decoration data value : corner radius policy
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  int GetCornerRadiusPolicy()
+  {
+    return mDecorationData ? mDecorationData->mCornerRadiusPolicy : static_cast<int>(Toolkit::Visual::Transform::Policy::ABSOLUTE);
+  }
+
+  /**
+   * @brief Set decoration data value : corner radius policy
+   *
+   * Keep these API as inline function due to the performance.
+   */
+  void SetCornerRadiusPolicy(int value)
+  {
+    EnsureDecorationData()->mCornerRadiusPolicy = value;
+  }
+
+  VisualRenderer                  mRenderer;
   CustomShader*                   mCustomShader;
   EventObserver*                  mEventObserver; ///< Allows controls to observe when the visual has events to notify
   std::string                     mName;
   Transform                       mTransform;
   Vector4                         mMixColor;
   Size                            mControlSize;
-  float                           mBorderlineWidth;
-  Vector4                         mBorderlineColor;
-  float                           mBorderlineOffset;
-  Vector4                         mCornerRadius;
-  float                           mCornerRadiusPolicy;
+  DecorationData*                 mDecorationData;
   int                             mDepthIndex;
-  Property::Index                 mMixColorIndex;
-  Property::Index                 mBorderlineWidthIndex;
-  Property::Index                 mBorderlineColorIndex;
-  Property::Index                 mBorderlineOffsetIndex;
-  Property::Index                 mCornerRadiusIndex;
   FittingMode                     mFittingMode; ///< How the contents should fit the view
   int                             mFlags;
   Toolkit::Visual::ResourceStatus mResourceStatus;
   const Toolkit::Visual::Type     mType;
-  bool                            mAlwaysUsingBorderline : 1;   ///< Whether we need the borderline in shader always.
-  bool                            mAlwaysUsingCornerRadius : 1; ///< Whether we need the corner radius in shader always.
+  bool                            mAlwaysUsingBorderline : 1;     ///< Whether we need the borderline in shader always.
+  bool                            mAlwaysUsingCornerRadius : 1;   ///< Whether we need the corner radius in shader always.
 };
 
 } // namespace Visual