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/tizen/drawable-impl-tizen.h>
22 #include <dali/devel-api/common/stage.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/public-api/object/type-registry.h>
32 namespace // unnamed namespace
35 Dali::BaseHandle Create()
37 return Dali::BaseHandle();
40 Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::Drawable), typeid(Dali::BaseHandle), Create);
42 } // unnamed namespace
44 DrawableTizen* DrawableTizen::New()
46 return new DrawableTizen();
49 DrawableTizen::DrawableTizen()
56 DrawableTizen::~DrawableTizen()
58 if(mTvgPaint && !mAdded)
64 bool DrawableTizen::SetOpacity(float opacity)
68 DALI_LOG_ERROR("Drawable is null [%p]\n", this);
71 if(mTvgPaint->opacity(round(opacity * 255.f)) != tvg::Result::Success)
73 DALI_LOG_ERROR("Set opacity fail [%p]\n", this);
80 float DrawableTizen::GetOpacity() const
84 DALI_LOG_ERROR("Drawable is null [%p]\n", this);
87 return (float)mTvgPaint->opacity() / 255.f;
90 bool DrawableTizen::Rotate(Degree degree)
94 DALI_LOG_ERROR("Drawable is null\n");
98 if(mTvgPaint->rotate(degree.degree) != tvg::Result::Success)
100 DALI_LOG_ERROR("Rotate fail.\n");
107 bool DrawableTizen::Scale(float factor)
111 DALI_LOG_ERROR("Drawable is null\n");
115 if(mTvgPaint->scale(factor) != tvg::Result::Success)
117 DALI_LOG_ERROR("Scale fail.\n");
124 bool DrawableTizen::Translate(Vector2 translate)
128 DALI_LOG_ERROR("Drawable is null\n");
132 if(mTvgPaint->translate(translate.x, translate.y) != tvg::Result::Success)
134 DALI_LOG_ERROR("Translate fail.\n");
141 bool DrawableTizen::Transform(const Dali::Matrix3& matrix)
145 DALI_LOG_ERROR("Drawable is null\n");
149 tvg::Matrix tvgMatrix = {matrix.AsFloat()[0], matrix.AsFloat()[1], matrix.AsFloat()[2], matrix.AsFloat()[3], matrix.AsFloat()[4], matrix.AsFloat()[5], matrix.AsFloat()[6], matrix.AsFloat()[7], matrix.AsFloat()[8]};
151 if(mTvgPaint->transform(tvgMatrix) != tvg::Result::Success)
153 DALI_LOG_ERROR("Transform fail.\n");
160 void DrawableTizen::SetDrawableAdded(bool added)
165 void* DrawableTizen::GetObject() const
167 return static_cast<void*>(mTvgPaint);
170 void DrawableTizen::SetObject(const void* object)
174 mTvgPaint = static_cast<tvg::Paint*>((void*)object);
177 DALI_LOG_ERROR("Drawable is invalid [%p]\n", this);
193 void DrawableTizen::SetChanged(bool changed)
195 if(!mChanged && changed) Dali::Stage::GetCurrent().KeepRendering(0.0f);
196 mChanged = !!changed;
199 bool DrawableTizen::GetChanged() const
203 } // namespace Adaptor
205 } // namespace Internal