1 #ifndef __DALI_INTERNAL_ATLAS_H__
2 #define __DALI_INTERNAL_ATLAS_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.
22 #include <dali/public-api/images/atlas.h>
23 #include <dali/internal/event/images/image-impl.h>
34 * @brief An Atlas is a large image containing multiple smaller images.
36 * Bitmap images must be uploaded at a specified position, to populate the Atlas.
37 * The client is reponsible for generating the appropriate geometry (UV coordinates),
38 * needed to draw images within the Atlas.
40 class Atlas : public Image
45 * @brief Create a new Atlas.
47 * @pre width & height are greater than zero.
48 * The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
49 * @param [in] width The atlas width in pixels.
50 * @param [in] height The atlas height in pixels.
51 * @param [in] pixelFormat The pixel format (rgba 32 bit by default).
52 * @return A pointer to a new Atlas.
54 static Atlas* New( std::size_t width,
56 Pixel::Format pixelFormat = Pixel::RGBA8888 );
59 * @brief Upload a buffer image to the atlas.
61 * @pre The bitmap pixel format must match the Atlas format.
62 * @param [in] bufferImage The buffer image to upload.
63 * @param [in] xOffset Specifies an offset in the x direction within the atlas.
64 * @param [in] yOffset Specifies an offset in the y direction within the atlas.
65 * @return True if the bitmap fits within the atlas at the specified offset.
67 bool Upload( const BufferImage& bufferImage,
69 std::size_t yOffset );
74 * @brief Protected constructor.
76 * @pre width & height are greater than zero.
77 * The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
78 * @param [in] width The atlas width in pixels.
79 * @param [in] height The atlas height in pixels.
80 * @param [in] pixelFormat The pixel format (rgba 32 bit by default).
82 Atlas( std::size_t width,
84 Pixel::Format pixelFormat );
87 * A reference counted object may only be deleted by calling Unreference()
92 * @copydoc Dali::Internal::Image::Connect
94 virtual void Connect();
97 * @copydoc Dali::Internal::Image::Disconnect
99 virtual void Disconnect();
104 * Helper for Upload methods
105 * @return True if the bitmap fits within the atlas at the specified offset
107 bool IsWithin( const BufferImage& bufferImage,
109 std::size_t yOffset );
112 * Helper to create the Atlas resource
114 void AllocateAtlas();
117 * Helper to release the Atlas resource
123 ResourceClient& mResourceClient;
125 Pixel::Format mPixelFormat;
128 } // namespace Internal
131 * Helper methods for public API.
133 inline Internal::Atlas& GetImplementation(Dali::Atlas& image)
135 DALI_ASSERT_ALWAYS( image && "Atlas handle is empty" );
137 BaseObject& handle = image.GetBaseObject();
139 return static_cast<Internal::Atlas&>(handle);
142 inline const Internal::Atlas& GetImplementation(const Dali::Atlas& image)
144 DALI_ASSERT_ALWAYS( image && "Atlas handle is empty" );
146 const BaseObject& handle = image.GetBaseObject();
148 return static_cast<const Internal::Atlas&>(handle);
153 #endif // __DALI_INTERNAL_ATLAS_H__