CanvasRenderer: Add Drawable::SetClipPath() Api
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / tizen / drawable-impl-tizen.cpp
index 9bae6a6..9333c75 100644 (file)
@@ -48,7 +48,10 @@ DrawableTizen* DrawableTizen::New()
 
 DrawableTizen::DrawableTizen()
 : mAdded(false),
-  mChanged(false)
+  mChanged(false),
+  mType(Drawable::Types::NONE),
+  mCompositionType(Drawable::CompositionType::NONE),
+  mCompositionDrawable()
 #ifdef THORVG_SUPPORT
   ,
   mTvgPaint(nullptr)
@@ -59,7 +62,7 @@ DrawableTizen::DrawableTizen()
 DrawableTizen::~DrawableTizen()
 {
 #ifdef THORVG_SUPPORT
-  if(mTvgPaint && !mAdded)
+  if(mTvgPaint)
   {
     delete mTvgPaint;
   }
@@ -209,6 +212,43 @@ Rect<float> DrawableTizen::GetBoundingBox() const
 #endif
 }
 
+bool DrawableTizen::SetClipPath(Dali::CanvasRenderer::Drawable& clip)
+{
+#ifdef THORVG_SUPPORT
+  if(!mTvgPaint)
+  {
+    DALI_LOG_ERROR("Drawable is null\n");
+    return false;
+  }
+
+  Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(clip);
+  if(drawableImpl.IsAdded())
+  {
+    DALI_LOG_ERROR("Already used [%p][%p]\n", this, &clip);
+    return false;
+  }
+
+  drawableImpl.SetAdded(true);
+  mCompositionDrawable = clip;
+  mCompositionType     = Drawable::CompositionType::CLIP_PATH;
+  Drawable::SetChanged(true);
+
+  return true;
+#else
+  return false;
+#endif
+}
+
+Dali::CanvasRenderer::Drawable DrawableTizen::GetCompositionDrawable() const
+{
+  return mCompositionDrawable;
+}
+
+Drawable::CompositionType DrawableTizen::GetCompositionType() const
+{
+  return mCompositionType;
+}
+
 void DrawableTizen::SetAdded(bool added)
 {
   mAdded = !!added;
@@ -235,17 +275,6 @@ void DrawableTizen::SetObject(const void* object)
   {
     mTvgPaint = static_cast<tvg::Paint*>((void*)object);
   }
-  else
-  {
-    if(mAdded)
-    {
-      mTvgPaint = nullptr;
-    }
-    if(mTvgPaint)
-    {
-      delete mTvgPaint;
-    }
-  }
 #endif
 }
 
@@ -259,6 +288,16 @@ bool DrawableTizen::GetChanged() const
 {
   return mChanged;
 }
+
+void DrawableTizen::SetType(Drawable::Types type)
+{
+  mType = type;
+}
+
+Drawable::Types DrawableTizen::GetType() const
+{
+  return mType;
+}
 } // namespace Adaptor
 
 } // namespace Internal