Drawable::Create();
Drawable::SetObject(static_cast<void*>(mTvgScene));
+ Drawable::SetType(Drawable::Types::DRAWABLE_GROUP);
#endif
}
bool DrawableGroupTizen::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
{
#ifdef THORVG_SUPPORT
- for(auto& it : mDrawables)
- {
- if(it.GetHandle() == drawable)
- {
- DALI_LOG_ERROR("Already added [%p][%p]\n", this, &drawable);
- return false;
- }
- }
-
- Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(drawable);
- tvg::Paint* pDrawable = static_cast<tvg::Paint*>(drawableImpl.GetObject());
- if(!pDrawable)
- {
- DALI_LOG_ERROR("Invalid drawable object [%p]\n", this);
- return false;
- }
-
- if(drawableImpl.IsDrawableAdded())
+ if(!Drawable::GetObject() || !mTvgScene)
{
- DALI_LOG_ERROR("Already added somewhere [%p][%p]\n", this, &drawable);
+ DALI_LOG_ERROR("DrawableGroup is null\n");
return false;
}
- if(mTvgScene->push(std::unique_ptr<tvg::Paint>(pDrawable)) != tvg::Result::Success)
+ Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(drawable);
+ if(drawableImpl.IsAdded())
{
- DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
+ DALI_LOG_ERROR("Already added [%p][%p]\n", this, &drawable);
return false;
}
- drawableImpl.SetDrawableAdded(true);
+ drawableImpl.SetAdded(true);
mDrawables.push_back(drawable);
Drawable::SetChanged(true);
#endif
}
-bool DrawableGroupTizen::Clear()
+bool DrawableGroupTizen::RemoveDrawable(Dali::CanvasRenderer::Drawable drawable)
{
#ifdef THORVG_SUPPORT
- if(!mTvgScene)
+ DrawableGroup::DrawableVector::iterator it = std::find(mDrawables.begin(), mDrawables.end(), drawable);
+ if(it != mDrawables.end())
+ {
+ Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(*it);
+ drawableImpl.SetAdded(false);
+
+ mDrawables.erase(it);
+
+ Drawable::SetChanged(true);
+
+ return true;
+ }
+
+#endif
+ return false;
+}
+
+bool DrawableGroupTizen::RemoveAllDrawables()
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgScene)
{
DALI_LOG_ERROR("DrawableGroup is null\n");
return false;
for(auto& it : mDrawables)
{
- Dali::CanvasRenderer::Drawable drawable = it.GetHandle();
- if(DALI_UNLIKELY(!drawable))
- {
- continue;
- }
- Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(drawable);
- drawableImpl.SetDrawableAdded(false);
+ Internal::Adaptor::Drawable& drawableImpl = Dali::GetImplementation(it);
+ drawableImpl.SetAdded(false);
}
mDrawables.clear();
if(static_cast<tvg::Scene*>(mTvgScene)->clear() != tvg::Result::Success)
{
- DALI_LOG_ERROR("Clear() fail.\n");
+ DALI_LOG_ERROR("RemoveAllDrawables() fail.\n");
return false;
}
#endif
}
+DrawableGroup::DrawableVector DrawableGroupTizen::GetDrawables() const
+{
+ return mDrawables;
+}
+
} // namespace Adaptor
} // namespace Internal