Remove RenderSurface from Core
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.h
index b9472cd..9272e16 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_CORE_H__
-#define __DALI_INTERNAL_CORE_H__
+#ifndef DALI_INTERNAL_CORE_H
+#define DALI_INTERNAL_CORE_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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/public-api/common/dali-vector.h>
 #include <dali/public-api/object/ref-object.h>
 #include <dali/integration-api/context-notifier.h>
+#include <dali/integration-api/core-enumerations.h>
 #include <dali/internal/common/owner-pointer.h>
+#include <dali/devel-api/common/owner-container.h>
 #include <dali/internal/event/animation/animation-playlist-declarations.h>
 #include <dali/internal/event/common/stage-def.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-#include <dali/public-api/common/view-mode.h>
 #include <dali/integration-api/resource-policies.h>
+#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/common/object-registry-impl.h>
 
 namespace Dali
 {
 
 namespace Integration
 {
+class Processor;
 class RenderController;
 class PlatformAbstraction;
-class GestureManager;
 class GlAbstraction;
 class GlSyncAbstraction;
-class SystemOverlay;
+class GlContextHelperAbstraction;
 class UpdateStatus;
 class RenderStatus;
 struct Event;
@@ -53,25 +56,23 @@ class AnimationPlaylist;
 class PropertyNotificationManager;
 class EventProcessor;
 class GestureEventProcessor;
-class ResourceClient;
-class ResourceManager;
-class ImageFactory;
 class ShaderFactory;
 class TouchResampler;
 class RelayoutController;
+class EventThreadServices;
 
 namespace SceneGraph
 {
 class UpdateManager;
 class RenderManager;
 class DiscardQueue;
-class TextureCacheDispatcher;
+class RenderTaskProcessor;
 }
 
 /**
  * Internal class for Dali::Integration::Core
  */
-class Core
+class Core : public EventThreadServices
 {
 public:
 
@@ -82,8 +83,10 @@ public:
         Integration::PlatformAbstraction& platform,
         Integration::GlAbstraction& glAbstraction,
         Integration::GlSyncAbstraction& glSyncAbstraction,
-        Integration::GestureManager& gestureManager,
-        ResourcePolicy::DataRetention dataRetentionPolicy );
+        Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
+        Integration::RenderToFrameBuffer renderToFboEnabled,
+        Integration::DepthBufferAvailable depthBufferAvailable,
+        Integration::StencilBufferAvailable stencilBufferAvailable );
 
   /**
    * Destructor
@@ -91,6 +94,11 @@ public:
   ~Core();
 
   /**
+   * @copydoc Dali::Integration::Core::Initialize()
+   */
+  void Initialize();
+
+  /**
    * @copydoc Dali::Integration::Core::GetContextNotifier()
    */
   Integration::ContextNotifierInterface* GetContextNotifier();
@@ -111,39 +119,29 @@ public:
   void RecoverFromContextLoss();
 
   /**
-   * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
-   */
-  void SurfaceResized(unsigned int width, unsigned int height);
-
-  /**
-   * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
-   */
-  void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
-
-  /**
-   * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(unsigned int)
+   * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
    */
-  void SetMinimumFrameTimeInterval(unsigned int interval);
+  void SetMinimumFrameTimeInterval(uint32_t interval);
 
   /**
    * @copydoc Dali::Integration::Core::Update()
    */
-  void Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status );
+  void Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
 
   /**
    * @copydoc Dali::Integration::Core::Render()
    */
