1 #ifndef DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
2 #define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_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.
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/common/intrusive-ptr.h>
27 #include <dali/integration-api/scene-holder.h>
28 #include <dali/integration-api/scene.h>
30 #ifdef DALI_ADAPTOR_COMPILATION
31 #include <dali/integration-api/render-surface-interface.h>
33 #include <dali/integration-api/adaptors/render-surface-interface.h>
36 #include <dali/internal/adaptor/common/adaptor-impl.h>
63 using SceneHolderPtr = IntrusivePtr< SceneHolder >;
66 * @brief SceneHolder creates a Scene for rendering.
68 class SceneHolder : public BaseObject
74 * @copydoc Dali::Integration::SceneHolder::Add
76 void Add( Dali::Actor actor );
79 * @copydoc Dali::Integration::SceneHolder::Remove
81 void Remove( Dali::Actor actor );
84 * @copydoc Dali::Integration::SceneHolder::GetRootLayer
86 Dali::Layer GetRootLayer() const;
89 * @brief Gets the window name.
90 * @return The name of the window
92 std::string GetName() const;
95 * @brief Retrieve the unique ID of the window.
98 uint32_t GetId() const;
101 * @brief Retrieve the Scene.
104 Dali::Integration::Scene GetScene();
107 * @brief Set the render surface
108 * @param[in] surface The render surface
110 void SetSurface( Dali::RenderSurfaceInterface* surface );
113 * @brief Get the render surface
114 * @return The render surface
116 Dali::RenderSurfaceInterface* GetSurface() const;
119 * @brief Set the adaptor to the scene holder
120 * @param[in] adaptor An initialized adaptor
122 void SetAdaptor( Dali::Adaptor& adaptor );
125 * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor
127 void SetBackgroundColor( const Dali::Vector4& color );
130 * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor
132 Vector4 GetBackgroundColor() const;
135 * @brief Pause the rendering of the scene holder.
140 * @brief Resume the rendering of the scene holder (from pause).
144 public: // The following methods can be overridden if required
147 * @brief Returns whether the Scene is visible or not.
148 * @return True if the Scene is visible, false otherwise.
150 virtual bool IsVisible() const;
152 public: // The following methods must be overridden
155 * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
157 virtual Dali::Any GetNativeHandle() const = 0;
160 * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
162 virtual void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) = 0;
165 * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
167 virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent ) = 0;
170 * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
172 virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent ) = 0;
180 SceneHolder(const SceneHolder&) = delete;
183 SceneHolder& operator=(const SceneHolder& rhs) = delete;
188 virtual ~SceneHolder();
190 private: // The following methods can be overridden if required
193 * @brief Called by the base class to inform deriving classes that the adaptor has been set.
194 * @param[in] adaptor The adaptor
196 virtual void OnAdaptorSet( Dali::Adaptor& adaptor ) {};
199 * @brief Called by the base class to inform deriving classes that a new surface has been set.
200 * @param[in] surface The new render surface
202 virtual void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) {};
205 * @brief Called by the base class to inform deriving classes that we are being paused.
207 virtual void OnPause() {};
210 * @brief Called by the base class to inform deriving classes that we are resuming from a paused state.
212 virtual void OnResume() {};
216 static uint32_t mSceneHolderCounter; ///< A counter to track the SceneHolder creation
218 class SceneHolderLifeCycleObserver;
219 std::unique_ptr< SceneHolderLifeCycleObserver > mLifeCycleObserver; ///< The adaptor life cycle observer
223 uint32_t mId; ///< A unique ID to identify the SceneHolder starting from 0
224 Dali::Integration::Scene mScene; ///< The Scene
225 std::string mName; ///< The name of the SceneHolder
227 std::unique_ptr< Dali::RenderSurfaceInterface > mSurface; ///< The window rendering surface
228 Adaptor* mAdaptor; ///< The adaptor
230 bool mAdaptorStarted:1; ///< Whether the adaptor has started or not
231 bool mVisible:1; ///< Whether the scene is visible or not
238 // Get impl of handle
239 inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
241 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
242 Dali::RefObject& object = sceneHolder.GetBaseObject();
243 return static_cast<Internal::Adaptor::SceneHolder&>( object );
246 inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
248 DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
249 const Dali::RefObject& object = sceneHolder.GetBaseObject();
250 return static_cast<const Internal::Adaptor::SceneHolder&>( object );
255 #endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H