CanvasRenderer:: Add Picture class
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / tizen / shape-impl-tizen.cpp
index 04db5c4..9e5946e 100644 (file)
@@ -46,8 +46,11 @@ ShapeTizen* ShapeTizen::New()
 }
 
 ShapeTizen::ShapeTizen()
+: mFillGradient(),
+  mStrokeGradient()
 #ifdef THORVG_SUPPORT
-: mTvgShape(nullptr)
+  ,
+  mTvgShape(nullptr)
 #endif
 {
   Initialize();
@@ -68,13 +71,14 @@ void ShapeTizen::Initialize()
 
   Drawable::Create();
   Drawable::SetObject(static_cast<void*>(mTvgShape));
+  Drawable::SetType(Drawable::Types::SHAPE);
 #endif
 }
 
 bool ShapeTizen::AddRect(Rect<float> rect, Vector2 roundedCorner)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null [%p]\n", this);
     return false;
@@ -94,7 +98,7 @@ bool ShapeTizen::AddRect(Rect<float> rect, Vector2 roundedCorner)
 bool ShapeTizen::AddCircle(Vector2 center, Vector2 radius)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null [%p]\n", this);
     return false;
@@ -114,7 +118,7 @@ bool ShapeTizen::AddCircle(Vector2 center, Vector2 radius)
 bool ShapeTizen::AddArc(Vector2 center, float radius, float startAngle, float sweep, bool pie)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -135,7 +139,7 @@ bool ShapeTizen::AddArc(Vector2 center, float radius, float startAngle, float sw
 bool ShapeTizen::AddMoveTo(Vector2 point)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -156,7 +160,7 @@ bool ShapeTizen::AddMoveTo(Vector2 point)
 bool ShapeTizen::AddLineTo(Vector2 line)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -177,7 +181,7 @@ bool ShapeTizen::AddLineTo(Vector2 line)
 bool ShapeTizen::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector2 endPoint)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -198,7 +202,7 @@ bool ShapeTizen::AddCubicTo(Vector2 controlPoint1, Vector2 controlPoint2, Vector
 bool ShapeTizen::Close()
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -216,10 +220,31 @@ bool ShapeTizen::Close()
 #endif
 }
 
+bool ShapeTizen::ResetPath()
+{
+#ifdef THORVG_SUPPORT
+  if(!Drawable::GetObject() || !mTvgShape)
+  {
+    DALI_LOG_ERROR("Shape is null\n");
+    return false;
+  }
+
+  if(static_cast<tvg::Shape*>(mTvgShape)->reset() != tvg::Result::Success)
+  {
+    DALI_LOG_ERROR("reset() fail.\n");
+    return false;
+  }
+  Drawable::SetChanged(true);
+  return true;
+#else
+  return false;
+#endif
+}
+
 bool ShapeTizen::SetFillColor(Vector4 color)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null [%p]\n", this);
     return false;
@@ -240,7 +265,7 @@ bool ShapeTizen::SetFillColor(Vector4 color)
 Vector4 ShapeTizen::GetFillColor() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null [%p]\n", this);
     return Vector4(0, 0, 0, 0);
@@ -258,10 +283,31 @@ Vector4 ShapeTizen::GetFillColor() const
 #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
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -281,7 +327,7 @@ bool ShapeTizen::SetFillRule(Dali::CanvasRenderer::Shape::FillRule rule)
 Dali::CanvasRenderer::Shape::FillRule ShapeTizen::GetFillRule() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return Dali::CanvasRenderer::Shape::FillRule::WINDING;
@@ -297,7 +343,7 @@ Dali::CanvasRenderer::Shape::FillRule ShapeTizen::GetFillRule() const
 bool ShapeTizen::SetStrokeWidth(float width)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -318,7 +364,7 @@ bool ShapeTizen::SetStrokeWidth(float width)
 float ShapeTizen::GetStrokeWidth() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -332,7 +378,7 @@ float ShapeTizen::GetStrokeWidth() const
 bool ShapeTizen::SetStrokeColor(Vector4 color)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -353,7 +399,7 @@ bool ShapeTizen::SetStrokeColor(Vector4 color)
 Vector4 ShapeTizen::GetStrokeColor() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return Vector4(0, 0, 0, 0);
@@ -372,10 +418,31 @@ Vector4 ShapeTizen::GetStrokeColor() const
 #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
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -403,7 +470,7 @@ bool ShapeTizen::SetStrokeDash(const Dali::Vector<float> dashPattern)
 Dali::Vector<float> ShapeTizen::GetStrokeDash() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return Vector<float>();
@@ -435,12 +502,11 @@ Dali::Vector<float> ShapeTizen::GetStrokeDash() const
 bool ShapeTizen::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
   }
-
   if(static_cast<tvg::Shape*>(mTvgShape)->stroke(static_cast<tvg::StrokeCap>(cap)) != tvg::Result::Success)
   {
     DALI_LOG_ERROR("SetStrokeCap fail.\n");
@@ -456,7 +522,7 @@ bool ShapeTizen::SetStrokeCap(Dali::CanvasRenderer::Shape::StrokeCap cap)
 Dali::CanvasRenderer::Shape::StrokeCap ShapeTizen::GetStrokeCap() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return Dali::CanvasRenderer::Shape::StrokeCap::SQUARE;
@@ -472,7 +538,7 @@ Dali::CanvasRenderer::Shape::StrokeCap ShapeTizen::GetStrokeCap() const
 bool ShapeTizen::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return false;
@@ -493,7 +559,7 @@ bool ShapeTizen::SetStrokeJoin(Dali::CanvasRenderer::Shape::StrokeJoin join)
 Dali::CanvasRenderer::Shape::StrokeJoin ShapeTizen::GetStrokeJoin() const
 {
 #ifdef THORVG_SUPPORT
-  if(!mTvgShape)
+  if(!Drawable::GetObject() || !mTvgShape)
   {
     DALI_LOG_ERROR("Shape is null\n");
     return Dali::CanvasRenderer::Shape::StrokeJoin::BEVEL;