CanvasRenderer: Add Drawable::SetClipPath() Api
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / ubuntu / drawable-impl-ubuntu.cpp
index 36a84aa..f4cb431 100644 (file)
@@ -49,7 +49,9 @@ DrawableUbuntu* DrawableUbuntu::New()
 DrawableUbuntu::DrawableUbuntu()
 : mAdded(false),
   mChanged(false),
-  mType(Drawable::Types::NONE)
+  mType(Drawable::Types::NONE),
+  mCompositionType(Drawable::CompositionType::NONE),
+  mCompositionDrawable()
 #ifdef THORVG_SUPPORT
   ,
   mTvgPaint(nullptr)
@@ -210,6 +212,43 @@ Rect<float> DrawableUbuntu::GetBoundingBox() const
 #endif
 }
 
+bool DrawableUbuntu::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 DrawableUbuntu::GetCompositionDrawable() const
+{
+  return mCompositionDrawable;
+}
+
+Drawable::CompositionType DrawableUbuntu::GetCompositionType() const
+{
+  return mCompositionType;
+}
+
 void DrawableUbuntu::SetAdded(bool added)
 {
   mAdded = !!added;