Text clean.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / clipping / text-clipper.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
3
4 /*
5  * Copyright (c) 2015 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/actors/layer.h>
23 #include <dali/public-api/actors/image-actor.h>
24 #include <dali/public-api/actors/camera-actor.h>
25 #include <dali/public-api/render-tasks/render-task.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Text
34 {
35
36 class Clipper;
37 typedef IntrusivePtr<Clipper> ClipperPtr;
38
39 /**
40  * @brief A helper class for clipping actors using a FrameBufferImage.
41  */
42 class Clipper : public RefObject
43 {
44 public:
45
46   /**
47    * @brief Create a clipper.
48    *
49    * @param[in] size The size of the clipping region.
50    */
51   static ClipperPtr New( const Vector2& size );
52
53   /**
54    * @brief Children added to this actor will be clipped with the specified region.
55    *
56    * @note This is done by rendering to a FrameBufferImage which must then be displayed; see also GetImageActor().
57    * @return The root actor.
58    */
59   Actor GetRootActor() const;
60
61   /**
62    * @brief This actor will display the resulting FrameBufferImage.
63    *
64    * @return The image actor.
65    */
66   ImageActor GetImageActor() const;
67
68   /**
69    * @brief Refresh the contents of the FrameBufferImage.
70    *
71    * @param[in] size The size of the clipping region.
72    */
73   void Refresh( const Vector2& size );
74
75 private: // Implementation
76
77   /**
78    * @brief Second-phase init
79    *
80    * @param[in] size The size of the clipping region.
81    */
82   void Initialize( const Vector2& size );
83
84   /**
85    * Construct a new Clipper.
86    */
87   Clipper();
88
89   /**
90    * A reference counted object may only be deleted by calling Unreference()
91    */
92   virtual ~Clipper();
93
94 private:
95
96   // Undefined copy constructor and assignment operators
97   Clipper(const Clipper&);
98   Clipper& operator=(const Clipper& rhs);
99
100 private: // Data
101
102   Layer mOffscreenRootActor;
103   CameraActor mOffscreenCameraActor;
104   ImageActor mImageActor;
105   RenderTask mRenderTask;
106   Vector2 mCurrentOffscreenSize;
107 };
108
109 } // namespace Text
110
111 } // namespace Toolkit
112
113 } // namespace Dali
114
115 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__