1 #ifndef DALI_TOOLKIT_INTERNAL_DRAWABLE_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_DRAWABLE_VIEW_H
5 * Copyright (c) 2022 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.
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 #include <dali/public-api/signals/render-callback.h>
28 #include "gl-view-interface-impl.h"
31 #include <dali-toolkit/internal/controls/gl-view/gl-view-interface-impl.h>
32 #include <dali-toolkit/internal/controls/gl-view/drawable-view-native-renderer.h>
33 #include <dali-toolkit/public-api/controls/control-impl.h>
34 #include <dali-toolkit/public-api/controls/gl-view/gl-view.h>
36 namespace Dali::Toolkit
42 class DrawableView : public Dali::Toolkit::Internal::GlViewImpl
45 virtual ~DrawableView();
50 * @brief Creates GlView interface object using DrawableView implementation
52 * @param[in] backendMode Backend mode to be used. Only DIRECT_RENDERING and DIRECT_RENDERING_THREADED
54 * @return Valid GlView object or nullptr on error
56 static Dali::Toolkit::GlView New(GlView::BackendMode backendMode);
59 * @brief Constructor creates GlView interface object using DrawableView implementation
61 * @param[in] backendMode Backend mode to be used. Only DIRECT_RENDERING and DIRECT_RENDERING_THREADED
64 explicit DrawableView(GlView::BackendMode backendMode);
67 * @copydoc Dali::Toolkit::GlView::RegisterGlCallbacks()
69 void RegisterGlCallbacks(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback) override;
72 * @copydoc Dali::Toolkit::GlView::SetResizeCallback()
74 void SetResizeCallback(CallbackBase* resizeCallback) override;
77 * @copydoc Dali::Toolkit::GlView::SetGraphicsConfig()
79 bool SetGraphicsConfig(bool depth, bool stencil, int msaa, Dali::Toolkit::GlView::GraphicsApiVersion version) override;
82 * @copydoc Dali::Toolkit::GlView::SetRenderingMode()
84 void SetRenderingMode(Dali::Toolkit::GlView::RenderingMode mode) override;
87 * @copydoc Dali::Toolkit::GlView::GetRenderingMode()
89 Dali::Toolkit::GlView::RenderingMode GetRenderingMode() const override;
92 * @copydoc Dali::Toolkit::GlView::RenderOnce()
96 private: // From Control
98 * @copydoc Toolkit::Control::OnInitialize()
100 virtual void OnInitialize() override;
103 * @copydoc Toolkit::Control::OnSceneConnection()
105 void OnSceneConnection(int depth) override;
108 * @copydoc Toolkit::Control::OnSceneDisconnection()
110 void OnSceneDisconnection() override;
113 * @copydoc Toolkit::Control::OnSizeSet()
115 void OnSizeSet(const Vector3& targetSize) override;
118 // Undefined copy constructor and assignment operators
119 DrawableView(const DrawableView& GlView);
120 DrawableView& operator=(const DrawableView& GlView);
123 * Callback when the visibility of the GlView is changed
125 void OnControlVisibilityChanged(Dali::Actor actor, bool visible, Dali::DevelActor::VisibilityChange::Type type);
128 * Callback when the visibility of the window is changed
130 void OnWindowVisibilityChanged(Dali::Window window, bool visible);
133 * Adds renderer to Actor.
139 bool OnRenderCallback( const RenderCallbackInput& renderCallbackInput );
142 Dali::Toolkit::GlView::RenderingMode mRenderingMode;
148 std::unique_ptr<RenderCallback> mRenderCallback;
151 * Used within RenderCallback to handle the current render state
160 ViewState mCurrentViewState{ViewState::INIT}; ///< state within RenderCallback
162 std::unique_ptr<CallbackBase> mOnResizeCallback; ///< Resize callback called when surface size changes
164 std::atomic_bool mSurfaceResized{false}; ///< Flag to invoke surface resize callback
166 Size mSurfaceSize{}; ///< Surface size
168 std::unique_ptr<Dali::Internal::DrawableViewNativeRenderer> mNativeRenderer; ///< Pointer to the native renderer
171 } // namespace Internal
175 #endif // DALI_TOOLKIT_INTERNAL_DRAWABLE_VIEW_H