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