Merge changes Ia2ec4b45,Ied29583a into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / text-typesetter.h
1 #ifndef DALI_TOOLKIT_TEXT_TYPESETTER_H
2 #define DALI_TOOLKIT_TEXT_TYPESETTER_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/ref-object.h>
24 #include <dali/public-api/images/pixel-data.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Text
33 {
34
35 class ModelInterface;
36 class ViewModel;
37 class Typesetter;
38
39 typedef IntrusivePtr<Typesetter> TypesetterPtr;
40
41 /**
42  * @brief This class is responsible of controlling the data flow of the text's rendering process.
43  */
44 class Typesetter : public RefObject
45 {
46 public: // Constructor.
47   /**
48    * @brief Creates a Typesetter instance.
49    *
50    * The typesetter composes the final text retrieving the glyphs and the
51    * styles from the text's model.
52    *
53    * @param[in] model Pointer to the text's data model.
54    */
55   static TypesetterPtr New( const ModelInterface* const model );
56
57 public:
58   /**
59    * @brief Retrieves the pointer to the view model.
60    *
61    * @return A pointer to the view model.
62    */
63   ViewModel* GetViewModel();
64
65   /**
66    * @brief Renders the text.
67    *
68    * Does the following operations:
69    * - Finds the visible pages needed to be rendered.
70    * - Elide glyphs if needed.
71    * - Retrieves the data buffers from the text model.
72    * - Creates the pixel data used to generate the final image with the given size.
73    * - Traverse the visible glyphs, retrieve their bitmaps and compose the final pixel data.
74    *
75    * @param[in] size The renderer size.
76    *
77    * @return A pixel data with the text rendered.
78    */
79   PixelData Render( const Vector2& size );
80
81 private:
82   /**
83    * @brief Private constructor.
84    *
85    * @param[in] model Pointer to the text's data model.
86    */
87   Typesetter( const ModelInterface* const model );
88
89   // Declared private and left undefined to avoid copies.
90   Typesetter( const Typesetter& handle );
91
92   // Declared private and left undefined to avoid copies.
93   Typesetter& operator=( const Typesetter& handle );
94
95 protected:
96
97   /**
98    * @brief A reference counted object may only be deleted by calling Unreference().
99    *
100    * Destroys the visual model.
101    */
102   virtual ~Typesetter();
103
104 private:
105    ViewModel* mModel;
106 };
107
108 } // namespace Text
109
110 } // namespace Toolkit
111
112 } // namespace Dali
113
114 #endif // DALI_TOOLKIT_TEXT_TYPESETTER_H