Extending the event loop with Processors
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.h
index a722f79..d4d19e2 100644 (file)
@@ -1,34 +1,40 @@
-#ifndef __DALI_INTERNAL_CORE_H__
-#define __DALI_INTERNAL_CORE_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+#ifndef DALI_INTERNAL_CORE_H
+#define DALI_INTERNAL_CORE_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
 
 // 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/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>
 
 namespace Dali
 {
 
 namespace Integration
 {
+class Processor;
 class RenderController;
 class PlatformAbstraction;
 class GestureManager;
@@ -47,24 +53,18 @@ namespace Internal
 class NotificationManager;
 class AnimationPlaylist;
 class PropertyNotificationManager;
-class DynamicsNotifier;
-class Context;
 class EventProcessor;
 class GestureEventProcessor;
-class ResourceClient;
-class ResourceManager;
-class FrameTime;
-class FontFactory;
-class ImageFactory;
-class ModelFactory;
 class ShaderFactory;
 class TouchResampler;
+class RelayoutController;
 
 namespace SceneGraph
 {
 class UpdateManager;
 class RenderManager;
 class DiscardQueue;
+class RenderTaskProcessor;
 }
 
 /**
@@ -81,7 +81,11 @@ public:
         Integration::PlatformAbstraction& platform,
         Integration::GlAbstraction& glAbstraction,
         Integration::GlSyncAbstraction& glSyncAbstraction,
-        Integration::GestureManager& gestureManager );
+        Integration::GestureManager& gestureManager,
+        ResourcePolicy::DataRetention dataRetentionPolicy,
+        Integration::RenderToFrameBuffer renderToFboEnabled,
+        Integration::DepthBufferAvailable depthBufferAvailable,
+        Integration::StencilBufferAvailable stencilBufferAvailable );
 
   /**
    * Destructor
@@ -89,14 +93,24 @@ public:
   ~Core();
 
   /**
+   * @copydoc Dali::Integration::Core::GetContextNotifier()
+   */
+  Integration::ContextNotifierInterface* GetContextNotifier();
+
+  /**
    * @copydoc Dali::Integration::Core::ContextCreated()
    */
   void ContextCreated();
 
   /**
-   * @copydoc Dali::Integration::Core::ContextToBeDestroyed()
+   * @copydoc Dali::Integration::Core::ContextDestroyed()
+   */
+  void ContextDestroyed();
+
+  /**
+   * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
    */
-  void ContextToBeDestroyed();
+  void RecoverFromContextLoss();
 
   /**
    * @copydoc Dali::Integration::Core::SurfaceResized(unsigned int, unsigned int)
@@ -104,6 +118,11 @@ public:
   void SurfaceResized(unsigned int width, unsigned int height);
 
   /**
+   * @copydoc Dali::Integration::Core::SetTopMargin( unsigned int margin )
+   */
+  void SetTopMargin( unsigned int margin );
+
+  /**
    * @copydoc Dali::Integration::Core::SetDpi(unsigned int, unsigned int)
    */
   void SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical);
@@ -116,22 +135,17 @@ public:
   /**
    * @copydoc Dali::Integration::Core::Update()
    */
-  void Update( Integration::UpdateStatus& status );
+  void Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo );
 
   /**
    * @copydoc Dali::Integration::Core::Render()
    */
-  void Render( Integration::RenderStatus& status );
-
-  /**
-   * @copydoc Dali::Integration::Core::Suspend()
-   */
-  void Suspend();
+  void Render( Integration::RenderStatus& status, bool forceClear );
 
   /**
-   * @copydoc Dali::Integration::Core::Resume()
+   * @copydoc Dali::Integration::Core::SceneCreated()
    */
-  void Resume();
+  void SceneCreated();
 
   /**
    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
@@ -144,36 +158,55 @@ public:
   void ProcessEvents();
 
   /**
-   * @copydoc Dali::Integration::Core::UpdateTouchData(const Integration::TouchData&)
+   * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
    */
-  void UpdateTouchData(const Integration::TouchData& touch);
+  unsigned int GetMaximumUpdateCount() const;
 
   /**
-   * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
+   * @copydoc Dali::Integration::Core::GetSystemOverlay()
    */
-  unsigned int GetMaximumUpdateCount() const;
+  Integration::SystemOverlay& GetSystemOverlay();
+
+  // Stereoscopy
 
   /**
-   * @copydoc Dali::Integration::Core::Sleep()
+   * @copydoc Dali::Integration::Core::SetViewMode()
    */
