Implement base class to enable EvasPlugin to create the scene for rendering 33/204033/12
authorRichard Huang <r.huang@samsung.com>
Thu, 18 Apr 2019 15:51:12 +0000 (16:51 +0100)
committerRichard Huang <r.huang@samsung.com>
Fri, 3 May 2019 09:33:16 +0000 (10:33 +0100)
Change-Id: Ia502f492240a20769356889434357a8626344f96

15 files changed:
build/tizen/adaptor/Makefile.am
dali/devel-api/adaptor-framework/application-devel.cpp
dali/integration-api/adaptor.h
dali/integration-api/file.list
dali/integration-api/scene-holder-impl.cpp [new file with mode: 0644]
dali/integration-api/scene-holder-impl.h [new file with mode: 0644]
dali/integration-api/scene-holder.cpp [new file with mode: 0644]
dali/integration-api/scene-holder.h [new file with mode: 0644]
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor.cpp
dali/internal/adaptor/common/application-impl.cpp
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h
dali/public-api/adaptor-framework/window.cpp

index 8a79d7d..de67a78 100644 (file)
@@ -49,6 +49,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_ubuntu_x11_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_ubuntu_x11_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
@@ -104,6 +105,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_tizen_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_tizen_wayland_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
@@ -168,6 +170,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_tizen_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_tizen_wayland_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
@@ -231,6 +234,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_tizen_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_tizen_wayland_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
@@ -293,6 +297,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_tizen_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_tizen_wayland_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
@@ -358,6 +363,7 @@ LIBDALI_ADAPTOR_LA_SOURCES = \
                   $(adaptor_imaging_tizen_src_files) \
                   $(adaptor_input_common_src_files) \
                   $(adaptor_input_tizen_wayland_src_files) \
+                  $(adaptor_integration_api_src_files) \
                   $(adaptor_legacy_common_src_files) \
                   $(adaptor_network_common_src_files) \
                   $(adaptor_public_api_src_files) \
index 196664a..b9ef5dd 100644 (file)
 #include <dali/devel-api/adaptor-framework/application-devel.h>
 #include <dali/internal/adaptor/common/application-impl.h>
 
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/scene-holder.h>
+#else
+#include <dali/integration-api/adaptors/scene-holder.h>
+#endif
+
 namespace Dali
 {
 
index 8b5e658..279ccb8 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTEGRATION_ADAPTOR_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/common/view-mode.h>
+#include <dali/public-api/object/any.h>
 #include <dali/integration-api/processor-interface.h>
 
 // INTERNAL INCLUDES
@@ -43,6 +44,12 @@ namespace Dali
 
 class RenderSurfaceInterface;
 
+namespace Integration
+{
+class SceneHolder;
+}
+
+
 namespace Internal
 {
 namespace Adaptor
@@ -154,6 +161,42 @@ public:
   static Adaptor& New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS);
 
   /**
+   * @brief Create a new adaptor using the SceneHolder.
+   *
+   * @param[in] sceneHolder The SceneHolder to draw onto
+   * @return a reference to the adaptor handle
+   */
+  static Adaptor& New( Dali::Integration::SceneHolder sceneHolder );
+
+  /**
+   * @brief Create a new adaptor using the SceneHolder.
+   *
+   * @param[in] sceneHolder The SceneHolder to draw onto
+   * @param[in] configuration The context loss configuration.
+   * @return a reference to the adaptor handle
+   */
+  static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, Configuration::ContextLoss configuration );
+
+  /**
+   * @brief Create a new adaptor using render surface.
+   *
+   * @param[in] sceneHolder The SceneHolder to draw onto
+   * @param[in] surface The surface to draw onto
+   * @return a reference to the adaptor handle
+   */
+  static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, const Dali::RenderSurfaceInterface& surface );
+
+  /**
+   * @brief Create a new adaptor using render surface.
+   *
+   * @param[in] sceneHolder The SceneHolder to draw onto
+   * @param[in] surface The surface to draw onto
+   * @param[in] configuration The context loss configuration.
+   * @return a reference to the adaptor handle
+   */
+  static Adaptor& New( Dali::Integration::SceneHolder sceneHolder, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration = Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS);
+
+  /**
    * @brief Virtual Destructor.
    */
   virtual ~Adaptor();
