Formatting API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / image-loader / image-atlas.cpp
1 /*
2  * Copyright (c) 2020 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 "image-atlas.h"
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 ImageAtlas::ImageAtlas()
29 {
30 }
31
32 ImageAtlas::~ImageAtlas()
33 {
34 }
35
36 Texture ImageAtlas::PackToAtlas(const std::vector<PixelData>& pixelData, Dali::Vector<Vector4>& textureRects)
37 {
38   return Internal::ImageAtlas::PackToAtlas(pixelData, textureRects);
39 }
40
41 ImageAtlas::ImageAtlas(Internal::ImageAtlas* internal)
42 : BaseHandle(internal)
43 {
44 }
45
46 ImageAtlas::ImageAtlas(const ImageAtlas& handle)
47 : BaseHandle(handle)
48 {
49 }
50
51 ImageAtlas& ImageAtlas::operator=(const ImageAtlas& handle)
52 {
53   BaseHandle::operator=(handle);
54   return *this;
55 }
56
57 ImageAtlas ImageAtlas::New(SizeType width, SizeType height, Pixel::Format pixelFormat)
58 {
59   IntrusivePtr<Internal::ImageAtlas> internal = Internal::ImageAtlas::New(width, height, pixelFormat);
60   return ImageAtlas(internal.Get());
61 }
62
63 Texture ImageAtlas::GetAtlas()
64 {
65   return GetImplementation(*this).GetAtlas();
66 }
67
68 float ImageAtlas::GetOccupancyRate() const
69 {
70   return GetImplementation(*this).GetOccupancyRate();
71 }
72
73 void ImageAtlas::SetBrokenImage(const std::string& brokenImageUrl)
74 {
75   GetImplementation(*this).SetBrokenImage(brokenImageUrl);
76 }
77
78 bool ImageAtlas::Upload(Vector4&           textureRect,
79                         const std::string& url,
80                         ImageDimensions    size,
81                         FittingMode::Type  fittingMode,
82                         bool               orientationCorrection)
83 {
84   return Upload(textureRect, url, size, fittingMode, orientationCorrection, NULL);
85 }
86
87 bool ImageAtlas::Upload(Vector4&             textureRect,
88                         const std::string&   url,
89                         ImageDimensions      size,
90                         FittingMode::Type    fittingMode,
91                         bool                 orientationCorrection,
92                         AtlasUploadObserver* atlasUploadObserver)
93 {
94   return GetImplementation(*this).Upload(textureRect, url, size, fittingMode, orientationCorrection, atlasUploadObserver);
95 }
96
97 bool ImageAtlas::Upload(Vector4& textureRect, PixelData pixelData)
98 {
99   return GetImplementation(*this).Upload(textureRect, pixelData);
100 }
101
102 void ImageAtlas::Remove(const Vector4& textureRect)
103 {
104   GetImplementation(*this).Remove(textureRect);
105 }
106
107 } // namespace Toolkit
108
109 } // namespace Dali