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