CanvasRenderer:: Add Picture class
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / tizen / radial-gradient-impl-tizen.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/canvas-renderer/tizen/radial-gradient-impl-tizen.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/canvas-renderer/common/gradient-impl.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 namespace // unnamed namespace
35 {
36 // Type Registration
37 Dali::BaseHandle Create()
38 {
39   return Dali::BaseHandle();
40 }
41
42 Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::RadialGradient), typeid(Dali::BaseHandle), Create);
43
44 } // unnamed namespace
45
46 RadialGradientTizen* RadialGradientTizen::New()
47 {
48   return new RadialGradientTizen();
49 }
50
51 RadialGradientTizen::RadialGradientTizen()
52 #ifdef THORVG_SUPPORT
53 : mTvgRadialGradient(nullptr)
54 #endif
55 {
56   Initialize();
57 }
58
59 RadialGradientTizen::~RadialGradientTizen()
60 {
61 }
62
63 void RadialGradientTizen::Initialize()
64 {
65 #ifdef THORVG_SUPPORT
66   mTvgRadialGradient = tvg::RadialGradient::gen().release();
67   if(!mTvgRadialGradient)
68   {
69     DALI_LOG_ERROR("RadialGradient is null [%p]\n", this);
70   }
71
72   Gradient::Create();
73   Gradient::SetObject(static_cast<void*>(mTvgRadialGradient));
74 #endif
75 }
76
77 bool RadialGradientTizen::SetBounds(Vector2 centerPoint, float radius)
78 {
79 #ifdef THORVG_SUPPORT
80   if(!Gradient::GetObject() || !mTvgRadialGradient)
81   {
82     DALI_LOG_ERROR("RadialGradient is null\n");
83     return false;
84   }
85
86   if(mTvgRadialGradient->radial(centerPoint.x, centerPoint.y, radius) != tvg::Result::Success)
87   {
88     DALI_LOG_ERROR("SetBounds() fail.\n");
89     return false;
90   }
91
92   Gradient::SetChanged(true);
93
94   return true;
95 #else
96   return false;
97 #endif
98 }
99
100 bool RadialGradientTizen::GetBounds(Vector2& centerPoint, float& radius) const
101 {
102 #ifdef THORVG_SUPPORT
103   if(!Gradient::GetObject() || !mTvgRadialGradient)
104   {
105     DALI_LOG_ERROR("RadialGradient is null\n");
106     return false;
107   }
108
109   if(mTvgRadialGradient->radial(&centerPoint.x, &centerPoint.y, &radius) != tvg::Result::Success)
110   {
111     DALI_LOG_ERROR("GetBounds() fail.\n");
112     return false;
113   }
114
115   return true;
116 #else
117   return false;
118 #endif
119 }
120
121 } // namespace Adaptor
122
123 } // namespace Internal
124
125 } // namespace Dali