Add Picture class to rasterize Image to canvas with vector primitive.
ex)
Dali::CanvasRenderer::Picture picture = Dali::CanvasRenderer::Picture::New();
picture.Load(IMAGE_PATH);
picture.SetSize(Vector2(100, 400));
CanvasView.AddDrawable(picture);
Change-Id: I5a74a3b8baef206893aa1cf2a6559b6cf854707b
--- /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-picture.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/picture-factory.h>
+#include <dali/internal/canvas-renderer/common/picture-impl.h>
+
+namespace Dali
+{
+CanvasRenderer::Picture CanvasRenderer::Picture::New()
+{
+ return Picture(Internal::Adaptor::PictureFactory::New());
+}
+
+CanvasRenderer::Picture::Picture()
+{
+}
+
+CanvasRenderer::Picture::~Picture()
+{
+}
+
+CanvasRenderer::Picture::Picture(Internal::Adaptor::Picture* impl)
+: CanvasRenderer::Drawable(impl)
+{
+}
+
+bool CanvasRenderer::Picture::Load(const std::string& url)
+{
+ return GetImplementation(*this).Load(url);
+}
+
+bool CanvasRenderer::Picture::SetSize(Vector2 size)
+{
+ return GetImplementation(*this).SetSize(size);
+}
+
+Vector2 CanvasRenderer::Picture::GetSize() const
+{
+ return GetImplementation(*this).GetSize();
+}
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_PICTURE_H
+#define DALI_CANVAS_RENDERER_PICTURE_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 Picture;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief A class representing an image read in one of the supported formats: raw, svg, png and etc.
+ * Besides the methods inherited from the Drawable, it provides methods to load & draw images on the canvas.
+ */
+class DALI_ADAPTOR_API CanvasRenderer::Picture : public CanvasRenderer::Drawable
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer::Picture.
+ *
+ * @return A handle to a newly allocated Picture
+ */
+ static Picture New();
+
+public:
+ /**
+ * @brief Creates an empty handle.
+ * Use CanvasRenderer::Picture::New() to create an initialized object.
+ */
+ Picture();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Picture();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ Picture(const Picture& handle) = default;
+
+public:
+ /**
+ * @brief Loads a picture data directly from a file.
+ * @param[in] url A path to the picture file.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Load(const std::string& url);
+
+ /**
+ * @brief Resize the picture content with the given size.
+ *
+ * Resize the picture content while keeping the default size aspect ratio.
+ * The scaling factor is established for each of dimensions and the smaller value is applied to both of them.
+ * @param[in] size A new size of the image in pixels.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetSize(Vector2 size);
+
+ /**
+ * @brief Gets the size of the image.
+ * @return Returns The size of the image in pixels.
+ */
+ Vector2 GetSize() const;
+
+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::Picture
+ */
+ explicit DALI_INTERNAL Picture(Internal::Adaptor::Picture* impl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_PICTURE_H
class Drawable;
class Shape;
class DrawableGroup;
+ class Picture;
class Gradient;
class LinearGradient;
${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.cpp
${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-picture.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable-group.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-shape.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-gradient.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-gradient.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-linear-gradient.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-radial-gradient.h
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-picture.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
*/
enum class Types
{
- NONE = 0, ///< Means that type is not defined.
- SHAPE, ///< Meaning of Shape class that inherits Drawable.
- DRAWABLE_GROUP ///< Meaning of DrawableGorup class that inherits Drawable.
+ NONE = 0, ///< Means that type is not defined.
+ SHAPE, ///< Meaning of Shape class that inherits Drawable.
+ DRAWABLE_GROUP, ///< Meaning of DrawableGorup class that inherits Drawable.
+ PICTURE ///< Meaning of Picture class that inherits Drawable.
};
/**
--- /dev/null
+#ifndef DALI_INTERNAL_PICTURE_FACTORY_H
+#define DALI_INTERNAL_PICTURE_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-picture.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace PictureFactory
+{
+/**
+ * @brief Creates new instance of Picture implementation
+ * @return pointer to Picture implementation instance
+ */
+Dali::Internal::Adaptor::Picture* New();
+
+} // namespace PictureFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_PICTURE_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/picture-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+Picture::Picture() = default;
+
+Picture::~Picture() = default;
+
+bool Picture::Load(const std::string& url)
+{
+ return false;
+}
+
+bool Picture::SetSize(Vector2 size)
+{
+ return false;
+}
+
+Vector2 Picture::GetSize() const
+{
+ return Vector2::ZERO;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_PICTURE_IMPL_H
+#define DALI_INTERNAL_PICTURE_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-picture.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Picture.
+ */
+class Picture : public Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Picture();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Picture() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::Load()
+ */
+ virtual bool Load(const std::string& url);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::SetSize()
+ */
+ virtual bool SetSize(Vector2 size);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::GetSize()
+ */
+ virtual Vector2 GetSize() const;
+
+ Picture(const Picture&) = delete;
+ Picture& operator=(Picture&) = delete;
+ Picture(Picture&&) = delete;
+ Picture& operator=(Picture&&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::Picture& GetImplementation(Dali::CanvasRenderer::Picture& picture)
+{
+ DALI_ASSERT_ALWAYS(picture && "Picture handle is empty.");
+
+ BaseObject& handle = picture.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Picture&>(handle);
+}
+
+inline static const Internal::Adaptor::Picture& GetImplementation(const Dali::CanvasRenderer::Picture& picture)
+{
+ DALI_ASSERT_ALWAYS(picture && "Picture handle is empty.");
+
+ const BaseObject& handle = picture.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Picture&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_PICTURE_IMPL_H
${adaptor_canvas_renderer_dir}/common/radial-gradient-impl.cpp
${adaptor_canvas_renderer_dir}/generic/radial-gradient-factory-generic.cpp
${adaptor_canvas_renderer_dir}/generic/radial-gradient-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/picture-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/picture-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/picture-impl-generic.cpp
)
# module: canvas-renderer, backend: ubuntu
${adaptor_canvas_renderer_dir}/common/radial-gradient-impl.cpp
${adaptor_canvas_renderer_dir}/ubuntu/radial-gradient-factory-ubuntu.cpp
${adaptor_canvas_renderer_dir}/ubuntu/radial-gradient-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/picture-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/picture-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/picture-impl-ubuntu.cpp
)
# module: canvas-renderer, backend: tizen (generic, ivi, mobile, tizen-post, tv, wearable)
${adaptor_canvas_renderer_dir}/tizen/radial-gradient-factory-tizen.cpp
${adaptor_canvas_renderer_dir}/tizen/radial-gradient-impl-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/common/picture-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/picture-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/picture-impl-tizen.cpp
)
--- /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/picture-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace PictureFactory
+{
+Dali::Internal::Adaptor::Picture* New()
+{
+ return Dali::Internal::Adaptor::PictureGeneric::New();
+}
+
+} // namespace PictureFactory
+
+} // 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/picture-impl-generic.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#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::Picture), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+PictureGeneric* PictureGeneric::New()
+{
+ return new PictureGeneric();
+}
+
+PictureGeneric::PictureGeneric()
+{
+}
+
+PictureGeneric::~PictureGeneric()
+{
+}
+
+bool PictureGeneric::Load(const std::string& url)
+{
+ return false;
+}
+
+bool PictureGeneric::SetSize(Vector2 size)
+{
+ return false;
+}
+
+Vector2 PictureGeneric::GetSize() const
+{
+ return Vector2::ZERO;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_PICTURE_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_PICTURE_IMPL_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-picture.h>
+#include <dali/internal/canvas-renderer/common/picture-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Picture.
+ */
+class PictureGeneric : public Dali::Internal::Adaptor::Picture
+{
+public:
+ /**
+ * @brief Creates a Picture object.
+ * @return A pointer to a newly allocated picture
+ */
+ static PictureGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::Load()
+ */
+ bool Load(const std::string& url) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::SetSize()
+ */
+ bool SetSize(Vector2 size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::GetSize()
+ */
+ Vector2 GetSize() const override;
+
+private:
+ PictureGeneric(const PictureGeneric&) = delete;
+ PictureGeneric& operator=(PictureGeneric&) = delete;
+ PictureGeneric(PictureGeneric&&) = delete;
+ PictureGeneric& operator=(PictureGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ PictureGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ ~PictureGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_PICTURE_IMPL_GENERIC_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.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/tizen/picture-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace PictureFactory
+{
+Dali::Internal::Adaptor::Picture* New()
+{
+ return Dali::Internal::Adaptor::PictureTizen::New();
+}
+
+} // namespace PictureFactory
+
+} // 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/picture-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#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::Picture), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+PictureTizen* PictureTizen::New()
+{
+ return new PictureTizen();
+}
+
+PictureTizen::PictureTizen()
+#ifdef THORVG_SUPPORT
+: mTvgPicture(nullptr)
+#endif
+{
+ Initialize();
+}
+
+PictureTizen::~PictureTizen()
+{
+}
+
+void PictureTizen::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgPicture = tvg::Picture::gen().release();
+ if(!mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgPicture));
+ Drawable::SetType(Drawable::Types::PICTURE);
+#endif
+}
+
+bool PictureTizen::Load(const std::string& url)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return false;
+ }
+ if(url.empty())
+ {
+ DALI_LOG_ERROR("Url is empty [%p]\n", this);
+ return false;
+ }
+
+ if(mTvgPicture->load(url.c_str()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Load() fail. (%s)\n", url.c_str());
+ return false;
+ }
+
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool PictureTizen::SetSize(Vector2 size)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgPicture->size(size.width, size.height) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetSize() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Vector2 PictureTizen::GetSize() const
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return Vector2::ZERO;
+ }
+
+ auto width = 0.0f;
+ auto height = 0.0f;
+
+ if(mTvgPicture->size(&width, &height) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetSize() fail.\n");
+ return Vector2::ZERO;
+ }
+ return Vector2(width, height);
+#else
+ return Vector2::ZERO;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_PICTURE_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_PICTURE_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>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-picture.h>
+#include <dali/internal/canvas-renderer/common/picture-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Picture.
+ */
+class PictureTizen : public Dali::Internal::Adaptor::Picture
+{
+public:
+ /**
+ * @brief Creates a Picture object.
+ * @return A pointer to a newly allocated picture
+ */
+ static PictureTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::Load()
+ */
+ bool Load(const std::string& url) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::SetSize()
+ */
+ bool SetSize(Vector2 size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::GetSize()
+ */
+ Vector2 GetSize() const override;
+
+private:
+ PictureTizen(const PictureTizen&) = delete;
+ PictureTizen& operator=(PictureTizen&) = delete;
+ PictureTizen(PictureTizen&&) = delete;
+ PictureTizen& operator=(PictureTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ PictureTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ ~PictureTizen() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::Picture* mTvgPicture;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_PICTURE_IMPL_TIZEN_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.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace PictureFactory
+{
+Dali::Internal::Adaptor::Picture* New()
+{
+ return Dali::Internal::Adaptor::PictureUbuntu::New();
+}
+
+} // namespace PictureFactory
+
+} // 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/picture-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#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::Picture), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+PictureUbuntu* PictureUbuntu::New()
+{
+ return new PictureUbuntu();
+}
+
+PictureUbuntu::PictureUbuntu()
+#ifdef THORVG_SUPPORT
+: mTvgPicture(nullptr)
+#endif
+{
+ Initialize();
+}
+
+PictureUbuntu::~PictureUbuntu()
+{
+}
+
+void PictureUbuntu::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgPicture = tvg::Picture::gen().release();
+ if(!mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgPicture));
+ Drawable::SetType(Drawable::Types::PICTURE);
+#endif
+}
+
+bool PictureUbuntu::Load(const std::string& url)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return false;
+ }
+ if(url.empty())
+ {
+ DALI_LOG_ERROR("Url is empty [%p]\n", this);
+ return false;
+ }
+
+ if(mTvgPicture->load(url.c_str()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Load() fail. (%s)\n", url.c_str());
+ return false;
+ }
+
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool PictureUbuntu::SetSize(Vector2 size)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgPicture->size(size.width, size.height) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetSize() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Vector2 PictureUbuntu::GetSize() const
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgPicture)
+ {
+ DALI_LOG_ERROR("Picture is null [%p]\n", this);
+ return Vector2::ZERO;
+ }
+
+ auto width = 0.0f;
+ auto height = 0.0f;
+
+ if(mTvgPicture->size(&width, &height) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetSize() fail.\n");
+ return Vector2::ZERO;
+ }
+
+ return Vector2(width, height);
+#else
+ return Vector2::ZERO;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_PICTURE_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_PICTURE_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>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-picture.h>
+#include <dali/internal/canvas-renderer/common/picture-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Picture.
+ */
+class PictureUbuntu : public Dali::Internal::Adaptor::Picture
+{
+public:
+ /**
+ * @brief Creates a Picture object.
+ * @return A pointer to a newly allocated picture
+ */
+ static PictureUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::Load()
+ */
+ bool Load(const std::string& url) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::SetSize()
+ */
+ bool SetSize(Vector2 size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Picture::GetSize()
+ */
+ Vector2 GetSize() const override;
+
+private:
+ PictureUbuntu(const PictureUbuntu&) = delete;
+ PictureUbuntu& operator=(PictureUbuntu&) = delete;
+ PictureUbuntu(PictureUbuntu&&) = delete;
+ PictureUbuntu& operator=(PictureUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ PictureUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ ~PictureUbuntu() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::Picture* mTvgPicture;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_PICTURE_IMPL_UBUNTU_H