GlView using DirectRendering
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / gl-view / gl-view-interface-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_GL_VIEW_IMPL_H
2 #define DALI_TOOLKIT_INTERNAL_GL_VIEW_IMPL_H
3
4 /*
5  * Copyright (c) 2022 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::Toolkit
34 {
35 class GlView;
36
37 namespace Internal
38 {
39 class GlViewImpl : public Dali::Toolkit::Internal::Control
40 {
41 protected:
42
43   virtual ~GlViewImpl() = default;
44
45 public:
46
47   /**
48    * Construct a new GlView.
49    */
50   explicit GlViewImpl( GlView::BackendMode backendMode ) :
51     Control(ControlBehaviour(0u | ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS)),
52     mBackendMode(backendMode)
53   {
54   }
55
56   /**
57    * @copydoc Dali::Toolkit::GlView::RegisterGlCallbacks()
58    */
59   virtual void RegisterGlCallbacks(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback) = 0;
60
61   /**
62    * @copydoc Dali::Toolkit::GlView::SetResizeCallback()
63    */
64   virtual void SetResizeCallback(CallbackBase* resizeCallback) = 0;
65
66   /**
67    * @copydoc Dali::Toolkit::GlView::SetGraphisConfig()
68    */
69   virtual bool SetGraphicsConfig(bool depth, bool stencil, int msaa, Dali::Toolkit::GlView::GraphicsApiVersion version) = 0;
70
71   /**
72    * @copydoc Dali::Toolkit::GlView::SetRenderingMode()
73    */
74   virtual void SetRenderingMode(Dali::Toolkit::GlView::RenderingMode mode) = 0;
75
76   /**
77    * @copydoc Dali::Toolkit::GlView::GetRenderingMode()
78    */
79   virtual Dali::Toolkit::GlView::RenderingMode GetRenderingMode() const = 0;
80
81   /**
82    * @copydoc Dali::Toolkit::GlView::GetBackendMode()
83    */
84   [[nodiscard]] Dali::Toolkit::GlView::BackendMode GetBackendMode() const
85   {
86     return mBackendMode;
87   }
88
89   /**
90    * @copydoc Dali::Toolkit::GlView::RenderOnce()
91    */
92   virtual void RenderOnce() = 0;
93
94 private: // From Control
95   /**
96    * @copydoc Toolkit::Control::OnInitialize()
97    */
98   virtual void OnInitialize() override = 0;
99
100   /**
101    * @copydoc Toolkit::Control::OnSceneConnection()
102    */
103   virtual void OnSceneConnection(int depth) override = 0;
104
105   /**
106    * @copydoc Toolkit::Control::OnSceneDisconnection()
107    */
108   virtual void OnSceneDisconnection() override = 0;
109
110 protected:
111
112   GlView::BackendMode mBackendMode { GlView::BackendMode::DEFAULT }; ///< Implementation backend mode (DirectRendering, EGL image)
113 };
114
115 } // namespace Internal
116
117 inline Dali::Toolkit::Internal::GlViewImpl& GetImpl(Dali::Toolkit::GlView& handle)
118 {
119   DALI_ASSERT_ALWAYS(handle);
120   Dali::RefObject& impl = handle.GetImplementation();
121   return static_cast<Dali::Toolkit::Internal::GlViewImpl&>(impl);
122 }
123
124 inline const Dali::Toolkit::Internal::GlViewImpl& GetImpl(const Dali::Toolkit::GlView& handle)
125 {
126   DALI_ASSERT_ALWAYS(handle);
127   const Dali::RefObject& impl = handle.GetImplementation();
128   return static_cast<const Dali::Toolkit::Internal::GlViewImpl&>(impl);
129 }
130
131 } // namespace Dali
132
133 #endif // DALI_TOOLKIT_INTERNAL_GL_VIEW_IMPL_H