CanvasRenderer:: Add Picture class
[platform/core/uifw/dali-adaptor.git] / dali / internal / canvas-renderer / tizen / linear-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/linear-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::LinearGradient), typeid(Dali::BaseHandle), Create);
43
44 } // unnamed namespace
45
46 LinearGradientTizen* LinearGradientTizen::New()
47 {
48   return new LinearGradientTizen();
49 }
50
51 LinearGradientTizen::LinearGradientTizen()
52 #ifdef THORVG_SUPPORT
53 : mTvgLinearGradient(nullptr)
54 #endif
55 {
56   Initialize();
57 }
58
59 LinearGradientTizen::~LinearGradientTizen()
60 {
61 }
62
63 void LinearGradientTizen::Initialize()
64 {
65 #ifdef THORVG_SUPPORT
66   mTvgLinearGradient = tvg::LinearGradient::gen().release();
67   if(!mTvgLinearGradient)
68   {
69     DALI_LOG_ERROR("LinearGradient is null [%p]\n", this);
70   }
71
72   Gradient::Create();
73   Gradient::SetObject(static_cast<void*>(mTvgLinearGradient));
74 #endif
75 }
76
77 bool LinearGradientTizen::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
78 {
79 #ifdef THORVG_SUPPORT
80   if(!Gradient::GetObject() || !mTvgLinearGradient)
81   {
82     DALI_LOG_ERROR("LinearGradient is null\n");
83     return false;
84   }
85
86   if(mTvgLinearGradient->linear(firstPoint.x, firstPoint.y, secondPoint.x, secondPoint.y) != 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 LinearGradientTizen::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
101 {
102 #ifdef THORVG_SUPPORT
103   if(!Gradient::GetObject() || !mTvgLinearGradient)
104   {
105     DALI_LOG_ERROR("LinearGradient is null\n");
106     return false;
107   }
108
109   if(mTvgLinearGradient->linear(&firstPoint.x, &firstPoint.y, &secondPoint.x, &secondPoint.y) != 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