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>
28 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
29 #include <dali-toolkit/devel-api/image-loader/async-image-loader.h>
30 #include <dali-toolkit/internal/image-loader/atlas-packer.h>
34 class EventThreadCallback;
42 class ImageAtlas : public BaseObject, public ConnectionTracker
46 typedef Toolkit::ImageAtlas::SizeType SizeType;
50 * @param [in] width The atlas width in pixels.
51 * @param [in] height The atlas height in pixels.
52 * @param [in] pixelFormat The pixel format.
54 ImageAtlas( SizeType width, SizeType height, Pixel::Format pixelFormat );
57 * @copydoc Toolkit::ImageAtlas::New
59 static IntrusivePtr<ImageAtlas> New( SizeType width, SizeType height, Pixel::Format pixelFormat );
62 * @copydoc Toolkit::ImageAtlas::GetAtlas
67 * @copydoc Toolkit::ImageAtlas::GetOccupancyRate
69 float GetOccupancyRate() const;
72 * @copydoc Toolkit::ImageAtlas::SetBrokenImage
74 void SetBrokenImage( const std::string& brokenImageUrl );
77 * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, const std::string&, ImageDimensions,FittingMode::Type, bool )
79 bool Upload( Vector4& textureRect,
80 const std::string& url,
82 FittingMode::Type fittingMode,
83 bool orientationCorrection);
86 * @copydoc Toolkit::ImageAtlas::Upload( Vector4&, PixelData )
88 bool Upload( Vector4& textureRect, PixelData pixelData );
91 * @copydoc Toolkit::ImageAtlas::Remove
93 void Remove( const Vector4& textureRect );
105 * @copydoc PixelDataRequester::ProcessPixels
107 void UploadToAtlas( unsigned int id, PixelData pixelData );
110 * Upload broken image
112 * @param[in] area The pixel area for uploading.
114 void UploadBrokenImage( const Rect<unsigned int>& area );
117 ImageAtlas( const ImageAtlas& imageAtlas);
120 ImageAtlas& operator=( const ImageAtlas& imageAtlas );
126 IdRectPair( unsigned short loadTaskId,
127 unsigned int packPositionX,
128 unsigned int packPositionY,
130 unsigned int height )
131 : loadTaskId( loadTaskId ),
132 packRect( packPositionX, packPositionY, width, height )
135 unsigned short loadTaskId;
136 Rect<unsigned int> packRect;
139 OwnerContainer<IdRectPair*> mIdRectContainer;
143 Toolkit::AsyncImageLoader mAsyncLoader;
144 std::string mBrokenImageUrl;
145 ImageDimensions mBrokenImageSize;
148 Pixel::Format mPixelFormat;
152 } // namespace Internal
154 inline const Internal::ImageAtlas& GetImplementation( const Toolkit::ImageAtlas& imageAtlas )
156 DALI_ASSERT_ALWAYS( imageAtlas && "ImageAtlas handle is empty" );
158 const BaseObject& handle = imageAtlas.GetBaseObject();
160 return static_cast<const Internal::ImageAtlas&>(handle);
163 inline Internal::ImageAtlas& GetImplementation( Toolkit::ImageAtlas& imageAtlas )
165 DALI_ASSERT_ALWAYS( imageAtlas && "ImageAtlas handle is empty" );
167 BaseObject& handle = imageAtlas.GetBaseObject();
169 return static_cast<Internal::ImageAtlas&>(handle);
172 } // namespace Toolkit
176 #endif /* __DALI_TOOLKIT_IMAGE_ATLAS_IMPL_H__ */