1 #ifndef __DALI_INTERNAL_ATLAS_RANKING_H__
2 #define __DALI_INTERNAL_ATLAS_RANKING_H__
5 * Copyright (c) 2014 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.
29 * Small class used to store and compare how suitable an atlas is
30 * for storing a string of text.
32 * The search ranking allows us to chose the best Atlas / tweak behaviour.
34 * The ranking algorithm is based on various factors, such as:
35 * - Whether all or some of the characters are in the atlas already
36 * - Whether the atlas contains other characters of the same font
37 * - Whether the atlas is full but can be split up (if it has more than one font)
38 * - Whether the atlas is full, but can be enlarged.
48 * Character match status
52 NO_CHARACTERS_MATCHED = 0x0, ///< Atlas contains no matching characters
53 SOME_CHARACTERS_MATCHED = 0x1, ///< Some characters are in the Atlas
54 ALL_CHARACTERS_MATCHED = 0x2 ///< All characters are in the atlas
62 NO_FONT_MATCHED = 0x0, ///< Atlas has no characters using the the same font
63 FONT_MATCHED = 0x1 ///< Atlas characters using the same font
71 FULL_CANNOT_BE_RESIZED = 0x0, ///< Atlas can't be resized ( recached max texture size)
72 FULL_CAN_BE_SPLIT = 0x1, ///< Atlas is full and contains more than one font, so can be split up
73 FULL_CAN_BE_RESIZED = 0x2, ///< Atlas is full and can be resized
74 HAS_SPACE = 0x4 ///< Atlas has free space
79 * @param[in] unMatchedCharacters number of un-matched characters
81 AtlasRanking( unsigned int unMatchedCharacters );
85 * @param[in] characterMatch character match status
86 * @param[in] fontMatch font match status
87 * @param[in] spaceStatus space status
88 * @param[in] unMatchedCharacters number of un-matched characters
90 AtlasRanking( CharacterMatch characterMatch,
92 SpaceStatus spaceStatus,
93 unsigned int unMatchedCharacters);
97 * non virtual destructor, not intended as a base class.
103 * @param[in] rhs atlas to copy
105 AtlasRanking( const AtlasRanking& rhs);
108 * Assignment operator.
109 * @param[in] rhs atlas to assign
110 * @return reference to this
112 AtlasRanking& operator=( const AtlasRanking& rhs );
115 * Returns if this atlas ranking is higher than the
116 * parameter passed in,
117 * @param atlasRank the rank to compare against
118 * @return true if it is higher ranked
120 bool HigherRanked(const AtlasRanking &atlasRank) const;
123 * @return true if the text fits in the atlas
125 bool TextFits() const;
128 * @return true if the atlas already contains all the characters in the text
130 bool AllCharactersMatched() const;
133 * @return the atlas space status
135 SpaceStatus GetSpaceStatus() const;
140 * Compare two atlas rankings
141 * @param a atlas a ranking
142 * @param b atlas b ranking
143 * @return -1 if a<b, 0 if a==b, 1 if a > b
145 int Compare( const AtlasRanking &a, const AtlasRanking &b) const;
147 unsigned int mUnMatchedCharacters:10; ///< number of un-matched characters
148 CharacterMatch mChararacterMatch:2; ///< character match status
149 FontMatch mFontMatch:1; ///< font match status
150 SpaceStatus mSpaceStatus:3; ///< space tatus
153 } // namespace Internal
157 #endif // __DALI_INTERNAL_ATLAS_RANKING_H__