--- /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-gradient.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/canvas-renderer-impl.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+
+namespace Dali
+{
+// CanvasRenderer::Gradient
+//
+CanvasRenderer::Gradient::Gradient()
+{
+}
+
+CanvasRenderer::Gradient::~Gradient()
+{
+}
+
+CanvasRenderer::Gradient::Gradient(Internal::Adaptor::Gradient* pImpl)
+: BaseHandle(pImpl)
+{
+}
+
+bool CanvasRenderer::Gradient::SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops)
+{
+ return GetImplementation(*this).SetColorStops(colorStops);
+}
+
+Dali::CanvasRenderer::Gradient::ColorStops CanvasRenderer::Gradient::GetColorStops() const
+{
+ return GetImplementation(*this).GetColorStops();
+}
+
+bool CanvasRenderer::Gradient::SetSpread(Dali::CanvasRenderer::Gradient::Spread spread)
+{
+ return GetImplementation(*this).SetSpread(spread);
+}
+
+Dali::CanvasRenderer::Gradient::Spread CanvasRenderer::Gradient::GetSpread() const
+{
+ return GetImplementation(*this).GetSpread();
+}
+
+CanvasRenderer::Gradient CanvasRenderer::Gradient::DownCast(BaseHandle handle)
+{
+ return CanvasRenderer::Gradient(dynamic_cast<Internal::Adaptor::Gradient*>(handle.GetObjectPtr()));
+}
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_GRADIENT_H
+#define DALI_CANVAS_RENDERER_GRADIENT_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 Gradient;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief An abstract class representing the gradient fill of the Shape object.
+ *
+ * It contains the information about the gradient colors and their arrangement
+ * inside the gradient bounds. The gradients bounds are defined in the LinearGradient
+ * or RadialGradient class, depending on the type of the gradient to be used.
+ * It specifies the gradient behavior in case the area defined by the gradient bounds
+ * is smaller than the area to be filled.
+ */
+class DALI_ADAPTOR_API CanvasRenderer::Gradient : public BaseHandle
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Gradient();
+
+ /**
+ * @brief Destructor.
+ */
+ ~Gradient();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ Gradient(const Gradient& handle) = default;
+
+public:
+ /**
+ * @brief Enumeration specifying how to fill the area outside the gradient bounds.
+ */
+ enum class Spread
+ {
+ PAD = 0, ///< The remaining area is filled with the closest stop color.
+ REFLECT, ///< The gradient pattern is reflected outside the gradient area until the expected region is filled.
+ REPEAT ///< The gradient pattern is repeated continuously beyond the gradient area until the expected region is filled.
+ };
+
+ /**
+ * @brief A data structure storing the information about the color and its relative position inside the gradient bounds.
+ */
+ struct ColorStop
+ {
+ float offset; /**< The relative position of the color. */
+ Vector4 color; /**< The color value. */
+ };
+
+ /// @brief List of Colorstop.
+ using ColorStops = Dali::Vector<ColorStop>;
+
+public:
+ /**
+ * @brief Sets the parameters of the colors of the gradient and their position.
+ * @param[in] colorStops An array of ColorStop data structure.
+ * @return Result::Success when succeed.
+ */
+ bool SetColorStops(ColorStops& colorStops);
+
+ /**
+ * @brief Gets the parameters of the colors of the gradient, their position and number.
+ * @return Returns the colorstops list.
+ */
+ ColorStops GetColorStops() const;
+
+ /**
+ * @brief Set the spread.
+ * @param[in] spread The current spraed type of the shape.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetSpread(Spread spread);
+
+ /**
+ * @brief Get the spread type
+ * @return Returns the current spread type of the shape.
+ */
+ Spread GetSpread() const;
+
+ /**
+ * @brief Downcast a handle to Gradient 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 Gradient or an uninitialized handle.
+ */
+ static Gradient 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::Gradient
+ */
+ explicit DALI_INTERNAL Gradient(Internal::Adaptor::Gradient* pImpl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_GRADIENT_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-linear-gradient.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/linear-gradient-factory.h>
+#include <dali/internal/canvas-renderer/common/linear-gradient-impl.h>
+
+namespace Dali
+{
+CanvasRenderer::LinearGradient CanvasRenderer::LinearGradient::New()
+{
+ return LinearGradient(Internal::Adaptor::LinearGradientFactory::New());
+}
+
+CanvasRenderer::LinearGradient::LinearGradient()
+{
+}
+
+CanvasRenderer::LinearGradient::~LinearGradient()
+{
+}
+
+CanvasRenderer::LinearGradient::LinearGradient(Internal::Adaptor::LinearGradient* impl)
+: CanvasRenderer::Gradient(impl)
+{
+}
+
+bool CanvasRenderer::LinearGradient::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
+{
+ return GetImplementation(*this).SetBounds(firstPoint, secondPoint);
+}
+
+bool CanvasRenderer::LinearGradient::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
+{
+ return GetImplementation(*this).GetBounds(firstPoint, secondPoint);
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_LINEAR_GRADIENT_H
+#define DALI_CANVAS_RENDERER_LINEAR_GRADIENT_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-gradient.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 LinearGradient;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief A class representing the linear gradient fill of the Shape object.
+ *
+ * Besides the class inherited from the Gradient class, it enables setting and getting the linear gradient bounds.
+ * The behavior outside the gradient bounds depends on the value specified in the spread API.
+ */
+class DALI_ADAPTOR_API CanvasRenderer::LinearGradient : public CanvasRenderer::Gradient
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer::LinearGradient.
+ * @return A handle to a newly allocated LinearGradient
+ */
+ static LinearGradient New();
+
+public:
+ /**
+ * @brief Creates an empty handle. Use CanvasRenderer::LinearGradient::New() to create an initialized object.
+ */
+ LinearGradient();
+
+ /**
+ * @brief Destructor.
+ */
+ ~LinearGradient();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ LinearGradient(const LinearGradient& handle) = default;
+
+public:
+ /**
+ * @brief Sets the linear gradient bounds.
+ * The bounds of the linear gradient are defined as a surface constrained by two parallel lines crossing
+ * the given points (@p x1, @p y1) and (@p x2, @p y2), respectively. Both lines are perpendicular to the line linking
+ * (@p x1, @p y1) and (@p x2, @p y2).
+ * @param[in] firstPoint The first point used to determine the gradient bounds.
+ * @param[in] secondPoint The second point used to determine the gradient bounds.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetBounds(Vector2 firstPoint, Vector2 secondPoint);
+
+ /**
+ * @brief Gets the linear gradient bounds.
+ * @param[out] firstPoint The first point used to determine the gradient bounds.
+ * @param[out] secondPoint The second point used to determine the gradient bounds.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool GetBounds(Vector2& firstPoint, Vector2& secondPoint) 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::LinearGradient
+ */
+ explicit DALI_INTERNAL LinearGradient(Internal::Adaptor::LinearGradient* impl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_LINEAR_GRADIENT_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-radial-gradient.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/radial-gradient-factory.h>
+#include <dali/internal/canvas-renderer/common/radial-gradient-impl.h>
+
+namespace Dali
+{
+CanvasRenderer::RadialGradient CanvasRenderer::RadialGradient::New()
+{
+ return RadialGradient(Internal::Adaptor::RadialGradientFactory::New());
+}
+
+CanvasRenderer::RadialGradient::RadialGradient()
+{
+}
+
+CanvasRenderer::RadialGradient::~RadialGradient()
+{
+}
+
+CanvasRenderer::RadialGradient::RadialGradient(Internal::Adaptor::RadialGradient* impl)
+: CanvasRenderer::Gradient(impl)
+{
+}
+
+bool CanvasRenderer::RadialGradient::SetBounds(Vector2 centerPoint, float radius)
+{
+ return GetImplementation(*this).SetBounds(centerPoint, radius);
+}
+
+bool CanvasRenderer::RadialGradient::GetBounds(Vector2& centerPoint, float& radius) const
+{
+ return GetImplementation(*this).GetBounds(centerPoint, radius);
+}
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_CANVAS_RENDERER_RADIAL_GRADIENT_H
+#define DALI_CANVAS_RENDERER_RADIAL_GRADIENT_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-gradient.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 RadialGradient;
+} // namespace Adaptor
+} // namespace DALI_INTERNAL
+
+/**
+ * @brief A class representing the radial gradient fill of the Shape object.
+ */
+class DALI_ADAPTOR_API CanvasRenderer::RadialGradient : public CanvasRenderer::Gradient
+{
+public:
+ /**
+ * @brief Creates an initialized handle to a new CanvasRenderer::RadialGradient.
+ * @return A handle to a newly allocated RadialGradient
+ */
+ static RadialGradient New();
+
+public:
+ /**
+ * @brief Creates an empty handle. Use CanvasRenderer::RadialGradient::New() to create an initialized object.
+ */
+ RadialGradient();
+
+ /**
+ * @brief Destructor.
+ */
+ ~RadialGradient();
+
+ /**
+ * @brief This copy constructor is required for (smart) pointer semantics.
+ *
+ * @param[in] handle A reference to the copied handle
+ */
+ RadialGradient(const RadialGradient& handle) = default;
+
+public:
+ /**
+ * @brief Sets the radial gradient bounds.
+ * The radial gradient bounds are defined as a circle centered in a given point of a given radius.
+ * @param[in] centerPoint The point of the center of the bounding circle.
+ * @param[in] radius The radius of the bounding circle.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetBounds(Vector2 centerPoint, float radius);
+
+ /**
+ * @brief Gets the radial gradient bounds.
+ * @param[out] centerPoint The point used to determine the gradient bounds.
+ * @param[out] radius The radius of the bounding circle.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool GetBounds(Vector2& centerPoint, float& radius) 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::RadialGradient
+ */
+ explicit DALI_INTERNAL RadialGradient(Internal::Adaptor::RadialGradient* impl);
+ /// @endcond
+};
+
+/**
+ * @}
+ */
+} // namespace Dali
+
+#endif // DALI_CANVAS_RENDERER_RADIAL_GRADIENT_H
return GetImplementation(*this).GetFillColor();
}
+bool CanvasRenderer::Shape::SetFillGradient(CanvasRenderer::Gradient& gradient)
+{
+ return GetImplementation(*this).SetFillGradient(gradient);
+}
+
+CanvasRenderer::Gradient CanvasRenderer::Shape::GetFillGradient() const
+{
+ return GetImplementation(*this).GetFillGradient();
+}
+
bool CanvasRenderer::Shape::SetFillRule(CanvasRenderer::Shape::FillRule rule)
{
return GetImplementation(*this).SetFillRule(rule);
return GetImplementation(*this).GetStrokeColor();
}
+bool CanvasRenderer::Shape::SetStrokeGradient(CanvasRenderer::Gradient& gradient)
+{
+ return GetImplementation(*this).SetStrokeGradient(gradient);
+}
+
+CanvasRenderer::Gradient CanvasRenderer::Shape::GetStrokeGradient() const
+{
+ return GetImplementation(*this).GetStrokeGradient();
+}
+
bool CanvasRenderer::Shape::SetStrokeDash(const Dali::Vector<float>& dashPattern)
{
return GetImplementation(*this).SetStrokeDash(dashPattern);
Vector4 GetFillColor() const;
/**
+ * @brief Set the gradient to use for filling the path.
+ * @param[in] gradient The gradient object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetFillGradient(CanvasRenderer::Gradient& gradient);
+
+ /**
+ * @brief Get the gradient to use for filling the path.
+ * @return Returns The gradient object.
+ */
+ CanvasRenderer::Gradient GetFillGradient() 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.
Vector4 GetStrokeColor() const;
/**
+ * @brief Set the gradient to use for stroking the path.
+ * @param[in] gradient The gradient object.
+ * @return Returns True when it's successful. False otherwise.
+ */
+ bool SetStrokeGradient(CanvasRenderer::Gradient& gradient);
+
+ /**
+ * @brief Get the gradient to use for stroking the path.
+ * @return Returns The gradient object.
+ */
+ CanvasRenderer::Gradient GetStrokeGradient() 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.
class Shape;
class DrawableGroup;
+ class Gradient;
+ class LinearGradient;
+ class RadialGradient;
+
public:
/**
* @brief Prepare for drawing drawables added to CanvasRenderer on inner canvas.
${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/canvas-renderer-drawable-group.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-shape.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-gradient.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-linear-gradient.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-radial-gradient.cpp
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.cpp
${adaptor_devel_api_dir}/adaptor-framework/clipboard.cpp
${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.cpp
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-shape.h
${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-drawable-group.h
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-gradient.h
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-linear-gradient.h
+ ${adaptor_devel_api_dir}/adaptor-framework/canvas-renderer-radial-gradient.h
${adaptor_devel_api_dir}/adaptor-framework/capture-devel.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.h
${adaptor_devel_api_dir}/adaptor-framework/clipboard.h
--- /dev/null
+#ifndef DALI_INTERNAL_GRADIENT_FACTORY_H
+#define DALI_INTERNAL_GRADIENT_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-gradient.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace GradientFactory
+{
+/**
+ * @brief Creates new instance of Gradient implementation
+ * @return pointer to Gradient implementation instance
+ */
+Dali::Internal::Adaptor::Gradient* New();
+
+} // namespace GradientFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GRADIENT_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/gradient-factory.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+Gradient::Gradient() = default;
+
+Gradient::~Gradient()
+{
+ if(mImpl)
+ {
+ delete mImpl;
+ }
+}
+
+void Gradient::Create()
+{
+ if(!mImpl)
+ {
+ mImpl = Internal::Adaptor::GradientFactory::New();
+ }
+}
+
+bool Gradient::SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops)
+{
+ if(!mImpl)
+ {
+ return false;
+ }
+ return mImpl->SetColorStops(colorStops);
+}
+
+Dali::CanvasRenderer::Gradient::ColorStops Gradient::GetColorStops() const
+{
+ if(!mImpl)
+ {
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+ }
+ return mImpl->GetColorStops();
+}
+
+bool Gradient::SetSpread(Dali::CanvasRenderer::Gradient::Spread spread)
+{
+ if(!mImpl)
+ {
+ return false;
+ }
+ return mImpl->SetSpread(spread);
+}
+
+Dali::CanvasRenderer::Gradient::Spread Gradient::GetSpread() const
+{
+ if(!mImpl)
+ {
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+ }
+ return mImpl->GetSpread();
+}
+
+void* Gradient::GetObject() const
+{
+ if(!mImpl)
+ {
+ return nullptr;
+ }
+ return mImpl->GetObject();
+}
+
+void Gradient::SetObject(const void* object)
+{
+ if(!mImpl)
+ {
+ return;
+ }
+ mImpl->SetObject(object);
+}
+
+void Gradient::SetChanged(bool changed)
+{
+ if(!mImpl)
+ {
+ return;
+ }
+ mImpl->SetChanged(changed);
+}
+
+bool Gradient::GetChanged() const
+{
+ if(!mImpl)
+ {
+ return false;
+ }
+ return mImpl->GetChanged();
+}
+
+Dali::Internal::Adaptor::Gradient* Gradient::GetImplementation()
+{
+ return mImpl;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GRADIENT_IMPL_H
+#define DALI_INTERNAL_GRADIENT_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-gradient.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Gradient.
+ */
+class Gradient : public Dali::BaseObject
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ Gradient();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~Gradient() override;
+
+ /**
+ * @brief Create factory item(implementation) object.
+ */
+ void Create();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetColorStops()
+ */
+ virtual bool SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetColorStops()
+ */
+ virtual Dali::CanvasRenderer::Gradient::ColorStops GetColorStops() const;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetSpread()
+ */
+ virtual bool SetSpread(Dali::CanvasRenderer::Gradient::Spread spread);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetSpread()
+ */
+ virtual Dali::CanvasRenderer::Gradient::Spread GetSpread() const;
+
+ /**
+ * @brief Set a gradient object
+ * @param[in] object gradient object
+ */
+ virtual void SetObject(const void* object);
+
+ /**
+ * @brief Returns a gradient object pointer.
+ * @return Returns a gradient object pointer.
+ */
+ virtual void* GetObject() const;
+
+ /**
+ * @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 gradient's implements object pointer.
+ * @return Returns a gradient's implements object pointer.
+ */
+ Dali::Internal::Adaptor::Gradient* GetImplementation();
+
+ Gradient(const Gradient&) = delete;
+ Gradient& operator=(Gradient&) = delete;
+ Gradient(Gradient&&) = delete;
+ Gradient& operator=(Gradient&&) = delete;
+
+private:
+ Dali::Internal::Adaptor::Gradient* mImpl = nullptr;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::Gradient& GetImplementation(Dali::CanvasRenderer::Gradient& gradient)
+{
+ DALI_ASSERT_ALWAYS(gradient && "Gradient handle is empty.");
+
+ BaseObject& handle = gradient.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::Gradient&>(handle);
+}
+
+inline static const Internal::Adaptor::Gradient& GetImplementation(const Dali::CanvasRenderer::Gradient& gradient)
+{
+ DALI_ASSERT_ALWAYS(gradient && "Gradient handle is empty.");
+
+ const BaseObject& handle = gradient.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::Gradient&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GRADIENT_IMPL_H
--- /dev/null
+#ifndef DALI_INTERNAL_LINEAR_GRADIENT_FACTORY_H
+#define DALI_INTERNAL_LINEAR_GRADIENT_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-linear-gradient.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace LinearGradientFactory
+{
+/**
+ * @brief Creates new instance of LinearGradient implementation
+ * @return pointer to LinearGradient implementation instance
+ */
+Dali::Internal::Adaptor::LinearGradient* New();
+
+} // namespace LinearGradientFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_LINEAR_GRADIENT_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/linear-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+LinearGradient::LinearGradient() = default;
+
+LinearGradient::~LinearGradient() = default;
+
+bool LinearGradient::SetBounds(Vector2 firstPoint, Vector2 SecondPoint)
+{
+ return false;
+}
+
+bool LinearGradient::GetBounds(Vector2& firstPoint, Vector2& SecondPoint) const
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_LINEAR_GRADIENT_IMPL_H
+#define DALI_INTERNAL_LINEAR_GRADIENT_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-linear-gradient.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal LinearGradient.
+ */
+class LinearGradient : public Internal::Adaptor::Gradient
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ LinearGradient();
+
+ /**
+ * @brief Destructor.
+ */
+ ~LinearGradient() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ virtual bool SetBounds(Vector2 firstPoint, Vector2 SecondPoint);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ virtual bool GetBounds(Vector2& firstPoint, Vector2& SecondPoint) const;
+
+ LinearGradient(const LinearGradient&) = delete;
+ LinearGradient& operator=(LinearGradient&) = delete;
+ LinearGradient(LinearGradient&&) = delete;
+ LinearGradient& operator=(LinearGradient&&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::LinearGradient& GetImplementation(Dali::CanvasRenderer::LinearGradient& linearGradient)
+{
+ DALI_ASSERT_ALWAYS(linearGradient && "LinearGradient handle is empty.");
+
+ BaseObject& handle = linearGradient.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::LinearGradient&>(handle);
+}
+
+inline static const Internal::Adaptor::LinearGradient& GetImplementation(const Dali::CanvasRenderer::LinearGradient& linearGradient)
+{
+ DALI_ASSERT_ALWAYS(linearGradient && "LinearGradient handle is empty.");
+
+ const BaseObject& handle = linearGradient.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::LinearGradient&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_LINEAR_GRADIENT_IMPL_H
--- /dev/null
+#ifndef DALI_INTERNAL_RADIAL_GRADIENT_FACTORY_H
+#define DALI_INTERNAL_RADIAL_GRADIENT_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-radial-gradient.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace RadialGradientFactory
+{
+/**
+ * @brief Creates new instance of RadialGradient implementation
+ * @return pointer to RadialGradient implementation instance
+ */
+Dali::Internal::Adaptor::RadialGradient* New();
+
+} // namespace RadialGradientFactory
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_RADIAL_GRADIENT_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/radial-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+RadialGradient::RadialGradient() = default;
+
+RadialGradient::~RadialGradient() = default;
+
+bool RadialGradient::SetBounds(const Vector2 centerPoint, float radius)
+{
+ return false;
+}
+
+bool RadialGradient::GetBounds(Vector2& centerPoint, float& radius) const
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_RADIAL_GRADIENT_IMPL_H
+#define DALI_INTERNAL_RADIAL_GRADIENT_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-radial-gradient.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal RadialGradient.
+ */
+class RadialGradient : public Internal::Adaptor::Gradient
+{
+public:
+ /**
+ * @brief Constructor
+ */
+ RadialGradient();
+
+ /**
+ * @brief Destructor.
+ */
+ ~RadialGradient() override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ virtual bool SetBounds(Vector2 centerPoint, float radius);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ virtual bool GetBounds(Vector2& centerPoint, float& radius) const;
+
+ RadialGradient(const RadialGradient&) = delete;
+ RadialGradient& operator=(RadialGradient&) = delete;
+ RadialGradient(RadialGradient&&) = delete;
+ RadialGradient& operator=(RadialGradient&&) = delete;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+inline static Internal::Adaptor::RadialGradient& GetImplementation(Dali::CanvasRenderer::RadialGradient& radialGradient)
+{
+ DALI_ASSERT_ALWAYS(radialGradient && "RadialGradient handle is empty.");
+
+ BaseObject& handle = radialGradient.GetBaseObject();
+
+ return static_cast<Internal::Adaptor::RadialGradient&>(handle);
+}
+
+inline static const Internal::Adaptor::RadialGradient& GetImplementation(const Dali::CanvasRenderer::RadialGradient& radialGradient)
+{
+ DALI_ASSERT_ALWAYS(radialGradient && "RadialGradient handle is empty.");
+
+ const BaseObject& handle = radialGradient.GetBaseObject();
+
+ return static_cast<const Internal::Adaptor::RadialGradient&>(handle);
+}
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_RADIAL_GRADIENT_IMPL_H
return Vector4(0, 0, 0, 0);
}
+bool Shape::SetFillGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Gradient Shape::GetFillGradient() const
+{
+ return Dali::CanvasRenderer::Gradient();
+}
+
bool Shape::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
{
return false;
return Vector4(0, 0, 0, 0);
}
+bool Shape::SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Gradient Shape::GetStrokeGradient() const
+{
+ return Dali::CanvasRenderer::Gradient();
+}
+
bool Shape::SetStrokeDash(const Dali::Vector<float> dashPattern)
{
return false;
#include <dali/public-api/signals/connection-tracker.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-gradient.h>
#include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
#include <dali/internal/canvas-renderer/common/drawable-impl.h>
virtual Vector4 GetFillColor() const;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillGradient()
+ */
+ virtual bool SetFillGradient(Dali::CanvasRenderer::Gradient& gradient);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillGradient()
+ */
+ virtual Dali::CanvasRenderer::Gradient GetFillGradient() const;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetFillRule()
*/
virtual bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule);
virtual Vector4 GetStrokeColor() const;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeGradient()
+ */
+ virtual bool SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient);
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeGradient()
+ */
+ virtual Dali::CanvasRenderer::Gradient GetStrokeGradient() const;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash()
*/
virtual bool SetStrokeDash(const Dali::Vector<float> dashPattern);
${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
${adaptor_canvas_renderer_dir}/generic/drawable-group-factory-generic.cpp
${adaptor_canvas_renderer_dir}/generic/drawable-group-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/gradient-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/gradient-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/linear-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/linear-gradient-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/linear-gradient-impl-generic.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/radial-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/generic/radial-gradient-factory-generic.cpp
+ ${adaptor_canvas_renderer_dir}/generic/radial-gradient-impl-generic.cpp
)
# module: canvas-renderer, backend: ubuntu
${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
${adaptor_canvas_renderer_dir}/ubuntu/drawable-group-factory-ubuntu.cpp
${adaptor_canvas_renderer_dir}/ubuntu/drawable-group-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/gradient-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/gradient-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/linear-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/linear-gradient-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/linear-gradient-impl-ubuntu.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/radial-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/radial-gradient-factory-ubuntu.cpp
+ ${adaptor_canvas_renderer_dir}/ubuntu/radial-gradient-impl-ubuntu.cpp
)
# module: canvas-renderer, backend: tizen (generic, ivi, mobile, tizen-post, tv, wearable)
${adaptor_canvas_renderer_dir}/common/drawable-group-impl.cpp
${adaptor_canvas_renderer_dir}/tizen/drawable-group-factory-tizen.cpp
${adaptor_canvas_renderer_dir}/tizen/drawable-group-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/gradient-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/gradient-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/linear-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/linear-gradient-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/linear-gradient-impl-tizen.cpp
+
+ ${adaptor_canvas_renderer_dir}/common/radial-gradient-impl.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/radial-gradient-factory-tizen.cpp
+ ${adaptor_canvas_renderer_dir}/tizen/radial-gradient-impl-tizen.cpp
+
)
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/generic/gradient-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace GradientFactory
+{
+Dali::Internal::Adaptor::Gradient* New()
+{
+ return Dali::Internal::Adaptor::GradientGeneric::New();
+}
+
+} // namespace GradientFactory
+
+} // 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/gradient-impl-generic.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::Gradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+GradientGeneric* GradientGeneric::New()
+{
+ return new GradientGeneric();
+}
+
+GradientGeneric::GradientGeneric()
+{
+}
+
+GradientGeneric::~GradientGeneric()
+{
+}
+
+bool GradientGeneric::SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Gradient::ColorStops GradientGeneric::GetColorStops() const
+{
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+}
+
+bool GradientGeneric::SetSpread(Dali::CanvasRenderer::Gradient::Spread spread)
+{
+ return false;
+}
+
+Dali::CanvasRenderer::Gradient::Spread GradientGeneric::GetSpread() const
+{
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+}
+
+void GradientGeneric::SetObject(const void* object)
+{
+}
+
+void* GradientGeneric::GetObject() const
+{
+ return nullptr;
+}
+
+void GradientGeneric::SetChanged(bool changed)
+{
+}
+
+bool GradientGeneric::GetChanged() const
+{
+ return false;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_GRADIENT_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_GRADIENT_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-gradient.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+#include <dali/internal/canvas-renderer/generic/canvas-renderer-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Gradient.
+ */
+class GradientGeneric : public Dali::Internal::Adaptor::Gradient
+{
+public:
+ /**
+ * @brief Creates a Gradient object.
+ * @return A pointer to a newly allocated Gradient
+ */
+ static GradientGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetColorStops()
+ */
+ bool SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetColorStops()
+ */
+ Dali::CanvasRenderer::Gradient::ColorStops GetColorStops() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetSpread()
+ */
+ bool SetSpread(Dali::CanvasRenderer::Gradient::Spread spread) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetSpread()
+ */
+ Dali::CanvasRenderer::Gradient::Spread GetSpread() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetObject()
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetObject()
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetChanged()
+ */
+ void SetChanged(bool changed) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetChanged()
+ */
+ bool GetChanged() const override;
+
+ GradientGeneric(const Gradient&) = delete;
+ GradientGeneric& operator=(Gradient&) = delete;
+ GradientGeneric(Gradient&&) = delete;
+ GradientGeneric& operator=(Gradient&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ GradientGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~GradientGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_GRADIENT_IMPL_GENERIC_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/generic/linear-gradient-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace LinearGradientFactory
+{
+Dali::Internal::Adaptor::LinearGradient* New()
+{
+ return Dali::Internal::Adaptor::LinearGradientGeneric::New();
+}
+
+} // namespace LinearGradientFactory
+
+} // 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/linear-gradient-impl-generic.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::LinearGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+LinearGradientGeneric* LinearGradientGeneric::New()
+{
+ return new LinearGradientGeneric();
+}
+
+LinearGradientGeneric::LinearGradientGeneric()
+{
+}
+
+LinearGradientGeneric::~LinearGradientGeneric()
+{
+}
+
+bool LinearGradientGeneric::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
+{
+ return false;
+}
+
+bool LinearGradientGeneric::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_LINEAR_GRADIENT_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_LINEAR_GRADIENT_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-linear-gradient.h>
+#include <dali/internal/canvas-renderer/common/linear-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal LinearGradient.
+ */
+class LinearGradientGeneric : public Dali::Internal::Adaptor::LinearGradient
+{
+public:
+ /**
+ * @brief Creates a LinearGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static LinearGradientGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 firstPoint, Vector2 secondPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& firstPoint, Vector2& secondPoint) const override;
+
+private:
+ LinearGradientGeneric(const LinearGradientGeneric&) = delete;
+ LinearGradientGeneric& operator=(LinearGradientGeneric&) = delete;
+ LinearGradientGeneric(LinearGradientGeneric&&) = delete;
+ LinearGradientGeneric& operator=(LinearGradientGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ LinearGradientGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~LinearGradientGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_LINEAR_GRADIENT_IMPL_GENERIC_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/generic/radial-gradient-impl-generic.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace RadialGradientFactory
+{
+Dali::Internal::Adaptor::RadialGradient* New()
+{
+ return Dali::Internal::Adaptor::RadialGradientGeneric::New();
+}
+
+} // namespace RadialGradientFactory
+
+} // 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/radial-gradient-impl-generic.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::RadialGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+RadialGradientGeneric* RadialGradientGeneric::New()
+{
+ return new RadialGradientGeneric();
+}
+
+RadialGradientGeneric::RadialGradientGeneric()
+{
+}
+
+RadialGradientGeneric::~RadialGradientGeneric()
+{
+}
+
+bool RadialGradientGeneric::SetBounds(Vector2 centerPoint, float radius)
+{
+ return false;
+}
+
+bool RadialGradientGeneric::GetBounds(Vector2& centerPoint, float& radius) const
+{
+ return false;
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GENERIC_RADIAL_GRADIENT_IMPL_GENERIC_H
+#define DALI_INTERNAL_GENERIC_RADIAL_GRADIENT_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-radial-gradient.h>
+#include <dali/internal/canvas-renderer/common/radial-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal RadialGradient.
+ */
+class RadialGradientGeneric : public Dali::Internal::Adaptor::RadialGradient
+{
+public:
+ /**
+ * @brief Creates a RadialGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static RadialGradientGeneric* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 centerPoint, float radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& centerPoint, float& radius) const override;
+
+private:
+ RadialGradientGeneric(const RadialGradientGeneric&) = delete;
+ RadialGradientGeneric& operator=(RadialGradientGeneric&) = delete;
+ RadialGradientGeneric(RadialGradientGeneric&&) = delete;
+ RadialGradientGeneric& operator=(RadialGradientGeneric&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ RadialGradientGeneric();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~RadialGradientGeneric() override;
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GENERIC_RADIAL_GRADIENT_IMPL_GENERIC_H
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
namespace Dali
}
}
}
+ else if(drawableImpl.GetType() == Drawable::Types::SHAPE)
+ {
+ const Dali::CanvasRenderer::Shape& shape = static_cast<const Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ if(fillGradientImpl.GetChanged())
+ {
+ return true;
+ }
+ }
+
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ if(strokeGradientImpl.GetChanged())
+ {
+ return true;
+ }
+ }
+ }
return false;
}
UpdateDrawablesChanged(it, changed);
}
}
+ else if(drawableImpl.GetType() == Drawable::Types::SHAPE)
+ {
+ Dali::CanvasRenderer::Shape& shape = static_cast<Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ fillGradientImpl.SetChanged(changed);
+ }
+
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ strokeGradientImpl.SetChanged(changed);
+ }
+ }
}
#endif
PushDrawableToGroup(it, static_cast<tvg::Scene*>(tvgDuplicatedObject));
}
}
+ else if(type == Drawable::Types::SHAPE)
+ {
+ //FillGradient
+ Dali::CanvasRenderer::Shape& shape = static_cast<Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ tvg::Fill* tvgDuplicatedFillGradient = static_cast<tvg::Fill*>(fillGradientImpl.GetObject())->duplicate();
+ if(!tvgDuplicatedFillGradient)
+ {
+ DALI_LOG_ERROR("Invalid gradient object [%p]\n", this);
+ return;
+ }
+ if(static_cast<tvg::Shape*>(tvgDuplicatedObject)->fill(std::unique_ptr<tvg::Fill>(tvgDuplicatedFillGradient)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg gradient set fail [%p]\n", this);
+ return;
+ }
+ }
+
+ //StrokeGradient
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ tvg::Fill* tvgDuplicatedStrokeGradient = static_cast<tvg::Fill*>(strokeGradientImpl.GetObject())->duplicate();
+ if(!tvgDuplicatedStrokeGradient)
+ {
+ DALI_LOG_ERROR("Invalid gradient object [%p]\n", this);
+ return;
+ }
+ if(static_cast<tvg::Shape*>(tvgDuplicatedObject)->stroke(std::unique_ptr<tvg::Fill>(tvgDuplicatedStrokeGradient)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg gradient set fail [%p]\n", this);
+ return;
+ }
+ }
+ }
Dali::CanvasRenderer::Drawable compositeDrawable = drawableImpl.GetCompositionDrawable();
if(DALI_UNLIKELY(compositeDrawable))
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/tizen/gradient-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace GradientFactory
+{
+Dali::Internal::Adaptor::Gradient* New()
+{
+ return Dali::Internal::Adaptor::GradientTizen::New();
+}
+
+} // namespace GradientFactory
+
+} // 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/gradient-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::Gradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+GradientTizen* GradientTizen::New()
+{
+ return new GradientTizen();
+}
+
+GradientTizen::GradientTizen()
+: mChanged(false)
+#ifdef THORVG_SUPPORT
+ ,
+ mTvgFill(nullptr)
+#endif
+{
+}
+
+GradientTizen::~GradientTizen()
+{
+#ifdef THORVG_SUPPORT
+ if(mTvgFill)
+ {
+ delete mTvgFill;
+ }
+#endif
+}
+
+bool GradientTizen::SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return false;
+ }
+ SetChanged(true);
+
+ tvg::Fill::ColorStop* tvgColorStops = (tvg::Fill::ColorStop*)alloca(sizeof(tvg::Fill::ColorStop) * colorStops.Count());
+
+ for(unsigned int i = 0u; i < colorStops.Count(); ++i)
+ {
+ tvgColorStops[i].offset = colorStops[i].offset;
+ tvgColorStops[i].r = colorStops[i].color.r * 255.0f;
+ tvgColorStops[i].g = colorStops[i].color.g * 255.0f;
+ tvgColorStops[i].b = colorStops[i].color.b * 255.0f;
+ tvgColorStops[i].a = colorStops[i].color.a * 255.0f;
+ }
+
+ if(mTvgFill->colorStops(tvgColorStops, colorStops.Count()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetColorStops() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient::ColorStops GradientTizen::GetColorStops() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+ }
+
+ const tvg::Fill::ColorStop* tvgColorStops = nullptr;
+ uint32_t count = 0;
+
+ count = mTvgFill->colorStops(&tvgColorStops);
+ if(!tvgColorStops || count <= 0)
+ {
+ DALI_LOG_ERROR("GetColorStops() fail.\n");
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+ }
+
+ Dali::CanvasRenderer::Gradient::ColorStops colorStops;
+
+ colorStops.Reserve(count);
+
+ for(unsigned int i = 0u; i < count; ++i)
+ {
+ Dali::CanvasRenderer::Gradient::ColorStop stop = {tvgColorStops[i].offset, Vector4(tvgColorStops[i].r / 255.0f, tvgColorStops[i].g / 255.0f, tvgColorStops[i].b / 255.0f, tvgColorStops[i].a / 255.0f)};
+
+ colorStops.PushBack(stop);
+ }
+ return colorStops;
+#else
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+#endif
+}
+
+bool GradientTizen::SetSpread(Dali::CanvasRenderer::Gradient::Spread spread)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgFill->spread(static_cast<tvg::FillSpread>(spread)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetSpread() fail.\n");
+ return false;
+ }
+ SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient::Spread GradientTizen::GetSpread() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+ }
+
+ tvg::FillSpread spread = mTvgFill->spread();
+
+ return static_cast<Dali::CanvasRenderer::Gradient::Spread>(spread);
+#else
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+#endif
+}
+
+void GradientTizen::SetObject(const void* object)
+{
+#ifdef THORVG_SUPPORT
+ if(object)
+ {
+ mTvgFill = static_cast<tvg::Fill*>((void*)object);
+ }
+#endif
+}
+
+void* GradientTizen::GetObject() const
+{
+#ifdef THORVG_SUPPORT
+ return static_cast<void*>(mTvgFill);
+#else
+ return nullptr;
+#endif
+}
+
+void GradientTizen::SetChanged(bool changed)
+{
+ if(!mChanged && changed) Dali::Stage::GetCurrent().KeepRendering(0.0f);
+ mChanged = !!changed;
+}
+
+bool GradientTizen::GetChanged() const
+{
+ return mChanged;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_GRADIENT_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_GRADIENT_IMPL_TIZEN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-gradient.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+#include <dali/internal/canvas-renderer/tizen/canvas-renderer-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Gradient.
+ */
+class GradientTizen : public Dali::Internal::Adaptor::Gradient
+{
+public:
+ /**
+ * @brief Creates a Gradient object.
+ * @return A pointer to a newly allocated Gradient
+ */
+ static GradientTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetColorStops()
+ */
+ bool SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetColorStops()
+ */
+ Dali::CanvasRenderer::Gradient::ColorStops GetColorStops() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetSpread()
+ */
+ bool SetSpread(Dali::CanvasRenderer::Gradient::Spread spread) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetSpread()
+ */
+ Dali::CanvasRenderer::Gradient::Spread GetSpread() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetObject()
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetObject()
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetChanged()
+ */
+ void SetChanged(bool changed) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetChanged()
+ */
+ bool GetChanged() const override;
+
+ GradientTizen(const Gradient&) = delete;
+ GradientTizen& operator=(Gradient&) = delete;
+ GradientTizen(Gradient&&) = delete;
+ GradientTizen& operator=(Gradient&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ GradientTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~GradientTizen() override;
+
+private:
+ bool mChanged;
+#ifdef THORVG_SUPPORT
+ tvg::Fill* mTvgFill;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_GRADIENT_IMPL_TIZEN_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/tizen/linear-gradient-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace LinearGradientFactory
+{
+Dali::Internal::Adaptor::LinearGradient* New()
+{
+ return Dali::Internal::Adaptor::LinearGradientTizen::New();
+}
+
+} // namespace LinearGradientFactory
+
+} // 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/linear-gradient-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::LinearGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+LinearGradientTizen* LinearGradientTizen::New()
+{
+ return new LinearGradientTizen();
+}
+
+LinearGradientTizen::LinearGradientTizen()
+#ifdef THORVG_SUPPORT
+: mTvgLinearGradient(nullptr)
+#endif
+{
+ Initialize();
+}
+
+LinearGradientTizen::~LinearGradientTizen()
+{
+}
+
+void LinearGradientTizen::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgLinearGradient = tvg::LinearGradient::gen().release();
+ if(!mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null [%p]\n", this);
+ }
+
+ Gradient::Create();
+ Gradient::SetObject(static_cast<void*>(mTvgLinearGradient));
+#endif
+}
+
+bool LinearGradientTizen::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null\n");
+ return false;
+ }
+
+ if(mTvgLinearGradient->linear(firstPoint.x, firstPoint.y, secondPoint.x, secondPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetBounds() fail.\n");
+ return false;
+ }
+
+ Gradient::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool LinearGradientTizen::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null\n");
+ return false;
+ }
+
+ if(mTvgLinearGradient->linear(&firstPoint.x, &firstPoint.y, &secondPoint.x, &secondPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetBounds() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_LINEAR_GRADIENT_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_LINEAR_GRADIENT_IMPL_TIZEN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/weak-handle.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-linear-gradient.h>
+#include <dali/internal/canvas-renderer/common/linear-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal LinearGradient.
+ */
+class LinearGradientTizen : public Dali::Internal::Adaptor::LinearGradient
+{
+public:
+ /**
+ * @brief Creates a LinearGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static LinearGradientTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 firstPoint, Vector2 secondPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& firstPoint, Vector2& secondPoint) const override;
+
+private:
+ LinearGradientTizen(const LinearGradientTizen&) = delete;
+ LinearGradientTizen& operator=(LinearGradientTizen&) = delete;
+ LinearGradientTizen(LinearGradientTizen&&) = delete;
+ LinearGradientTizen& operator=(LinearGradientTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ LinearGradientTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~LinearGradientTizen() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::LinearGradient* mTvgLinearGradient;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_LINEAR_GRADIENT_IMPL_TIZEN_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/tizen/radial-gradient-impl-tizen.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace RadialGradientFactory
+{
+Dali::Internal::Adaptor::RadialGradient* New()
+{
+ return Dali::Internal::Adaptor::RadialGradientTizen::New();
+}
+
+} // namespace RadialGradientFactory
+
+} // 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/radial-gradient-impl-tizen.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::RadialGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+RadialGradientTizen* RadialGradientTizen::New()
+{
+ return new RadialGradientTizen();
+}
+
+RadialGradientTizen::RadialGradientTizen()
+#ifdef THORVG_SUPPORT
+: mTvgRadialGradient(nullptr)
+#endif
+{
+ Initialize();
+}
+
+RadialGradientTizen::~RadialGradientTizen()
+{
+}
+
+void RadialGradientTizen::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgRadialGradient = tvg::RadialGradient::gen().release();
+ if(!mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null [%p]\n", this);
+ }
+
+ Gradient::Create();
+ Gradient::SetObject(static_cast<void*>(mTvgRadialGradient));
+#endif
+}
+
+bool RadialGradientTizen::SetBounds(Vector2 centerPoint, float radius)
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null\n");
+ return false;
+ }
+
+ if(mTvgRadialGradient->radial(centerPoint.x, centerPoint.y, radius) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetBounds() fail.\n");
+ return false;
+ }
+
+ Gradient::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool RadialGradientTizen::GetBounds(Vector2& centerPoint, float& radius) const
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null\n");
+ return false;
+ }
+
+ if(mTvgRadialGradient->radial(¢erPoint.x, ¢erPoint.y, &radius) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetBounds() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_TIZEN_RADIAL_GRADIENT_IMPL_TIZEN_H
+#define DALI_INTERNAL_TIZEN_RADIAL_GRADIENT_IMPL_TIZEN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#ifdef THORVG_SUPPORT
+#include <thorvg.h>
+#endif
+#include <dali/public-api/object/base-object.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/canvas-renderer-radial-gradient.h>
+#include <dali/internal/canvas-renderer/common/radial-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal RadialGradient.
+ */
+class RadialGradientTizen : public Dali::Internal::Adaptor::RadialGradient
+{
+public:
+ /**
+ * @brief Creates a RadialGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static RadialGradientTizen* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 centerPoint, float radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& centerPoint, float& radius) const override;
+
+private:
+ RadialGradientTizen(const RadialGradientTizen&) = delete;
+ RadialGradientTizen& operator=(RadialGradientTizen&) = delete;
+ RadialGradientTizen(RadialGradientTizen&&) = delete;
+ RadialGradientTizen& operator=(RadialGradientTizen&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ RadialGradientTizen();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~RadialGradientTizen() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::RadialGradient* mTvgRadialGradient;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_TIZEN_RADIAL_GRADIENT_IMPL_TIZEN_H
}
ShapeTizen::ShapeTizen()
+: mFillGradient(),
+ mStrokeGradient()
#ifdef THORVG_SUPPORT
-: mTvgShape(nullptr)
+ ,
+ mTvgShape(nullptr)
#endif
{
Initialize();
#endif
}
+bool ShapeTizen::SetFillGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ mFillGradient = gradient;
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient ShapeTizen::GetFillGradient() const
+{
+ return mFillGradient;
+}
+
bool ShapeTizen::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
{
#ifdef THORVG_SUPPORT
#endif
}
+bool ShapeTizen::SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ mStrokeGradient = gradient;
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient ShapeTizen::GetStrokeGradient() const
+{
+ return mStrokeGradient;
+}
+
bool ShapeTizen::SetStrokeDash(const Dali::Vector<float> dashPattern)
{
#ifdef THORVG_SUPPORT
Vector4 GetFillColor() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillGradient()
+ */
+ bool SetFillGradient(Dali::CanvasRenderer::Gradient& gradient) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillGradient()
+ */
+ Dali::CanvasRenderer::Gradient GetFillGradient() const override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetFillRule()
*/
bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule) override;
Vector4 GetStrokeColor() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeGradient()
+ */
+ bool SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeGradient()
+ */
+ Dali::CanvasRenderer::Gradient GetStrokeGradient() const override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash()
*/
bool SetStrokeDash(const Dali::Vector<float> dashPattern) override;
*/
void Initialize();
-#ifdef THORVG_SUPPORT
private:
+ Dali::CanvasRenderer::Gradient mFillGradient;
+ Dali::CanvasRenderer::Gradient mStrokeGradient;
+#ifdef THORVG_SUPPORT
tvg::Shape* mTvgShape;
#endif
};
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/internal/canvas-renderer/common/drawable-group-impl.h>
#include <dali/internal/canvas-renderer/common/drawable-impl.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+#include <dali/internal/canvas-renderer/common/shape-impl.h>
#include <dali/internal/imaging/common/pixel-buffer-impl.h>
namespace Dali
}
}
}
+ else if(drawableImpl.GetType() == Drawable::Types::SHAPE)
+ {
+ const Dali::CanvasRenderer::Shape& shape = static_cast<const Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ if(fillGradientImpl.GetChanged())
+ {
+ return true;
+ }
+ }
+
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ if(strokeGradientImpl.GetChanged())
+ {
+ return true;
+ }
+ }
+ }
return false;
}
UpdateDrawablesChanged(it, changed);
}
}
+ else if(drawableImpl.GetType() == Drawable::Types::SHAPE)
+ {
+ Dali::CanvasRenderer::Shape& shape = static_cast<Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ fillGradientImpl.SetChanged(changed);
+ }
+
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ strokeGradientImpl.SetChanged(changed);
+ }
+ }
}
#endif
PushDrawableToGroup(it, static_cast<tvg::Scene*>(tvgDuplicatedObject));
}
}
+ else if(type == Drawable::Types::SHAPE)
+ {
+ //FillGradient
+ Dali::CanvasRenderer::Shape& shape = static_cast<Dali::CanvasRenderer::Shape&>(drawable);
+ Dali::CanvasRenderer::Gradient fillGradient = shape.GetFillGradient();
+ if(DALI_UNLIKELY(fillGradient))
+ {
+ Internal::Adaptor::Gradient& fillGradientImpl = Dali::GetImplementation(fillGradient);
+ tvg::Fill* tvgDuplicatedFillGradient = static_cast<tvg::Fill*>(fillGradientImpl.GetObject())->duplicate();
+ if(!tvgDuplicatedFillGradient)
+ {
+ DALI_LOG_ERROR("Invalid gradient object [%p]\n", this);
+ return;
+ }
+ if(static_cast<tvg::Shape*>(tvgDuplicatedObject)->fill(std::unique_ptr<tvg::Fill>(tvgDuplicatedFillGradient)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg gradient set fail [%p]\n", this);
+ return;
+ }
+ }
+
+ //StrokeGradient
+ Dali::CanvasRenderer::Gradient strokeGradient = shape.GetStrokeGradient();
+ if(DALI_UNLIKELY(strokeGradient))
+ {
+ Internal::Adaptor::Gradient& strokeGradientImpl = Dali::GetImplementation(strokeGradient);
+ tvg::Fill* tvgDuplicatedStrokeGradient = static_cast<tvg::Fill*>(strokeGradientImpl.GetObject())->duplicate();
+ if(!tvgDuplicatedStrokeGradient)
+ {
+ DALI_LOG_ERROR("Invalid gradient object [%p]\n", this);
+ return;
+ }
+ if(static_cast<tvg::Shape*>(tvgDuplicatedObject)->stroke(std::unique_ptr<tvg::Fill>(tvgDuplicatedStrokeGradient)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("Tvg gradient set fail [%p]\n", this);
+ return;
+ }
+ }
+ }
Dali::CanvasRenderer::Drawable compositeDrawable = drawableImpl.GetCompositionDrawable();
if(DALI_UNLIKELY(compositeDrawable))
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/ubuntu/gradient-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace GradientFactory
+{
+Dali::Internal::Adaptor::Gradient* New()
+{
+ return Dali::Internal::Adaptor::GradientUbuntu::New();
+}
+
+} // namespace GradientFactory
+
+} // 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/gradient-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::Gradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+GradientUbuntu* GradientUbuntu::New()
+{
+ return new GradientUbuntu();
+}
+
+GradientUbuntu::GradientUbuntu()
+: mChanged(false)
+#ifdef THORVG_SUPPORT
+ ,
+ mTvgFill(nullptr)
+#endif
+{
+}
+
+GradientUbuntu::~GradientUbuntu()
+{
+#ifdef THORVG_SUPPORT
+ if(mTvgFill)
+ {
+ delete mTvgFill;
+ }
+#endif
+}
+
+bool GradientUbuntu::SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return false;
+ }
+ SetChanged(true);
+
+ tvg::Fill::ColorStop* tvgColorStops = (tvg::Fill::ColorStop*)alloca(sizeof(tvg::Fill::ColorStop) * colorStops.Count());
+
+ for(unsigned int i = 0u; i < colorStops.Count(); ++i)
+ {
+ tvgColorStops[i].offset = colorStops[i].offset;
+ tvgColorStops[i].r = colorStops[i].color.r * 255.0f;
+ tvgColorStops[i].g = colorStops[i].color.g * 255.0f;
+ tvgColorStops[i].b = colorStops[i].color.b * 255.0f;
+ tvgColorStops[i].a = colorStops[i].color.a * 255.0f;
+ }
+
+ if(mTvgFill->colorStops(tvgColorStops, colorStops.Count()) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetColorStops() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient::ColorStops GradientUbuntu::GetColorStops() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+ }
+
+ const tvg::Fill::ColorStop* tvgColorStops = nullptr;
+ uint32_t count = 0;
+
+ count = mTvgFill->colorStops(&tvgColorStops);
+ if(!tvgColorStops || count <= 0)
+ {
+ DALI_LOG_ERROR("GetColorStops() fail.\n");
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+ }
+
+ Dali::CanvasRenderer::Gradient::ColorStops colorStops;
+
+ colorStops.Reserve(count);
+
+ for(unsigned int i = 0u; i < count; ++i)
+ {
+ Dali::CanvasRenderer::Gradient::ColorStop stop = {tvgColorStops[i].offset, Vector4(tvgColorStops[i].r / 255.0f, tvgColorStops[i].g / 255.0f, tvgColorStops[i].b / 255.0f, tvgColorStops[i].a / 255.0f)};
+
+ colorStops.PushBack(stop);
+ }
+ return colorStops;
+#else
+ return Dali::CanvasRenderer::Gradient::ColorStops();
+#endif
+}
+
+bool GradientUbuntu::SetSpread(Dali::CanvasRenderer::Gradient::Spread spread)
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return false;
+ }
+ if(mTvgFill->spread(static_cast<tvg::FillSpread>(spread)) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetSpread() fail.\n");
+ return false;
+ }
+ SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient::Spread GradientUbuntu::GetSpread() const
+{
+#ifdef THORVG_SUPPORT
+ if(!mTvgFill)
+ {
+ DALI_LOG_ERROR("Fill(Gradient) is null [%p]\n", this);
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+ }
+
+ tvg::FillSpread spread = mTvgFill->spread();
+
+ return static_cast<Dali::CanvasRenderer::Gradient::Spread>(spread);
+#else
+ return Dali::CanvasRenderer::Gradient::Spread::PAD;
+#endif
+}
+
+void GradientUbuntu::SetObject(const void* object)
+{
+#ifdef THORVG_SUPPORT
+ if(object)
+ {
+ mTvgFill = static_cast<tvg::Fill*>((void*)object);
+ }
+#endif
+}
+
+void* GradientUbuntu::GetObject() const
+{
+#ifdef THORVG_SUPPORT
+ return static_cast<void*>(mTvgFill);
+#else
+ return nullptr;
+#endif
+}
+
+void GradientUbuntu::SetChanged(bool changed)
+{
+ if(!mChanged && changed) Dali::Stage::GetCurrent().KeepRendering(0.0f);
+ mChanged = !!changed;
+}
+
+bool GradientUbuntu::GetChanged() const
+{
+ return mChanged;
+}
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_GRADIENT_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_GRADIENT_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-gradient.h>
+#include <dali/devel-api/adaptor-framework/canvas-renderer.h>
+#include <dali/internal/canvas-renderer/common/gradient-impl.h>
+#include <dali/internal/canvas-renderer/ubuntu/canvas-renderer-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal Gradient.
+ */
+class GradientUbuntu : public Dali::Internal::Adaptor::Gradient
+{
+public:
+ /**
+ * @brief Creates a Gradient object.
+ * @return A pointer to a newly allocated Gradient
+ */
+ static GradientUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetColorStops()
+ */
+ bool SetColorStops(Dali::CanvasRenderer::Gradient::ColorStops& colorStops) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetColorStops()
+ */
+ Dali::CanvasRenderer::Gradient::ColorStops GetColorStops() const override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::SetSpread()
+ */
+ bool SetSpread(Dali::CanvasRenderer::Gradient::Spread spread) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Gradient::GetSpread()
+ */
+ Dali::CanvasRenderer::Gradient::Spread GetSpread() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetObject()
+ */
+ void SetObject(const void* object) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetObject()
+ */
+ void* GetObject() const override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::SetChanged()
+ */
+ void SetChanged(bool changed) override;
+
+ /**
+ * @copydoc Internal::Adaptor::Gradient::GetChanged()
+ */
+ bool GetChanged() const override;
+
+ GradientUbuntu(const Gradient&) = delete;
+ GradientUbuntu& operator=(Gradient&) = delete;
+ GradientUbuntu(Gradient&&) = delete;
+ GradientUbuntu& operator=(Gradient&&) = delete;
+
+protected:
+ /**
+ * @brief Constructor
+ */
+ GradientUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~GradientUbuntu() override;
+
+private:
+ bool mChanged;
+#ifdef THORVG_SUPPORT
+ tvg::Fill* mTvgFill;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_GRADIENT_IMPL_UBUNTU_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/ubuntu/linear-gradient-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace LinearGradientFactory
+{
+Dali::Internal::Adaptor::LinearGradient* New()
+{
+ return Dali::Internal::Adaptor::LinearGradientUbuntu::New();
+}
+
+} // namespace LinearGradientFactory
+
+} // 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/linear-gradient-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::LinearGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+LinearGradientUbuntu* LinearGradientUbuntu::New()
+{
+ return new LinearGradientUbuntu();
+}
+
+LinearGradientUbuntu::LinearGradientUbuntu()
+#ifdef THORVG_SUPPORT
+: mTvgLinearGradient(nullptr)
+#endif
+{
+ Initialize();
+}
+
+LinearGradientUbuntu::~LinearGradientUbuntu()
+{
+}
+
+void LinearGradientUbuntu::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgLinearGradient = tvg::LinearGradient::gen().release();
+ if(!mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null [%p]\n", this);
+ }
+
+ Gradient::Create();
+ Gradient::SetObject(static_cast<void*>(mTvgLinearGradient));
+#endif
+}
+
+bool LinearGradientUbuntu::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null\n");
+ return false;
+ }
+
+ if(mTvgLinearGradient->linear(firstPoint.x, firstPoint.y, secondPoint.x, secondPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetBounds() fail.\n");
+ return false;
+ }
+
+ Gradient::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool LinearGradientUbuntu::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgLinearGradient)
+ {
+ DALI_LOG_ERROR("LinearGradient is null\n");
+ return false;
+ }
+
+ if(mTvgLinearGradient->linear(&firstPoint.x, &firstPoint.y, &secondPoint.x, &secondPoint.y) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetBounds() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_LINEAR_GRADIENT_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_LINEAR_GRADIENT_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-linear-gradient.h>
+#include <dali/internal/canvas-renderer/common/linear-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal LinearGradient.
+ */
+class LinearGradientUbuntu : public Dali::Internal::Adaptor::LinearGradient
+{
+public:
+ /**
+ * @brief Creates a LinearGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static LinearGradientUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 firstPoint, Vector2 secondPoint) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::LinearGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& firstPoint, Vector2& secondPoint) const override;
+
+private:
+ LinearGradientUbuntu(const LinearGradientUbuntu&) = delete;
+ LinearGradientUbuntu& operator=(LinearGradientUbuntu&) = delete;
+ LinearGradientUbuntu(LinearGradientUbuntu&&) = delete;
+ LinearGradientUbuntu& operator=(LinearGradientUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ LinearGradientUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~LinearGradientUbuntu() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::LinearGradient* mTvgLinearGradient;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_LINEAR_GRADIENT_IMPL_UBUNTU_H
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/internal/canvas-renderer/ubuntu/radial-gradient-impl-ubuntu.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+namespace RadialGradientFactory
+{
+Dali::Internal::Adaptor::RadialGradient* New()
+{
+ return Dali::Internal::Adaptor::RadialGradientUbuntu::New();
+}
+
+} // namespace RadialGradientFactory
+
+} // 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/radial-gradient-impl-ubuntu.h>
+
+// EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/canvas-renderer/common/gradient-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::RadialGradient), typeid(Dali::BaseHandle), Create);
+
+} // unnamed namespace
+
+RadialGradientUbuntu* RadialGradientUbuntu::New()
+{
+ return new RadialGradientUbuntu();
+}
+
+RadialGradientUbuntu::RadialGradientUbuntu()
+#ifdef THORVG_SUPPORT
+: mTvgRadialGradient(nullptr)
+#endif
+{
+ Initialize();
+}
+
+RadialGradientUbuntu::~RadialGradientUbuntu()
+{
+}
+
+void RadialGradientUbuntu::Initialize()
+{
+#ifdef THORVG_SUPPORT
+ mTvgRadialGradient = tvg::RadialGradient::gen().release();
+ if(!mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null [%p]\n", this);
+ }
+
+ Gradient::Create();
+ Gradient::SetObject(static_cast<void*>(mTvgRadialGradient));
+#endif
+}
+
+bool RadialGradientUbuntu::SetBounds(Vector2 centerPoint, float radius)
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null\n");
+ return false;
+ }
+
+ if(mTvgRadialGradient->radial(centerPoint.x, centerPoint.y, radius) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("SetBounds() fail.\n");
+ return false;
+ }
+
+ Gradient::SetChanged(true);
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool RadialGradientUbuntu::GetBounds(Vector2& centerPoint, float& radius) const
+{
+#ifdef THORVG_SUPPORT
+ if(!Gradient::GetObject() || !mTvgRadialGradient)
+ {
+ DALI_LOG_ERROR("RadialGradient is null\n");
+ return false;
+ }
+
+ if(mTvgRadialGradient->radial(¢erPoint.x, ¢erPoint.y, &radius) != tvg::Result::Success)
+ {
+ DALI_LOG_ERROR("GetBounds() fail.\n");
+ return false;
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_UBUNTU_RADIAL_GRADIENT_IMPL_UBUNTU_H
+#define DALI_INTERNAL_UBUNTU_RADIAL_GRADIENT_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-radial-gradient.h>
+#include <dali/internal/canvas-renderer/common/radial-gradient-impl.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+/**
+ * Dali internal RadialGradient.
+ */
+class RadialGradientUbuntu : public Dali::Internal::Adaptor::RadialGradient
+{
+public:
+ /**
+ * @brief Creates a RadialGradient object.
+ * @return A pointer to a newly allocated drawablegroup
+ */
+ static RadialGradientUbuntu* New();
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool SetBounds(Vector2 centerPoint, float radius) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::RadialGradient::SetBounds()
+ */
+ bool GetBounds(Vector2& centerPoint, float& radius) const override;
+
+private:
+ RadialGradientUbuntu(const RadialGradientUbuntu&) = delete;
+ RadialGradientUbuntu& operator=(RadialGradientUbuntu&) = delete;
+ RadialGradientUbuntu(RadialGradientUbuntu&&) = delete;
+ RadialGradientUbuntu& operator=(RadialGradientUbuntu&&) = delete;
+
+ /**
+ * @brief Constructor
+ */
+ RadialGradientUbuntu();
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~RadialGradientUbuntu() override;
+
+private:
+ /**
+ * @brief Initializes member data.
+ */
+ void Initialize();
+
+private:
+#ifdef THORVG_SUPPORT
+ tvg::RadialGradient* mTvgRadialGradient;
+#endif
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_UBUNTU_RADIAL_GRADIENT_IMPL_UBUNTU_H
}
ShapeUbuntu::ShapeUbuntu()
+: mFillGradient(),
+ mStrokeGradient()
#ifdef THORVG_SUPPORT
-: mTvgShape(nullptr)
+ ,
+ mTvgShape(nullptr)
#endif
{
Initialize();
#endif
}
+bool ShapeUbuntu::SetFillGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ mFillGradient = gradient;
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient ShapeUbuntu::GetFillGradient() const
+{
+ return mFillGradient;
+}
+
bool ShapeUbuntu::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
{
#ifdef THORVG_SUPPORT
#endif
}
+bool ShapeUbuntu::SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient)
+{
+#ifdef THORVG_SUPPORT
+ if(!Drawable::GetObject() || !mTvgShape)
+ {
+ DALI_LOG_ERROR("Shape is null [%p]\n", this);
+ return false;
+ }
+ mStrokeGradient = gradient;
+ Drawable::SetChanged(true);
+ return true;
+#else
+ return false;
+#endif
+}
+
+Dali::CanvasRenderer::Gradient ShapeUbuntu::GetStrokeGradient() const
+{
+ return mStrokeGradient;
+}
+
bool ShapeUbuntu::SetStrokeDash(const Dali::Vector<float> dashPattern)
{
#ifdef THORVG_SUPPORT
Vector4 GetFillColor() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetFillGradient()
+ */
+ bool SetFillGradient(Dali::CanvasRenderer::Gradient& gradient) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetFillGradient()
+ */
+ Dali::CanvasRenderer::Gradient GetFillGradient() const override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetFillRule()
*/
bool SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule) override;
Vector4 GetStrokeColor() const override;
/**
+ * @copydoc Dali::CanvasRenderer::Shape::SetStrokeGradient()
+ */
+ bool SetStrokeGradient(Dali::CanvasRenderer::Gradient& gradient) override;
+
+ /**
+ * @copydoc Dali::CanvasRenderer::Shape::GetStrokeGradient()
+ */
+ Dali::CanvasRenderer::Gradient GetStrokeGradient() const override;
+
+ /**
* @copydoc Dali::CanvasRenderer::Shape::SetStrokeDash()
*/
bool SetStrokeDash(const Dali::Vector<float> dashPattern) override;
*/
void Initialize();
-#ifdef THORVG_SUPPORT
private:
+ Dali::CanvasRenderer::Gradient mFillGradient;
+ Dali::CanvasRenderer::Gradient mStrokeGradient;
+#ifdef THORVG_SUPPORT
tvg::Shape* mTvgShape;
#endif
};