@@ -224,6 +267,14 @@ public:
   void ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface );
 
   /**
+   * @brief Replaces the rendering surface
+   *
+   * @param[in] sceneHolder The SceneHolder to replace the surface for
+   * @param[in] surface to use
+   */
+  void ReplaceSurface( Dali::Integration::SceneHolder sceneHolder, Dali::RenderSurfaceInterface& surface );
+
+  /**
    * @brief Get the render surface the adaptor is using to render to.
    *
    * @return reference to current render surface
index 40f91cf..08e5df8 100755 (executable)
@@ -1,3 +1,7 @@
+adaptor_integration_api_src_files = \
+  $(adaptor_integration_api_dir)/scene-holder.cpp \
+  $(adaptor_integration_api_dir)/scene-holder-impl.cpp
+
 adaptor_integration_api_header_files = \
   $(adaptor_integration_api_dir)/adaptor.h \
   $(adaptor_integration_api_dir)/egl-interface.h \
@@ -5,6 +9,8 @@ adaptor_integration_api_header_files = \
   $(adaptor_integration_api_dir)/native-render-surface.h \
   $(adaptor_integration_api_dir)/native-render-surface-factory.h \
   $(adaptor_integration_api_dir)/render-surface-interface.h \
+  $(adaptor_integration_api_dir)/scene-holder.h \
+  $(adaptor_integration_api_dir)/scene-holder-impl.h \
   $(adaptor_integration_api_dir)/thread-synchronization-interface.h \
   $(adaptor_integration_api_dir)/trigger-event-interface.h \
   $(adaptor_integration_api_dir)/trigger-event-factory-interface.h \
diff --git a/dali/integration-api/scene-holder-impl.cpp b/dali/integration-api/scene-holder-impl.cpp
new file mode 100644 (file)
index 0000000..e085ed3
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/integration-api/scene-holder-impl.h>
+
+// EXTERNAL HEADERS
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/actors/layer.h>
+
+// INTERNAL HEADERS
+#include <dali/internal/adaptor/common/lifecycle-observer.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+uint32_t SceneHolder::mSceneHolderCounter = 0;
+
+class SceneHolder::SceneHolderLifeCycleObserver : public LifeCycleObserver
+{
+public:
+
+  SceneHolderLifeCycleObserver(Adaptor*& adaptor)
+  : mAdaptor( adaptor )
+  {
+  };
+
+private: // Adaptor::LifeCycleObserver interface
+
+  void OnStart() override {};
+  void OnPause() override {};
+  void OnResume() override {};
+  void OnStop() override {};
+  void OnDestroy() override
+  {
+    mAdaptor = nullptr;
+  };
+
+private:
+  Adaptor*& mAdaptor;
+};
+
+
+SceneHolder::SceneHolder()
+: mLifeCycleObserver( new SceneHolderLifeCycleObserver( mAdaptor ) ),
+  mId( mSceneHolderCounter++ ),
+  mSurface( nullptr ),
+  mAdaptor( nullptr ),
+  mAdaptorStarted( false ),
+  mVisible( true )
+{
+}
+
+SceneHolder::~SceneHolder()
+{
+  if ( mAdaptor )
+  {
+    mAdaptor->RemoveObserver( *mLifeCycleObserver.get() );
+    mAdaptor->RemoveWindow( this );
+    mAdaptor = nullptr;
+  }
+}
+
+void SceneHolder::Add( Dali::Actor actor )
+{
+  if ( mScene )
+  {
+    mScene.Add( actor );
+  }
+}
+
+void SceneHolder::Remove( Dali::Actor actor )
+{
+  if ( mScene )
+  {
+    mScene.Remove( actor );
+  }
+}
+
+Dali::Layer SceneHolder::GetRootLayer() const
+{
+  return mScene ? mScene.GetRootLayer() : Dali::Layer();
+}
+
+uint32_t SceneHolder::GetId() const
+{
+  return mId;
+}
+
+std::string SceneHolder::GetName() const
+{
+  return mName;
+}
+
+bool SceneHolder::IsVisible() const
+{
+  return mVisible;
+}
+
+Dali::Integration::Scene SceneHolder::GetScene()
+{
+  return mScene;
+}
+
+void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface)
+{
+  mSurface.reset( surface );
+
+  mScene.SetSurface( *mSurface.get() );
+
+  unsigned int dpiHorizontal, dpiVertical;
+  dpiHorizontal = dpiVertical = 0;
+
+  mSurface->GetDpi( dpiHorizontal, dpiVertical );
+  mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
+
+  mSurface->SetAdaptor( *mAdaptor );
+
+  OnSurfaceSet( surface );
+}
+
+Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const
+{
+  return mSurface.get();
+}
+
+void SceneHolder::SetBackgroundColor( Vector4 color )
+{
+  if ( mSurface )
+  {
+    mSurface->SetBackgroundColor( color );
+  }
+}
+
+Vector4 SceneHolder::GetBackgroundColor() const
+{
+  return mSurface ? mSurface->GetBackgroundColor() : Vector4();
+}
+
+void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
+{
+  // Avoid doing this more than once
+  if( mAdaptorStarted )
+  {
+    return;
+  }
+
+  mAdaptorStarted = true;
+
+  // Create the scene
+  PositionSize positionSize = mSurface->GetPositionSize();
+  mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) );
+  mScene.SetSurface( *mSurface.get() );
+
+  Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( adaptor );
+  mAdaptor = &adaptorImpl;
+
+  // Create an observer for the adaptor lifecycle
+  mAdaptor->AddObserver( *mLifeCycleObserver );
+
+  if ( mSurface )
+  {
+    unsigned int dpiHorizontal, dpiVertical;
+    dpiHorizontal = dpiVertical = 0;
+
+    mSurface->GetDpi( dpiHorizontal, dpiVertical );
+    mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
+
+    mSurface->SetAdaptor( *mAdaptor );
+  }
+
+  OnAdaptorSet( adaptor );
+}
+
+void SceneHolder::Pause()
+{
+  OnPause();
+}
+
+void SceneHolder::Resume()
+{
+  OnResume();
+}
+
+}// Adaptor
+
+}// Internal
+
+} // Dali
diff --git a/dali/integration-api/scene-holder-impl.h b/dali/integration-api/scene-holder-impl.h
new file mode 100644 (file)
index 0000000..d720f7f
--- /dev/null
@@ -0,0 +1,255 @@
+#ifndef DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
+#define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
+
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/common/intrusive-ptr.h>
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/scene-holder.h>
+#include <dali/integration-api/scene.h>
+
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/render-surface-interface.h>
+#else
+#include <dali/integration-api/adaptors/render-surface-interface.h>
+#endif
+
+#include <dali/internal/adaptor/common/adaptor-impl.h>
+
+namespace Dali
+{
+
+class Any;
+class Adaptor;
+class Actor;
+class Layer;
+struct TouchPoint;
+struct WheelEvent;
+struct KeyEvent;
+
+namespace Integration
+{
+
+class Scene;
+
+}
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class SceneHolder;
+using SceneHolderPtr = IntrusivePtr< SceneHolder >;
+
+/**
+ * @brief SceneHolder creates a Scene for rendering.
+ */
+class SceneHolder : public BaseObject
+{
+
+public:
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::Add
+   */
+  void Add( Dali::Actor actor );
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::Remove
+   */
+  void Remove( Dali::Actor actor );
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::GetRootLayer
+   */
+  Dali::Layer GetRootLayer() const;
+
+  /**
+   * @brief Gets the window name.
+   * @return The name of the window
+   */
+  std::string GetName() const;
+
+  /**
+   * @brief Retrieve the unique ID of the window.
+   * @return The ID
+   */
+  uint32_t GetId() const;
+
+  /**
+   * @brief Retrieve the Scene.
+   * @return The Scene
+   */
+  Dali::Integration::Scene GetScene();
+
+  /**
+   * @brief Set the render surface
+   * @param[in] surface The render surface
+   */
+  void SetSurface( Dali::RenderSurfaceInterface* surface );
+
+  /**
+   * @brief Get the render surface
+   * @return The render surface
+   */
+  Dali::RenderSurfaceInterface* GetSurface() const;
+
+  /**
+   * @brief Set the adaptor to the scene holder
+   * @param[in] adaptor An initialized adaptor
+   */
+  void SetAdaptor( Dali::Adaptor& adaptor );
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::SetBackgroundColor
+   */
+  void SetBackgroundColor( Dali::Vector4 color );
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::GetBackgroundColor
+   */
+  Vector4 GetBackgroundColor() const;
+
+  /**
+   * @brief Pause the rendering of the scene holder.
+   */
+  void Pause();
+
+  /**
+   * @brief Resume the rendering of the scene holder (from pause).
+   */
+  void Resume();
+
+public: // The following methods can be overridden if required
+
+  /**
+   * @brief Returns whether the Scene is visible or not.
+   * @return True if the Scene is visible, false otherwise.
+   */
+  virtual bool IsVisible() const;
+
+public: // The following methods must be overridden
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::GetNativeHandle
+   */
+  virtual Dali::Any GetNativeHandle() const = 0;
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::FeedTouchPoint
+   */
+  virtual void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) = 0;
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::FeedWheelEvent
+   */
+  virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent ) = 0;
+
+  /**
+   * @copydoc Dali::Integration::SceneHolder::FeedKeyEvent
+   */
+  virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent ) = 0;
+
+protected:
+
+  // Constructor
+  SceneHolder();
+
+  // Undefined
+  SceneHolder(const SceneHolder&) = delete;
+
+  // Undefined
+  SceneHolder& operator=(const SceneHolder& rhs) = delete;
+
+  /**
+   * virtual destructor
+   */
+  virtual ~SceneHolder();
+
+private: // The following methods can be overridden if required
+
+  /**
+   * @brief Called by the base class to inform deriving classes that the adaptor has been set.
+   * @param[in] adaptor The adaptor
+   */
+  virtual void OnAdaptorSet( Dali::Adaptor& adaptor ) {};
+
+  /**
+   * @brief Called by the base class to inform deriving classes that a new surface has been set.
+   * @param[in] surface The new render surface
+   */
+  virtual void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) {};
+
+  /**
+   * @brief Called by the base class to inform deriving classes that we are being paused.
+   */
+  virtual void OnPause() {};
+
+  /**
+   * @brief Called by the base class to inform deriving classes that we are resuming from a paused state.
+   */
+  virtual void OnResume() {};
+
+private:
+
+  static uint32_t                                 mSceneHolderCounter; ///< A counter to track the SceneHolder creation
+
+  class SceneHolderLifeCycleObserver;
+  std::unique_ptr< SceneHolderLifeCycleObserver > mLifeCycleObserver;  ///< The adaptor life cycle observer
+
+protected:
+
+  uint32_t                                        mId;                 ///< A unique ID to identify the SceneHolder starting from 0
+  Dali::Integration::Scene                        mScene;              ///< The Scene
+  std::string                                     mName;               ///< The name of the SceneHolder
+
+  std::unique_ptr< Dali::RenderSurfaceInterface > mSurface;            ///< The window rendering surface
+  Adaptor*                                        mAdaptor;            ///< The adaptor
+
+  bool                                            mAdaptorStarted:1;   ///< Whether the adaptor has started or not
+  bool                                            mVisible:1;          ///< Whether the scene is visible or not
+};
+
+} // Adaptor
+
+} // Internal
+
+// Get impl of handle
+inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder )
+{
+  DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
+  Dali::RefObject& object = sceneHolder.GetBaseObject();
+  return static_cast<Internal::Adaptor::SceneHolder&>( object );
+}
+
+inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder )
+{
+  DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" );
+  const Dali::RefObject& object = sceneHolder.GetBaseObject();
+  return static_cast<const Internal::Adaptor::SceneHolder&>( object );
+}
+
+} // Dali
+
+#endif // DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
diff --git a/dali/integration-api/scene-holder.cpp b/dali/integration-api/scene-holder.cpp
new file mode 100644 (file)
index 0000000..9b6c91e
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/integration-api/scene-holder.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/layer.h>
+#include <dali/integration-api/scene-holder-impl.h>
+
+namespace Dali
+{
+
+namespace Integration
+{
+
+SceneHolder::SceneHolder()
+{
+}
+
+SceneHolder::~SceneHolder()
+{
+}
+
+SceneHolder::SceneHolder( const SceneHolder& handle )
+:BaseHandle(handle)
+{
+}
+
+SceneHolder::SceneHolder( Internal::Adaptor::SceneHolder* internal )
+: BaseHandle(internal)
+{
+}
+
+SceneHolder& SceneHolder::operator=( const SceneHolder& rhs )
+{
+  BaseHandle::operator=(rhs);
+  return *this;
+}
+
+void SceneHolder::Add( Actor actor )
+{
+  GetImplementation(*this).Add( actor );
+}
+
+void SceneHolder::Remove( Actor actor )
+{
+  GetImplementation(*this).Remove( actor );
+}
+
+Layer SceneHolder::GetRootLayer() const
+{
+  return GetImplementation(*this).GetRootLayer();
+}
+
+void SceneHolder::SetBackgroundColor( Vector4 color )
+{
+  GetImplementation(*this).SetBackgroundColor( color );
+}
+
+Vector4 SceneHolder::GetBackgroundColor() const
+{
+  return GetImplementation(*this).GetBackgroundColor();
+}
+
+void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
+{
+  GetImplementation(*this).FeedTouchPoint( point, timeStamp );
+}
+
+void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
+{
+  GetImplementation(*this).FeedWheelEvent( wheelEvent );
+}
+
+void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
+{
+  GetImplementation(*this).FeedKeyEvent( keyEvent );
+}
+
+}// Integration
+
+} // Dali
diff --git a/dali/integration-api/scene-holder.h b/dali/integration-api/scene-holder.h
new file mode 100644 (file)
index 0000000..57c648b
--- /dev/null
@@ -0,0 +1,168 @@
+#ifndef DALI_INTEGRATION_SCENEHOLDER_H
+#define DALI_INTEGRATION_SCENEHOLDER_H
+
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali/public-api/math/vector4.h>
+
+namespace Dali
+{
+
+class Actor;
+class Layer;
+class Any;
+struct TouchPoint;
+struct WheelEvent;
+struct KeyEvent;
+
+namespace Internal DALI_INTERNAL
+{
+
+namespace Adaptor
+{
+
+class SceneHolder;
+
+}
+
+}
+
+namespace Integration
+{
+
+/**
+ * @brief SceneHolder is responsible for creating a Scene for rendering.
+ */
+class DALI_ADAPTOR_API SceneHolder : public BaseHandle
+{
+public:
+
+  /**
+   * @brief Create an uninitialized SceneHolder handle.
+   */
+  SceneHolder();
+
+  /**
+   * @brief Destructor
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~SceneHolder();
+
+  /**
+   * @brief This copy constructor is required for (smart) pointer semantics.
+   *
+   * @param [in] handle A reference to the copied handle
+   */
+  SceneHolder( const SceneHolder& handle );
+
+  /**
+   * @brief This assignment operator is required for (smart) pointer semantics.
+   *
+   * @param [in] rhs  A reference to the copied handle
+   * @return A reference to this
+   */
+  SceneHolder& operator=( const SceneHolder& rhs );
+
+  /**
+   * @brief Adds a child Actor to the SceneHolder.
+   *
+   * The child will be referenced.
+   * @param[in] actor The child
+   * @pre The actor has been initialized.
+   * @pre The actor does not have a parent.
+   */
+  void Add( Actor actor );
+
+  /**
+   * @brief Removes a child Actor from the SceneHolder.
+   *
+   * The child will be unreferenced.
+   * @param[in] actor The child
+   * @pre The actor has been added to the SceneHolder.
+   */
+  void Remove( Actor actor );
+
+  /**
+   * @brief Returns the Scene's Root Layer.
+   *
+   * @return The root layer
+   */
+  Layer GetRootLayer() const;
+
+  /**
+   * @brief Sets the background color.
+   *
+   * @param[in] color The new background color
+   */
+  void SetBackgroundColor( Vector4 color );
+
+  /**
+   * @brief Gets the background color.
+   *
+   * @return The background color
+   */
+  Vector4 GetBackgroundColor() const;
+
+  /**
+   * @brief Gets the native handle.
+   *
+   * When users call this function, it wraps the actual type used by the underlying system.
+   *
+   * @return The native handle or an empty handle
+   */
+  Any GetNativeHandle() const;
+
+  /**
+   * @brief Feed (Send) touch event to core
+   * @param[in] point The touch point
+   * @param[in] timeStamp The time stamp
+   */
+  void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp );
+
+  /**
+   * @brief Feed (Send) wheel event to core
+   * @param[in] wheelEvent The wheel event
+   */
+  void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
+
+  /**
+   * @brief Feed (Send) key event to core
+   * @param[in] keyEvent The key event holding the key information.
+   */
+  void FeedKeyEvent( Dali::KeyEvent& keyEvent );
+
+public: // Not intended for application developers
+
+  /**
+   * @brief This constructor is used internally to create additional SceneHolder handles.
+   *
+   * @param[in] sceneHolder A pointer to a newly allocated Dali resource
+   */
+  explicit DALI_INTERNAL SceneHolder( Internal::Adaptor::SceneHolder* sceneHolder );
+
+};
+
+} // namespace Integration
+
+} // namespace Dali
+
+#endif // DALI_INTEGRATION_SCENEHOLDER_H
index d943263..a28c2c0 100755 (executable)
@@ -82,7 +82,7 @@ namespace
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 } // unnamed namespace
 
-Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
   Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions );
@@ -97,15 +97,15 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::RenderSurfaceInterface *
   return adaptor;
 }
 
-Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
-  Window& windowImpl = Dali::GetImplementation( window );
+  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
   Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), configuration, environmentOptions );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 }
 
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
   Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); // Impl adaptor
@@ -116,9 +116,9 @@ Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window wind
   return adaptor;
 } // Called second
 
-Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
-  Window& windowImpl = Dali::GetImplementation( window );
+  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window );
   Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), configuration, environmentOptions );
   windowImpl.SetAdaptor( *adaptor );
   return adaptor;
@@ -155,7 +155,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
 
   mCallbackManager = CallbackManager::New();
 
-  WindowPtr defaultWindow = mWindows.front();
+  SceneHolderPtr defaultWindow = mWindows.front();
 
   DALI_ASSERT_DEBUG( defaultWindow->GetSurface() && "Surface not initialized" );
 
@@ -184,7 +184,7 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration:
                                   mGraphics->GetDepthBufferRequired(),
                                   mGraphics->GetStencilBufferRequired() );
 
-  defaultWindow->SetAdaptor( *this );
+  defaultWindow->SetAdaptor( Get() );
 
   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
   if( 0u < timeInterval )
@@ -328,7 +328,7 @@ void Adaptor::Start()
   // Start the callback manager
   mCallbackManager->Start();
 
