Clipping source drawable based on Path data.
Change-Id: Idd0a20d4d5e0a2243bc1b7781b06f02296fc508d
return GetImplementation(*this).GetBoundingBox();
}
+bool CanvasRenderer::Drawable::SetClipPath(Drawable& clip)
+{
+ return GetImplementation(*this).SetClipPath(clip);
+}
+
CanvasRenderer::Drawable CanvasRenderer::Drawable::DownCast(BaseHandle handle)
{
return CanvasRenderer::Drawable(dynamic_cast<Internal::Adaptor::Drawable*>(handle.GetObjectPtr()));
Rect<float> GetBoundingBox() const;
/**
+ * @brief The intersection with clip drawable is determined and only the resulting pixels from own drawable are rendered.
+ * @param[in] clip The clip drawable object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetClipPath(Drawable& clip);
+
+ /**
* @brief Downcast a handle to Drawable handle.
*
* If handle points to an InputMethodContext the downcast produces valid
return mImpl->GetBoundingBox();
}
+bool Drawable::SetClipPath(Dali::CanvasRenderer::Drawable& clip)
+{
+ if(!mImpl)
+ {
+ return false;
+ }
+ return mImpl->SetClipPath(clip);
+}
+
+Dali::CanvasRenderer::Drawable Drawable::GetCompositionDrawable() const
+{
+ if(!mImpl)
+ {
+ return Dali::CanvasRenderer::Drawable();
+ }
+ return mImpl->GetCompositionDrawable();
+}
+
+Dali::Internal::Adaptor::Drawable::CompositionType Drawable::GetCompositionType() const
+{
+ if(!mImpl)
+ {
+ return Dali::Internal::Adaptor::Drawable::CompositionType::NONE;
+ }
+ return mImpl->GetCompositionType();
+}
+
void Drawable::SetAdded(bool added)
{
if(!mImpl)
DRAWABLE_GROUP ///< Meaning of DrawableGorup class that inherits Drawable.
};
+ /**
+ * @brief Enumeration indicating type used in the composition of two objects - the target and the source.
+ */
+ enum class CompositionType
+ {
+ NONE = 0, ///< Means that type is not defined.
+ CLIP_PATH, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered.
+ ALPHA_MASK, ///< The pixels of the source and the target are alpha blended. As a result, only the part of the source, which intersects with the target is visible.
+ ALPHA_MASK_INVERSE ///< The pixels of the source and the complement to the target's pixels are alpha blended. As a result, only the part of the source which is not covered by the target is visible.
+ };
+
public:
/**
* @brief Constructor
virtual Rect<float> GetBoundingBox() const;
/**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
+ */
+ virtual bool SetClipPath(Dali::CanvasRenderer::Drawable& clip);
+
+ /**
+ * @brief Returns a composition drawble object.
+ * @return Returns a composition drawble object.
+ */
+ virtual Dali::CanvasRenderer::Drawable GetCompositionDrawable() const;
+
+ /**
+ * @brief Returns a composition type
+ * @return Returns a composition type
+ */
+ virtual CompositionType GetCompositionType() const;
+
+ /**
* @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
* @param[in] added Ture if added, false otherwise.
*/
return Rect<float>(0, 0, 0, 0);
}
+bool DrawableGeneric::SetClipPath(Dali::CanvasRenderer::Drawable& clip)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Drawable DrawableGeneric::GetCompositionDrawable() const
+{
+ return Dali::CanvasRenderer::Drawable();
+}
+
+Drawable::CompositionType DrawableGeneric::GetCompositionType() const
+{
+ return Drawable::CompositionType::NONE;
+}
+
void DrawableGeneric::SetAdded(bool added)
{
}
Rect<float> GetBoundingBox() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
+ */
+ bool SetClipPath(Dali::CanvasRenderer::Drawable& clip) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionDrawable()
+ */
+ Dali::CanvasRenderer::Drawable GetCompositionDrawable() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionType()
+ */
+ CompositionType GetCompositionType() const override;
+
+ /**
* @copydoc Internal::Adaptor::Drawable::SetAdded()
*/
void SetAdded(bool added) override;
}
}
+ Dali::CanvasRenderer::Drawable compositeDrawable = drawableImpl.GetCompositionDrawable();
+ if(DALI_UNLIKELY(compositeDrawable))
+ {
+ Internal::Adaptor::Drawable& compositeDrawableImpl = Dali::GetImplementation(compositeDrawable);
+ tvg::Paint* tvgCompositeObject = static_cast<tvg::Paint*>(compositeDrawableImpl.GetObject());
+ if(tvgCompositeObject)
+ {
+ tvg::Paint* tvgDuplicatedCompositeObject = tvgCompositeObject->duplicate();
+ Drawable::Types type = compositeDrawableImpl.GetType();
+
+ if(type == Drawable::Types::DRAWABLE_GROUP)
+ {
+ Dali::CanvasRenderer::DrawableGroup& compositeGroup = static_cast<Dali::CanvasRenderer::DrawableGroup&>(compositeDrawable);
+ Internal::Adaptor::DrawableGroup& compositeDrawableGroupImpl = Dali::GetImplementation(compositeGroup);
+ DrawableGroup::DrawableVector compositeDrawables = compositeDrawableGroupImpl.GetDrawables();
+ for(auto& it : compositeDrawables)
+ {
+ PushDrawableToGroup(it, static_cast<tvg::Scene*>(tvgDuplicatedCompositeObject));
+ }
+ }
+
+ if(tvgDuplicatedObject->composite(std::move(std::unique_ptr<tvg::Paint>(tvgDuplicatedCompositeObject)), static_cast<tvg::CompositeMethod>(drawableImpl.GetCompositionType())) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg composite fail [%p]\n", this);
+ return;
+ }
+ }
+ }
+
if(parent->push(std::move(std::unique_ptr<tvg::Paint>(tvgDuplicatedObject))) != tvg::Result::Success)
{
DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
DrawableTizen::DrawableTizen()
: mAdded(false),
mChanged(false),
- mType(Drawable::Types::NONE)
+ mType(Drawable::Types::NONE),
+ mCompositionType(Drawable::CompositionType::NONE),
+ mCompositionDrawable()
#ifdef THORVG_SUPPORT
,
mTvgPaint(nullptr)
#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;
* @copydoc Dali::CanvasRenderer::Drawable::GetBoundingBox()
*/
Rect<float> GetBoundingBox() const override;
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
+ */
+ bool SetClipPath(Dali::CanvasRenderer::Drawable& clip) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionDrawable()
+ */
+ Dali::CanvasRenderer::Drawable GetCompositionDrawable() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionType()
+ */
+ CompositionType GetCompositionType() const override;
/**
* @copydoc Internal::Adaptor::Drawable::SetAdded()
virtual ~DrawableTizen() override;
private:
- bool mAdded;
- bool mChanged;
- Drawable::Types mType;
+ bool mAdded;
+ bool mChanged;
+ Drawable::Types mType;
+ Drawable::CompositionType mCompositionType;
+ Dali::CanvasRenderer::Drawable mCompositionDrawable;
#ifdef THORVG_SUPPORT
tvg::Paint* mTvgPaint;
}
}
+ Dali::CanvasRenderer::Drawable compositeDrawable = drawableImpl.GetCompositionDrawable();
+ if(DALI_UNLIKELY(compositeDrawable))
+ {
+ Internal::Adaptor::Drawable& compositeDrawableImpl = Dali::GetImplementation(compositeDrawable);
+ tvg::Paint* tvgCompositeObject = static_cast<tvg::Paint*>(compositeDrawableImpl.GetObject());
+ if(tvgCompositeObject)
+ {
+ tvg::Paint* tvgDuplicatedCompositeObject = tvgCompositeObject->duplicate();
+ Drawable::Types type = compositeDrawableImpl.GetType();
+
+ if(type == Drawable::Types::DRAWABLE_GROUP)
+ {
+ Dali::CanvasRenderer::DrawableGroup& compositeGroup = static_cast<Dali::CanvasRenderer::DrawableGroup&>(compositeDrawable);
+ Internal::Adaptor::DrawableGroup& compositeDrawableGroupImpl = Dali::GetImplementation(compositeGroup);
+ DrawableGroup::DrawableVector compositeDrawables = compositeDrawableGroupImpl.GetDrawables();
+ for(auto& it : compositeDrawables)
+ {
+ PushDrawableToGroup(it, static_cast<tvg::Scene*>(tvgDuplicatedCompositeObject));
+ }
+ }
+
+ if(tvgDuplicatedObject->composite(std::move(std::unique_ptr<tvg::Paint>(tvgDuplicatedCompositeObject)), static_cast<tvg::CompositeMethod>(drawableImpl.GetCompositionType())) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg composite fail [%p]\n", this);
+ return;
+ }
+ }
+ }
+
if(group->push(std::move(std::unique_ptr<tvg::Paint>(tvgDuplicatedObject))) != tvg::Result::Success)
{
DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
DrawableUbuntu::DrawableUbuntu()
: mAdded(false),
mChanged(false),
- mType(Drawable::Types::NONE)
+ mType(Drawable::Types::NONE),
+ mCompositionType(Drawable::CompositionType::NONE),
+ mCompositionDrawable()
#ifdef THORVG_SUPPORT
,
mTvgPaint(nullptr)
#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;
Rect<float> GetBoundingBox() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetClipPath()
+ */
+ bool SetClipPath(Dali::CanvasRenderer::Drawable& clip) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionDrawable()
+ */
+ Dali::CanvasRenderer::Drawable GetCompositionDrawable() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetCompositionType()
+ */
+ CompositionType GetCompositionType() const override;
+
+ /**
* @copydoc Internal::Adaptor::Drawable::SetAdded()
*/
void SetAdded(bool added) override;
virtual ~DrawableUbuntu() override;
private:
- bool mAdded;
- bool mChanged;
- Drawable::Types mType;
+ bool mAdded;
+ bool mChanged;
+ Drawable::Types mType;
+ Drawable::CompositionType mCompositionType;
+ Dali::CanvasRenderer::Drawable mCompositionDrawable;
#ifdef THORVG_SUPPORT
tvg::Paint* mTvgPaint;