[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / gl-view / drawable-view-native-renderer.h
1 #ifndef DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H
2 #define DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H
3
4 /*
5 * Copyright (c) 2024 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 #include <dali/public-api/signals/callback.h>
22 #include <dali/public-api/signals/render-callback.h>
23 #include <memory>
24
25
26 namespace Dali::Internal
27 {
28 /**
29  * The structure containing the initialization data for the
30  * DrawableViewNativeRenderer instance.
31  */
32 struct NativeRendererCreateInfo
33 {
34   /**
35    * Presentation mode is used only for threaded renderer
36    */
37   enum class PresentationMode
38   {
39     FIFO, // First-in first-out
40     MAILBOX // Only most recent out
41   };
42
43   bool threadEnabled { false };
44   bool directExecution { false };
45
46   uint32_t maxOffscreenBuffers { 3u };
47   PresentationMode presentationMode {PresentationMode::FIFO};
48 };
49
50 /**
51  * The DrawableViewNativeRenderer is responsible for delegating rendering
52  * either to the own thread (in parallel mode) or calling the GlView render callbacks
53  * directly.
54  *
55  * The parallel mode creates the thread that invokes GLView callbacks directly.
56  * The actual render callback will only pass the input data and blit the result.
57  *
58  * Parallel mode renders always to the offscreen framebuffer.
59  */
60 class DrawableViewNativeRenderer
61 {
62 public:
63   explicit DrawableViewNativeRenderer( const NativeRendererCreateInfo& createInfo );
64   ~DrawableViewNativeRenderer();
65
66   /**
67    * Registers GlView callbacks
68    */
69   void RegisterGlCallbacks( Dali::CallbackBase* onInitCallback,Dali::CallbackBase* onRenderCallback, Dali::CallbackBase* onTerminateCallback );
70
71   /**
72    * Dispatches the GlView init callback
73    * @param renderCallbackInput
74    */
75   void InvokeGlInitCallback( const RenderCallbackInput& renderCallbackInput );
76
77   /**
78    * Dispatches the GlView render callback
79    * @param renderCallbackInput
80    */
81   void InvokeGlRenderCallback(  const RenderCallbackInput& renderCallbackInput  );
82
83   /**
84    * Dispatches the GlView terminate callback
85    * @param[in] renderCallbackInput
86    */
87   void InvokeGlTerminateCallback(  const RenderCallbackInput& renderCallbackInput );
88
89   /**
90    * @brief Resizes the render surface
91    *
92    * @param[in] width Width of surface
93    * @param[in] height Height of surface
94    */
95   void Resize( uint32_t width, uint32_t height );
96
97   /**
98    * @brief Pushes render callback input data into the native renderer thread
99    *
100    * @param[in] renderCallbackInput Valid RenderCallbackInput object
101    */
102   void PushRenderCallbackInputData( const Dali::RenderCallbackInput& renderCallbackInput );
103
104   /**
105    * @brief Terminates thread in parallel mode
106    */
107   void Terminate();
108
109 private:
110
111   struct Impl;
112   std::unique_ptr<Impl> mImpl;
113 };
114 }
115
116 #endif // DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H