1 #ifndef DALI_TOOLKIT_INTERNAL_GL_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_GL_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/object/weak-handle.h>
26 #include <dali/public-api/rendering/geometry.h>
27 #include <dali/public-api/rendering/shader.h>
30 #include <dali-toolkit/internal/controls/gl-view/gl-view-interface-impl.h>
31 #include <dali-toolkit/internal/controls/gl-view/gl-view-render-thread.h>
32 #include <dali-toolkit/public-api/controls/control-impl.h>
33 #include <dali-toolkit/public-api/controls/gl-view/gl-view.h>
35 namespace Dali::Toolkit
41 class GlView : public Dali::Toolkit::Internal::GlViewImpl
48 * @copydoc Dali::Toolkit::GlView::New()
50 static Dali::Toolkit::GlView New(Dali::Toolkit::GlView::ColorFormat colorFormat);
53 * Construct a new GlView.
55 GlView(Dali::Toolkit::GlView::ColorFormat colorFormat);
58 * @copydoc Dali::Toolkit::GlView::RegisterGlCallbacks()
60 void RegisterGlCallbacks(CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback) override;
63 * @copydoc Dali::Toolkit::GlView::SetResizeCallback()
65 void SetResizeCallback(CallbackBase* resizeCallback) override;
68 * @copydoc Dali::Toolkit::GlView::SetGraphicsConfig()
70 bool SetGraphicsConfig(bool depth, bool stencil, int msaa, Dali::Toolkit::GlView::GraphicsApiVersion version) override;
73 * @copydoc Dali::Toolkit::GlView::SetRenderingMode()
75 void SetRenderingMode(Dali::Toolkit::GlView::RenderingMode mode) override;
78 * @copydoc Dali::Toolkit::GlView::GetRenderingMode()
80 Dali::Toolkit::GlView::RenderingMode GetRenderingMode() const override;
83 * @copydoc Dali::Toolkit::GlView::RenderOnce()
85 void RenderOnce() override;
88 * @copydoc Dali::Toolkit::GlView::BindTextureResources()
90 void BindTextureResources(std::vector<Dali::Texture> textures) override;
92 private: // From Control
94 * @copydoc Toolkit::Control::OnInitialize()
96 virtual void OnInitialize() override;
99 * @copydoc Toolkit::Control::OnSceneConnection()
101 void OnSceneConnection(int depth) override;
104 * @copydoc Toolkit::Control::OnSceneDisconnection()
106 void OnSceneDisconnection() override;
109 * @copydoc Toolkit::Control::OnSizeSet()
111 void OnSizeSet(const Vector3& targetSize) override;
114 // Undefined copy constructor and assignment operators
115 GlView(const GlView& GlView);
116 GlView& operator=(const GlView& GlView);
119 * Callback when the visibility of the GlView is changed
121 void OnControlVisibilityChanged(Dali::Actor actor, bool visible, Dali::DevelActor::VisibilityChange::Type type);
124 * Callback when the visibility of the window is changed
126 void OnWindowVisibilityChanged(Dali::Window window, bool visible);
129 * Creates the geometry for texturing.
131 Dali::Geometry CreateTexturedQuad();
134 * Adds renderer to Actor.
139 * Creates shader for rendering.
141 Dali::Shader CreateShader();
144 * @brief Gets the NativeImageSourceQueue's ColorFormat with the GlView's ColorFormat.
145 * @param[in] colorFormat the color format of the GlView.
146 * @return The color format of NativeImageSourceQueue
148 Dali::NativeImageSourceQueue::ColorFormat GetColorFormat(Dali::Toolkit::GlView::ColorFormat format);
151 WeakHandle<Window> mPlacementWindow;
152 std::unique_ptr<GlViewRenderThread> mRenderThread;
153 Dali::NativeImageSourceQueuePtr mNativeImageQueue;
154 Dali::Toolkit::GlView::RenderingMode mRenderingMode;
155 Dali::Toolkit::GlView::ColorFormat mColorFormat;
162 } // namespace Internal
164 } // namespace Dali::Toolkit
166 #endif // DALI_TOOLKIT_INTERNAL_GL_VIEW_H