CanvasRenderer:: Add Picture class 65/261765/6
authorJunsuChoi <jsuya.choi@samsung.com>
Mon, 26 Jul 2021 01:46:26 +0000 (10:46 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Fri, 13 Aug 2021 00:08:35 +0000 (09:08 +0900)
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

18 files changed:
dali/devel-api/adaptor-framework/canvas-renderer-picture.cpp [new file with mode: 0644]
dali/devel-api/adaptor-framework/canvas-renderer-picture.h [new file with mode: 0644]
dali/devel-api/adaptor-framework/canvas-renderer.h
dali/devel-api/file.list
dali/internal/canvas-renderer/common/drawable-impl.h
dali/internal/canvas-renderer/common/picture-factory.h [new file with mode: 0644]
dali/internal/canvas-renderer/common/picture-impl.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/common/picture-impl.h [new file with mode: 0644]
dali/internal/canvas-renderer/file.list
dali/internal/canvas-renderer/generic/picture-factory-generic.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/generic/picture-impl-generic.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/generic/picture-impl-generic.h [new file with mode: 0644]
dali/internal/canvas-renderer/tizen/picture-factory-tizen.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/tizen/picture-impl-tizen.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/tizen/picture-impl-tizen.h [new file with mode: 0644]
dali/internal/canvas-renderer/ubuntu/picture-factory-ubuntu.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.cpp [new file with mode: 0644]
dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.h [new file with mode: 0644]

diff --git a/dali/devel-api/adaptor-framework/canvas-renderer-picture.cpp b/dali/devel-api/adaptor-framework/canvas-renderer-picture.cpp
new file mode 100644 (file)
index 0000000..7a897a5
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* 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
diff --git a/dali/devel-api/adaptor-framework/canvas-renderer-picture.h b/dali/devel-api/adaptor-framework/canvas-renderer-picture.h
new file mode 100644 (file)
index 0000000..c3af63e
--- /dev/null
@@ -0,0 +1,119 @@
+#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
index b68208e..1f3e168 100644 (file)
@@ -85,6 +85,7 @@ public:
   class Drawable;
   class Shape;
   class DrawableGroup;
+  class Picture;
 
   class Gradient;
   class LinearGradient;
index 5c2de65..c87ab49 100755 (executable)
@@ -8,6 +8,7 @@ SET( devel_api_src_files
   ${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
@@ -65,6 +66,7 @@ SET( devel_api_adaptor_framework_header_files
   ${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
index 8526dec..811a0d3 100644 (file)
@@ -42,9 +42,10 @@ public:
    */
   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.
   };
 
   /**
diff --git a/dali/internal/canvas-renderer/common/picture-factory.h b/dali/internal/canvas-renderer/common/picture-factory.h
new file mode 100644 (file)
index 0000000..2a32581
--- /dev/null
@@ -0,0 +1,46 @@
+#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
diff --git a/dali/internal/canvas-renderer/common/picture-impl.cpp b/dali/internal/canvas-renderer/common/picture-impl.cpp
new file mode 100644 (file)
index 0000000..ef28b5d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/common/picture-impl.h b/dali/internal/canvas-renderer/common/picture-impl.h
new file mode 100644 (file)
index 0000000..ed4aa59
--- /dev/null
@@ -0,0 +1,95 @@
+#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
index a941e5d..c98ad01 100644 (file)
@@ -28,6 +28,10 @@ SET( adaptor_canvas_renderer_generic_src_files
     ${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
@@ -59,6 +63,10 @@ SET( adaptor_canvas_renderer_ubuntu_src_files
     ${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)
@@ -91,4 +99,7 @@ SET( adaptor_canvas_renderer_tizen_src_files
     ${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
 )
diff --git a/dali/internal/canvas-renderer/generic/picture-factory-generic.cpp b/dali/internal/canvas-renderer/generic/picture-factory-generic.cpp
new file mode 100644 (file)
index 0000000..b587426
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/generic/picture-impl-generic.cpp b/dali/internal/canvas-renderer/generic/picture-impl-generic.cpp
new file mode 100644 (file)
index 0000000..15b9611
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/generic/picture-impl-generic.h b/dali/internal/canvas-renderer/generic/picture-impl-generic.h
new file mode 100644 (file)
index 0000000..983478d
--- /dev/null
@@ -0,0 +1,84 @@
+#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
diff --git a/dali/internal/canvas-renderer/tizen/picture-factory-tizen.cpp b/dali/internal/canvas-renderer/tizen/picture-factory-tizen.cpp
new file mode 100644 (file)
index 0000000..681b89b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/tizen/picture-impl-tizen.cpp b/dali/internal/canvas-renderer/tizen/picture-impl-tizen.cpp
new file mode 100644 (file)
index 0000000..c3b24f1
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/tizen/picture-impl-tizen.h b/dali/internal/canvas-renderer/tizen/picture-impl-tizen.h
new file mode 100644 (file)
index 0000000..3ceae49
--- /dev/null
@@ -0,0 +1,98 @@
+#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
diff --git a/dali/internal/canvas-renderer/ubuntu/picture-factory-ubuntu.cpp b/dali/internal/canvas-renderer/ubuntu/picture-factory-ubuntu.cpp
new file mode 100644 (file)
index 0000000..16d5d7c
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.cpp b/dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.cpp
new file mode 100644 (file)
index 0000000..c4cd4e5
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 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
diff --git a/dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.h b/dali/internal/canvas-renderer/ubuntu/picture-impl-ubuntu.h
new file mode 100644 (file)
index 0000000..3c2f796
--- /dev/null
@@ -0,0 +1,98 @@
+#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