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/picture-impl-ubuntu.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry.h>
31 namespace // unnamed namespace
34 Dali::BaseHandle Create()
36 return Dali::BaseHandle();
39 Dali::TypeRegistration type(typeid(Dali::CanvasRenderer::Picture), typeid(Dali::BaseHandle), Create);
41 } // unnamed namespace
43 PictureUbuntu* PictureUbuntu::New()
45 return new PictureUbuntu();
48 PictureUbuntu::PictureUbuntu()
50 : mTvgPicture(nullptr)
56 PictureUbuntu::~PictureUbuntu()
60 void PictureUbuntu::Initialize()
63 mTvgPicture = tvg::Picture::gen().release();
66 DALI_LOG_ERROR("Picture is null [%p]\n", this);
70 Drawable::SetObject(static_cast<void*>(mTvgPicture));
71 Drawable::SetType(Drawable::Types::PICTURE);
75 bool PictureUbuntu::Load(const std::string& url)
78 if(!Drawable::GetObject() || !mTvgPicture)
80 DALI_LOG_ERROR("Picture is null [%p]\n", this);
85 DALI_LOG_ERROR("Url is empty [%p]\n", this);
89 if(mTvgPicture->load(url.c_str()) != tvg::Result::Success)
91 DALI_LOG_ERROR("Load() fail. (%s)\n", url.c_str());
95 Drawable::SetChanged(true);
102 bool PictureUbuntu::SetSize(Vector2 size)
104 #ifdef THORVG_SUPPORT
105 if(!Drawable::GetObject() || !mTvgPicture)
107 DALI_LOG_ERROR("Picture is null [%p]\n", this);
110 if(mTvgPicture->size(size.width, size.height) != tvg::Result::Success)
112 DALI_LOG_ERROR("SetSize() fail.\n");
115 Drawable::SetChanged(true);
123 Vector2 PictureUbuntu::GetSize() const
125 #ifdef THORVG_SUPPORT
126 if(!Drawable::GetObject() || !mTvgPicture)
128 DALI_LOG_ERROR("Picture is null [%p]\n", this);
129 return Vector2::ZERO;
135 if(mTvgPicture->size(&width, &height) != tvg::Result::Success)
137 DALI_LOG_ERROR("GetSize() fail.\n");
138 return Vector2::ZERO;
141 return Vector2(width, height);
143 return Vector2::ZERO;
147 } // namespace Adaptor
149 } // namespace Internal