-  void Render( Integration::RenderStatus& status );
+  void PreRender( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
 
   /**
-   * @copydoc Dali::Integration::Core::Suspend()
+   * @copydoc Dali::Integration::Core::RenderScene()
    */
-  void Suspend();
+  void RenderScene( Integration::Scene& scene, bool renderToFbo );
 
   /**
-   * @copydoc Dali::Integration::Core::Resume()
+   * @copydoc Dali::Integration::Core::Render()
    */
-  void Resume();
+  void PostRender( bool uploadOnly );
 
   /**
    * @copydoc Dali::Integration::Core::SceneCreated()
@@ -163,84 +161,101 @@ public:
   /**
    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
    */
-  unsigned int GetMaximumUpdateCount() const;
+  uint32_t GetMaximumUpdateCount() const;
 
   /**
-   * @copydoc Dali::Integration::Core::GetSystemOverlay()
+   * @copydoc Dali::Integration::Core::RegisterProcessor
    */
-  Integration::SystemOverlay& GetSystemOverlay();
+  void RegisterProcessor( Dali::Integration::Processor& processor );
 
-  // Stereoscopy
+  /**
+   * @copydoc Dali::Integration::Core::UnregisterProcessor
+   */
+  void UnregisterProcessor( Dali::Integration::Processor& processor );
 
   /**
-   * @copydoc Dali::Integration::Core::SetViewMode()
+   * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
    */
-  void SetViewMode( ViewMode viewMode );
+  void AddScene( Scene* scene );
 
   /**
-   * @copydoc Dali::Integration::Core::GetViewMode()
+   * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
    */
-  ViewMode GetViewMode() const;
+  void RemoveScene( Scene* scene );
+
+public: // Implementation of EventThreadServices
 
   /**
-   * @copydoc Dali::Integration::Core::SetStereoBase()
+   * @copydoc EventThreadServices::RegisterObject
    */
-  void SetStereoBase( float stereoBase );
+  void RegisterObject( BaseObject* object) override;
 
   /**
-   * @copydoc Dali::Integration::Core::GetStereoBase()
+   * @copydoc EventThreadServices::UnregisterObject
    */
-  float GetStereoBase() const;
+  void UnregisterObject( BaseObject* object) override;
 
-private:  // for use by ThreadLocalStorage
+  /**
+   * @copydoc EventThreadServices::GetUpdateManager
+   */
+  SceneGraph::UpdateManager& GetUpdateManager() override;
 
   /**
-   * Returns the current stage.
-   * @return A smart-pointer to the current stage.
+   * @copydoc EventThreadServices::GetRenderController
    */
-  StagePtr GetCurrentStage();
+  Integration::RenderController& GetRenderController() override;
 
   /**
-   * Returns the platform abstraction.
-   * @return A reference to the platform abstraction.
+   * @copydoc EventThreadServices::ReserveMessageSlot
    */
-  Integration::PlatformAbstraction& GetPlatform();
+  uint32_t* ReserveMessageSlot( uint32_t size, bool updateScene ) override;
 
   /**
-   * Returns the update manager.
-   * @return A reference to the update manager.
+   * @copydoc EventThreadServices::GetEventBufferIndex
    */
-  SceneGraph::UpdateManager& GetUpdateManager();
+  BufferIndex GetEventBufferIndex() const override;
 
   /**
-   * Returns the render manager.
-   * @return A reference to the render manager.
+   * @copydoc EventThreadServices::ForceNextUpdate
    */
-  SceneGraph::RenderManager& GetRenderManager();
+  void ForceNextUpdate() override;
 
   /**
-   * Returns the notification manager.
-   * @return A reference to the Notification Manager.
+   * @copydoc EventThreadServices::IsNextUpdateForced
    */
-  NotificationManager& GetNotificationManager();
+  bool IsNextUpdateForced() override;
+
+private:
+  /**
+   * Run each registered processor
+   */
+  void RunProcessors();
+
+  // for use by ThreadLocalStorage
+
+  /**
+   * Returns the current stage.
+   * @return A smart-pointer to the current stage.
+   */
+  StagePtr GetCurrentStage();
 
   /**
-   * Returns the Resource Manager.
-   * @return A reference to the Resource Manager.
+   * Returns the platform abstraction.
+   * @return A reference to the platform abstraction.
    */
-  ResourceManager& GetResourceManager();
+  Integration::PlatformAbstraction& GetPlatform();
 
   /**
-   * Returns the Resource client.
-   * @return A reference to the Resource Client.
+   * Returns the render manager.
+   * @return A reference to the render manager.
    */
-  ResourceClient& GetResourceClient();
+  SceneGraph::RenderManager& GetRenderManager();
 
   /**
-   * Returns the Image factory
-   * @return A reference to the Image factory.
+   * Returns the notification manager.
+   * @return A reference to the Notification Manager.
    */
-  ImageFactory& GetImageFactory();
+  NotificationManager& GetNotificationManager();
 
   /**
    * Returns the Shader factory
@@ -260,13 +275,37 @@ private:  // for use by ThreadLocalStorage
    */
   RelayoutController& GetRelayoutController();
 
+  /**
+   * @brief Gets the Object registry.
+   * @return A reference to the object registry
+   */
+  ObjectRegistry& GetObjectRegistry() const;
+
+  /**
+   * @brief Gets the event thread services.
+   * @return A reference to the event thread services
+   */
+  EventThreadServices& GetEventThreadServices();
+
+  /**
+   * @brief Gets the property notification manager.
+   * @return A reference to the property notification manager
+   */
+  PropertyNotificationManager& GetPropertyNotificationManager() const;
+
+  /**
+   * @brief Gets the animation play list.
+   * @return A reference to the animation play list
+   */
+  AnimationPlaylist& GetAnimationPlaylist() const;
+
 private:
 
   /**
    * Undefined copy and assignment operators
    */
-  Core(const Core& core);  // No definition
-  Core& operator=(const Core& core);  // No definition
+  Core(const Core& core) = delete;  // No definition
+  Core& operator=(const Core& core) = delete;  // No definition
 
   /**
    * Create Thread local storage
@@ -279,24 +318,27 @@ private:
   Integration::PlatformAbstraction&         mPlatform;                    ///< The interface providing platform specific services.
 
   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
-  GestureEventProcessor*                    mGestureEventProcessor;       ///< The gesture event processor
-  EventProcessor*                           mEventProcessor;              ///< The event processor
-  SceneGraph::UpdateManager*                mUpdateManager;               ///< Update manager
-  SceneGraph::RenderManager*                mRenderManager;               ///< Render manager
-  SceneGraph::DiscardQueue*                 mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
-  SceneGraph::TextureCacheDispatcher*       mTextureCacheDispatcher;      ///< Used to send messages to TextureCache
-  LockedResourceQueue*                      mTextureUploadedQueue;        ///< Stores resource ids which require post processing after render
-  NotificationManager*                      mNotificationManager;         ///< Notification manager
   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
-  ImageFactory*                             mImageFactory;                ///< Image resource factory
-  ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
-  ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
-  ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
   IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
 
-  bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
+  OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;         ///< Handles the processing of render tasks
+  OwnerPointer<SceneGraph::RenderManager>       mRenderManager;               ///< Render manager
+  OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;               ///< Update manager
+  OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;                ///< Used to cleanup nodes & resources when no longer in use.
+  OwnerPointer<ShaderFactory>                   mShaderFactory;               ///< Shader resource factory
+  OwnerPointer<NotificationManager>             mNotificationManager;         ///< Notification manager
+  OwnerPointer<GestureEventProcessor>           mGestureEventProcessor;       ///< The gesture event processor
+  Dali::Vector<Integration::Processor*>         mProcessors;                  ///< Registered processors (not owned)
+
+  using SceneContainer = std::vector<ScenePtr>;
+  SceneContainer                                mScenes;                      ///< A container of scenes that bound to a surface for rendering, owned by Core
+
+  // The object registry
+  ObjectRegistryPtr                             mObjectRegistry;
+
   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
+  bool                                      mForceNextUpdate:1;           ///< True if the next rendering is really required.
 
   friend class ThreadLocalStorage;
 
@@ -306,4 +348,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_CORE_H__
+#endif // DALI_INTERNAL_CORE_H