1 #ifndef __DALI_TOOLKIT_IMAGE_ATLAS_IMPL_H__
2 #define __DALI_TOOLKIT_IMAGE_ATLAS_IMPL_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/common/intrusive-ptr.h>
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/signals/connection-tracker.h>
24 #include <dali/devel-api/common/owner-container.h>
25 #include <dali/devel-api/images/atlas.h>
26 #include <dali/devel-api/common/owner-container.h>
29 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
30 #include <dali-toolkit/internal/image-loader/atlas-packer.h>
31 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
35 class EventThreadCallback;
43 class ImageAtlas : public BaseObject, public ConnectionTracker
47 typedef Toolkit::ImageAtlas::SizeType SizeType;
51 * @param [in] width The atlas width in pixels.
52 * @param [in] height The atlas height in pixels.
53 * @param [in] pixelFormat The pixel format.
55 ImageAtlas( SizeType width, SizeType height, Pixel::Format pixelFormat );
58 * @copydoc Toolkit::ImageAtlas::New
60 static IntrusivePtr<ImageAtlas> New( SizeType width, SizeType height, Pixel::Format pixelFormat );
63 * @copydoc Toolkit::ImageAtlas::GetAtlas
68 * @copydoc Toolkit::ImageAtlas::GetOccupancyRate
70 float GetOccupancyRate() const;
73 * @copydoc Toolkit::ImageAtlas::SetBrokenImage
75 void SetBrokenImage( const std::string& brokenImageUrl );
78 * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, const std::string&, ImageDimensions,FittingMode::Type, bool )
80 bool Upload( Vector4& textureRect,
81 const std::string& url,
83 FittingMode::Type fittingMode,
84 bool orientationCorrection,
85 AtlasUploadObserver* atlasUploadObserver );
88 * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, PixelData )
90 bool Upload( Vector4& textureRect, PixelData pixelData );
93 * @copydoc Toolkit::ImageAtlas::Remove
95 void Remove( const Vector4& textureRect );
98 * Resets the destroying observer pointer so that we know not to call methods of this object any more.
100 void ObserverDestroyed( AtlasUploadObserver* observer );
112 * @copydoc PixelDataRequester::ProcessPixels
114 void UploadToAtlas( uint32_t id, PixelData pixelData );
117 * Upload broken image
119 * @param[in] area The pixel area for uploading.
121 void UploadBrokenImage( const Rect<unsigned int>& area );
124 ImageAtlas( const ImageAtlas& imageAtlas);
127 ImageAtlas& operator=( const ImageAtlas& imageAtlas );
132 * Each loading task( identified with an ID ) is associated with a rect region for packing the loaded pixel data into the atlas,
133 * and an AtlasUploadObserver whose UploadCompleted method should get executed once the sub texture is ready.
135 struct LoadingTaskInfo
137 LoadingTaskInfo( unsigned short loadTaskId,
138 unsigned int packPositionX,
139 unsigned int packPositionY,
142 AtlasUploadObserver* observer )
143 : loadTaskId( loadTaskId ),
144 packRect( packPositionX, packPositionY, width, height ),
148 unsigned short loadTaskId;
149 Rect<unsigned int> packRect;
150 AtlasUploadObserver* observer;
153 OwnerContainer<LoadingTaskInfo*> mLoadingTaskInfoContainer;
157 Toolkit::AsyncImageLoader mAsyncLoader;
158 std::string mBrokenImageUrl;
159 ImageDimensions mBrokenImageSize;
162 Pixel::Format mPixelFormat;
167 } // namespace Internal
169 inline const Internal::ImageAtlas& GetImplementation( const Toolkit::ImageAtlas& imageAtlas )
171 DALI_ASSERT_ALWAYS( imageAtlas && "ImageAtlas handle is empty" );
173 const BaseObject& handle = imageAtlas.GetBaseObject();
175 return static_cast<const Internal::ImageAtlas&>(handle);
178 inline Internal::ImageAtlas& GetImplementation( Toolkit::ImageAtlas& imageAtlas )
180 DALI_ASSERT_ALWAYS( imageAtlas && "ImageAtlas handle is empty" );
182 BaseObject& handle = imageAtlas.GetBaseObject();
184 return static_cast<Internal::ImageAtlas&>(handle);
187 } // namespace Toolkit
191 #endif /* __DALI_TOOLKIT_IMAGE_ATLAS_IMPL_H__ */