Merge "Add post processor" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / canvas-view / canvas-view-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
3
4 /*
5  * Copyright (c) 2021 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/devel-api/adaptor-framework/canvas-renderer-drawable.h>
23 #include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
24 #include <dali/devel-api/adaptor-framework/canvas-renderer.h>
25 #include <dali/devel-api/rendering/renderer-devel.h>
26 #include <dali/integration-api/processor-interface.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/devel-api/controls/canvas-view/canvas-view.h>
30 #include <dali-toolkit/public-api/controls/control-impl.h>
31
32 namespace Dali
33 {
34 namespace Toolkit
35 {
36 class CanvasView;
37
38 namespace Internal
39 {
40 class CanvasView : public Control, public Integration::Processor
41 {
42 public:
43   /**
44    * Construct a new CanvasView.
45    */
46   CanvasView(const Vector2& viewBox);
47
48   /**
49    * A reference counted object may only be deleted by calling Unreference()
50    */
51   virtual ~CanvasView();
52
53 public:
54   /**
55    * Create a new CanvasView.
56    * @return A smart-pointer to the newly allocated CanvasView.
57    */
58   static Toolkit::CanvasView New(const Vector2& viewBox);
59
60   /**
61    * @copydoc Toolkit::Control::CanvasView::AddDrawable
62    */
63   bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
64
65 private: // From Control
66   /**
67    * @copydoc Control::OnRelayout
68    */
69   void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
70
71   /**
72    * @copydoc Toolkit::Control::OnSizeSet()
73    */
74   void OnSizeSet(const Vector3& targetSize) override;
75
76   /**
77    * @copydoc Toolkit::Control::OnInitialize
78    */
79   void OnInitialize() override;
80
81 protected: // Implementation of Processor
82   /**
83    * @copydoc Dali::Integration::Processor::Process()
84    */
85   void Process(bool postProcessor) override;
86
87 private:
88   /**
89    * @brief Draw drawables added to CanvasView on inner canvas.
90    * Then make that buffer into a texture and add it to renderer.
91    */
92   void Commit();
93
94 private:
95   CanvasView(const CanvasView&) = delete;
96   CanvasView& operator=(const CanvasView&) = delete;
97
98 private:
99   CanvasRenderer mCanvasRenderer;
100   Dali::Texture  mTexture;
101   bool           mChanged;
102 };
103
104 } // namespace Internal
105
106 // Helpers for public-api forwarding methods
107 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
108 {
109   DALI_ASSERT_ALWAYS(obj);
110   Dali::RefObject& handle = obj.GetImplementation();
111   return static_cast<Toolkit::Internal::CanvasView&>(handle);
112 }
113
114 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
115 {
116   DALI_ASSERT_ALWAYS(obj);
117   const Dali::RefObject& handle = obj.GetImplementation();
118   return static_cast<const Toolkit::Internal::CanvasView&>(handle);
119 }
120
121 } // namespace Toolkit
122
123 } // namespace Dali
124
125 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H