-  WindowPtr defaultWindow = mWindows.front();
+  SceneHolderPtr defaultWindow = mWindows.front();
 
   unsigned int dpiHor, dpiVer;
   dpiHor = dpiVer = 0;
@@ -369,7 +369,7 @@ void Adaptor::Pause()
     }
 
     // Pause all windows event handlers when adaptor paused
-    for( WindowPtr window : mWindows )
+    for( SceneHolderPtr window : mWindows )
     {
       window->Pause();
     }
@@ -397,7 +397,7 @@ void Adaptor::Resume()
     mState = RUNNING;
 
     // Reset the event handlers when adaptor resumed
-    for( WindowPtr window : mWindows )
+    for( SceneHolderPtr window : mWindows )
     {
       window->Resume();
     }
@@ -486,10 +486,10 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
   mWindows.front()->FeedKeyEvent( keyEvent );
 }
 
-void Adaptor::ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& newSurface )
+void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& newSurface )
 {
-  Window* windowImpl = &Dali::GetImplementation( window );
-  for( WindowPtr windowPtr : mWindows )
+  Internal::Adaptor::SceneHolder* windowImpl = &Dali::GetImplementation( window );
+  for( SceneHolderPtr windowPtr : mWindows )
   {
     if( windowPtr.Get() == windowImpl ) // the window is not deleted
     {
@@ -498,7 +498,7 @@ void Adaptor::ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface&
 
       mResizedSignal.Emit( mAdaptor );
 
-      windowImpl->SetSurface( static_cast<WindowRenderSurface*>( &newSurface ) );
+      windowImpl->SetSurface( &newSurface );
 
       // Flush the event queue to give the update-render thread chance
       // to start processing messages for new camera setup etc as soon as possible
@@ -555,19 +555,19 @@ void Adaptor::SetPreRenderCallback( CallbackBase* callback )
   mThreadController->SetPreRenderCallback( callback );
 }
 
-bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode )
+bool Adaptor::AddWindow( Dali::Integration::SceneHolder* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode )
 {
-  Window& windowImpl = Dali::GetImplementation( *childWindow );
+  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow );
   windowImpl.SetAdaptor( Get() );
 
   // Add the new Window to the container - the order is not important
-  mWindows.push_back( WindowPtr( &windowImpl ) );
+  mWindows.push_back( SceneHolderPtr( &windowImpl ) );
   return true;
 }
 
-bool Adaptor::RemoveWindow( Dali::Window* childWindow )
+bool Adaptor::RemoveWindow( Dali::Integration::SceneHolder* childWindow )
 {
-  Window& windowImpl = Dali::GetImplementation( *childWindow );
+  Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( *childWindow );
   for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
     if( *iter == &windowImpl )
@@ -594,7 +594,7 @@ bool Adaptor::RemoveWindow( std::string childWindowName )
   return false;
 }
 
