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