1 #ifndef DALI_TOOLKIT_NPATCH_LOADER_H
2 #define DALI_TOOLKIT_NPATCH_LOADER_H
5 * Copyright (c) 2016 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/rendering/texture-set.h>
23 #include <dali/devel-api/common/owner-container.h>
24 #include <dali/devel-api/images/nine-patch-image.h>
27 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
39 * The manager for loading Npatch textures.
40 * It caches them internally for better performance; i.e. to avoid loading and
41 * parsing the files over and over.
43 * Cache is not cleaned during app lifecycle as N patches take considerably
44 * small space and there's not usually a lot of them. Usually N patches are specified in
45 * toolkit default style and there is 1-2 per control that are shared across the whole application.
53 UNINITIALIZED_ID = 0 ///< uninitialised id, use to initialize ids
58 std::string url; ///< Url of the N-Patch
59 TextureSet textureSet; ///< Texture containing the cropped image
60 NinePatchImage::StretchRanges stretchPixelsX; ///< X stretch pixels
61 NinePatchImage::StretchRanges stretchPixelsY; ///< Y stretch pixels
62 std::size_t hash; ///< Hash code for the Url
63 uint32_t croppedWidth; ///< Width of the cropped middle part of N-patch
64 uint32_t croppedHeight; ///< Height of the cropped middle part of N-patch
75 * Destructor, non-virtual as not a base class
80 * @brief Retrieve a texture matching the n-patch url.
82 * @param [in] url to retrieve
83 * @return id of the texture.
85 std::size_t Load( const std::string& url );
88 * @brief Retrieve N patch data matching to an id
89 * @param [in] id of data
90 * @param [out] data const pointer to the data
91 * @return true if data matching to id was really found
93 bool GetNPatchData( std::size_t id, const Data*& data );
98 * Undefined copy constructor.
100 NPatchLoader(const NPatchLoader&);
103 * Undefined assignment operator.
105 NPatchLoader& operator=(const NPatchLoader& rhs);
109 OwnerContainer< Data* > mCache;
115 } // namespace Toolkit
119 #endif // DALI_TOOLKIT_NPATCH_LOADER_H