Use RegisterUniqueProperty for some more renderers
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / border / border-visual.cpp
index e0e5830..b60cc27 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * 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.
@@ -39,6 +39,8 @@ namespace Internal
 {
 namespace
 {
+const int CUSTOM_PROPERTY_COUNT(7); // 5 transform properties + color,size
+
 const char* const POSITION_ATTRIBUTE_NAME("aPosition");
 const char* const DRIFT_ATTRIBUTE_NAME("aDrift");
 const char* const INDEX_NAME("indices");
@@ -127,12 +129,18 @@ void BorderVisual::DoSetProperty(Dali::Property::Index        index,
 
 void BorderVisual::DoSetOnScene(Actor& actor)
 {
-  mBorderColorIndex = mImpl->mRenderer.RegisterProperty(Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor);
+  if(mBorderColorIndex == Property::INVALID_INDEX)
+  {
+    mBorderColorIndex = mImpl->mRenderer.RegisterUniqueProperty(Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor);
+  }
   if(mBorderColor.a < 1.f || mAntiAliasing)
   {
     mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
   }
-  mBorderSizeIndex = mImpl->mRenderer.RegisterProperty(Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize);
+  if(mBorderSizeIndex == Property::INVALID_INDEX)
+  {
+    mBorderSizeIndex = mImpl->mRenderer.RegisterUniqueProperty(Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize);
+  }
 
   actor.AddRenderer(mImpl->mRenderer);
 
@@ -173,6 +181,7 @@ void BorderVisual::OnInitialize()
 
   Shader shader    = GetBorderShader();
   mImpl->mRenderer = Renderer::New(geometry, shader);
+  mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
 
   //Register transform properties
   mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);