1 #ifndef DALI_INTERNAL_SCENE_H
2 #define DALI_INTERNAL_SCENE_H
5 * Copyright (c) 2019 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/integration-api/scene.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/public-api/actors/layer.h>
25 #include <dali/public-api/render-tasks/render-task-list.h>
26 #include <dali/integration-api/render-surface.h>
27 #include <dali/internal/common/owner-pointer.h>
28 #include <dali/internal/event/actors/layer-impl.h>
29 #include <dali/internal/event/render-tasks/render-task-defaults.h>
43 using FrameBufferPtr = IntrusivePtr<FrameBuffer>;
44 using ScenePtr = IntrusivePtr<Scene>;
47 * @brief Scene creates a "world" that can be bound to a surface for rendering.
49 class Scene : public BaseObject, public RenderTaskDefaults
55 * @copydoc Dali::Integration::Scene::New
57 static ScenePtr New( Size size );
65 * @copydoc Dali::Integration::Scene::Add
67 void Add(Actor& actor);
70 * @copydoc Dali::Integration::Scene::Remove
72 void Remove(Actor& actor);
75 * @copydoc Dali::Integration::Scene::GetSize
80 * @copydoc Dali::Integration::Scene::SetDpi
82 void SetDpi( Vector2 dpi );
85 * @copydoc Dali::Integration::Scene::GetDpi
87 Vector2 GetDpi() const;
90 * @copydoc Dali::Integration::Scene::GetRenderTaskList
92 RenderTaskList& GetRenderTaskList() const;
95 * @copydoc Dali::Integration::Scene::GetRootLayer
97 Dali::Layer GetRootLayer() const;
100 * @copydoc Dali::Integration::Scene::GetLayerCount
102 uint32_t GetLayerCount() const;
105 * @copydoc Dali::Integration::Scene::GetLayer
107 Dali::Layer GetLayer(uint32_t depth) const;
110 * @copydoc Dali::Integration::Scene::SetSurface
112 void SetSurface( Integration::RenderSurface& surface );
115 * Retrieve the render surface the scene is binded to.
116 * @return The render surface.
118 Integration::RenderSurface* GetSurface() const;
121 * Retrieve the ordered list of on-stage layers.
122 * @return The layer-list.
124 LayerList& GetLayerList() const;
127 * Request that the depth tree is rebuilt
129 void RequestRebuildDepthTree();
132 * Rebuilds the depth tree at the end of the event frame if
133 * it was requested this frame.
135 void RebuildDepthTree();
138 * @brief Sets the background color of the render surface.
139 * @param[in] color The new background color
141 void SetBackgroundColor(Vector4 color);
144 * @brief Gets the background color of the render surface.
145 * @return The background color
147 Vector4 GetBackgroundColor() const;
152 * From RenderTaskDefaults; retrieve the default root actor.
153 * @return The default root actor.
155 virtual Actor& GetDefaultRootActor();
158 * From RenderTaskDefaults; retrieve the default camera actor.
159 * @return The default camera actor.
161 virtual CameraActor& GetDefaultCameraActor();
169 * Second-phase constructor.
174 Scene(const Scene&) = delete;
177 Scene& operator=(const Scene& rhs) = delete;
181 Integration::RenderSurface* mSurface;
183 // The scene-size may be different with the surface-size
191 // Ordered list of currently on-stage layers
192 OwnerPointer<LayerList> mLayerList;
194 IntrusivePtr<CameraActor> mDefaultCamera;
196 // The list of render-tasks
197 IntrusivePtr<RenderTaskList> mRenderTaskList;
200 FrameBufferPtr mFrameBuffer;
202 bool mDepthTreeDirty:1; ///< True if the depth tree needs recalculating
207 // Get impl of handle
208 inline Internal::Scene& GetImplementation(Dali::Integration::Scene& scene)
210 DALI_ASSERT_ALWAYS( scene && "Scene handle is empty" );
211 Dali::RefObject& object = scene.GetBaseObject();
212 return static_cast<Internal::Scene&>(object);
215 inline const Internal::Scene& GetImplementation(const Dali::Integration::Scene& scene)
217 DALI_ASSERT_ALWAYS( scene && "Scene handle is empty" );
218 const Dali::RefObject& object = scene.GetBaseObject();
219 return static_cast<const Internal::Scene&>(object);
224 #endif // DALI_INTERNAL_SCENE_H