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