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