DrawableGroup is a class that implements ThorVG's tvg::Scene 1:1.
This feature can add and control multiple Drawable objects.
Since this class inherits Drawable, user can use Drawable's Opacity and Transformation methods.
class DALI_ADAPTOR_API DrawableGroup : public Drawable
AddDrawable
Clear
Change-Id: I8b95907c2df4510f3b2f7a62c249ab634214414e
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/drawable-group-factory.h>
+#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
+
+namespace Dali
+{
+CanvasRenderer::DrawableGroup CanvasRenderer::DrawableGroup::New()
+{
+ return DrawableGroup(Internal::Adaptor::DrawableGroupFactory::New());
+}
+
+CanvasRenderer::DrawableGroup::DrawableGroup()
+{
+}
+
+CanvasRenderer::DrawableGroup::~DrawableGroup()
+{
+}
+
+CanvasRenderer::DrawableGroup::DrawableGroup(Internal::Adaptor::DrawableGroup* impl)
+: CanvasRenderer::Drawable(impl)
+{
+}
+
+bool CanvasRenderer::DrawableGroup::AddDrawable(Drawable& drawable)
+{
+ return GetImplementation(*this).AddDrawable(drawable);
+}
+
+bool CanvasRenderer::DrawableGroup::Clear()
+{
+ return GetImplementation(*this).Clear();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_DRAWABLE_GROUP_H
+#define DALI_CANVAS_RENDERER_DRAWABLE_GROUP_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-handle.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class CanvasRenderer;
+class DrawableGroup;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief A class that holds many Drawable object. As a whole they can be transformed, their transparency can be changed.
+ */
+class DALI_ADAPTOR_API CanvasRenderer::DrawableGroup : public CanvasRenderer::Drawable
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer::DrawableGroup.
+ * @return A handle to a newly allocated DrawableGroup
+ */
+ static DrawableGroup New();
+
+public:
+ /**
+ * @brief Creates an empty handle. Use CanvasRenderer::DrawableGroup::New() to create an initialized object.
+ */
+ DrawableGroup();
+
+ /**
+ * @brief Destructor.
+ */
+ ~DrawableGroup();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ DrawableGroup(const DrawableGroup& handle) = default;
+
+public:
+ /**
+ * @brief Add drawable object to the DrawableGroup. This method is similar to registration.
+ * @param[in] drawable The drawable object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddDrawable(Drawable& drawable);
+
+ /**
+ * @brief Clears the drawable object added to the DrawableGroup. This method does not free the memory of the added drawable object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Clear();
+
+public: // Not intended for application developers
+ /// @cond internal
+ /**
+ * @brief The constructor.
+ * @note Not intended for application developers.
+ *
+ * @param[in] pointer A pointer to a newly allocated CanvasRenderer::DrawableGroup
+ */
+ explicit DALI_INTERNAL DrawableGroup(Internal::Adaptor::DrawableGroup* impl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_DRAWABLE_GROUP_H
public:
class Drawable;
class Shape;
+ class DrawableGroup;
public:
/**
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-shape.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable-group.cpp
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.cpp
${adaptor_devel_api_dir}/adaptor-framework/clipboard.cpp
${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-shape.h
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable-group.h
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
--- /dev/null
+#ifndef DALI_INTERNAL_DRAWABLE_GROUP_FACTORY_H
+#define DALI_INTERNAL_DRAWABLE_GROUP_FACTORY_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableGroupFactory
+{
+/**
+ * @brief Creates new instance of DrawableGroup implementation
+ * @return pointer to DrawableGroup implementation instance
+ */
+Dali::Internal::Adaptor::DrawableGroup* New();
+
+} // namespace DrawableGroupFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_DRAWABLE_GROUP_FACTORY_H
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+DrawableGroup::DrawableGroup() = default;
+
+DrawableGroup::~DrawableGroup() = default;
+
+bool DrawableGroup::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+ return false;
+}
+
+bool DrawableGroup::Clear()
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_DRAWABLE_GROUP_IMPL_H
+#define DALI_INTERNAL_DRAWABLE_GROUP_IMPL_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal DrawableGroup.
+ */
+class DrawableGroup : public Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ DrawableGroup();
+
+ /**
+ * @brief Destructor.
+ */
+ ~DrawableGroup() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::AddDrawable()
+ */
+ virtual bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::Clear
+ */
+ virtual bool Clear();
+
+ DrawableGroup(const DrawableGroup&) = delete;
+ DrawableGroup& operator=(DrawableGroup&) = delete;
+ DrawableGroup(DrawableGroup&&) = delete;
+ DrawableGroup& operator=(DrawableGroup&&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::DrawableGroup& GetImplementation(Dali::CanvasRenderer::DrawableGroup& drawablegroup)
+{
+ DALI_ASSERT_ALWAYS(drawablegroup && "DrawableGroup handle is empty.");
+
+ BaseObject& handle = drawablegroup.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::DrawableGroup&>(handle);
+}
+
+inline static const Internal::Adaptor::DrawableGroup& GetImplementation(const Dali::CanvasRenderer::DrawableGroup& drawablegroup)
+{
+ DALI_ASSERT_ALWAYS(drawablegroup && "DrawableGroup handle is empty.");
+
+ const BaseObject& handle = drawablegroup.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::DrawableGroup&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_DRAWABLE_GROUP_IMPL_H
return pImpl->GetBoundingBox();
}
-void Drawable::SetDrawableAdded(bool added)
+void Drawable::SetAdded(bool added)
{
if(!pImpl)
{
return;
}
- pImpl->SetDrawableAdded(added);
+ pImpl->SetAdded(added);
+}
+
+bool Drawable::IsAdded() const
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->IsAdded();
}
void* Drawable::GetObject() const
virtual Rect<float> GetBoundingBox() const;
/**
- * @brief Set whether drawable added to the other object(canvas or drawable) or not.
+ * @brief Set whether this drawable object was added to other object(CanvasRenderer or DrawableGroup) or not.
* @param[in] added Ture if added, false otherwise.
*/
- virtual void SetDrawableAdded(bool added);
+ virtual void SetAdded(bool added);
+
+ /**
+ * @brief Returns whether this drawable object was added to another object(CanvasRenderer or DrawableGroup).
+ * @return Returns Ture if added, false otherwise.
+ */
+ virtual bool IsAdded() const;
/**
* @brief Returns a drawable object pointer.
${adaptor_canvas_renderer_dir}/common/shape-impl.cpp
${adaptor_canvas_renderer_dir}/generic/shape-factory-generic.cpp
${adaptor_canvas_renderer_dir}/generic/shape-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/drawable-group-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/drawable-group-impl-generic.cpp
)
# module: canvas-renderer, backend: ubuntu
${adaptor_canvas_renderer_dir}/common/shape-impl.cpp
${adaptor_canvas_renderer_dir}/ubuntu/shape-factory-ubuntu.cpp
${adaptor_canvas_renderer_dir}/ubuntu/shape-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/drawable-group-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/drawable-group-impl-ubuntu.cpp
)
# module: canvas-renderer, backend: tizen (generic, ivi, mobile, tizen-post, tv, wearable)
${adaptor_canvas_renderer_dir}/common/shape-impl.cpp
${adaptor_canvas_renderer_dir}/tizen/shape-factory-tizen.cpp
${adaptor_canvas_renderer_dir}/tizen/shape-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/drawable-group-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/drawable-group-impl-tizen.cpp
)
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/generic/drawable-group-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableGroupFactory
+{
+Dali::Internal::Adaptor::DrawableGroup* New()
+{
+ return Dali::Internal::Adaptor::DrawableGroupGeneric::New();
+}
+
+} // namespace DrawableGroupFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/canvas-renderer/generic/drawable-group-impl-generic.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace // unnamed namespace
+{
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::DrawableGroup), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableGroupGeneric* DrawableGroupGeneric::New()
+{
+ return new DrawableGroupGeneric();
+}
+
+DrawableGroupGeneric::DrawableGroupGeneric()
+{
+}
+
+DrawableGroupGeneric::~DrawableGroupGeneric()
+{
+}
+
+bool DrawableGroupGeneric::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+ return false;
+}
+
+bool DrawableGroupGeneric::Clear()
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_DRAWABLE_GROUP_INTERFACE_GENERIC_H
+#define DALI_INTERNAL_GENERIC_DRAWABLE_GROUP_INTERFACE_GENERIC_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal DrawableGroup.
+ */
+class DrawableGroupGeneric : public Dali::Internal::Adaptor::DrawableGroup
+{
+public:
+ /**
+ * @brief Creates a DrawableGroup object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static DrawableGroupGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::Clear
+ */
+ bool Clear() override;
+
+private:
+ DrawableGroupGeneric(const DrawableGroupGeneric&) = delete;
+ DrawableGroupGeneric& operator=(DrawableGroupGeneric&) = delete;
+ DrawableGroupGeneric(DrawableGroupGeneric&&) = delete;
+ DrawableGroupGeneric& operator=(DrawableGroupGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ DrawableGroupGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableGroupGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_DRAWABLE_GROUP_INTERFACE_GENERIC_H
return Rect<float>(0, 0, 0, 0);
}
-void DrawableGeneric::SetDrawableAdded(bool added)
+void DrawableGeneric::SetAdded(bool added)
{
}
+bool DrawableGeneric::IsAdded() const
+{
+ return false;
+}
+
void DrawableGeneric::SetObject(const void* object)
{
}
Rect<float> GetBoundingBox() const override;
/**
- * @copydoc Internal::Adaptor::Drawable::SetDrawableAdded
+ * @copydoc Internal::Adaptor::Drawable::SetAdded
*/
- void SetDrawableAdded(bool added) override;
+ void SetAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::IsAdded
+ */
+ bool IsAdded() const override;
/**
* @copydoc Internal::Adaptor::Drawable::SetObject
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
return false;
}
- drawableImpl.SetDrawableAdded(true);
+ drawableImpl.SetAdded(true);
mDrawables.push_back(drawable);
mChanged = true;
std::unique_ptr<tvg::SwCanvas> mTvgCanvas;
tvg::Scene* mTvgRoot;
#endif
- typedef std::vector<WeakHandle<Dali::CanvasRenderer::Drawable> > DrawableVector;
- typedef DrawableVector::iterator DrawableVectorIterator;
- DrawableVector mDrawables;
+ using DrawableVector = std::vector<WeakHandle<Dali::CanvasRenderer::Drawable>>;
+ using DrawableVectorIterator = DrawableVector::iterator;
+ DrawableVector mDrawables;
Vector2 mSize;
Vector2 mViewBox;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/tizen/drawable-group-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableGroupFactory
+{
+Dali::Internal::Adaptor::DrawableGroup* New()
+{
+ return Dali::Internal::Adaptor::DrawableGroupTizen::New();
+}
+
+} // namespace DrawableGroupFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/canvas-renderer/tizen/drawable-group-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace // unnamed namespace
+{
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::DrawableGroup), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableGroupTizen* DrawableGroupTizen::New()
+{
+ return new DrawableGroupTizen();
+}
+
+DrawableGroupTizen::DrawableGroupTizen()
+#ifdef THORVG_SUPPORT
+: mTvgScene(nullptr)
+#endif
+{
+ Initialize();
+}
+
+DrawableGroupTizen::~DrawableGroupTizen()
+{
+}
+
+void DrawableGroupTizen::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgScene = tvg::Scene::gen().release();
+ if(!mTvgScene)
+ {
+ DALI_LOG_ERROR("DrawableGroup is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgScene));
+#endif
+}
+
+bool DrawableGroupTizen::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+#ifdef THORVG_SUPPORT
+ 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.IsAdded())
+ {
+ DALI_LOG_ERROR("Already added somewhere [%p][%p]\n", this, &drawable);
+ return false;
+ }
+
+ if(mTvgScene->push(std::unique_ptr<tvg::Paint>(pDrawable)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
+ return false;
+ }
+
+ drawableImpl.SetAdded(true);
+ mDrawables.push_back(drawable);
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool DrawableGroupTizen::Clear()
+{
+#ifdef THORVG_SUPPORT
+ if(!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.SetAdded(false);
+ }
+
+ mDrawables.clear();
+
+ if(static_cast<tvg::Scene*>(mTvgScene)->clear() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Clear() fail.\n");
+ return false;
+ }
+
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_DRAWABLE_GROUP_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_DRAWABLE_GROUP_IMPL_TIZEN_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/weak-handle.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal DrawableGroup.
+ */
+class DrawableGroupTizen : public Dali::Internal::Adaptor::DrawableGroup
+{
+public:
+ /**
+ * @brief Creates a DrawableGroup object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static DrawableGroupTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::Clear
+ */
+ bool Clear() override;
+
+private:
+ DrawableGroupTizen(const DrawableGroupTizen&) = delete;
+ DrawableGroupTizen& operator=(DrawableGroupTizen&) = delete;
+ DrawableGroupTizen(DrawableGroupTizen&&) = delete;
+ DrawableGroupTizen& operator=(DrawableGroupTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ DrawableGroupTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableGroupTizen() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::Scene* mTvgScene;
+#endif
+ using DrawableVector = std::vector<WeakHandle<Dali::CanvasRenderer::Drawable>>;
+ using DrawableVectorIterator = DrawableVector::iterator;
+ DrawableVector mDrawables;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_DRAWABLE_GROUP_IMPL_TIZEN_H
#endif
}
-void DrawableTizen::SetDrawableAdded(bool added)
+void DrawableTizen::SetAdded(bool added)
{
mAdded = !!added;
}
+bool DrawableTizen::IsAdded() const
+{
+ return mAdded;
+}
+
void* DrawableTizen::GetObject() const
{
#ifdef THORVG_SUPPORT
Rect<float> GetBoundingBox() const override;
/**
- * @copydoc Internal::Adaptor::Drawable::SetDrawableAdded
+ * @copydoc Internal::Adaptor::Drawable::SetAdded
*/
- void SetDrawableAdded(bool added) override;
+ void SetAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::IsAdded
+ */
+ bool IsAdded() const override;
/**
* @copydoc Internal::Adaptor::Drawable::SetObject
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~ShapeTizen() override;
private:
+ /**
+ * @brief Initializes member data.
+ */
void Initialize();
#ifdef THORVG_SUPPORT
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
return false;
}
- drawableImpl.SetDrawableAdded(true);
+ drawableImpl.SetAdded(true);
mDrawables.push_back(drawable);
mChanged = true;
std::unique_ptr<tvg::SwCanvas> mTvgCanvas;
tvg::Scene* mTvgRoot;
#endif
- typedef std::vector<WeakHandle<Dali::CanvasRenderer::Drawable> > DrawableVector;
- typedef DrawableVector::iterator DrawableVectorIterator;
- DrawableVector mDrawables;
+ using DrawableVector = std::vector<WeakHandle<Dali::CanvasRenderer::Drawable>>;
+ using DrawableVectorIterator = DrawableVector::iterator;
+ DrawableVector mDrawables;
Vector2 mSize;
Vector2 mViewBox;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/ubuntu/drawable-group-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableGroupFactory
+{
+Dali::Internal::Adaptor::DrawableGroup* New()
+{
+ return Dali::Internal::Adaptor::DrawableGroupUbuntu::New();
+}
+
+} // namespace DrawableGroupFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/canvas-renderer/ubuntu/drawable-group-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace // unnamed namespace
+{
+// Type Registration
+Dali::BaseHandle Create()
+{
+ return Dali::BaseHandle();
+}
+
+Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::DrawableGroup), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableGroupUbuntu* DrawableGroupUbuntu::New()
+{
+ return new DrawableGroupUbuntu();
+}
+
+DrawableGroupUbuntu::DrawableGroupUbuntu()
+#ifdef THORVG_SUPPORT
+: mTvgScene(nullptr)
+#endif
+{
+ Initialize();
+}
+
+DrawableGroupUbuntu::~DrawableGroupUbuntu()
+{
+}
+
+void DrawableGroupUbuntu::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgScene = tvg::Scene::gen().release();
+ if(!mTvgScene)
+ {
+ DALI_LOG_ERROR("DrawableGroup is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgScene));
+#endif
+}
+
+bool DrawableGroupUbuntu::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+#ifdef THORVG_SUPPORT
+ 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.IsAdded())
+ {
+ DALI_LOG_ERROR("Already added somewhere [%p][%p]\n", this, &drawable);
+ return false;
+ }
+
+ if(mTvgScene->push(std::unique_ptr<tvg::Paint>(pDrawable)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
+ return false;
+ }
+
+ drawableImpl.SetAdded(true);
+ mDrawables.push_back(drawable);
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool DrawableGroupUbuntu::Clear()
+{
+#ifdef THORVG_SUPPORT
+ if(!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.SetAdded(false);
+ }
+
+ mDrawables.clear();
+
+ if(static_cast<tvg::Scene*>(mTvgScene)->clear() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Clear() fail.\n");
+ return false;
+ }
+
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_DRAWABLE_GROUP_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_DRAWABLE_GROUP_IMPL_UBUNTU_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/weak-handle.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable-group.h>
+#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal DrawableGroup.
+ */
+class DrawableGroupUbuntu : public Dali::Internal::Adaptor::DrawableGroup
+{
+public:
+ /**
+ * @brief Creates a DrawableGroup object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static DrawableGroupUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::DrawableGroup::Clear
+ */
+ bool Clear() override;
+
+private:
+ DrawableGroupUbuntu(const DrawableGroupUbuntu&) = delete;
+ DrawableGroupUbuntu& operator=(DrawableGroupUbuntu&) = delete;
+ DrawableGroupUbuntu(DrawableGroupUbuntu&&) = delete;
+ DrawableGroupUbuntu& operator=(DrawableGroupUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ DrawableGroupUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableGroupUbuntu() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::Scene* mTvgScene;
+#endif
+ using DrawableVector = std::vector<WeakHandle<Dali::CanvasRenderer::Drawable>>;
+ using DrawableVectorIterator = DrawableVector::iterator;
+ DrawableVector mDrawables;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_DRAWABLE_GROUP_IMPL_UBUNTU_H
#endif
}
-void DrawableUbuntu::SetDrawableAdded(bool added)
+void DrawableUbuntu::SetAdded(bool added)
{
mAdded = !!added;
}
+bool DrawableUbuntu::IsAdded() const
+{
+ return mAdded;
+}
+
void* DrawableUbuntu::GetObject() const
{
#ifdef THORVG_SUPPORT
Rect<float> GetBoundingBox() const override;
/**
- * @copydoc Internal::Adaptor::Drawable::SetDrawableAdded
+ * @copydoc Internal::Adaptor::Drawable::SetAdded
*/
- void SetDrawableAdded(bool added) override;
+ void SetAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::IsAdded
+ */
+ bool IsAdded() const override;
/**
* @copydoc Internal::Adaptor::Drawable::SetObject
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~ShapeUbuntu() override;
private:
+ /**
+ * @brief Initializes member data.
+ */
void Initialize();
#ifdef THORVG_SUPPORT