CanvasRenderer draws Vector Primitives using ThorVG library and draws them to Buffer.
Note:
Currently, the Canvas's buffer is using PixelData.
This buffer strategy will be changed to tbmBuffer in the future.
class CanvasRenderer : public BaseHandle
New
Commit
AddDrawable
GetPixelBuffer
SetSize
GetSize
class Drawable : public BaseHandle
SetOpacity
GetOpacity
Rotate
Scale
Translate
Transform
class DALI_ADAPTOR_API Shape : public Drawable
enum StrokeCap{ SQUARE, ROUND, BUTT };
enum StrokeJoin { BEVEL, ROUND, MITER };
enum FillRule { WINDING, EVENODD };
New
AddRect
AddCircle
AddArc
AddMoveTo
AddLineTo
AddCubicTo
Close
SetFillColor
GetFillColor
SetFillRule
GetFillRule
SetStrokeWidth
GetStrokeWidth
SetStrokeColor
GetStrokeColor
SetStrokeDash
GetStrokeDash
SetStrokeCap
GetStrokeCap
SetStrokeJoin
GetStrokeJoin
Change-Id: I1b7ee95eeb528e599deb403bbe8599bd23b08d35
CHECK_MODULE_AND_SET( DALICORE dali2-core [] )
+CHECK_MODULE_AND_SET( THORVG thorvg thorvg_support )
+
+IF( thorvg_support )
+ ADD_DEFINITIONS( -DTHORVG_SUPPORT )
+ENDIF()
+
IF( ANDROID_PROFILE )
INCLUDE_DIRECTORIES( ${ANDROID_NDK} )
INCLUDE_DIRECTORIES( ${ANDROID_NDK}/sources )
${FREETYPE_CFLAGS}
${FONTCONFIG_CFLAGS}
${CAIRO_CFLAGS}
+ ${THORVG_CFLAGS}
${PNG_CFLAGS}
${WEBP_CFLAGS}
${WEBP_DEMUX_CFLAGS}
${FREETYPE_LDFLAGS}
${FONTCONFIG_LDFLAGS}
${CAIRO_LDFLAGS}
+ ${THORVG_LDFLAGS}
${PNG_LDFLAGS}
${WEBP_LDFLAGS}
${WEBP_DEMUX_LDFLAGS}
SET( adaptor_vector_image_dir ${ADAPTOR_ROOT}/dali/internal/vector-image )
include( ${ADAPTOR_ROOT}/dali/internal/vector-image/file.list )
+SET( adaptor_canvas_renderer_dir ${ADAPTOR_ROOT}/dali/internal/canvas-renderer )
+include( ${ADAPTOR_ROOT}/dali/internal/canvas-renderer/file.list )
+
SET( adaptor_public_api_dir ${ADAPTOR_ROOT}/dali/public-api )
include( ${ADAPTOR_ROOT}/dali/public-api/file.list )
SET( adaptor_vector_image_dir ${ADAPTOR_ROOT}/dali/internal/vector-image )
include( ${ADAPTOR_ROOT}/dali/internal/vector-image/file.list )
+SET( adaptor_canvas_renderer_dir ${ADAPTOR_ROOT}/dali/internal/canvas-renderer )
+include( ${ADAPTOR_ROOT}/dali/internal/canvas-renderer/file.list )
+
SET( adaptor_public_api_dir ${ADAPTOR_ROOT}/dali/public-api )
include( ${ADAPTOR_ROOT}/dali/public-api/file.list )
${adaptor_accessibility_common_src_files}
${adaptor_accessibility_android_src_files}
${adaptor_adaptor_common_src_files}
+ ${adaptor_canvas_renderer_generic_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_android_src_files}
${adaptor_framework_android_src_files}
${adaptor_accessibility_tizen_common_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
+ ${adaptor_canvas_renderer_tizen_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${adaptor_accessibility_tizen_ivi_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
+ ${adaptor_canvas_renderer_tizen_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${adaptor_accessibility_common_src_files}
${adaptor_accessibility_macos_src_files}
${adaptor_adaptor_common_src_files}
+ ${adaptor_canvas_renderer_generic_src_files}
${adaptor_adaptor_macos_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_macos_src_files}
${adaptor_accessibility_tizen_mobile_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
+ ${adaptor_canvas_renderer_tizen_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${adaptor_accessibility_tizen_tv_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
+ ${adaptor_canvas_renderer_tizen_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${adaptor_accessibility_ubuntu_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_ubuntu_src_files}
+ ${adaptor_canvas_renderer_ubuntu_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_ubuntu_x11_src_files}
${adaptor_framework_generic_src_files}
${adaptor_adaptor_common_src_files}
${adaptor_adaptor_tizen_wayland_src_files}
${adaptor_adaptor_tizen_wearable_src_files}
+ ${adaptor_canvas_renderer_tizen_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_clipboard_tizen_wayland_src_files}
${adaptor_framework_generic_src_files}
${adaptor_accessibility_common_src_files}
${adaptor_accessibility_windows_src_files}
${adaptor_adaptor_common_src_files}
+ ${adaptor_canvas_renderer_generic_src_files}
${adaptor_clipboard_common_src_files}
${adaptor_framework_generic_src_files}
${devel_api_src_files}
--- /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.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+// CanvasRenderer::Drawable
+//
+CanvasRenderer::Drawable::Drawable()
+{
+}
+
+CanvasRenderer::Drawable::~Drawable()
+{
+}
+
+CanvasRenderer::Drawable::Drawable(Internal::Adaptor::Drawable* pImpl)
+: BaseHandle(pImpl)
+{
+}
+
+bool CanvasRenderer::Drawable::SetOpacity(float opacity)
+{
+ return GetImplementation(*this).SetOpacity(opacity);
+}
+
+float CanvasRenderer::Drawable::GetOpacity() const
+{
+ return GetImplementation(*this).GetOpacity();
+}
+
+bool CanvasRenderer::Drawable::Rotate(Degree degree)
+{
+ return GetImplementation(*this).Rotate(degree);
+}
+
+bool CanvasRenderer::Drawable::Scale(float factor)
+{
+ return GetImplementation(*this).Scale(factor);
+}
+
+bool CanvasRenderer::Drawable::Translate(Vector2 translate)
+{
+ return GetImplementation(*this).Translate(translate);
+}
+
+bool CanvasRenderer::Drawable::Transform(const Dali::Matrix3& matrix)
+{
+ return GetImplementation(*this).Transform(matrix);
+}
+
+CanvasRenderer::Drawable CanvasRenderer::Drawable::DownCast(BaseHandle handle)
+{
+ return CanvasRenderer::Drawable(dynamic_cast<Internal::Adaptor::Drawable*>(handle.GetObjectPtr()));
+}
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_DRAWABLE_H
+#define DALI_CANVAS_RENDERER_DRAWABLE_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.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class CanvasRenderer;
+class Drawable;
+class Shape;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief Drawable is a object class for drawing a vector primitive.
+ */
+class CanvasRenderer::Drawable : public BaseHandle
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Drawable();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Drawable();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ Drawable(const Drawable& handle) = default;
+
+public:
+ /**
+ * @brief Set the transparency value
+ * @param[in] opacity The transparency level [0 ~ 1.0], 0 means totally transparent, while 1 means opaque.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetOpacity(float opacity);
+
+ /**
+ * @brief Get the transparency value
+ * @return Returns the transparency level
+ */
+ float GetOpacity() const;
+
+ /**
+ * @brief Set the angle of rotation transformation.
+ * @param[in] degree The degree value of angle.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Rotate(Degree degree);
+
+ /**
+ * @brief Set the scale value of scale transformation.
+ * @param[in] factor The scale factor value.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Scale(float factor);
+
+ /**
+ * @brief Set the x, y movement value of translate transformation.
+ * @param[in] translate The x and y-axis movement value.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Translate(Vector2 translate);
+
+ /**
+ * @brief Set the matrix value for affine transform.
+ * @param[in] matrix The 3x3 matrix value.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Transform(const Dali::Matrix3& matrix);
+
+ /**
+ * @brief Downcast a handle to Drawable handle.
+ *
+ * If handle points to an InputMethodContext the downcast produces valid
+ * handle. If not the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object.
+ * @return Handle to an Drawable or an uninitialized handle.
+ */
+ static Drawable DownCast(BaseHandle handle);
+
+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::Drawable
+ */
+ explicit DALI_INTERNAL Drawable(Internal::Adaptor::Drawable* pImpl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_DRAWABLE_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/devel-api/adaptor-framework/canvas-renderer-shape.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/shape-factory.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
+
+namespace Dali
+{
+CanvasRenderer::Shape CanvasRenderer::Shape::New()
+{
+ return Shape(Internal::Adaptor::ShapeFactory::New());
+}
+
+CanvasRenderer::Shape::Shape()
+{
+}
+
+CanvasRenderer::Shape::~Shape()
+{
+}
+
+CanvasRenderer::Shape::Shape(Internal::Adaptor::Shape* impl)
+: CanvasRenderer::Drawable(impl)
+{
+}
+
+bool CanvasRenderer::Shape::AddRect(Rect<float> rect, Vector2 roundedCorner)
+{
+ return GetImplementation(*this).AddRect(rect, roundedCorner);
+}
+
+bool CanvasRenderer::Shape::AddCircle(Vector2 center, Vector2 radius)
+{
+ return GetImplementation(*this).AddCircle(center, radius);
+}
+
+bool CanvasRenderer::Shape::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
+{
+ return GetImplementation(*this).AddArc(center, radius, startAngle, sweep, pie);
+}
+
+bool CanvasRenderer::Shape::AddMoveTo(Vector2 point)
+{
+ return GetImplementation(*this).AddMoveTo(point);
+}
+
+bool CanvasRenderer::Shape::AddLineTo(Vector2 line)
+{
+ return GetImplementation(*this).AddLineTo(line);
+}
+
+bool CanvasRenderer::Shape::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
+{
+ return GetImplementation(*this).AddCubicTo(controlPoint1, controlPoint2, endPoint);
+}
+
+bool CanvasRenderer::Shape::Close()
+{
+ return GetImplementation(*this).Close();
+}
+
+bool CanvasRenderer::Shape::SetFillColor(Vector4 color)
+{
+ return GetImplementation(*this).SetFillColor(color);
+}
+
+Vector4 CanvasRenderer::Shape::GetFillColor() const
+{
+ return GetImplementation(*this).GetFillColor();
+}
+
+bool CanvasRenderer::Shape::SetFillRule(CanvasRenderer::Shape::FillRule rule)
+{
+ return GetImplementation(*this).SetFillRule(rule);
+}
+
+CanvasRenderer::Shape::FillRule CanvasRenderer::Shape::GetFillRule() const
+{
+ return GetImplementation(*this).GetFillRule();
+}
+
+bool CanvasRenderer::Shape::SetStrokeWidth(float width)
+{
+ return GetImplementation(*this).SetStrokeWidth(width);
+}
+
+float CanvasRenderer::Shape::GetStrokeWidth() const
+{
+ return GetImplementation(*this).GetStrokeWidth();
+}
+
+bool CanvasRenderer::Shape::SetStrokeColor(Vector4 color)
+{
+ return GetImplementation(*this).SetStrokeColor(color);
+}
+
+Vector4 CanvasRenderer::Shape::GetStrokeColor() const
+{
+ return GetImplementation(*this).GetStrokeColor();
+}
+
+bool CanvasRenderer::Shape::SetStrokeDash(const Dali::Vector<float>& dashPattern)
+{
+ return GetImplementation(*this).SetStrokeDash(dashPattern);
+}
+
+Dali::Vector<float> CanvasRenderer::Shape::GetStrokeDash() const
+{
+ return GetImplementation(*this).GetStrokeDash();
+}
+
+bool CanvasRenderer::Shape::SetStrokeCap(CanvasRenderer::Shape::StrokeCap cap)
+{
+ return GetImplementation(*this).SetStrokeCap(cap);
+}
+
+CanvasRenderer::Shape::StrokeCap CanvasRenderer::Shape::GetStrokeCap() const
+{
+ return GetImplementation(*this).GetStrokeCap();
+}
+
+bool CanvasRenderer::Shape::SetStrokeJoin(CanvasRenderer::Shape::StrokeJoin join)
+{
+ return GetImplementation(*this).SetStrokeJoin(join);
+}
+
+CanvasRenderer::Shape::StrokeJoin CanvasRenderer::Shape::GetStrokeJoin() const
+{
+ return GetImplementation(*this).GetStrokeJoin();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_SHAPE_H
+#define DALI_CANVAS_RENDERER_SHAPE_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 Shape;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief Shape is a command list for drawing one shape groups
+ * It has own path data & properties for sync/asynchronous drawing
+ */
+class DALI_ADAPTOR_API CanvasRenderer::Shape : public CanvasRenderer::Drawable
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer::Shape.
+ *
+ * @return A handle to a newly allocated Shape
+ */
+ static Shape New();
+
+public:
+ /**
+ * @brief Creates an empty handle.
+ * Use CanvasRenderer::Shape::New() to create an initialized object.
+ */
+ Shape();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Shape();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ Shape(const Shape& handle) = default;
+
+public:
+ /**
+ * @brief Enumeration for The cap style to be used for stroking the path.
+ */
+ enum class StrokeCap
+ {
+ SQUARE = 0, ///< The end of lines is rendered as a square around the last point.
+ ROUND, ///< The end of lines is rendered as a half-circle around the last point.
+ BUTT ///< The end of lines is rendered as a full stop on the last point itself.
+ };
+
+ /**
+ * @brief Enumeration for The join style to be used for stroking the path.
+ */
+ enum class StrokeJoin
+ {
+ BEVEL = 0, ///< Used to render beveled line joins. The outer corner of the joined lines is filled by enclosing the triangular region of the corner with a straight line between the outer corners of each stroke.
+ ROUND, ///< Used to render rounded line joins. Circular arcs are used to join two lines smoothly.
+ MITER ///< Used to render mitered line joins. The intersection of the strokes is clipped at a line perpendicular to the bisector of the angle between the strokes, at the distance from the intersection of the segments equal to the product of the miter limit value and the border radius. This prevents long spikes being created.
+ };
+
+ /**
+ * @brief Enumeration for The fill rule of shape.
+ */
+ enum class FillRule
+ {
+ WINDING = 0, ///< Draw a horizontal line from the point to a location outside the shape. Determine whether the direction of the line at each intersection point is up or down. The winding number is determined by summing the direction of each intersection. If the number is non zero, the point is inside the shape.
+ EVEN_ODD ///< Draw a horizontal line from the point to a location outside the shape, and count the number of intersections. If the number of intersections is an odd number, the point is inside the shape.
+ };
+
+public:
+ /**
+ * @brief Append the given rectangle with rounded corner to the path.
+ * The roundedCorner arguments specify the radii of the ellipses defining the
+ * corners of the rounded rectangle.
+ *
+ * roundedCorner are specified in terms of width and height respectively.
+ *
+ * If roundedCorner's values are 0, then it will draw a rectangle without rounded corner.
+ *
+ * @param[in] rect size of the rectangle.
+ * @param[in] roundedCorner The radius of the rounded corner and should be in range [ 0 to w/2 ]
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddRect(Rect<float> rect, Vector2 roundedCorner);
+
+ /**
+ * @brief Append a circle with given center and x,y-axis radius.
+ * @param[in] center X and Y co-ordinate of the center of the circle.
+ * @param[in] radius X and Y co-ordinate of radius of the circle.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddCircle(Vector2 center, Vector2 radius);
+
+ /**
+ * @brief Append the arcs .
+ * @param[in] center X and Y co-ordinate of the center of the arc.
+ * @param[in] radius Radius of the arc.
+ * @param[in] startAngle Start angle (in degrees) where the arc begins.
+ * @param[in] sweep The Angle measures how long the arc will be drawn.
+ * @param[in] pie If True, the area is created by connecting start angle point and sweep angle point of the drawn arc. If false, it doesn't.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie);
+
+ /**
+ * @brief Add a point that sets the given point as the current point,
+ * implicitly starting a new subpath and closing the previous one.
+ * @param[in] point X and Y co-ordinate of the current point.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddMoveTo(Vector2 point);
+
+ /**
+ * @brief Adds a straight line from the current position to the given end point.
+ * After the line is drawn, the current position is updated to be at the
+ * end point of the line.
+ * If no current position present, it draws a line to itself, basically * a point.
+ * @param[in] line X and Y co-ordinate of end point of the line.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddLineTo(Vector2 line);
+
+ /**
+ * @brief Adds a cubic Bezier curve between the current position and the
+ * given end point (lineEndPoint) using the control points specified by
+ * (controlPoint1), and (controlPoint2). After the path is drawn,
+ * the current position is updated to be at the end point of the path.
+ * @param[in] controlPoint1 X and Y co-ordinate of 1st control point.
+ * @param[in] controlPoint2 X and Y co-ordinate of 2nd control point.
+ * @param[in] endPoint X and Y co-ordinate of end point of the line.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint);
+
+ /**
+ * @brief Closes the current subpath by drawing a line to the beginning of the
+ * subpath, automatically starting a new path. The current point of the
+ * new path is (0, 0).
+ * If the subpath does not contain any points, this function does nothing.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool Close();
+
+ /**
+ * @brief Set the color to use for filling the path.
+ * @param[in] color The color value.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetFillColor(Vector4 color);
+
+ /**
+ * @brief Get the color to use for filling the path.
+ * @return Returns The color value.
+ */
+ Vector4 GetFillColor() const;
+
+ /**
+ * @brief Set the fill rule.
+ * @param[in] rule The current fill rule of the shape.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetFillRule(CanvasRenderer::Shape::FillRule rule);
+
+ /**
+ * @brief Get the fill rule.
+ * @return Returns the current fill rule of the shape.
+ */
+ CanvasRenderer::Shape::FillRule GetFillRule() const;
+
+ /**
+ * @brief Set the stroke width to use for stroking the path.
+ * @param[in] width Stroke width to be used.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeWidth(float width);
+
+ /**
+ * @brief Get the stroke width to use for stroking the path.
+ * @return Returns stroke width to be used.
+ */
+ float GetStrokeWidth() const;
+
+ /**
+ * @brief Set the color to use for stroking the path.
+ * @param[in] color The stroking color.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeColor(Vector4 color);
+
+ /**
+ * @brief Get the color to use for stroking the path.
+ * @return Returns the stroking color.
+ */
+ Vector4 GetStrokeColor() const;
+
+ /**
+ * @brief Sets the stroke dash pattern. The dash pattern is specified dash pattern.
+ * @param[in] dashPattern Lenght and a gap list.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeDash(const Dali::Vector<float>& dashPattern);
+
+ /**
+ * @brief Gets the stroke dash pattern.
+ * @return Returns the stroke dash pattern. The dash pattern is specified dash pattern.
+ */
+ Dali::Vector<float> GetStrokeDash() const;
+
+ /**
+ * @brief Set the cap style to use for stroking the path. The cap will be used for capping the end point of a open subpath.
+ * @param[in] cap Cap style to use.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeCap(CanvasRenderer::Shape::StrokeCap cap);
+
+ /**
+ * @brief Get the cap style to use for stroking the path.
+ * @return Returns the cap style.
+ */
+ CanvasRenderer::Shape::StrokeCap GetStrokeCap() const;
+
+ /**
+ * @brief Set the join style to use for stroking the path.
+ * The join style will be used for joining the two line segment while stroking the path.
+ * @param[in] join Join style to use.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeJoin(CanvasRenderer::Shape::StrokeJoin join);
+
+ /**
+ * @brief Get the join style to use for stroking the path.
+ * @return Returns join style to use.
+ */
+ CanvasRenderer::Shape::StrokeJoin GetStrokeJoin() 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::Shape
+ */
+ explicit DALI_INTERNAL Shape(Internal::Adaptor::Shape* impl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_SHAPE_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/devel-api/adaptor-framework/canvas-renderer.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-factory.h>
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+CanvasRenderer CanvasRenderer::New(const Vector2& viewBox)
+{
+ return CanvasRenderer(Internal::Adaptor::CanvasRendererFactory::New(viewBox));
+}
+
+CanvasRenderer::CanvasRenderer()
+{
+}
+
+CanvasRenderer::~CanvasRenderer()
+{
+}
+
+CanvasRenderer::CanvasRenderer(Internal::Adaptor::CanvasRenderer* internal)
+: BaseHandle(internal)
+{
+}
+
+bool CanvasRenderer::Commit()
+{
+ return GetImplementation(*this).Commit();
+}
+
+Devel::PixelBuffer CanvasRenderer::GetPixelBuffer()
+{
+ return GetImplementation(*this).GetPixelBuffer();
+}
+
+bool CanvasRenderer::AddDrawable(Drawable& drawable)
+{
+ return GetImplementation(*this).AddDrawable(drawable);
+}
+
+bool CanvasRenderer::SetSize(const Vector2& size)
+{
+ return GetImplementation(*this).SetSize(size);
+}
+
+const Vector2& CanvasRenderer::GetSize()
+{
+ return GetImplementation(*this).GetSize();
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_H
+#define DALI_CANVAS_RENDERER_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/pixel-buffer.h>
+#include <dali/public-api/dali-adaptor-common.h>
+
+namespace Dali
+{
+/**
+ * @addtogroup dali_adaptor_framework
+ * @{
+ */
+
+namespace Internal DALI_INTERNAL
+{
+namespace Adaptor
+{
+class CanvasRenderer;
+}
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief Used for rendering a vector primitives
+ */
+class DALI_ADAPTOR_API CanvasRenderer : public BaseHandle
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer.
+ * @param[in] viewBox The viewBox of canvas.
+ * @return A handle to a newly allocated CanvasRenderer
+ */
+ static CanvasRenderer New(const Vector2& viewBox);
+
+public:
+ /**
+ * @brief Creates an empty handle.
+ * Use CanvasRenderer::New() to create an initialized object.
+ */
+ CanvasRenderer();
+
+ /**
+ * @brief Destructor.
+ */
+ ~CanvasRenderer();
+
+public:
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ CanvasRenderer(const CanvasRenderer& handle) = default;
+
+ /**
+ * @brief This assignment operator is required for (smart) pointer semantics.
+ *
+ * @param[in] rhs A reference to the copied handle
+ * @return A reference to this
+ */
+ CanvasRenderer& operator=(const CanvasRenderer& rhs) = default;
+
+public:
+ class Drawable;
+ class Shape;
+
+public:
+ /**
+ * @brief Draw inner canvas the contexts added to the CanvasRenderer.
+ */
+ bool Commit();
+
+ /**
+ * @brief Add drawable object to the Canvas. This method is similar to registration.
+ * The added drawable object(shape) is drawn on the inner canvas using @ref Commit().
+ * @param[in] drawable The drawable object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool AddDrawable(Drawable& drawable);
+
+ /**
+ * @brief Returns the PixelBuffer, which is the Render buffer of Canvas.
+ *
+ * @return Returns the pixel buffer.
+ */
+ Devel::PixelBuffer GetPixelBuffer();
+
+ /**
+ * @brief This is the size of the buffer in the Canvas.
+ * @param[in] size The size of canvas buffer.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetSize(const Vector2& size);
+
+ /**
+ * @brief This is the size of the Buffer in the Canvas.
+ * @return Returns The size of canvas buffer.
+ */
+ const Vector2& GetSize();
+
+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
+ */
+ explicit DALI_INTERNAL CanvasRenderer(Internal::Adaptor::CanvasRenderer* internal);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_H
${adaptor_devel_api_dir}/adaptor-framework/autofill-item.cpp
${adaptor_devel_api_dir}/adaptor-framework/autofill-manager.cpp
${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-shape.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/color-controller.cpp
${adaptor_devel_api_dir}/adaptor-framework/autofill-item.h
${adaptor_devel_api_dir}/adaptor-framework/autofill-manager.h
${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.h
+ ${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/clipboard-event-notifier.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
${adaptor_devel_api_dir}/adaptor-framework/color-controller-plugin.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/common/canvas-renderer-factory.h>
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace CanvasRendererFactory
+{
+__attribute__((weak)) Dali::Internal::Adaptor::CanvasRenderer* New(const Vector2& viewBox)
+{
+ return new Internal::Adaptor::CanvasRenderer();
+}
+
+} // namespace CanvasRendererFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_CANVAS_RENDERER_FACTORY_H
+#define DALI_INTERNAL_CANVAS_RENDERER_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.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class CanvasRenderer;
+
+namespace CanvasRendererFactory
+{
+/**
+ * @brief Creates new instance of CanvasRenderer implementation
+ * @param[in] viewBox The viewBox of canvas.
+ * @return pointer to CanvasRenderer implementation instance
+ */
+Dali::Internal::Adaptor::CanvasRenderer* New(const Vector2& viewBox);
+
+} // namespace CanvasRendererFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_CANVAS_RENDERER_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/canvas-renderer-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+CanvasRenderer::CanvasRenderer()
+: mSize(0, 0)
+{
+}
+
+CanvasRenderer::~CanvasRenderer() = default;
+
+bool CanvasRenderer::Commit()
+{
+ return false;
+}
+
+Devel::PixelBuffer CanvasRenderer::GetPixelBuffer()
+{
+ return Devel::PixelBuffer();
+}
+
+bool CanvasRenderer::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+ return false;
+}
+
+bool CanvasRenderer::SetSize(const Vector2& size)
+{
+ return false;
+}
+
+const Vector2& CanvasRenderer::GetSize()
+{
+ return mSize;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_CANVAS_RENDERER_IMPL_H
+#define DALI_INTERNAL_CANVAS_RENDERER_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.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal CanvasRenderer.
+ */
+class CanvasRenderer : public Dali::BaseObject
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ CanvasRenderer();
+
+ /**
+ * @brief Destructor.
+ */
+ ~CanvasRenderer() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Commit()
+ */
+ virtual bool Commit();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetPixelBuffer()
+ */
+ virtual Devel::PixelBuffer GetPixelBuffer();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::AddDrawable()
+ */
+ virtual bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::SetSize()
+ */
+ virtual bool SetSize(const Vector2& size);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetSize()
+ */
+ virtual const Vector2& GetSize();
+
+ CanvasRenderer(const CanvasRenderer&) = delete;
+ CanvasRenderer& operator=(CanvasRenderer&) = delete;
+ CanvasRenderer(CanvasRenderer&&) = delete;
+ CanvasRenderer& operator=(CanvasRenderer&&) = delete;
+
+private:
+ Vector2 mSize;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::CanvasRenderer& GetImplementation(Dali::CanvasRenderer& renderer)
+{
+ DALI_ASSERT_ALWAYS(renderer && "CanvasRenderer handle is empty.");
+
+ BaseObject& handle = renderer.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::CanvasRenderer&>(handle);
+}
+
+inline static const Internal::Adaptor::CanvasRenderer& GetImplementation(const Dali::CanvasRenderer& renderer)
+{
+ DALI_ASSERT_ALWAYS(renderer && "CanvasRenderer handle is empty.");
+
+ const BaseObject& handle = renderer.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::CanvasRenderer&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_CANVAS_RENDERER_IMPL_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/common/drawable-factory.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableFactory
+{
+__attribute__((weak)) Dali::Internal::Adaptor::Drawable* New()
+{
+ return new Internal::Adaptor::Drawable();
+}
+
+} // namespace DrawableFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_DRAWABLE_FACTORY_H
+#define DALI_INTERNAL_DRAWABLE_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.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class s;
+
+namespace DrawableFactory
+{
+/**
+ * @brief Creates new instance of Drawable implementation
+ * @return pointer to Drawable implementation instance
+ */
+Dali::Internal::Adaptor::Drawable* New();
+
+} // namespace DrawableFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_DRAWABLE_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-factory.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+Drawable::Drawable() = default;
+
+Drawable::~Drawable()
+{
+ if(pImpl)
+ {
+ delete pImpl;
+ }
+}
+
+void Drawable::Create()
+{
+ if(!pImpl)
+ {
+ pImpl = Internal::Adaptor::DrawableFactory::New();
+ }
+}
+
+bool Drawable::SetOpacity(float opacity)
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->SetOpacity(opacity);
+}
+
+float Drawable::GetOpacity() const
+{
+ if(!pImpl)
+ {
+ return 0.0f;
+ }
+ return pImpl->GetOpacity();
+}
+
+bool Drawable::Rotate(Degree degree)
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->Rotate(degree);
+}
+
+bool Drawable::Scale(float factor)
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->Scale(factor);
+}
+
+bool Drawable::Translate(Vector2 translate)
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->Translate(translate);
+}
+
+bool Drawable::Transform(const Dali::Matrix3& matrix)
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->Transform(matrix);
+}
+
+void Drawable::SetDrawableAdded(bool added)
+{
+ if(!pImpl)
+ {
+ return;
+ }
+ pImpl->SetDrawableAdded(added);
+}
+
+void* Drawable::GetObject() const
+{
+ if(!pImpl)
+ {
+ return nullptr;
+ }
+ return pImpl->GetObject();
+}
+
+void Drawable::SetObject(const void* object)
+{
+ if(!pImpl)
+ {
+ return;
+ }
+ pImpl->SetObject(object);
+}
+
+void Drawable::SetChanged(bool changed)
+{
+ if(!pImpl)
+ {
+ return;
+ }
+ pImpl->SetChanged(changed);
+}
+
+bool Drawable::GetChanged() const
+{
+ if(!pImpl)
+ {
+ return false;
+ }
+ return pImpl->GetChanged();
+}
+
+Dali::Internal::Adaptor::Drawable* Drawable::GetImplementation()
+{
+ return pImpl;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_DRAWABLE_IMPL_H
+#define DALI_INTERNAL_DRAWABLE_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
+#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-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Drawable.
+ */
+class Drawable : public Dali::BaseObject
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Drawable();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~Drawable() override;
+
+ /**
+ * @brief Create factory item(implementation) object.
+ */
+ void Create();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
+ */
+ virtual bool SetOpacity(float opacity);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
+ */
+ virtual float GetOpacity() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Rotate
+ */
+ virtual bool Rotate(Degree degree);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Scale
+ */
+ virtual bool Scale(float factor);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Translate
+ */
+ virtual bool Translate(Vector2 translate);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Transform
+ */
+ virtual bool Transform(const Dali::Matrix3& matrix);
+
+ /**
+ * @brief Set whether drawable added to the other object(canvas or drawable) or not.
+ * @param[in] added Ture if added, false otherwise.
+ */
+ virtual void SetDrawableAdded(bool added);
+
+ /**
+ * @brief Returns a drawable object pointer.
+ * @return Returns a drawable object pointer.
+ */
+ virtual void* GetObject() const;
+
+ /**
+ * @brief Set a drawable object
+ * @param[in] object drawable object
+ */
+ virtual void SetObject(const void* object);
+
+ /**
+ * @brief Set a changed state.
+ * @param[in] changed The state of changed.
+ */
+ virtual void SetChanged(bool changed);
+
+ /**
+ * @brief Get a changed state.
+ * @return Returns state of changed.
+ */
+ virtual bool GetChanged() const;
+
+ /**
+ * @brief Returns a drawable's implements object pointer.
+ * @return Returns a drawable's implements object pointer.
+ */
+ Dali::Internal::Adaptor::Drawable* GetImplementation();
+
+ Drawable(const Drawable&) = delete;
+ Drawable& operator=(Drawable&) = delete;
+ Drawable(Drawable&&) = delete;
+ Drawable& operator=(Drawable&&) = delete;
+
+private:
+ Dali::Internal::Adaptor::Drawable* pImpl = nullptr;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::Drawable& GetImplementation(Dali::CanvasRenderer::Drawable& drawable)
+{
+ DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
+
+ BaseObject& handle = drawable.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Drawable&>(handle);
+}
+
+inline static const Internal::Adaptor::Drawable& GetImplementation(const Dali::CanvasRenderer::Drawable& drawable)
+{
+ DALI_ASSERT_ALWAYS(drawable && "Drawable handle is empty.");
+
+ const BaseObject& handle = drawable.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Drawable&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_DRAWABLE_IMPL_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/common/shape-factory.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace ShapeFactory
+{
+__attribute__((weak)) Dali::Internal::Adaptor::Shape* New()
+{
+ // default implementation returns 'dummy'.
+ return new Internal::Adaptor::Shape();
+}
+
+} // namespace ShapeFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SHAPE_FACTORY_H
+#define DALI_INTERNAL_SHAPE_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-shape.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+class s;
+
+namespace ShapeFactory
+{
+/**
+ * @brief Creates new instance of Shape implementation
+ * @return pointer to Shape implementation instance
+ */
+Dali::Internal::Adaptor::Shape* New();
+
+} // namespace ShapeFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SHAPE_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/shape-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+Shape::Shape() = default;
+
+Shape::~Shape() = default;
+
+bool Shape::AddRect(Rect<float> rect, Vector2 roundedCorner)
+{
+ return false;
+}
+
+bool Shape::AddCircle(Vector2 center, Vector2 radius)
+{
+ return false;
+}
+
+bool Shape::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
+{
+ return false;
+}
+
+bool Shape::AddMoveTo(Vector2 point)
+{
+ return false;
+}
+
+bool Shape::AddLineTo(Vector2 line)
+{
+ return false;
+}
+
+bool Shape::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
+{
+ return false;
+}
+
+bool Shape::Close()
+{
+ return false;
+}
+
+bool Shape::SetFillColor(Vector4 color)
+{
+ return false;
+}
+
+Vector4 Shape::GetFillColor() const
+{
+ return Vector4(0, 0, 0, 0);
+}
+
+bool Shape::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::FillRule Shape::GetFillRule() const
+{
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
+}
+
+bool Shape::SetStrokeWidth(float width)
+{
+ return false;
+}
+
+float Shape::GetStrokeWidth() const
+{
+ return false;
+}
+
+bool Shape::SetStrokeColor(Vector4 color)
+{
+ return false;
+}
+
+Vector4 Shape::GetStrokeColor() const
+{
+ return Vector4(0, 0, 0, 0);
+}
+
+bool Shape::SetStrokeDash(const Dali::Vector<float> dashPattern)
+{
+ return false;
+}
+
+Dali::Vector<float> Shape::GetStrokeDash() const
+{
+ return Vector<float>();
+}
+
+bool Shape::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::StrokeCap Shape::GetStrokeCap() const
+{
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
+}
+
+bool Shape::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::StrokeJoin Shape::GetStrokeJoin() const
+{
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_SHAPE_IMPL_H
+#define DALI_INTERNAL_SHAPE_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
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Shape.
+ */
+class Shape : public Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Shape();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Shape() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddRect
+ */
+ virtual bool AddRect(Rect<float> rect, Vector2 roundedCorner);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCircle
+ */
+ virtual bool AddCircle(Vector2 center, Vector2 radius);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddArc
+ */
+ virtual bool AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddMoveTo
+ */
+ virtual bool AddMoveTo(Vector2 point);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddLineTo
+ */
+ virtual bool AddLineTo(Vector2 line);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCubicTo
+ */
+ virtual bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddClose
+ */
+ virtual bool Close();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillColor
+ */
+ virtual bool SetFillColor(Vector4 color);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillColor
+ */
+ virtual Vector4 GetFillColor() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillRule
+ */
+ virtual bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillRule
+ */
+ virtual Dali::CanvasRenderer::Shape::FillRule GetFillRule() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeWidth
+ */
+ virtual bool SetStrokeWidth(float width);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeWidth
+ */
+ virtual float GetStrokeWidth() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeColor
+ */
+ virtual bool SetStrokeColor(Vector4 color);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeColor
+ */
+ virtual Vector4 GetStrokeColor() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash
+ */
+ virtual bool SetStrokeDash(const Dali::Vector<float> dashPattern);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeDash
+ */
+ virtual Dali::Vector<float> GetStrokeDash() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeCap
+ */
+ virtual bool SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeCap
+ */
+ virtual Dali::CanvasRenderer::Shape::StrokeCap GetStrokeCap() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeJoin
+ */
+ virtual bool SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeJoin
+ */
+ virtual Dali::CanvasRenderer::Shape::StrokeJoin GetStrokeJoin() const;
+
+ Shape(const Shape&) = delete;
+ Shape& operator=(Shape&) = delete;
+ Shape(Shape&&) = delete;
+ Shape& operator=(Shape&&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::Shape& GetImplementation(Dali::CanvasRenderer::Shape& shape)
+{
+ DALI_ASSERT_ALWAYS(shape && "Shape handle is empty.");
+
+ BaseObject& handle = shape.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Shape&>(handle);
+}
+
+inline static const Internal::Adaptor::Shape& GetImplementation(const Dali::CanvasRenderer::Shape& shape)
+{
+ DALI_ASSERT_ALWAYS(shape && "Shape handle is empty.");
+
+ const BaseObject& handle = shape.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Shape&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_SHAPE_IMPL_H
--- /dev/null
+
+# module: canvas-renderer, backend: generic (android, macos, window)
+SET( adaptor_canvas_renderer_generic_src_files
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/canvas-renderer-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/canvas-renderer-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/drawable-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/drawable-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/drawable-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/shape-factory.cpp
+ ${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
+)
+
+# module: canvas-renderer, backend: ubuntu
+SET( adaptor_canvas_renderer_ubuntu_src_files
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/canvas-renderer-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/canvas-renderer-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/drawable-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/drawable-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/drawable-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/shape-factory.cpp
+ ${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
+)
+
+# module: canvas-renderer, backend: tizen (generic, ivi, mobile, tizen-post, tv, wearable)
+SET( adaptor_canvas_renderer_tizen_src_files
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/canvas-renderer-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/canvas-renderer-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/canvas-renderer-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/drawable-factory.cpp
+ ${adaptor_canvas_renderer_dir}/common/drawable-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/drawable-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/drawable-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/shape-factory.cpp
+ ${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
+)
--- /dev/null
+/*
+ * Copyright (c) 2014 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/canvas-renderer-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace CanvasRendererFactory
+{
+Dali::Internal::Adaptor::CanvasRenderer* New(const Vector2& viewBox)
+{
+ return Dali::Internal::Adaptor::CanvasRendererGeneric::New(viewBox);
+}
+
+} // namespace CanvasRendererFactory
+
+} // 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/canvas-renderer-impl-generic.h>
+
+// EXTERNAL INCLUDES
+#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), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+CanvasRendererGeneric* CanvasRendererGeneric::New(const Vector2& viewBox)
+{
+ return new CanvasRendererGeneric(viewBox);
+}
+
+CanvasRendererGeneric::CanvasRendererGeneric(const Vector2& viewBox)
+: mPixelBuffer(nullptr),
+ mSize(0, 0)
+{
+}
+
+CanvasRendererGeneric::~CanvasRendererGeneric()
+{
+}
+
+bool CanvasRendererGeneric::Commit()
+{
+ return false;
+}
+
+Devel::PixelBuffer CanvasRendererGeneric::GetPixelBuffer()
+{
+ return mPixelBuffer;
+}
+
+bool CanvasRendererGeneric::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+ return false;
+}
+
+bool CanvasRendererGeneric::SetSize(const Vector2& size)
+{
+ return false;
+}
+
+const Vector2& CanvasRendererGeneric::GetSize()
+{
+ return mSize;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_CANVAS_RENDERER_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_CANVAS_RENDERER_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-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal CanvasRenderer.
+ */
+class CanvasRendererGeneric : public Dali::Internal::Adaptor::CanvasRenderer
+{
+public:
+ /**
+ * @brief Creates a CanvasRenderer object.
+ * @param[in] viewBox The viewBox of canvas.
+ * @return A pointer to a newly allocated CanvasRenderer
+ */
+ static CanvasRendererGeneric* New(const Vector2& viewBox);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Commit()
+ */
+ bool Commit() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetPixelBuffer()
+ */
+ Devel::PixelBuffer GetPixelBuffer() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::SetSize()
+ */
+ bool SetSize(const Vector2& size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetSize()
+ */
+ const Vector2& GetSize() override;
+
+private:
+ CanvasRendererGeneric() = delete;
+ CanvasRendererGeneric(const CanvasRendererGeneric&) = delete;
+ CanvasRendererGeneric& operator=(CanvasRendererGeneric&) = delete;
+ CanvasRendererGeneric(CanvasRendererGeneric&&) = delete;
+ CanvasRendererGeneric& operator=(CanvasRendererGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ CanvasRendererGeneric(const Vector2& viewBox);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~CanvasRendererGeneric() override;
+
+private:
+ Devel::PixelBuffer mPixelBuffer;
+ Vector2 mSize;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_CANVAS_RENDERER_IMPL_GENERIC_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableFactory
+{
+Dali::Internal::Adaptor::Drawable* New()
+{
+ return Dali::Internal::Adaptor::DrawableGeneric::New();
+}
+
+} // namespace DrawableFactory
+
+} // 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-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::Drawable), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableGeneric* DrawableGeneric::New()
+{
+ return new DrawableGeneric();
+}
+
+DrawableGeneric::DrawableGeneric()
+{
+}
+
+DrawableGeneric::~DrawableGeneric()
+{
+}
+
+bool DrawableGeneric::SetOpacity(float opacity)
+{
+ return false;
+}
+
+float DrawableGeneric::GetOpacity() const
+{
+ return 0;
+}
+
+bool DrawableGeneric::Rotate(Degree degree)
+{
+ return false;
+}
+
+bool DrawableGeneric::Scale(float factor)
+{
+ return false;
+}
+
+bool DrawableGeneric::Translate(Vector2 translate)
+{
+ return false;
+}
+
+bool DrawableGeneric::Transform(const Dali::Matrix3& matrix)
+{
+ return false;
+}
+
+void DrawableGeneric::SetDrawableAdded(bool added)
+{
+}
+
+void DrawableGeneric::SetObject(const void* object)
+{
+}
+
+void* DrawableGeneric::GetObject() const
+{
+ return nullptr;
+}
+
+void DrawableGeneric::SetChanged(bool changed)
+{
+}
+
+bool DrawableGeneric::GetChanged() const
+{
+ return false;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_DRAWABLE_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_DRAWABLE_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
+#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-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Drawable.
+ */
+class DrawableGeneric : public Dali::Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Creates a Drawable object.
+ * @return A pointer to a newly allocated Drawable
+ */
+ static DrawableGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
+ */
+ bool SetOpacity(float opacity) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
+ */
+ float GetOpacity() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Rotate
+ */
+ bool Rotate(Degree degree) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Scale
+ */
+ bool Scale(float factor) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Translate
+ */
+ bool Translate(Vector2 translate) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Transform
+ */
+ bool Transform(const Dali::Matrix3& matrix) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetDrawableAdded
+ */
+ void SetDrawableAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetObject
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetObject
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetChanged
+ */
+ void SetChanged(bool changed);
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetChanged
+ */
+ bool GetChanged() const;
+
+ DrawableGeneric(const DrawableGeneric&) = delete;
+ DrawableGeneric& operator=(DrawableGeneric&) = delete;
+ DrawableGeneric(DrawableGeneric&&) = delete;
+ DrawableGeneric& operator=(DrawableGeneric&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ DrawableGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_DRAWABLE_IMPL_GENERIC_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/shape-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace ShapeFactory
+{
+Dali::Internal::Adaptor::Shape* New()
+{
+ return Dali::Internal::Adaptor::ShapeGeneric::New();
+}
+
+} // namespace ShapeFactory
+
+} // 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/shape-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::Shape), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+ShapeGeneric* ShapeGeneric::New()
+{
+ return new ShapeGeneric();
+}
+
+ShapeGeneric::ShapeGeneric()
+{
+}
+
+ShapeGeneric::~ShapeGeneric()
+{
+}
+
+bool ShapeGeneric::AddRect(Rect<float> rect, Vector2 roundedCorner)
+{
+ return false;
+}
+
+bool ShapeGeneric::AddCircle(Vector2 center, Vector2 radius)
+{
+ return false;
+}
+
+bool ShapeGeneric::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
+{
+ return false;
+}
+
+bool ShapeGeneric::AddMoveTo(Vector2 point)
+{
+ return false;
+}
+
+bool ShapeGeneric::AddLineTo(Vector2 line)
+{
+ return false;
+}
+
+bool ShapeGeneric::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
+{
+ return false;
+}
+
+bool ShapeGeneric::Close()
+{
+ return false;
+}
+
+bool ShapeGeneric::SetFillColor(Vector4 color)
+{
+ return false;
+}
+
+Vector4 ShapeGeneric::GetFillColor() const
+{
+ return Vector4(0, 0, 0, 0);
+}
+
+bool ShapeGeneric::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::FillRule ShapeGeneric::GetFillRule() const
+{
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
+}
+
+bool ShapeGeneric::SetStrokeWidth(float width)
+{
+ return false;
+}
+
+float ShapeGeneric::GetStrokeWidth() const
+{
+ return false;
+}
+
+bool ShapeGeneric::SetStrokeColor(Vector4 color)
+{
+ return false;
+}
+
+Vector4 ShapeGeneric::GetStrokeColor() const
+{
+ return Vector4(0, 0, 0, 0);
+}
+
+bool ShapeGeneric::SetStrokeDash(const Dali::Vector<float> dashPattern)
+{
+ return false;
+}
+
+Dali::Vector<float> ShapeGeneric::GetStrokeDash() const
+{
+ return Vector<float>();
+}
+
+bool ShapeGeneric::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::StrokeCap ShapeGeneric::GetStrokeCap() const
+{
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
+}
+
+bool ShapeGeneric::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Shape::StrokeJoin ShapeGeneric::GetStrokeJoin() const
+{
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_SHAPE_INTERFACE_GENERIC_H
+#define DALI_INTERNAL_GENERIC_SHAPE_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
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Shape.
+ */
+class ShapeGeneric : public Dali::Internal::Adaptor::Shape
+{
+public:
+ /**
+ * @brief Creates a Shape object.
+ * @return A pointer to a newly allocated shape
+ */
+ static ShapeGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddRect
+ */
+ bool AddRect(Rect<float> rect, Vector2 roundedCorner) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCircle
+ */
+ bool AddCircle(Vector2 center, Vector2 radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddArc
+ */
+ bool AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddMoveTo
+ */
+ bool AddMoveTo(Vector2 point) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddLineTo
+ */
+ bool AddLineTo(Vector2 line) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCubicTo
+ */
+ bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::Close
+ */
+ bool Close() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillColor
+ */
+ bool SetFillColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillColor
+ */
+ Vector4 GetFillColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillRule
+ */
+ bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillRule
+ */
+ Dali::CanvasRenderer::Shape::FillRule GetFillRule() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeWidth
+ */
+ bool SetStrokeWidth(float width) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeWidth
+ */
+ float GetStrokeWidth() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeColor
+ */
+ bool SetStrokeColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeColor
+ */
+ Vector4 GetStrokeColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash
+ */
+ bool SetStrokeDash(const Dali::Vector<float> dashPattern) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeDash
+ */
+ Dali::Vector<float> GetStrokeDash() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeCap
+ */
+ bool SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeCap
+ */
+ Dali::CanvasRenderer::Shape::StrokeCap GetStrokeCap() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeJoin
+ */
+ bool SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeJoin
+ */
+ Dali::CanvasRenderer::Shape::StrokeJoin GetStrokeJoin() const override;
+
+private:
+ ShapeGeneric(const ShapeGeneric&) = delete;
+ ShapeGeneric& operator=(ShapeGeneric&) = delete;
+ ShapeGeneric(ShapeGeneric&&) = delete;
+ ShapeGeneric& operator=(ShapeGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ ShapeGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~ShapeGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_SHAPE_INTERFACE_GENERIC_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/canvas-renderer-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace CanvasRendererFactory
+{
+Dali::Internal::Adaptor::CanvasRenderer* New(const Vector2& viewBox)
+{
+ return Dali::Internal::Adaptor::CanvasRendererTizen::New(viewBox);
+}
+
+} // namespace CanvasRendererFactory
+
+} // 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/canvas-renderer-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/imaging/common/pixel-buffer-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), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+CanvasRendererTizen* CanvasRendererTizen::New(const Vector2& viewBox)
+{
+ return new CanvasRendererTizen(viewBox);
+}
+
+CanvasRendererTizen::CanvasRendererTizen(const Vector2& viewBox)
+: mPixelBuffer(nullptr),
+ mTvgCanvas(nullptr),
+ mTvgRoot(nullptr),
+ mSize(0, 0),
+ mViewBox(0, 0),
+ mChanged(false)
+{
+ Initialize(viewBox);
+}
+
+CanvasRendererTizen::~CanvasRendererTizen()
+{
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ Dali::CanvasRenderer::Drawable drawable = (*it).GetHandle();
+ if(DALI_UNLIKELY(!drawable))
+ {
+ continue;
+ }
+ Internal::Adaptor::Drawable& drawableImpl = GetImplementation(drawable);
+ drawableImpl.SetObject(nullptr);
+ }
+ //Terminate ThorVG Engine
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
+}
+
+void CanvasRendererTizen::Initialize(const Vector2& viewBox)
+{
+ if(tvg::Initializer::init(tvg::CanvasEngine::Sw, 0 /*threads*/) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("ThorVG engine initialize failed\n");
+ }
+ mTvgCanvas = tvg::SwCanvas::gen();
+
+ mSize = mViewBox = viewBox;
+ if(viewBox.width < 1.0f || viewBox.height < 1.0f)
+ {
+ return;
+ }
+
+ MakeTargetBuffer(mSize);
+
+ auto scene = tvg::Scene::gen();
+ mTvgRoot = scene.get();
+ mTvgCanvas->push(move(scene));
+}
+
+bool CanvasRendererTizen::Commit()
+{
+ bool changed = false;
+
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ Dali::CanvasRenderer::Drawable drawable = (*it).GetHandle();
+ if(DALI_UNLIKELY(!drawable))
+ {
+ continue;
+ }
+ Internal::Adaptor::Drawable& drawableImpl = GetImplementation(drawable);
+ if(drawableImpl.GetChanged())
+ {
+ changed = true;
+ drawableImpl.SetChanged(false);
+ break;
+ }
+ }
+
+ if(!changed && !mChanged)
+ {
+ return false;
+ }
+ else
+ {
+ if(!mPixelBuffer.GetBuffer())
+ {
+ MakeTargetBuffer(mSize);
+ mChanged = false;
+ }
+ }
+
+ if(mSize.width < 1.0f || mSize.height < 1.0f)
+ {
+ DALI_LOG_ERROR("Size is zero [%p]\n", this);
+ return false;
+ }
+
+ if(mViewBox != mSize)
+ {
+ auto scaleX = mSize.width / mViewBox.width;
+ auto scaleY = mSize.height / mViewBox.height;
+ mTvgRoot->scale(scaleX < scaleY ? scaleX : scaleY);
+ }
+ mTvgCanvas->update(mTvgRoot);
+
+ if(mTvgCanvas->draw() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("ThorVG Draw fail [%p]\n", this);
+ return false;
+ }
+ return true;
+}
+
+Devel::PixelBuffer CanvasRendererTizen::GetPixelBuffer()
+{
+ return mPixelBuffer;
+}
+
+bool CanvasRendererTizen::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+ bool exist = false;
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ if((*it) == drawable)
+ {
+ exist = true;
+ break;
+ }
+ }
+ if(exist)
+ {
+ DALI_LOG_ERROR("Already added [%p]\n", this);
+ return false;
+ }
+
+ Internal::Adaptor::Drawable& drawableImpl = 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(mSize.width < 1.0f || mSize.height < 1.0f)
+ {
+ DALI_LOG_ERROR("Size is zero [%p]\n", this);
+ return false;
+ }
+
+ if(mTvgRoot->push(std::unique_ptr<tvg::Paint>(pDrawable)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
+ return false;
+ }
+
+ drawableImpl.SetDrawableAdded(true);
+ mDrawables.push_back(drawable);
+ mChanged = true;
+
+ return true;
+}
+
+bool CanvasRendererTizen::SetSize(const Vector2& size)
+{
+ if(size.width < 1.0f || size.height < 1.0f)
+ {
+ return false;
+ }
+
+ if(size != mSize)
+ {
+ mSize = size;
+ MakeTargetBuffer(size);
+ }
+
+ mChanged = true;
+
+ return true;
+}
+
+const Vector2& CanvasRendererTizen::GetSize()
+{
+ return mSize;
+}
+
+void CanvasRendererTizen::MakeTargetBuffer(const Vector2& size)
+{
+ mPixelBuffer = Devel::PixelBuffer::New(size.width, size.height, Dali::Pixel::RGBA8888);
+
+ unsigned char* pBuffer;
+ pBuffer = mPixelBuffer.GetBuffer();
+
+ if(!pBuffer)
+ {
+ DALI_LOG_ERROR("Pixel buffer create to fail [%p]\n", this);
+ return;
+ }
+
+ mTvgCanvas->sync();
+
+ mTvgCanvas->target(reinterpret_cast<uint32_t*>(pBuffer), size.width, size.width, size.height, tvg::SwCanvas::ABGR8888);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_CANVAS_RENDERER_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_CANVAS_RENDERER_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
+#include <dali/public-api/object/weak-handle.h>
+#include <thorvg.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal CanvasRenderer.
+ */
+class CanvasRendererTizen : public Dali::Internal::Adaptor::CanvasRenderer
+{
+public:
+ /**
+ * @brief Creates a CanvasRenderer object.
+ * @param[in] viewBox The viewBox of canvas.
+ * @return A pointer to a newly allocated CanvasRenderer
+ */
+ static CanvasRendererTizen* New(const Vector2& viewBox);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Commit()
+ */
+ bool Commit() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetPixelBuffer()
+ */
+ Devel::PixelBuffer GetPixelBuffer() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::SetSize()
+ */
+ bool SetSize(const Vector2& size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetSize()
+ */
+ const Vector2& GetSize() override;
+
+private:
+ CanvasRendererTizen() = delete;
+ CanvasRendererTizen(const CanvasRendererTizen&) = delete;
+ CanvasRendererTizen& operator=(CanvasRendererTizen&) = delete;
+ CanvasRendererTizen(CanvasRendererTizen&&) = delete;
+ CanvasRendererTizen& operator=(CanvasRendererTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ CanvasRendererTizen(const Vector2& viewBox);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~CanvasRendererTizen() override;
+
+ /**
+ * @brief Initializes member data.
+ * @param[in] viewBox The viewBox of canvas.
+ */
+ void Initialize(const Vector2& viewBox);
+
+ /**
+ * @brief Create and set target buffer
+ * @param[in] viewBox The size of buffer.
+ */
+ void MakeTargetBuffer(const Vector2& size);
+
+private:
+ Devel::PixelBuffer mPixelBuffer;
+
+ std::unique_ptr<tvg::SwCanvas> mTvgCanvas;
+ tvg::Scene* mTvgRoot;
+ typedef std::vector<WeakHandle<Dali::CanvasRenderer::Drawable> > DrawableVector;
+ typedef DrawableVector::iterator DrawableVectorIterator;
+ DrawableVector mDrawables;
+
+ Vector2 mSize;
+ Vector2 mViewBox;
+ bool mChanged;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_CANVAS_RENDERER_IMPL_TIZEN_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableFactory
+{
+Dali::Internal::Adaptor::Drawable* New()
+{
+ return Dali::Internal::Adaptor::DrawableTizen::New();
+}
+
+} // namespace DrawableFactory
+
+} // 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-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/common/stage.h>
+#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::Drawable), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableTizen* DrawableTizen::New()
+{
+ return new DrawableTizen();
+}
+
+DrawableTizen::DrawableTizen()
+: mAdded(false),
+ mChanged(false),
+ mTvgPaint(nullptr)
+{
+}
+
+DrawableTizen::~DrawableTizen()
+{
+ if(mTvgPaint && !mAdded)
+ {
+ delete mTvgPaint;
+ }
+}
+
+bool DrawableTizen::SetOpacity(float opacity)
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgPaint->opacity(round(opacity * 255.f)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Set opacity fail [%p]\n", this);
+ return false;
+ }
+ SetChanged(true);
+ return true;
+}
+
+float DrawableTizen::GetOpacity() const
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null [%p]\n", this);
+ return 0;
+ }
+ return (float)mTvgPaint->opacity() / 255.f;
+}
+
+bool DrawableTizen::Rotate(Degree degree)
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->rotate(degree.degree) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Rotate fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+}
+
+bool DrawableTizen::Scale(float factor)
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->scale(factor) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Scale fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+}
+
+bool DrawableTizen::Translate(Vector2 translate)
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->translate(translate.x, translate.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Translate fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+}
+
+bool DrawableTizen::Transform(const Dali::Matrix3& matrix)
+{
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ tvg::Matrix tvgMatrix = {matrix.AsFloat()[0], matrix.AsFloat()[1], matrix.AsFloat()[2], matrix.AsFloat()[3], matrix.AsFloat()[4], matrix.AsFloat()[5], matrix.AsFloat()[6], matrix.AsFloat()[7], matrix.AsFloat()[8]};
+
+ if(mTvgPaint->transform(tvgMatrix) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Transform fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+}
+
+void DrawableTizen::SetDrawableAdded(bool added)
+{
+ mAdded = !!added;
+}
+
+void* DrawableTizen::GetObject() const
+{
+ return static_cast<void*>(mTvgPaint);
+}
+
+void DrawableTizen::SetObject(const void* object)
+{
+ if(object)
+ {
+ mTvgPaint = static_cast<tvg::Paint*>((void*)object);
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is invalid [%p]\n", this);
+ }
+ }
+ else
+ {
+ if(mAdded)
+ {
+ mTvgPaint = nullptr;
+ }
+ if(mTvgPaint)
+ {
+ delete mTvgPaint;
+ }
+ }
+}
+
+void DrawableTizen::SetChanged(bool changed)
+{
+ if(!mChanged && changed) Dali::Stage::GetCurrent().KeepRendering(0.0f);
+ mChanged = !!changed;
+}
+
+bool DrawableTizen::GetChanged() const
+{
+ return mChanged;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_DRAWABLE_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_DRAWABLE_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
+#include <dali/public-api/object/base-object.h>
+#include <thorvg.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Drawable.
+ */
+class DrawableTizen : public Dali::Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Creates a Drawable object.
+ * @return A pointer to a newly allocated Drawable
+ */
+ static DrawableTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
+ */
+ bool SetOpacity(float opacity) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
+ */
+ float GetOpacity() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Rotate
+ */
+ bool Rotate(Degree degree) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Scale
+ */
+ bool Scale(float factor) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Translate
+ */
+ bool Translate(Vector2 translate) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Transform
+ */
+ bool Transform(const Dali::Matrix3& matrix) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetDrawableAdded
+ */
+ void SetDrawableAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetObject
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetObject
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetChanged
+ */
+ void SetChanged(bool changed) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetChanged
+ */
+ bool GetChanged() const override;
+
+ DrawableTizen(const Drawable&) = delete;
+ DrawableTizen& operator=(Drawable&) = delete;
+ DrawableTizen(Drawable&&) = delete;
+ DrawableTizen& operator=(Drawable&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ DrawableTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableTizen() override;
+
+private:
+ bool mAdded;
+ bool mChanged;
+
+ tvg::Paint* mTvgPaint;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_DRAWABLE_IMPL_TIZEN_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/shape-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace ShapeFactory
+{
+Dali::Internal::Adaptor::Shape* New()
+{
+ return Dali::Internal::Adaptor::ShapeTizen::New();
+}
+
+} // namespace ShapeFactory
+
+} // 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/shape-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::Shape), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+ShapeTizen* ShapeTizen::New()
+{
+ return new ShapeTizen();
+}
+
+ShapeTizen::ShapeTizen()
+: mTvgShape(nullptr)
+{
+ Initialize();
+}
+
+ShapeTizen::~ShapeTizen()
+{
+}
+
+void ShapeTizen::Initialize()
+{
+ mTvgShape = tvg::Shape::gen().release();
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgShape));
+}
+
+bool ShapeTizen::AddRect(Rect<float> rect, Vector2 roundedCorner)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendRect(rect.x, rect.y, rect.width, rect.height, roundedCorner.x, roundedCorner.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add Rect Fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::AddCircle(Vector2 center, Vector2 radius)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendCircle(center.x, center.y, radius.x, radius.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add Circle Fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendArc(center.x, center.y, radius, startAngle, sweep, pie) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add arc fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::AddMoveTo(Vector2 point)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->moveTo(point.x, point.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddMoveTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::AddLineTo(Vector2 line)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->lineTo(line.x, line.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddLineTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->cubicTo(controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPoint.x, endPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("cubicTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::Close()
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->close() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("close() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+bool ShapeTizen::SetFillColor(Vector4 color)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->fill((uint8_t)(color.r * 255.f), (uint8_t)(color.g * 255.f), (uint8_t)(color.b * 255.f), (uint8_t)(color.a * 255.f)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetFillColor fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Vector4 ShapeTizen::GetFillColor() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return Vector4(0, 0, 0, 0);
+ }
+ uint8_t r, g, b, a;
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->fillColor(&r, &g, &b, &a) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetFillColor fail [%p]\n", this);
+ return Vector4(0, 0, 0, 0);
+ }
+ return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+}
+
+bool ShapeTizen::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->fill(static_cast<tvg::FillRule>(rule)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetFillRule fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Dali::CanvasRenderer::Shape::FillRule ShapeTizen::GetFillRule() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
+ }
+
+ tvg::FillRule rule = static_cast<tvg::Shape*>(mTvgShape)->fillRule();
+
+ return static_cast<Dali::CanvasRenderer::Shape::FillRule>(rule);
+}
+
+bool ShapeTizen::SetStrokeWidth(float width)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(width) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeWidth fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+float ShapeTizen::GetStrokeWidth() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+ return static_cast<tvg::Shape*>(mTvgShape)->strokeWidth();
+}
+
+bool ShapeTizen::SetStrokeColor(Vector4 color)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(color.r * 255.f, color.g * 255.f, color.b * 255.f, color.a * 255.f) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeColor fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Vector4 ShapeTizen::GetStrokeColor() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Vector4(0, 0, 0, 0);
+ }
+
+ uint8_t r, g, b, a;
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->strokeColor(&r, &g, &b, &a) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetStrokeColor fail.\n");
+ return Vector4(0, 0, 0, 0);
+ }
+ return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+}
+
+bool ShapeTizen::SetStrokeDash(const Dali::Vector<float> dashPattern)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ float* tvgDashPattern = (float*)alloca(sizeof(float) * dashPattern.Count());
+
+ for(unsigned int i = 0u; i < dashPattern.Count(); ++i)
+ {
+ tvgDashPattern[i] = dashPattern[i];
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(tvgDashPattern, dashPattern.Count()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeDash fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Dali::Vector<float> ShapeTizen::GetStrokeDash() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Vector<float>();
+ }
+ const float* tvgDashPattern = nullptr;
+ uint32_t count = 0;
+
+ count = static_cast<tvg::Shape*>(mTvgShape)->strokeDash(&tvgDashPattern);
+ if(!tvgDashPattern || count <= 0)
+ {
+ DALI_LOG_ERROR("GetStrokeDash() fail.\n");
+ return Vector<float>();
+ }
+
+ Dali::Vector<float> dashPattern;
+
+ dashPattern.Reserve(count);
+
+ for(unsigned int i = 0u; i < count; ++i)
+ {
+ dashPattern.PushBack(tvgDashPattern[i]);
+ }
+ return dashPattern;
+}
+
+bool ShapeTizen::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(static_cast<tvg::StrokeCap>(cap)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeCap fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Dali::CanvasRenderer::Shape::StrokeCap ShapeTizen::GetStrokeCap() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
+ }
+
+ tvg::StrokeCap cap = static_cast<tvg::Shape*>(mTvgShape)->strokeCap();
+
+ return static_cast<Dali::CanvasRenderer::Shape::StrokeCap>(cap);
+}
+
+bool ShapeTizen::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(static_cast<tvg::StrokeJoin>(join)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokejoin fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+}
+
+Dali::CanvasRenderer::Shape::StrokeJoin ShapeTizen::GetStrokeJoin() const
+{
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
+ }
+
+ tvg::StrokeJoin join = static_cast<tvg::Shape*>(mTvgShape)->strokeJoin();
+
+ return static_cast<Dali::CanvasRenderer::Shape::StrokeJoin>(join);
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_SHAPE_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_SHAPE_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
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/signals/connection-tracker.h>
+#include <thorvg.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Shape.
+ */
+class ShapeTizen : public Dali::Internal::Adaptor::Shape
+{
+public:
+ /**
+ * @brief Creates a Shape object.
+ * @return A pointer to a newly allocated shape
+ */
+ static ShapeTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddRect
+ */
+ bool AddRect(Rect<float> rect, Vector2 roundedCorner) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCircle
+ */
+ bool AddCircle(Vector2 center, Vector2 radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddArc
+ */
+ bool AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddMoveTo
+ */
+ bool AddMoveTo(Vector2 point) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddLineTo
+ */
+ bool AddLineTo(Vector2 line) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCubicTo
+ */
+ bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::Close
+ */
+ bool Close() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillColor
+ */
+ bool SetFillColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillColor
+ */
+ Vector4 GetFillColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillRule
+ */
+ bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillRule
+ */
+ Dali::CanvasRenderer::Shape::FillRule GetFillRule() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeWidth
+ */
+ bool SetStrokeWidth(float width) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeWidth
+ */
+ float GetStrokeWidth() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeColor
+ */
+ bool SetStrokeColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeColor
+ */
+ Vector4 GetStrokeColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash
+ */
+ bool SetStrokeDash(const Dali::Vector<float> dashPattern) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeDash
+ */
+ Dali::Vector<float> GetStrokeDash() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeCap
+ */
+ bool SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeCap
+ */
+ Dali::CanvasRenderer::Shape::StrokeCap GetStrokeCap() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeJoin
+ */
+ bool SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeJoin
+ */
+ Dali::CanvasRenderer::Shape::StrokeJoin GetStrokeJoin() const override;
+
+private:
+ ShapeTizen(const ShapeTizen&) = delete;
+ ShapeTizen& operator=(ShapeTizen&) = delete;
+ ShapeTizen(ShapeTizen&&) = delete;
+ ShapeTizen& operator=(ShapeTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ ShapeTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~ShapeTizen() override;
+
+private:
+ void Initialize();
+
+private:
+ tvg::Shape* mTvgShape;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_SHAPE_IMPL_TIZEN_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/canvas-renderer-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace CanvasRendererFactory
+{
+Dali::Internal::Adaptor::CanvasRenderer* New(const Vector2& viewBox)
+{
+ return Dali::Internal::Adaptor::CanvasRendererUbuntu::New(viewBox);
+}
+
+} // namespace CanvasRendererFactory
+
+} // 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/canvas-renderer-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/imaging/common/pixel-buffer-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), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+CanvasRendererUbuntu* CanvasRendererUbuntu::New(const Vector2& viewBox)
+{
+ return new CanvasRendererUbuntu(viewBox);
+}
+
+CanvasRendererUbuntu::CanvasRendererUbuntu(const Vector2& viewBox)
+: mPixelBuffer(nullptr),
+#ifdef THORVG_SUPPORT
+ mTvgCanvas(nullptr),
+ mTvgRoot(nullptr),
+#endif
+ mSize(0, 0),
+ mViewBox(0, 0),
+ mChanged(false)
+{
+ Initialize(viewBox);
+}
+
+CanvasRendererUbuntu::~CanvasRendererUbuntu()
+{
+#ifdef THORVG_SUPPORT
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ Dali::CanvasRenderer::Drawable drawable = (*it).GetHandle();
+ if(DALI_UNLIKELY(!drawable))
+ {
+ continue;
+ }
+ Internal::Adaptor::Drawable& drawableImpl = GetImplementation(drawable);
+ drawableImpl.SetObject(nullptr);
+ }
+ //Terminate ThorVG Engine
+ tvg::Initializer::term(tvg::CanvasEngine::Sw);
+#endif
+}
+
+void CanvasRendererUbuntu::Initialize(const Vector2& viewBox)
+{
+#ifdef THORVG_SUPPORT
+ if(tvg::Initializer::init(tvg::CanvasEngine::Sw, 0 /*threads*/) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("ThorVG engine initialize failed\n");
+ }
+ mTvgCanvas = tvg::SwCanvas::gen();
+
+ mSize = mViewBox = viewBox;
+ if(viewBox.width < 1.0f || viewBox.height < 1.0f)
+ {
+ return;
+ }
+
+ MakeTargetBuffer(mSize);
+
+ auto scene = tvg::Scene::gen();
+ mTvgRoot = scene.get();
+ mTvgCanvas->push(move(scene));
+#endif
+}
+
+bool CanvasRendererUbuntu::Commit()
+{
+#ifdef THORVG_SUPPORT
+ bool changed = false;
+
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ Dali::CanvasRenderer::Drawable drawable = (*it).GetHandle();
+ if(DALI_UNLIKELY(!drawable))
+ {
+ continue;
+ }
+ Internal::Adaptor::Drawable& drawableImpl = GetImplementation(drawable);
+ if(drawableImpl.GetChanged())
+ {
+ changed = true;
+ drawableImpl.SetChanged(false);
+ }
+ }
+
+ if(!changed && !mChanged)
+ {
+ return false;
+ }
+ else
+ {
+ if(!mPixelBuffer.GetBuffer())
+ {
+ MakeTargetBuffer(mSize);
+ mChanged = false;
+ }
+ }
+
+ if(mSize.width < 1.0f || mSize.height < 1.0f)
+ {
+ DALI_LOG_ERROR("Size is zero [%p]\n", this);
+ return false;
+ }
+
+ if(mViewBox != mSize)
+ {
+ auto scaleX = mSize.width / mViewBox.width;
+ auto scaleY = mSize.height / mViewBox.height;
+ mTvgRoot->scale(scaleX < scaleY ? scaleX : scaleY);
+ }
+ mTvgCanvas->update(mTvgRoot);
+
+ if(mTvgCanvas->draw() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("ThorVG Draw fail [%p]\n", this);
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
+Devel::PixelBuffer CanvasRendererUbuntu::GetPixelBuffer()
+{
+ return mPixelBuffer;
+}
+
+bool CanvasRendererUbuntu::AddDrawable(Dali::CanvasRenderer::Drawable& drawable)
+{
+#ifdef THORVG_SUPPORT
+ bool exist = false;
+ for(DrawableVectorIterator it = mDrawables.begin(),
+ endIt = mDrawables.end();
+ it != endIt;
+ ++it)
+ {
+ if((*it) == drawable)
+ {
+ exist = true;
+ break;
+ }
+ }
+ if(exist)
+ {
+ DALI_LOG_ERROR("Already added [%p]\n", this);
+ return false;
+ }
+
+ Internal::Adaptor::Drawable& drawableImpl = 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(mSize.width < 1.0f || mSize.height < 1.0f)
+ {
+ DALI_LOG_ERROR("Size is zero [%p]\n", this);
+ return false;
+ }
+
+ if(mTvgRoot->push(std::unique_ptr<tvg::Paint>(pDrawable)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg push fail [%p]\n", this);
+ return false;
+ }
+
+ drawableImpl.SetDrawableAdded(true);
+ mDrawables.push_back(drawable);
+ mChanged = true;
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool CanvasRendererUbuntu::SetSize(const Vector2& size)
+{
+ if(size.width < 1.0f || size.height < 1.0f)
+ {
+ return false;
+ }
+
+ if(size != mSize)
+ {
+ mSize = size;
+ MakeTargetBuffer(size);
+ }
+
+ mChanged = true;
+
+ return true;
+}
+
+const Vector2& CanvasRendererUbuntu::GetSize()
+{
+ return mSize;
+}
+
+void CanvasRendererUbuntu::MakeTargetBuffer(const Vector2& size)
+{
+#ifdef THORVG_SUPPORT
+ mPixelBuffer = Devel::PixelBuffer::New(size.width, size.height, Dali::Pixel::RGBA8888);
+
+ unsigned char* pBuffer;
+ pBuffer = mPixelBuffer.GetBuffer();
+
+ if(!pBuffer)
+ {
+ DALI_LOG_ERROR("Pixel buffer create to fail [%p]\n", this);
+ return;
+ }
+
+ mTvgCanvas->sync();
+
+ mTvgCanvas->target(reinterpret_cast<uint32_t*>(pBuffer), size.width, size.width, size.height, tvg::SwCanvas::ABGR8888);
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_CANVAS_RENDERER_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_CANVAS_RENDERER_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.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal CanvasRenderer.
+ */
+class CanvasRendererUbuntu : public Dali::Internal::Adaptor::CanvasRenderer
+{
+public:
+ /**
+ * @brief Creates a CanvasRenderer object.
+ * @param[in] viewBox The viewBox of canvas.
+ * @return A pointer to a newly allocated CanvasRenderer
+ */
+ static CanvasRendererUbuntu* New(const Vector2& viewBox);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Commit()
+ */
+ bool Commit() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetPixelBuffer()
+ */
+ Devel::PixelBuffer GetPixelBuffer() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::AddDrawable()
+ */
+ bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::SetSize()
+ */
+ bool SetSize(const Vector2& size) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::GetSize()
+ */
+ const Vector2& GetSize() override;
+
+private:
+ CanvasRendererUbuntu() = delete;
+ CanvasRendererUbuntu(const CanvasRendererUbuntu&) = delete;
+ CanvasRendererUbuntu& operator=(CanvasRendererUbuntu&) = delete;
+ CanvasRendererUbuntu(CanvasRendererUbuntu&&) = delete;
+ CanvasRendererUbuntu& operator=(CanvasRendererUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ CanvasRendererUbuntu(const Vector2& viewBox);
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~CanvasRendererUbuntu() override;
+
+ /**
+ * @brief Initializes member data.
+ * @param[in] viewBox The viewBox of canvas.
+ */
+ void Initialize(const Vector2& viewBox);
+
+ /**
+ * @brief Create and set target buffer
+ * @param[in] viewBox The size of buffer.
+ */
+ void MakeTargetBuffer(const Vector2& size);
+
+private:
+ Devel::PixelBuffer mPixelBuffer;
+
+#ifdef THORVG_SUPPORT
+ std::unique_ptr<tvg::SwCanvas> mTvgCanvas;
+ tvg::Scene* mTvgRoot;
+#endif
+ typedef std::vector<WeakHandle<Dali::CanvasRenderer::Drawable> > DrawableVector;
+ typedef DrawableVector::iterator DrawableVectorIterator;
+ DrawableVector mDrawables;
+
+ Vector2 mSize;
+ Vector2 mViewBox;
+ bool mChanged;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_CANVAS_RENDERER_IMPL_UBUNTU_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace DrawableFactory
+{
+Dali::Internal::Adaptor::Drawable* New()
+{
+ return Dali::Internal::Adaptor::DrawableUbuntu::New();
+}
+
+} // namespace DrawableFactory
+
+} // 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-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/common/stage.h>
+#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::Drawable), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+DrawableUbuntu* DrawableUbuntu::New()
+{
+ return new DrawableUbuntu();
+}
+
+DrawableUbuntu::DrawableUbuntu()
+: mAdded(false),
+ mChanged(false)
+#ifdef THORVG_SUPPORT
+ ,
+ mTvgPaint(nullptr)
+#endif
+{
+}
+
+DrawableUbuntu::~DrawableUbuntu()
+{
+#ifdef THORVG_SUPPORT
+ if(mTvgPaint && !mAdded)
+ {
+ delete mTvgPaint;
+ }
+#endif
+}
+
+bool DrawableUbuntu::SetOpacity(float opacity)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgPaint->opacity(round(opacity * 255.f)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Set opacity fail [%p]\n", this);
+ return false;
+ }
+ SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+float DrawableUbuntu::GetOpacity() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null [%p]\n", this);
+ return 0;
+ }
+ return (float)mTvgPaint->opacity() / 255.f;
+#else
+ return 0;
+#endif
+}
+
+bool DrawableUbuntu::Rotate(Degree degree)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->rotate(degree.degree) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Rotate fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool DrawableUbuntu::Scale(float factor)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->scale(factor) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Scale fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool DrawableUbuntu::Translate(Vector2 translate)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ if(mTvgPaint->translate(translate.x, translate.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Translate fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool DrawableUbuntu::Transform(const Dali::Matrix3& matrix)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is null\n");
+ return false;
+ }
+
+ tvg::Matrix tvgMatrix = {matrix.AsFloat()[0], matrix.AsFloat()[1], matrix.AsFloat()[2], matrix.AsFloat()[3], matrix.AsFloat()[4], matrix.AsFloat()[5], matrix.AsFloat()[6], matrix.AsFloat()[7], matrix.AsFloat()[8]};
+
+ if(mTvgPaint->transform(tvgMatrix) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Transform fail.\n");
+ return false;
+ }
+ SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+void DrawableUbuntu::SetDrawableAdded(bool added)
+{
+ mAdded = !!added;
+}
+
+void* DrawableUbuntu::GetObject() const
+{
+#ifdef THORVG_SUPPORT
+ return static_cast<void*>(mTvgPaint);
+#else
+ return nullptr;
+#endif
+}
+
+void DrawableUbuntu::SetObject(const void* object)
+{
+#ifdef THORVG_SUPPORT
+ if(object)
+ {
+ mTvgPaint = static_cast<tvg::Paint*>((void*)object);
+ if(!mTvgPaint)
+ {
+ DALI_LOG_ERROR("Drawable is invalid [%p]\n", this);
+ }
+ }
+ else
+ {
+ if(mAdded)
+ {
+ mTvgPaint = nullptr;
+ }
+ if(mTvgPaint)
+ {
+ delete mTvgPaint;
+ }
+ }
+#endif
+}
+
+void DrawableUbuntu::SetChanged(bool changed)
+{
+ if(!mChanged && changed) Dali::Stage::GetCurrent().KeepRendering(0.0f);
+ mChanged = !!changed;
+}
+
+bool DrawableUbuntu::GetChanged() const
+{
+ return mChanged;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_DRAWABLE_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_DRAWABLE_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-drawable.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/canvas-renderer/ubuntu/canvas-renderer-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Drawable.
+ */
+class DrawableUbuntu : public Dali::Internal::Adaptor::Drawable
+{
+public:
+ /**
+ * @brief Creates a Drawable object.
+ * @return A pointer to a newly allocated Drawable
+ */
+ static DrawableUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::SetOpacity
+ */
+ bool SetOpacity(float opacity) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::GetOpacity
+ */
+ float GetOpacity() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Rotate
+ */
+ bool Rotate(Degree degree) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Scale
+ */
+ bool Scale(float factor) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Translate
+ */
+ bool Translate(Vector2 translate) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Drawable::Transform
+ */
+ bool Transform(const Dali::Matrix3& matrix) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetdrawableAdded
+ */
+ void SetDrawableAdded(bool added) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetObject
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetObject
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::SetChanged
+ */
+ void SetChanged(bool changed) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Drawable::GetChanged
+ */
+ bool GetChanged() const override;
+
+ DrawableUbuntu(const Drawable&) = delete;
+ DrawableUbuntu& operator=(Drawable&) = delete;
+ DrawableUbuntu(Drawable&&) = delete;
+ DrawableUbuntu& operator=(Drawable&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ DrawableUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~DrawableUbuntu() override;
+
+private:
+ bool mAdded;
+ bool mChanged;
+
+#ifdef THORVG_SUPPORT
+ tvg::Paint* mTvgPaint;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_DRAWABLE_IMPL_UBUNTU_H
--- /dev/null
+/*
+ * Copyright (c) 2014 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/shape-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace ShapeFactory
+{
+Dali::Internal::Adaptor::Shape* New()
+{
+ return Dali::Internal::Adaptor::ShapeUbuntu::New();
+}
+
+} // namespace ShapeFactory
+
+} // 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/shape-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::Shape), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+ShapeUbuntu* ShapeUbuntu::New()
+{
+ return new ShapeUbuntu();
+}
+
+ShapeUbuntu::ShapeUbuntu()
+#ifdef THORVG_SUPPORT
+: mTvgShape(nullptr)
+#endif
+{
+ Initialize();
+}
+
+ShapeUbuntu::~ShapeUbuntu()
+{
+}
+
+void ShapeUbuntu::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgShape = tvg::Shape::gen().release();
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ }
+
+ Drawable::Create();
+ Drawable::SetObject(static_cast<void*>(mTvgShape));
+
+#endif
+}
+
+bool ShapeUbuntu::AddRect(Rect<float> rect, Vector2 roundedCorner)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendRect(rect.x, rect.y, rect.width, rect.height, roundedCorner.x, roundedCorner.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add Rect Fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::AddCircle(Vector2 center, Vector2 radius)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendCircle(center.x, center.y, radius.x, radius.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add Circle Fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->appendArc(center.x, center.y, radius, startAngle, sweep, pie) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Add arc fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::AddMoveTo(Vector2 point)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->moveTo(point.x, point.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddMoveTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::AddLineTo(Vector2 line)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->lineTo(line.x, line.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("AddLineTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->cubicTo(controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPoint.x, endPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("cubicTo() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::Close()
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->close() != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("close() fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::SetFillColor(Vector4 color)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->fill((uint8_t)(color.r * 255.f), (uint8_t)(color.g * 255.f), (uint8_t)(color.b * 255.f), (uint8_t)(color.a * 255.f)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetFillColor fail [%p]\n", this);
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Vector4 ShapeUbuntu::GetFillColor() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return Vector4(0, 0, 0, 0);
+ }
+ uint8_t r, g, b, a;
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->fillColor(&r, &g, &b, &a) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetFillColor fail [%p]\n", this);
+ return Vector4(0, 0, 0, 0);
+ }
+ return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+#else
+ return Vector4(0, 0, 0, 0);
+#endif
+}
+
+bool ShapeUbuntu::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->fill(static_cast<tvg::FillRule>(rule)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetFillRule fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Shape::FillRule ShapeUbuntu::GetFillRule() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
+ }
+
+ tvg::FillRule rule = static_cast<tvg::Shape*>(mTvgShape)->fillRule();
+
+ return static_cast<Dali::CanvasRenderer::Shape::FillRule>(rule);
+#endif
+ return Dali::CanvasRenderer::Shape::FillRule::WINDING;
+}
+
+bool ShapeUbuntu::SetStrokeWidth(float width)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(width) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeWidth fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+float ShapeUbuntu::GetStrokeWidth() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+ return static_cast<tvg::Shape*>(mTvgShape)->strokeWidth();
+#else
+ return false;
+#endif
+}
+
+bool ShapeUbuntu::SetStrokeColor(Vector4 color)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(color.r * 255.f, color.g * 255.f, color.b * 255.f, color.a * 255.f) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeColor fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Vector4 ShapeUbuntu::GetStrokeColor() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Vector4(0, 0, 0, 0);
+ }
+
+ uint8_t r, g, b, a;
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->strokeColor(&r, &g, &b, &a) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetStrokeColor fail.\n");
+ return Vector4(0, 0, 0, 0);
+ }
+ return Vector4(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+#else
+ return Vector4(0, 0, 0, 0);
+#endif
+}
+
+bool ShapeUbuntu::SetStrokeDash(const Dali::Vector<float> dashPattern)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ float* tvgDashPattern = (float*)alloca(sizeof(float) * dashPattern.Count());
+
+ for(unsigned int i = 0u; i < dashPattern.Count(); ++i)
+ {
+ tvgDashPattern[i] = dashPattern[i];
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(tvgDashPattern, dashPattern.Count()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeDash fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::Vector<float> ShapeUbuntu::GetStrokeDash() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Vector<float>();
+ }
+ const float* tvgDashPattern = nullptr;
+ uint32_t count = 0;
+
+ count = static_cast<tvg::Shape*>(mTvgShape)->strokeDash(&tvgDashPattern);
+ if(!tvgDashPattern || count <= 0)
+ {
+ DALI_LOG_ERROR("GetStrokeDash() fail.\n");
+ return Vector<float>();
+ }
+
+ Dali::Vector<float> dashPattern;
+
+ dashPattern.Reserve(count);
+
+ for(unsigned int i = 0u; i < count; ++i)
+ {
+ dashPattern.PushBack(tvgDashPattern[i]);
+ }
+ return dashPattern;
+#else
+ return Vector<float>();
+#endif
+}
+
+bool ShapeUbuntu::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(static_cast<tvg::StrokeCap>(cap)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokeCap fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Shape::StrokeCap ShapeUbuntu::GetStrokeCap() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
+ }
+
+ tvg::StrokeCap cap = static_cast<tvg::Shape*>(mTvgShape)->strokeCap();
+
+ return static_cast<Dali::CanvasRenderer::Shape::StrokeCap>(cap);
+#endif
+ return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
+}
+
+bool ShapeUbuntu::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return false;
+ }
+
+ if(static_cast<tvg::Shape*>(mTvgShape)->stroke(static_cast<tvg::StrokeJoin>(join)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetStrokejoin fail.\n");
+ return false;
+ }
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Shape::StrokeJoin ShapeUbuntu::GetStrokeJoin() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null\n");
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
+ }
+
+ tvg::StrokeJoin join = static_cast<tvg::Shape*>(mTvgShape)->strokeJoin();
+
+ return static_cast<Dali::CanvasRenderer::Shape::StrokeJoin>(join);
+#endif
+ return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_SHAPE_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_SHAPE_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/signals/connection-tracker.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Shape.
+ */
+class ShapeUbuntu : public Dali::Internal::Adaptor::Shape
+{
+public:
+ /**
+ * @brief Creates a Shape object.
+ * @return A pointer to a newly allocated shape
+ */
+ static ShapeUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddRect
+ */
+ bool AddRect(Rect<float> rect, Vector2 roundedCorner) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCircle
+ */
+ bool AddCircle(Vector2 center, Vector2 radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddArc
+ */
+ bool AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddMoveTo
+ */
+ bool AddMoveTo(Vector2 point) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddLineTo
+ */
+ bool AddLineTo(Vector2 line) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::AddCubicTo
+ */
+ bool AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::Close
+ */
+ bool Close() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillColor
+ */
+ bool SetFillColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillColor
+ */
+ Vector4 GetFillColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillRule
+ */
+ bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillRule
+ */
+ Dali::CanvasRenderer::Shape::FillRule GetFillRule() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeWidth
+ */
+ bool SetStrokeWidth(float width) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeWidth
+ */
+ float GetStrokeWidth() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeColor
+ */
+ bool SetStrokeColor(Vector4 color) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeColor
+ */
+ Vector4 GetStrokeColor() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash
+ */
+ bool SetStrokeDash(const Dali::Vector<float> dashPattern) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeDash
+ */
+ Dali::Vector<float> GetStrokeDash() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeCap
+ */
+ bool SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeCap
+ */
+ Dali::CanvasRenderer::Shape::StrokeCap GetStrokeCap() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeJoin
+ */
+ bool SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeJoin
+ */
+ Dali::CanvasRenderer::Shape::StrokeJoin GetStrokeJoin() const override;
+
+private:
+ ShapeUbuntu(const ShapeUbuntu&) = delete;
+ ShapeUbuntu& operator=(ShapeUbuntu&) = delete;
+ ShapeUbuntu(ShapeUbuntu&&) = delete;
+ ShapeUbuntu& operator=(ShapeUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ ShapeUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~ShapeUbuntu() override;
+
+private:
+ void Initialize();
+
+#ifdef THORVG_SUPPORT
+private:
+ tvg::Shape* mTvgShape;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_SHAPE_IMPL_UBUNTU_H
BuildRequires: pkgconfig(feedback)
BuildRequires: pkgconfig(component-based-core-base)
+
+%if ( 0%{?tizen_version_major} == 6 && 0%{?tizen_version_minor} >= 5 ) || 0%{?tizen_version_major} >= 7
+BuildRequires: pkgconfig(thorvg)
+%endif
+
# for multiprofile
Requires: %{name}-compat = %{version}-%{release}
Recommends: %{name}-profile_common = %{version}-%{release}