Fix: The last line of the text overlaps with the text-editor's border/edge
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / gl-view / gl-view-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_GL_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_GL_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/actors/actor-devel.h>
23 #include <dali/devel-api/adaptor-framework/native-image-source-queue.h>
24 #include <dali/public-api/adaptor-framework/window.h>
25 #include <dali/public-api/rendering/geometry.h>
26 #include <dali/public-api/rendering/shader.h>
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/internal/controls/gl-view/gl-view-render-thread.h>
30 #include <dali-toolkit/public-api/controls/control-impl.h>
31 #include <dali-toolkit/public-api/controls/gl-view/gl-view.h>
32
33 namespace Dali
34 {
35 namespace Toolkit
36 {
37 class GlView;
38
39 namespace Internal
40 {
41 class GlView : public Dali::Toolkit::Internal::Control
42 {
43 protected:
44   virtual ~GlView();
45
46 public:
47   /**
48    * @copydoc Dali::Toolkit::GlView::New()
49    */
50   static Dali::Toolkit::GlView New(Dali::Toolkit::GlView::ColorFormat colorFormat);
51
52   /**
53    * Construct a new GlView.
54    */
55   GlView(Dali::Toolkit::GlView::ColorFormat colorFormat);
56
57   /**
58    * @copydoc Dali::Toolkit::GlView::RegisterGlCallback()
59    */
60   void RegisterGlCallback(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback);
61
62   /**
63    * @copydoc Dali::Toolkit::GlView::SetResizeCallback()
64    */
65   void SetResizeCallback(CallbackBase* resizeCallback);
66
67   /**
68    * @copydoc Dali::Toolkit::GlView::SetGraphisConfig()
69    */
70   bool SetGraphicsConfig(bool depth, bool stencil, int msaa, Dali::Toolkit::GlView::GraphicsApiVersion version);
71
72   /**
73    * @copydoc Dali::Toolkit::GlView::SetRenderingMode()
74    */
75   void SetRenderingMode(Dali::Toolkit::GlView::RenderingMode mode);
76
77   /**
78    * @copydoc Dali::Toolkit::GlView::GetRenderingMode()
79    */
80   Dali::Toolkit::GlView::RenderingMode GetRenderingMode() const;
81
82   /**
83    * @copydoc Dali::Toolkit::GlView::RenderOnce()
84    */
85   void RenderOnce();
86
87 private: // From Control
88   /**
89    * @copydoc Toolkit::Control::OnInitialize()
90    */
91   virtual void OnInitialize() override;
92
93   /**
94    * @copydoc Toolkit::Control::OnSceneConnection()
95    */
96   void OnSceneConnection(int depth) override;
97
98   /**
99    * @copydoc Toolkit::Control::OnSceneDisconnection()
100    */
101   void OnSceneDisconnection() override;
102
103   /**
104    * @copydoc Toolkit::Control::OnSizeSet()
105    */
106   void OnSizeSet(const Vector3& targetSize) override;
107
108 private:
109   // Undefined copy constructor and assignment operators
110   GlView(const GlView& GlView);
111   GlView& operator=(const GlView& GlView);
112
113   /**
114    * Callback when the visibility of the GlView is changed
115    */
116   void OnControlVisibilityChanged(Dali::Actor actor, bool visible, Dali::DevelActor::VisibilityChange::Type type);
117
118   /**
119    * Callback when the visibility of the window is changed
120    */
121   void OnWindowVisibilityChanged(Dali::Window window, bool visible);
122
123   /**
124    * Creates the geometry for texturing.
125    */
126   Dali::Geometry CreateTexturedQuad();
127
128   /**
129    * Adds renderer to Actor.
130    */
131   void AddRenderer();
132
133   /**
134    * Creates shader for rendering.
135    */
136   Dali::Shader CreateShader();
137
138   /**
139    * @brief Gets the NativeImageSourceQueue's ColorFormat with the GlView's ColorFormat.
140    * @param[in] colorFormat the color format of the GlView.
141    * @return The color format of NativeImageSourceQueue
142    */
143   Dali::NativeImageSourceQueue::ColorFormat GetColorFormat(Dali::Toolkit::GlView::ColorFormat format);
144
145 private:
146   std::unique_ptr<GlViewRenderThread>  mRenderThread;
147   Dali::NativeImageSourceQueuePtr      mNativeImageQueue;
148   Dali::Toolkit::GlView::RenderingMode mRenderingMode;
149   Dali::Toolkit::GlView::ColorFormat   mColorFormat;
150
151   bool mDepth;
152   bool mStencil;
153   int  mMSAA;
154 };
155
156 } // namespace Internal
157
158 inline Dali::Toolkit::Internal::GlView& GetImpl(Dali::Toolkit::GlView& handle)
159 {
160   DALI_ASSERT_ALWAYS(handle);
161   Dali::RefObject& impl = handle.GetImplementation();
162   return static_cast<Dali::Toolkit::Internal::GlView&>(impl);
163 }
164
165 inline const Dali::Toolkit::Internal::GlView& GetImpl(const Dali::Toolkit::GlView& handle)
166 {
167   DALI_ASSERT_ALWAYS(handle);
168   const Dali::RefObject& impl = handle.GetImplementation();
169   return static_cast<const Dali::Toolkit::Internal::GlView&>(impl);
170 }
171
172 } // namespace Toolkit
173
174 } // namespace Dali
175
176 #endif // DALI_TOOLKIT_INTERNAL_GL_VIEW_H