-bool Adaptor::RemoveWindow( Window* childWindow )
+bool Adaptor::RemoveWindow( Internal::Adaptor::SceneHolder* childWindow )
 {
   for ( WindowContainer::iterator iter = mWindows.begin(); iter != mWindows.end(); ++iter )
   {
@@ -861,7 +861,7 @@ void Adaptor::OnWindowHidden()
   {
     bool allWindowsHidden = true;
 
-    for( WindowPtr window : mWindows )
+    for( SceneHolderPtr window : mWindows )
     {
       if ( window->IsVisible() )
       {
@@ -971,7 +971,7 @@ bool Adaptor::ProcessCoreEventsFromIdle()
   return false;
 }
 
-Adaptor::Adaptor(Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
+Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
 : mResizedSignal(),
   mLanguageChangedSignal(),
   mAdaptor( adaptor ),
@@ -1003,7 +1003,7 @@ Adaptor::Adaptor(Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfac
   mUseRemoteSurface( false )
 {
   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
-  mWindows.insert( mWindows.begin(), WindowPtr( &Dali::GetImplementation( window ) ) );
+  mWindows.insert( mWindows.begin(), SceneHolderPtr( &Dali::GetImplementation( window ) ) );
 
   gThreadLocalAdaptor = this;
 }
index 9b61083..4453269 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_ADAPTOR_IMPL_H
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 // INTERNAL INCLUDES
 #include <dali/integration-api/adaptor.h>
 #include <dali/integration-api/scene.h>
+
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/scene-holder-impl.h>
+#else
+#include <dali/integration-api/adaptors/scene-holder-impl.h>
+#endif
+
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 
@@ -40,7 +47,6 @@
 #include <dali/internal/system/common/core-event-interface.h>
 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
 #include <dali/internal/window-system/common/damage-observer.h>
-#include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/window-system/common/window-visibility-observer.h>
 #include <dali/internal/system/common/kernel-trace.h>
 #include <dali/internal/system/common/system-trace.h>
@@ -52,7 +58,6 @@ namespace Dali
 {
 
 class RenderSurfaceInterface;
-class Window;
 
 namespace Integration
 {
@@ -80,6 +85,7 @@ class VSyncMonitor;
 class PerformanceInterface;
 class LifeCycleObserver;
 class ObjectProfiler;
+class SceneHolder;
 
 /**
  * Implementation of the Adaptor class.
@@ -105,7 +111,7 @@ public:
    * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  static Dali::Adaptor* New( Dali::Window window,
+  static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
                              Dali::RenderSurfaceInterface* surface,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
@@ -116,7 +122,7 @@ public:
    * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  static Dali::Adaptor* New( Dali::Window window,
+  static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
 
@@ -131,7 +137,7 @@ public:
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
   static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
-                             Dali::Window window,
+                             Dali::Integration::SceneHolder window,
                              Dali::RenderSurfaceInterface* surface,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
@@ -144,7 +150,7 @@ public:
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
   static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
-                             Dali::Window window,
+                             Dali::Integration::SceneHolder window,
                              Dali::Configuration::ContextLoss configuration,
                              EnvironmentOptions* environmentOptions );
 
@@ -222,9 +228,9 @@ public: // AdaptorInternalServices implementation
   virtual void FeedKeyEvent( KeyEvent& keyEvent );
 
   /**
-   * @copydoc AdaptorInterface::ReplaceSurface()
+   * @copydoc Dali::Adaptor::ReplaceSurface()
    */
-  virtual void ReplaceSurface( Dali::Window window, Dali::RenderSurfaceInterface& surface );
+  virtual void ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface );
 
   /**
    * @copydoc Dali::Adaptor::GetSurface()
@@ -255,7 +261,7 @@ public: // AdaptorInternalServices implementation
    * @param[in]  childWindowClassName The class name that the child window belongs to
    * @param[in]  childWindowMode The mode of the child window
    */
-  virtual bool AddWindow( Dali::Window* childWindow,
+  virtual bool AddWindow( Dali::Integration::SceneHolder* childWindow,
                           const std::string& childWindowName,
                           const std::string& childWindowClassName,
                           const bool& childWindowMode );
@@ -264,7 +270,7 @@ public: // AdaptorInternalServices implementation
    * Removes an existing Window instance from the Adaptor
    * @param[in]  window The Window instance
    */
-  virtual bool RemoveWindow( Dali::Window* childWindow );
+  virtual bool RemoveWindow( Dali::Integration::SceneHolder* childWindow );
 
   /**
    * Removes an existing Window instance from the Adaptor
@@ -287,7 +293,7 @@ public: // AdaptorInternalServices implementation
    * Removes an existing Window instance from the Adaptor
    * @param[in]  childWindow The Window instance
    */
-  bool RemoveWindow( Dali::Internal::Adaptor::Window* childWindow );
+  bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
 
 public:
 
@@ -618,7 +624,7 @@ private:
    *                          - Window, adaptor will use existing Window to draw on to
    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  Adaptor( Dali::Window window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions );
+  Adaptor( Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions );
 
 private: // Types
 
@@ -631,8 +637,8 @@ private: // Types
     STOPPED,             ///< Adaptor has been stopped.
   };
 
-  using WindowPtr = IntrusivePtr< Window >;
-  using WindowContainer = std::vector<WindowPtr>;
+  using SceneHolderPtr = IntrusivePtr< Dali::Internal::Adaptor::SceneHolder >;
+  using WindowContainer = std::vector<SceneHolderPtr>;
   using ObserverContainer = std::vector<LifeCycleObserver*>;
 
 private: // Data
index 82382d8..9c7cfed 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/devel-api/adaptor-framework/style-monitor.h>
 #include <dali/integration-api/render-surface.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/window-system/common/window-impl.h>
+
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/scene-holder.h>
+#else
+#include <dali/integration-api/adaptors/scene-holder.h>
+#endif
 
 namespace Dali
 {
@@ -37,7 +44,8 @@ Adaptor& Adaptor::New( Window window )
 
 Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
 {
-  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, configuration, NULL );
+  Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), configuration, NULL );
   return *adaptor;
 }
 
@@ -48,6 +56,30 @@ Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surfac
 
 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
 {
+  Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
+  Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface *>(&surface);
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( Dali::Integration::SceneHolder( sceneHolder ), pSurface, configuration, NULL );
+  return *adaptor;
+}
+
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
+{
+  return New( window, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
+}
+
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration )
+{
+  Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, configuration, NULL );
+  return *adaptor;
+}
+
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
+{
+  return New( window, surface, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
+}
+
+Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
+{
   Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface *>(&surface);
   Adaptor* adaptor = Internal::Adaptor::Adaptor::New( window, pSurface, configuration, NULL );
   return *adaptor;
@@ -90,6 +122,12 @@ void Adaptor::RemoveIdle( CallbackBase* callback )
 
 void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
 {
+  Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation( window );
+  mImpl->ReplaceSurface( Dali::Integration::SceneHolder( sceneHolder ), surface );
+}
+
+void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
+{
   mImpl->ReplaceSurface( window, surface );
 }
 
index ce49e60..6f58fba 100755 (executable)
@@ -181,11 +181,13 @@ void Application::CreateAdaptor()
 
   auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
 
-  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( graphicsFactory, mMainWindow, mContextLossConfiguration, &mEnvironmentOptions );
+  Integration::SceneHolder sceneHolder = Integration::SceneHolder( &Dali::GetImplementation( mMainWindow ) );
+
+  mAdaptor = Adaptor::New( graphicsFactory, sceneHolder, mContextLossConfiguration, &mEnvironmentOptions );
 
   mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
 
-  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
+  Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
 }
 
 void Application::CreateAdaptorBuilder()
index d4eb2ef..503d662 100644 (file)
 #include <dali/public-api/rendering/frame-buffer.h>
 #include <dali/devel-api/adaptor-framework/orientation.h>
 
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/render-surface-interface.h>
+#else
+#include <dali/integration-api/adaptors/render-surface-interface.h>
+#endif
+
 // INTERNAL HEADERS
 #include <dali/internal/input/common/drag-and-drop-detector-impl.h>
 #include <dali/internal/window-system/common/event-handler.h>
@@ -46,8 +52,6 @@ namespace Internal
 namespace Adaptor
 {
 
-uint32_t Window::mWindowCounter = 0;
-
 namespace
 {
 
@@ -66,17 +70,13 @@ Window* Window::New( const PositionSize& positionSize, const std::string& name,
 }
 
 Window::Window()
-: mId( mWindowCounter++ ),
-  mSurface( nullptr ),
+: mWindowSurface( nullptr ),
   mWindowBase(),
-  mStarted( false ),
   mIsTransparent( false ),
   mIsFocusAcceptable( true ),
-  mVisible( true ),
   mIconified( false ),
   mOpaqueState( false ),
   mResizeEnabled( false ),
-  mAdaptor( NULL ),
   mType( Dali::Window::NORMAL ),
   mPreferredOrientation( Dali::Window::PORTRAIT ),
   mFocusChangedSignal(),
@@ -87,13 +87,6 @@ Window::Window()
 
 Window::~Window()
 {
-  if ( mAdaptor )
-  {
-    mAdaptor->RemoveObserver( *this );
-    mAdaptor->RemoveWindow( this );
-    mAdaptor = NULL;
-  }
-
   if ( mEventHandler )
   {
     mEventHandler->SetRotationObserver( nullptr );
@@ -106,16 +99,17 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam
   Any surface;
   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
   mSurface = renderSurfaceFactory->CreateWindowRenderSurface( positionSize, surface, mIsTransparent );
+  mWindowSurface = static_cast<WindowRenderSurface*>( mSurface.get() );
 
   // Get a window base
-  mWindowBase = mSurface->GetWindowBase();
+  mWindowBase = mWindowSurface->GetWindowBase();
 
   // Connect signals
   mWindowBase->IconifyChangedSignal().Connect( this, &Window::OnIconifyChanged );
   mWindowBase->FocusChangedSignal().Connect( this, &Window::OnFocusChanged );
   mWindowBase->DeleteRequestSignal().Connect( this, &Window::OnDeleteRequest );
 
-  mSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
+  mWindowSurface->OutputTransformedSignal().Connect( this, &Window::OnOutputTransformed );
 
   if( !positionSize.IsEmpty() )
   {
@@ -125,45 +119,16 @@ void Window::Initialize(const PositionSize& positionSize, const std::string& nam
 
   SetClass( name, className );
 
-  mSurface->Map();
+  mWindowSurface->Map();
 
   mOrientation = Orientation::New( this );
 }
 
-void Window::SetAdaptor(Dali::Adaptor& adaptor)
-{
-  Window::SetAdaptor( Internal::Adaptor::Adaptor::GetImplementation( adaptor ) );
-}
-
-void Window::SetAdaptor(Adaptor& adaptor)
+void Window::OnAdaptorSet(Dali::Adaptor& adaptor)
 {
-  if( mStarted )
-  {
-    return;
-  }
-
-  mStarted = true;
-
-  // Create scene for the window
-  PositionSize positionSize = mSurface->GetPositionSize();
-  mScene = Dali::Integration::Scene::New( Vector2( positionSize.width, positionSize.height ) );
-  mScene.SetSurface( *mSurface.get() );
-
-  unsigned int dpiHorizontal, dpiVertical;
-  dpiHorizontal = dpiVertical = 0;
-
-  mSurface->GetDpi( dpiHorizontal, dpiVertical );
-  mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
-
-  // Add the window to the adaptor observers
-  mAdaptor = &adaptor;
-  mAdaptor->AddObserver( *this );
-
   // Can only create the detector when we know the Core has been instantiated.
   mDragAndDropDetector = DragAndDropDetector::New();
 
-  mSurface->SetAdaptor( *mAdaptor );
-
   mEventHandler = EventHandlerPtr(
       new EventHandler( mScene, *mAdaptor, *mAdaptor->GetGestureManager(), *mAdaptor ) );
 
@@ -174,24 +139,9 @@ void Window::SetAdaptor(Adaptor& adaptor)
   }
 }
 
-WindowRenderSurface* Window::GetSurface() const
-{
-  return mSurface.get();
-}
-
-void Window::SetSurface(WindowRenderSurface* surface)
+void Window::OnSurfaceSet( Dali::RenderSurfaceInterface* surface )
 {
-  mSurface.reset( surface );
-
-  mScene.SetSurface( *mSurface.get() );
-
-  unsigned int dpiHorizontal, dpiVertical;
-  dpiHorizontal = dpiVertical = 0;
-
-  mSurface->GetDpi( dpiHorizontal, dpiVertical );
-  mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
-
-  mSurface->SetAdaptor( *mAdaptor );
+  mWindowSurface = static_cast<WindowRenderSurface*>( surface );
 }
 
 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
@@ -213,11 +163,6 @@ void Window::SetClass( std::string name, std::string className )
   mWindowBase->SetClass( name, className );
 }
 
-std::string Window::GetName() const
-{
-  return mName;
-}
-
 std::string Window::GetClassName() const
 {
   return mClassName;
@@ -238,21 +183,6 @@ void Window::Activate()
   mWindowBase->Activate();
 }
 
-void Window::Add( Dali::Actor actor )
-{
-  mScene.Add( actor );
-}
-
-void Window::Remove( Dali::Actor actor )
-{
-  mScene.Remove( actor );
-}
-
-Dali::Layer Window::GetRootLayer() const
-{
-  return mScene.GetRootLayer();
-}
-
 uint32_t Window::GetLayerCount() const
 {
   return mScene.GetLayerCount();
@@ -263,19 +193,6 @@ Dali::Layer Window::GetLayer( uint32_t depth ) const
   return mScene.GetLayer( depth );
 }
 
-void Window::SetBackgroundColor( Vector4 color )
-{
-  if ( mSurface )
-  {
-    mSurface->SetBackgroundColor( color );
-  }
-}
-
-Vector4 Window::GetBackgroundColor() const
-{
-  return mSurface ? mSurface->GetBackgroundColor() : Vector4();
-}
-
 void Window::AddAvailableOrientation( Dali::Window::WindowOrientation orientation )
 {
   bool found = false;
@@ -350,7 +267,7 @@ Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
 
 Dali::Any Window::GetNativeHandle() const
 {
-  return mSurface->GetNativeWindow();
+  return mWindowSurface->GetNativeWindow();
 }
 
 void Window::SetAcceptFocus( bool accept )
@@ -529,7 +446,7 @@ void Window::SetSize( Dali::Window::WindowSize size )
 
   PositionSize oldRect = mSurface->GetPositionSize();
 
-  mSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
+  mWindowSurface->MoveResize( PositionSize( oldRect.x, oldRect.y, size.GetWidth(), size.GetHeight() ) );
 
   PositionSize newRect = mSurface->GetPositionSize();
 
@@ -563,7 +480,7 @@ void Window::SetPosition( Dali::Window::WindowPosition position )
 
   PositionSize oldRect = mSurface->GetPositionSize();
 
-  mSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
+  mWindowSurface->MoveResize( PositionSize( position.GetX(), position.GetY(), oldRect.width, oldRect.height ) );
 }
 
 Dali::Window::WindowPosition Window::GetPosition() const
@@ -583,7 +500,7 @@ void Window::SetPositionSize( PositionSize positionSize )
 
   PositionSize oldRect = mSurface->GetPositionSize();
 
-  mSurface->MoveResize( positionSize );
+  mWindowSurface->MoveResize( positionSize );
 
   PositionSize newRect = mSurface->GetPositionSize();
 
@@ -607,7 +524,7 @@ Dali::Layer Window::GetRootLayer()
 
 void Window::SetTransparency( bool transparent )
 {
-  mSurface->SetTransparency( transparent );
+  mWindowSurface->SetTransparency( transparent );
 }
 
 bool Window::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode )
@@ -632,7 +549,7 @@ bool Window::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector<
 
 void Window::RotationDone( int orientation, int width, int height )
 {
-  mSurface->RequestRotation( orientation, width, height );
+  mWindowSurface->RequestRotation( orientation, width, height );
 
   mAdaptor->SurfaceResizePrepare( mSurface.get(), Adaptor::SurfaceSize( width, height ) );
 
@@ -687,32 +604,6 @@ void Window::OnDeleteRequest()
   mDeleteRequestSignal.Emit();
 }
 
-void Window::OnStart()
-{
-}
-
-void Window::OnPause()
-{
-}
-
-void Window::OnResume()
-{
-}
-
-void Window::OnStop()
-{
-}
-
-void Window::OnDestroy()
-{
-  mAdaptor = NULL;
-}
-
-uint32_t Window::GetId() const
-{
-  return mId;
-}
-
 void Window::FeedTouchPoint( TouchPoint& point, int timeStamp )
 {
   if( mEventHandler )
@@ -737,7 +628,7 @@ void Window::FeedKeyEvent( KeyEvent& keyEvent )
   }
 }
 
-void Window::Pause()
+void Window::OnPause()
 {
   if( mEventHandler )
   {
@@ -745,7 +636,7 @@ void Window::Pause()
   }
 }
 
-void Window::Resume()
+void Window::OnResume()
 {
   if( mEventHandler )
   {
index 414af24..cf21b18 100644 (file)
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/integration-api/scene.h>
+
+#ifdef DALI_ADAPTOR_COMPILATION
+#include <dali/integration-api/scene-holder-impl.h>
+#else
+#include <dali/integration-api/adaptors/scene-holder-impl.h>
+#endif
 
 // INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/lifecycle-observer.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/adaptor-framework/key-grab.h>
 #include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
@@ -37,6 +40,7 @@ namespace Dali
 {
 class Adaptor;
 class Actor;
+class RenderSurfaceInterface;
 
 namespace Internal
 {
@@ -56,7 +60,7 @@ using EventHandlerPtr = IntrusivePtr< EventHandler >;
 /**
  * Window provides a surface to render onto with orientation & indicator properties.
  */
-class Window : public Dali::BaseObject, public LifeCycleObserver, public ConnectionTracker
+class Window : public Dali::Internal::Adaptor::SceneHolder, public ConnectionTracker
 {
 public:
   typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
@@ -75,30 +79,6 @@ public:
   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent = false);
 
   /**
-   * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
-   * @param[in] adaptor An initialized adaptor
-   */
-  void SetAdaptor(Dali::Adaptor& adaptor);
-
-  /**
-   * Pass the adaptor back to the overlay. This allows the window to access Core's overlay.
-   * @param[in] adaptor implementation An initialized adaptor implementation
-   */
-  void SetAdaptor(Adaptor& adaptor);
-
-  /**
-   * Get the window surface
-   * @return The render surface
-   */
-  WindowRenderSurface* GetSurface() const;
-
-  /**
-   * Set the window surface
-   * @param[in] surface The surface
-   */
-  void SetSurface(WindowRenderSurface* surface);
-
-  /**
    * @copydoc Dali::Window::ShowIndicator()
    */
   void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode );
@@ -119,12 +99,6 @@ public:
   void SetClass( std::string name, std::string className );
 
   /**
-   * @brief Gets the window name.
-   * @return The name of the window
-   */
-  std::string GetName() const;
-
-  /**
    * @brief Gets the window class name.
    * @return The class of the window
    */
@@ -146,31 +120,6 @@ public:
   void Activate();
 
   /**
-   * @copydoc Dali::Window::Add()
-   */
-  void Add( Dali::Actor actor );
-
-  /**
-   * @copydoc Dali::Window::Remove()
-   */
-  void Remove( Dali::Actor remove );
-
-  /**
-   * @copydoc Dali::Window::SetBackgroundColor()
-   */
-  void SetBackgroundColor(Vector4 color);
-
-  /**
-   * @copydoc Dali::Window::GetBackgroundColor()
-   */
-  Vector4 GetBackgroundColor() const;
-
-  /**
-   * @copydoc Dali::Window::GetRootLayer()
-   */
-  Dali::Layer GetRootLayer() const;
-
-  /**
    * @copydoc Dali::Window::GetLayerCount()
    */
   uint32_t GetLayerCount() const;
@@ -216,11 +165,6 @@ public:
   Dali::DragAndDropDetector GetDragAndDropDetector() const;
 
   /**
-   * @copydoc Dali::Window::GetNativeHandle() const
-   */
-  Dali::Any GetNativeHandle() const;
-
-  /**
    * @copydoc Dali::Window::SetAcceptFocus()
    */
   void SetAcceptFocus( bool accept );
@@ -241,11 +185,6 @@ public:
   void Hide();
 
   /**
-   * @copydoc Dali::Window::IsVisible() const
-   */
-  bool IsVisible() const;
-
-  /**
    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
    */
   unsigned int GetSupportedAuxiliaryHintCount() const;
@@ -396,45 +335,23 @@ public:
   void RotationDone( int orientation, int width, int height );
 
   /**
-   * @brief Retrieves the unique ID of the window.
-   * @return The ID
-   */
-  uint32_t GetId() const;
-
-  /**
-   * Feed (Send) touch event to core and gesture manager
-   * @param[in] touchEvent  The touch event holding the touch point information.
-   */
-  void FeedTouchPoint( TouchPoint& point, int timeStamp );
-
-  /**
-   * Feed (Send) wheel event to core and gesture manager
-   * @param[in]  wheelEvent The wheel event
-   */
-  void FeedWheelEvent( WheelEvent& wheelEvent );
-
-  /**
-   * Feed (Send) key event to core
-   * @param[in] keyEvent The key event holding the key information.
+   * Set the rotation observer (note, some adaptors may not have a rotation observer)
+   * @param[in] observer The rotation observer
+   * @return If the rotation observer is set
    */
-  void FeedKeyEvent( KeyEvent& keyEvent );
+  bool SetRotationObserver( RotationObserver* observer );
 
-  /**
-   * Called when the adaptor is paused.
-   */
-  void Pause();
+public: // Dali::Internal::Adaptor::SceneHolder
 
   /**
-   * Called when the adaptor is resumed (from pause).
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::GetNativeHandle
    */
-  void Resume();
+  Dali::Any GetNativeHandle() const override;
 
   /**
-   * Set the rotation observer (note, some adaptors may not have a rotation observer)
-   * @param[in] observer The rotation observer
-   * @return If the rotation observer is set
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::IsVisible
    */
-  bool SetRotationObserver( RotationObserver* observer );
+  bool IsVisible() const override;
 
 private:
 
@@ -474,32 +391,42 @@ private:
    */
   void OnDeleteRequest();
 
-private: // Adaptor::Observer interface
+private: // Dali::Internal::Adaptor::SceneHolder
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStart()
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedTouchPoint
    */
-  virtual void OnStart();
+  void FeedTouchPoint( TouchPoint& point, int timeStamp ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnPause()
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedWheelEvent
    */
-  virtual void OnPause();
+  void FeedWheelEvent( WheelEvent& wheelEvent ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnResume()
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::FeedKeyEvent
    */
-  virtual void OnResume();
+  void FeedKeyEvent( KeyEvent& keyEvent ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnStop()
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnAdaptorSet
    */
-  virtual void OnStop();
+  void OnAdaptorSet( Dali::Adaptor& adaptor ) override;
 
   /**
-   * @copydoc Dali::Internal::Adaptor::Adaptor::Observer::OnDestroy()
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnSurfaceSet
    */
-  virtual void OnDestroy();
+  void OnSurfaceSet( Dali::RenderSurfaceInterface* surface ) override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnPause
+   */
+  void OnPause() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::SceneHolder::OnResume
+   */
+  void OnResume() override;
 
 public: // Signals
 
@@ -545,21 +472,15 @@ public: // Signals
 
 private:
 
-  static uint32_t                       mWindowCounter;    ///< A counter to track the window creation
-  uint32_t                              mId;               ///< A unique ID to identify the window starting from 0
-  std::unique_ptr< WindowRenderSurface >mSurface;          ///< The window rendering surface
-  Dali::Integration::Scene              mScene;
+  WindowRenderSurface*                  mWindowSurface;      ///< The window rendering surface
   WindowBase*                           mWindowBase;
   std::string                           mName;
   std::string                           mClassName;
-  bool                                  mStarted:1;
   bool                                  mIsTransparent:1;
   bool                                  mIsFocusAcceptable:1;
-  bool                                  mVisible:1;
   bool                                  mIconified:1;
   bool                                  mOpaqueState:1;
   bool                                  mResizeEnabled:1;
-  Adaptor*                              mAdaptor;
   Dali::DragAndDropDetector             mDragAndDropDetector;
   Dali::Window::Type                    mType;
 
@@ -569,8 +490,6 @@ private:
 
   EventHandlerPtr                       mEventHandler;      ///< The window events handler
 
-  Vector4                               mBackgroundColor;
-
   // Signals
   IndicatorSignalType                   mIndicatorVisibilityChangedSignal;
   FocusSignalType                       mFocusChangedSignal;
index 34eb7b0..eb0b58d 100644 (file)
@@ -28,22 +28,22 @@ namespace Dali
 
 Window Window::New(PositionSize posSize, const std::string& name, bool isTransparent)
 {
-  Internal::Adaptor::Window* windowImpl = Internal::Adaptor::Window::New(posSize, name, "", isTransparent);
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, "", isTransparent);
 
   Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
-  Dali::Window window = Dali::Window( windowImpl );
-  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &window, name, "", isTransparent );
+  Integration::SceneHolder sceneHolder = Integration::SceneHolder( window );
+  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, "", isTransparent );
 
   return Window(window);
 }
 
 Window Window::New(PositionSize posSize, const std::string& name, const std::string& className, bool isTransparent)
 {
-  Internal::Adaptor::Window* windowImpl = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(posSize, name, className, isTransparent);
 
   Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
-  Dali::Window window = Dali::Window( windowImpl );
-  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &window, name, className, isTransparent );
+  Integration::SceneHolder sceneHolder = Integration::SceneHolder( window );
+  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &sceneHolder, name, className, isTransparent );
 
   return Window(window);
 }