-  void Sleep();
+  void SetViewMode( ViewMode viewMode );
 
   /**
-   * @copydoc Dali::Integration::Core::Wake()
+   * @copydoc Dali::Integration::Core::GetViewMode()
    */
-  void WakeUp();
+  ViewMode GetViewMode() const;
 
   /**
-   * @copydoc Dali::Integration::Core::VSync()
+   * @copydoc Dali::Integration::Core::SetStereoBase()
    */
-  void VSync( unsigned int frameNumber, unsigned int seconds, unsigned int microseconds );
+  void SetStereoBase( float stereoBase );
 
   /**
-   * @copydoc Dali::Integration::Core::GetSystemOverlay()
+   * @copydoc Dali::Integration::Core::GetStereoBase()
    */
-  Integration::SystemOverlay& GetSystemOverlay();
+  float GetStereoBase() const;
+
+
+  /**
+   * @copydoc Dali::Integration::Core::RegisterProcessor
+   */
+  void RegisterProcessor( Dali::Integration::Processor& processor );
 
-private:  // for use by ThreadLocalStorage
+  /**
+   * @copydoc Dali::Integration::Core::UnregisterProcessor
+   */
+  void UnregisterProcessor( Dali::Integration::Processor& processor );
+
+private:
+  /**
+   * Run each registered processor
+   */
+  void RunProcessors();
+
+  // for use by ThreadLocalStorage
 
   /**
    * Returns the current stage.
@@ -206,36 +239,6 @@ private:  // for use by ThreadLocalStorage
   NotificationManager& GetNotificationManager();
 
   /**
-   * Returns the Resource Manager.
-   * @return A reference to the Resource Manager.
-   */
-  ResourceManager& GetResourceManager();
-
-  /**
-   * Returns the Resource client.
-   * @return A reference to the Resource Client.
-   */
-  ResourceClient& GetResourceClient();
-
-  /**
-   * Returns the Font factory
-   * @return A reference to the Font factory.
-   */
-  FontFactory& GetFontFactory();
-
-  /**
-   * Returns the Image factory
-   * @return A reference to the Image factory.
-   */
-  ImageFactory& GetImageFactory();
-
-  /**
-   * Returns the Model factory
-   * @return A reference to the Model factory.
-   */
-  ModelFactory& GetModelFactory();
-
-  /**
    * Returns the Shader factory
    * @return A reference to the Shader binary factory.
    */
@@ -247,6 +250,12 @@ private:  // for use by ThreadLocalStorage
    */
   GestureEventProcessor& GetGestureEventProcessor();
 
+  /**
+   * Return the relayout controller
+   * @Return Return a reference to the relayout controller
+   */
+  RelayoutController& GetRelayoutController();
+
 private:
 
   /**
@@ -266,28 +275,21 @@ 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.
-  ResourcePostProcessList*                  mResourcePostProcessQueue;    ///< 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
-  OwnerPointer<DynamicsNotifier>            mDynamicsNotifier;
-  FrameTime*                                mFrameTime;                   ///< Time when we render
-  FontFactory*                              mFontFactory;                 ///< font resource factory
-  ImageFactory*                             mImageFactory;                ///< Image resource factory
-  ModelFactory*                             mModelFactory;                ///< Model resource factory
-  ShaderFactory*                            mShaderFactory;               ///< Shader resource factory
-  ResourceClient*                           mResourceClient;              ///< Asynchronous Resource Loading
-  ResourceManager*                          mResourceManager;             ///< Asynchronous Resource Loading
-  TouchResampler*                           mTouchResampler;              ///< Resamples touches to correct frame rate.
-
-  bool                                      mIsActive         : 1;        ///< Whether Core is active or suspended
+  IntrusivePtr< RelayoutController >        mRelayoutController;          ///< Size negotiation relayout controller
   bool                                      mProcessingEvent  : 1;        ///< True during ProcessEvents()
 
+  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
+  OwnerPointer<EventProcessor>                  mEventProcessor;              ///< The event processor
+  Dali::Vector<Integration::Processor*>         mProcessors;                  ///< Registered processors (not owned)
+
   friend class ThreadLocalStorage;
 
 };
@@ -296,4 +298,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_CORE_H__
+#endif // DALI_INTERNAL_CORE_H