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
65 Rect< int > border; ///< The size of the border
76 * Destructor, non-virtual as not a base class
81 * @brief Retrieve a texture matching the n-patch url.
83 * @param [in] url to retrieve
84 * @param [in] border The border size of the image
85 * @return id of the texture.
87 std::size_t Load( const std::string& url, const Rect< int >& border );
90 * @brief Retrieve N patch data matching to an id
91 * @param [in] id of data
92 * @param [out] data const pointer to the data
93 * @return true if data matching to id was really found
95 bool GetNPatchData( std::size_t id, const Data*& data );
100 * Undefined copy constructor.
102 NPatchLoader(const NPatchLoader&);
105 * Undefined assignment operator.
107 NPatchLoader& operator=(const NPatchLoader& rhs);
111 OwnerContainer< Data* > mCache;
117 } // namespace Toolkit
121 #endif // DALI_TOOLKIT_NPATCH_LOADER_H