1 #ifndef DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H
2 #define DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H
5 * Copyright (c) 2022 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.
23 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
24 #include <string_view>
33 * TextVisualShaderFeature contains feature lists what text visual shader need to know.
35 namespace TextVisualShaderFeature
37 namespace TextMultiColor
40 * @brief Whether text contains single color or not.
44 SINGLE_COLOR_TEXT = 0, ///< The text contains single color only.
45 MULTI_COLOR_TEXT ///< The text contains multiple colors.
47 } // namespace TextMultiColor
52 * @brief Whether text contains emoji or not.
56 NO_EMOJI = 0, ///< The text contains no emoji.
57 HAS_EMOJI ///< The text contains emoji.
59 } // namespace TextEmoji
64 * @brief Whether text contains styles (like shadow or background color) or not.
68 NO_STYLES = 0, ///< The text contains contains no styles.
69 HAS_STYLES ///< The text contains contains styles.
71 } // namespace TextStyle
76 * @brief Whether text contains overlay styles (like markdown) or not.
80 NO_OVERLAY = 0, ///< The text contains contains no overlay.
81 HAS_OVERLAY ///< The text contains contains overlay.
83 } // namespace TextOverlay
86 * @brief Collection of current text visual feature.
91 : mTextMultiColor(TextMultiColor::SINGLE_COLOR_TEXT),
92 mTextEmoji(TextEmoji::NO_EMOJI),
93 mTextStyle(TextStyle::NO_STYLES),
94 mTextOverlay(TextOverlay::NO_OVERLAY)
98 FeatureBuilder& EnableMultiColor(bool enableMultiColor);
99 FeatureBuilder& EnableEmoji(bool enableEmoji);
100 FeatureBuilder& EnableStyle(bool enableStyle);
101 FeatureBuilder& EnableOverlay(bool enableOverlay);
103 bool IsEnabledMultiColor() const
105 return mTextMultiColor == TextMultiColor::MULTI_COLOR_TEXT;
107 bool IsEnabledEmoji() const
109 return mTextEmoji == TextEmoji::HAS_EMOJI;
111 bool IsEnabledStyle() const
113 return mTextStyle == TextStyle::HAS_STYLES;
115 bool IsEnabledOverlay() const
117 return mTextOverlay == TextOverlay::HAS_OVERLAY;
120 TextMultiColor::Type mTextMultiColor : 2; ///< Whether text has multiple color, or not. default as TextMultiColor::SINGLE_COLOR_TEXT
121 TextEmoji::Type mTextEmoji : 2; ///< Whether text has emoji, or not. default as TextEmoji::NO_EMOJI
122 TextStyle::Type mTextStyle : 2; ///< Whether text has style, or not. default as TextStyle::NO_STYLES
123 TextOverlay::Type mTextOverlay : 2; ///< Whether text has overlay style, or not. default as TextOverlay::NO_OVERLAY
126 } // namespace TextVisualShaderFeature
129 * TextVisualShaderFactory is an object that provides and shares shaders for text visuals
131 class TextVisualShaderFactory
137 TextVisualShaderFactory();
142 ~TextVisualShaderFactory();
145 * @brief Get the standard text rendering shader.
146 * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
147 * @param[in] featureBuilder Collection of current text shader's features
148 * @return The standard text rendering shader with features.
150 Shader GetShader(VisualFactoryCache& factoryCache, const TextVisualShaderFeature::FeatureBuilder& featureBuilder);
154 * Undefined copy constructor.
156 TextVisualShaderFactory(const TextVisualShaderFactory&);
159 * Undefined assignment operator.
161 TextVisualShaderFactory& operator=(const TextVisualShaderFactory& rhs);
166 } // namespace Internal
168 } // namespace Toolkit
172 #endif // DALI_TOOLKIT_TEXT_VISUAL_SHADER_FACTORY_H