1 #ifndef DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H
2 #define DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/public-api/signals/callback.h>
22 #include <dali/public-api/signals/render-callback.h>
26 namespace Dali::Internal
29 * The structure containing the initialization data for the
30 * DrawableViewNativeRenderer instance.
32 struct NativeRendererCreateInfo
35 * Presentation mode is used only for threaded renderer
37 enum class PresentationMode
39 FIFO, // First-in first-out
40 MAILBOX // Only most recent out
43 bool threadEnabled { false };
44 uint32_t maxOffscreenBuffers { 3u };
45 PresentationMode presentationMode {PresentationMode::FIFO};
49 * The DrawableViewNativeRenderer is responsible for delegating rendering
50 * either to the own thread (in parallel mode) or calling the GlView render callbacks
53 * The parallel mode creates the thread that invokes GLView callbacks directly.
54 * The actual render callback will only pass the input data and blit the result.
56 * Parallel mode renders always to the offscreen framebuffer.
58 class DrawableViewNativeRenderer
61 explicit DrawableViewNativeRenderer( const NativeRendererCreateInfo& createInfo );
62 ~DrawableViewNativeRenderer();
65 * Registers GlView callbacks
67 void RegisterGlCallbacks( Dali::CallbackBase* onInitCallback,Dali::CallbackBase* onRenderCallback, Dali::CallbackBase* onTerminateCallback );
70 * Dispatches the GlView init callback
71 * @param renderCallbackInput
73 void InvokeGlInitCallback( const RenderCallbackInput& renderCallbackInput );
76 * Dispatches the GlView render callback
77 * @param renderCallbackInput
79 void InvokeGlRenderCallback( const RenderCallbackInput& renderCallbackInput );
82 * Dispatches the GlView terminate callback
83 * @param[in] renderCallbackInput
85 void InvokeGlTerminateCallback( const RenderCallbackInput& renderCallbackInput );
88 * @brief Resizes the render surface
90 * @param[in] width Width of surface
91 * @param[in] height Height of surface
93 void Resize( uint32_t width, uint32_t height );
96 * @brief Pushes render callback input data into the native renderer thread
98 * @param[in] renderCallbackInput Valid RenderCallbackInput object
100 void PushRenderCallbackInputData( const Dali::RenderCallbackInput& renderCallbackInput );
103 * @brief Terminates thread in parallel mode
110 std::unique_ptr<Impl> mImpl;
114 #endif // DALI_PROJECT_DRAWABLE_VIEW_NATIVE_RENDERER_H