2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/canvas-renderer/ubuntu/linear-gradient-impl-ubuntu.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry.h>
26 #include <dali/internal/canvas-renderer/common/gradient-impl.h>
34 namespace // unnamed namespace
37 Dali::BaseHandle Create()
39 return Dali::BaseHandle();
42 Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::LinearGradient), typeid(Dali::BaseHandle), Create);
44 } // unnamed namespace
46 LinearGradientUbuntu* LinearGradientUbuntu::New()
48 return new LinearGradientUbuntu();
51 LinearGradientUbuntu::LinearGradientUbuntu()
53 : mTvgLinearGradient(nullptr)
59 LinearGradientUbuntu::~LinearGradientUbuntu()
63 void LinearGradientUbuntu::Initialize()
66 mTvgLinearGradient = tvg::LinearGradient::gen().release();
67 if(!mTvgLinearGradient)
69 DALI_LOG_ERROR("LinearGradient is null [%p]\n", this);
73 Gradient::SetObject(static_cast<void*>(mTvgLinearGradient));
77 bool LinearGradientUbuntu::SetBounds(Vector2 firstPoint, Vector2 secondPoint)
80 if(!Gradient::GetObject() || !mTvgLinearGradient)
82 DALI_LOG_ERROR("LinearGradient is null\n");
86 if(mTvgLinearGradient->linear(firstPoint.x, firstPoint.y, secondPoint.x, secondPoint.y) != tvg::Result::Success)
88 DALI_LOG_ERROR("SetBounds() fail.\n");
92 Gradient::SetChanged(true);
100 bool LinearGradientUbuntu::GetBounds(Vector2& firstPoint, Vector2& secondPoint) const
102 #ifdef THORVG_SUPPORT
103 if(!Gradient::GetObject() || !mTvgLinearGradient)
105 DALI_LOG_ERROR("LinearGradient is null\n");
109 if(mTvgLinearGradient->linear(&firstPoint.x, &firstPoint.y, &secondPoint.x, &secondPoint.y) != tvg::Result::Success)
111 DALI_LOG_ERROR("GetBounds() fail.\n");
121 } // namespace Adaptor
123 } // namespace Internal