1 #ifndef DALI_TOOLKIT_TEXT_ABSTRACTION_TEXT_RENDERER_H
2 #define DALI_TOOLKIT_TEXT_ABSTRACTION_TEXT_RENDERER_H
5 * Copyright (c) 2020 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/common/dali-vector.h>
23 #include <dali/public-api/object/base-handle.h>
26 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
27 #include <dali/devel-api/text-abstraction/glyph-info.h>
31 namespace TextAbstraction
35 // Forward declaration
38 } // namespace Internal
41 * @brief Renders the given @e glyphs at the given @e positions into a pixel buffer.
43 * @note This class renders glyphs not characters.
44 * Font selection, RTL reordering, shaping and layout
45 * has to be done before calling the @e Render()
46 * method of this class.
48 class DALI_ADAPTOR_API TextRenderer : public BaseHandle
52 * @brief Parameters to render the text.
57 * @brief Enum with the possible pixel formats of the output pixel buffer.
61 A8, ///< Alpha channel, 8-bit color depth.
62 RGBA8888 ///< Red, Green, Blue and Alpha channels, 8-bit color depth per channel.
66 * @brief Whether the circular layout is clockwise.
70 CLOCKWISE, ///< The text is laid clockwise on a circular path.
71 COUNTER_CLOCKWISE ///< The text is laid counter clockwise on a circular path.
75 * @brief Parameters for the text renderer function.
77 Parameters(Vector<GlyphInfo>& glyphs,
78 Vector<Vector2>& positions,
79 Vector<Vector4>& colors,
80 Vector<ColorIndex>& colorIndices,
81 Vector<ColorBlendingMode>& blendingMode,
82 Vector<bool>& isEmoji)
86 colorIndices(colorIndices),
87 blendingMode(blendingMode),
98 circularLayout{CLOCKWISE}
102 Vector<GlyphInfo>& glyphs; ///< The glyphs to be rendered.
103 Vector<Vector2>& positions; ///< The position for each glyph.
104 Vector<Vector4>& colors; ///< Colors of the glyphs.
105 Vector<ColorIndex>& colorIndices; ///< Indices to the vector of colors for each glyphs.
106 Vector<ColorBlendingMode>& blendingMode; ///< How each glyph is going to be blended with the color of the text.
107 Vector<bool>& isEmoji; ///< Whether each glyph is an emoji.
108 unsigned int width; ///< The width of the pixel buffer. @note Some implementations may change the width for performance reasons.
109 unsigned int height; ///< The height of the pixel buffer.
110 unsigned int radius; ///< The radius in pixels of the circular text.
111 unsigned int circularWidth; ///< The width of the text laid out on an horizontal straight line.
112 unsigned int circularHeight; ///< The height of the text laid out on an horizontal straight line.
113 int centerX; ///< The 'x' coordinate of the center. For circular layout.
114 int centerY; ///< The 'y' coordinate of the center. For circular layout.
115 float beginAngle; ///< The angle in radians where the circular text begins.
116 PixelFormat pixelFormat; ///< The pixel format of the pixel buffer.
117 CircularLayout circularLayout; ///< The direction of the text's layout.
122 * @brief Create an uninitialized TextRenderer handle.
130 * This is non-virtual since derived Handle types must not contain data or virtual methods.
135 * @brief Retrieve a handle to the TextRenderer instance.
137 * @return A handle to the TextRenderer.
139 static TextRenderer Get();
142 * @brief Renders the given @e glyphs into a pixel buffer.
144 * @param[in] parameters Struct with the glyphs, positions and the size of the pixel buffer.
146 * @return The pixel buffer with the text rendered on it.
148 Devel::PixelBuffer Render(const Parameters& parameters);
150 public: // Not intended for application developers.
153 * @brief This constructor is used by TextRenderer::Get().
155 * @param[in] implementation A pointer to the internal text renderer object.
157 explicit DALI_INTERNAL TextRenderer(Internal::TextRenderer* implementation);
161 } // namespace TextAbstraction
165 #endif // DALI_TOOLKIT_TEXT_ABSTRACTION_TEXT_RENDERER_H