Separate out Render Helper 20/186820/21
authorthothamon <jason.perry@partner.samsung.com>
Tue, 19 Jun 2018 17:41:09 +0000 (18:41 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 18 Oct 2018 09:54:40 +0000 (10:54 +0100)
Removed EGL dependencies from DisplayConnection public handle
Added methods to manage additional windows
Moved the DepthBufferAvailable and StencilBufferAvailable methods to the Graphics interface
Created the AdaptorBuilder
Reworked application-devel interface
Removeg egl-factory

Change-Id: I717e179eaa58f4236d85fd2a98d8426ddad0fb1f

48 files changed:
dali/devel-api/adaptor-framework/application-devel.cpp
dali/devel-api/adaptor-framework/application-devel.h
dali/integration-api/adaptor.h
dali/integration-api/render-surface.h
dali/internal/adaptor/common/adaptor-builder-impl.cpp [new file with mode: 0644]
dali/internal/adaptor/common/adaptor-builder-impl.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-internal-services.h
dali/internal/adaptor/common/application-impl.cpp
dali/internal/adaptor/common/application-impl.h
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/adaptor/common/combined-update-render-controller.h
dali/internal/adaptor/file.list
dali/internal/adaptor/tizen/adaptor-impl-tizen.cpp
dali/internal/graphics/common/graphics-factory-interface.h [new file with mode: 0644]
dali/internal/graphics/common/graphics-interface.h [new file with mode: 0644]
dali/internal/graphics/common/render-helper.cpp [deleted file]
dali/internal/graphics/common/render-helper.h [deleted file]
dali/internal/graphics/file.list
dali/internal/graphics/gles20/egl-factory-interface.h
dali/internal/graphics/gles20/egl-factory.cpp [deleted file]
dali/internal/graphics/gles20/egl-factory.h [deleted file]
dali/internal/graphics/gles20/egl-graphics-factory.cpp [new file with mode: 0644]
dali/internal/graphics/gles20/egl-graphics-factory.h [new file with mode: 0644]
dali/internal/graphics/gles20/egl-graphics.cpp [new file with mode: 0644]
dali/internal/graphics/gles20/egl-graphics.h [new file with mode: 0644]
dali/internal/imaging/common/native-bitmap-buffer-impl.cpp
dali/internal/imaging/common/native-bitmap-buffer-impl.h
dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp
dali/internal/imaging/tizen/native-image-source-queue-impl-tizen.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.cpp
dali/internal/imaging/ubuntu-x11/native-image-source-impl-x.h
dali/internal/system/common/thread-controller.h
dali/internal/window-system/common/display-connection-impl.h
dali/internal/window-system/common/display-connection.cpp
dali/internal/window-system/common/display-connection.h
dali/internal/window-system/common/window-render-surface.cpp
dali/internal/window-system/common/window-render-surface.h
dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.h
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h
dali/internal/window-system/ubuntu-x11/display-connection-impl-x.cpp
dali/internal/window-system/ubuntu-x11/display-connection-impl-x.h
dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.cpp
dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h
dali/public-api/adaptor-framework/application.h

index 85a4347..8444e89 100644 (file)
@@ -35,6 +35,29 @@ bool AddIdleWithReturnValue( Application application, CallbackBase* callback )
   return Internal::Adaptor::GetImplementation( application ).AddIdle( callback, true );
 }
 
+Dali::Window CreateWindow( Application application, PositionSize childPosSize, const std::string& childWindowName, const std::string& childWindowClassName, bool childWindowMode )
+{
+  auto& adaptor = Internal::Adaptor::GetImplementation( application ).GetAdaptor();
+
+  Dali::Window childWindow = Dali::Window::New( childPosSize, childWindowName, childWindowClassName, childWindowMode );
+  Internal::Adaptor::Adaptor::GetImplementation( adaptor ).AddWindow( &childWindow, childWindowName, childWindowClassName, childWindowMode );
+  return childWindow;
+}
+
+bool DestroyWindow( Application application, Dali::Window* childWindow )
+{
+  auto& adaptor = Internal::Adaptor::GetImplementation( application ).GetAdaptor();
+
+  return Internal::Adaptor::Adaptor::GetImplementation( adaptor ).RemoveWindow( childWindow );
+}
+
+bool DestroyWindow( Application application, const std::string& childWindowName )
+{
+  auto& adaptor = Internal::Adaptor::GetImplementation( application ).GetAdaptor();
+
+  return Internal::Adaptor::Adaptor::GetImplementation( adaptor ).RemoveWindow( childWindowName );
+}
+
 } // namespace DevelApplication
 
 } // namespace Dali
index 5ffbd2e..080d1db 100644 (file)
@@ -53,6 +53,37 @@ DALI_ADAPTOR_API void PreInitialize( int* argc, char** argv[] );
  */
 DALI_ADAPTOR_API bool AddIdleWithReturnValue( Application application, CallbackBase* callback );
 
+/**
+ * @brief Create and Add a child window to the application instance
+ * @param[in] application A handle to the Application
+ * @param[in] childPosSize The position and size of the child window to be created
+ * @param[in] childWindowName The title of the child window
+ * @param[in] childWindowClassName The class name of the child window
+ * @param[in] childWindowMode The mode of the newly created child window
+ * @return @c a window handle if added successfully, @c null otherwise
+ *
+ * @note Function must be called from main event thread only
+ */
+DALI_ADAPTOR_API Dali::Window CreateWindow( Application application, PositionSize childPosSize, const std::string& childWindowName, const std::string& childWindowClassName, bool childWindowMode );
+
+/**
+ * @brief Removes a previously created Window instance from the Adaptor internal list
+ * @note Function must be called from the main event thread only.
+ * @param[in] application A handle to the Application
+ * @param[in] childWindow The created Window instance
+ * @return true if removed successfully, false otherwise
+ */
+DALI_ADAPTOR_API bool DestroyWindow( Application application, Dali::Window* childWindow );
+
+/**
+ * @brief Removes a previously created Window instance from the Adaptor internal list
+ * @note Function must be called from the main event thread only.
+ * @param[in] application A handle to the Application
+ * @param[in] childWindowName The title of the window
+ * @return true if removed successfully, false otherwise
+ */
+DALI_ADAPTOR_API bool DestroyWindow( Application application, const std::string& childWindowName );
+
 } // namespace DevelApplication
 
 } // namespace Dali
index 8044163..f7a47ea 100755 (executable)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTEGRATION_ADAPTOR_H__
-#define __DALI_INTEGRATION_ADAPTOR_H__
+#ifndef DALI_INTEGRATION_ADAPTOR_H
+#define DALI_INTEGRATION_ADAPTOR_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -46,6 +46,7 @@ namespace Internal
 {
 namespace Adaptor
 {
+class GraphicsFactory;
 class Adaptor;
 }
 }
@@ -415,4 +416,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_ADAPTOR_H__
+#endif // DALI_INTEGRATION_ADAPTOR_H
index ceca9d3..e9e8921 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_RENDER_SURFACE_H__
-#define __DALI_RENDER_SURFACE_H__
+#ifndef DALI_RENDER_SURFACE_H
+#define DALI_RENDER_SURFACE_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
 
+
 namespace Dali
 {
 
-class EglInterface;
 class DisplayConnection;
 class ThreadSynchronizationInterface;
 
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class GraphicsInterface;
+
+} // namespace Adaptor
+
+} // namespace Internal
+
 namespace Integration
 {
 
@@ -95,32 +107,31 @@ public:
   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
 
   /**
-   * Initialize EGL, RenderSurface should create egl display and initialize
-   * @param egl implementation to use for the creation
+   * @brief InitializeGraphics the platform specific graphics surface interfaces
+   * @param[in] graphics The abstracted graphics interface
+   * @param[in] displayConnection The display connection interface
    */
-  virtual void InitializeEgl( EglInterface& egl ) = 0;
+  virtual void InitializeGraphics( Dali::Internal::Adaptor::GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) = 0;
 
   /**
-   * @brief Creates EGL Surface
-   * @param egl implementation to use for the creation
+   * @brief Creates the Surface
    */
-  virtual void CreateEglSurface( EglInterface& egl ) = 0;
+  virtual void CreateSurface() = 0;
 
   /**
-   * @brief Destroys EGL Surface
-   * @param egl implementation to use for the destruction
+   * @brief Destroys the Surface
    */
-  virtual void DestroyEglSurface( EglInterface& egl ) = 0;
+  virtual void DestroySurface() = 0;
 
   /**
-   * @brief Replace the EGL Surface
-   * @param egl implementation to use for the creation
+   * @brief Replace the Surface
    * @return true if context was lost
    */
-  virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
+  virtual bool ReplaceGraphicsSurface() = 0;
 
   /**
    * @brief Resizes the underlying surface.
+   * @param[in] The dimensions of the new position
    */
   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
 
@@ -139,23 +150,18 @@ public:
    * @brief Invoked by render thread before Core::Render
    * If the operation fails, then Core::Render should not be called until there is
    * a surface to render onto.
-   * @param[in] egl The Egl interface
-   * @param[in] glAbstraction OpenGLES abstraction interface
    * @param[in] resizingSurface True if the surface is being resized
    * @return True if the operation is successful, False if the operation failed
    */
-  virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) = 0;
+  virtual bool PreRender( bool resizingSurface ) = 0;
 
   /**
    * @brief Invoked by render thread after Core::Render
-   * @param[in] egl The Egl interface
-   * @param[in] glAbstraction OpenGLES abstraction interface
-   * @param[in] displayConnection display connection
+   * @param[in] renderToFbo True if render to FBO.
    * @param[in] replacingSurface True if the surface is being replaced.
    * @param[in] resizingSurface True if the surface is being resized.
    */
-  virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) = 0;
-
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) = 0;
   /**
    * @brief Invoked by render thread when the thread should be stop
    */
@@ -193,4 +199,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_RENDER_SURFACE_H__
+#endif // DALI_RENDER_SURFACE_H
diff --git a/dali/internal/adaptor/common/adaptor-builder-impl.cpp b/dali/internal/adaptor/common/adaptor-builder-impl.cpp
new file mode 100644 (file)
index 0000000..8ea291e
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
+#include <dali/internal/graphics/gles20/egl-graphics-factory.h>
+#include <dali/internal/window-system/common/display-utils.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+AdaptorBuilder::AdaptorBuilder()
+{
+  // Construct Graphics Factory
+  mGraphicsFactory = Utils::MakeUnique< GraphicsFactory >();
+}
+
+GraphicsFactory& AdaptorBuilder::GetGraphicsFactory() const
+{
+  return *mGraphicsFactory.get();
+}
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
diff --git a/dali/internal/adaptor/common/adaptor-builder-impl.h b/dali/internal/adaptor/common/adaptor-builder-impl.h
new file mode 100644 (file)
index 0000000..b382b4b
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef DALI_INTERNAL_ADAPTOR_BUILDER_IMPL_H
+#define DALI_INTERNAL_ADAPTOR_BUILDER_IMPL_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/internal/system/common/environment-options.h>
+#include <dali/internal/graphics/gles20/egl-graphics-factory.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Implementation of the Adaptor Builder class.
+ */
+class AdaptorBuilder
+{
+public:
+
+  /**
+   * Constructor
+   */
+  AdaptorBuilder();
+
+
+  /**
+   * Destructor
+   */
+  ~AdaptorBuilder() {};
+
+
+public:
+
+  /**
+   * @return reference to the GraphicsFactory object
+   */
+  GraphicsFactory& GetGraphicsFactory() const;
+
+
+private:
+  // Eliminate copy and assigned operations
+  AdaptorBuilder(const AdaptorBuilder&) = delete;
+  AdaptorBuilder& operator=(AdaptorBuilder&) = delete;
+
+
+private:
+  std::unique_ptr< GraphicsFactory > mGraphicsFactory; ///< GraphicsFactory object
+
+};
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // DALI_INTERNAL_ADAPTOR_BUILDER_IMPL_H
index 272a019..149064e 100755 (executable)
@@ -17,6 +17,7 @@
 
 // CLASS HEADER
 #include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/stage.h>
@@ -36,6 +37,9 @@
 #include <dali/internal/system/common/performance-interface-factory.h>
 #include <dali/internal/adaptor/common/lifecycle-observer.h>
 
+#include <dali/internal/graphics/gles20/egl-graphics-factory.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h> // Temporary until Core is abstracted
+
 #include <dali/devel-api/text-abstraction/font-client.h>
 
 #include <dali/internal/system/common/callback-manager.h>
@@ -47,7 +51,6 @@
 #include <dali/internal/graphics/gles20/gl-implementation.h>
 #include <dali/internal/graphics/gles20/egl-sync-implementation.h>
 #include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
 #include <dali/internal/clipboard/common/clipboard-impl.h>
 #include <dali/internal/graphics/common/vsync-monitor.h>
 #include <dali/internal/system/common/object-profiler.h>
@@ -61,6 +64,7 @@
 #include <dali/internal/system/common/locale-utils.h>
 #include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
 
+
 using Dali::TextAbstraction::FontClient;
 
 namespace Dali
@@ -77,13 +81,18 @@ namespace
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 } // unnamed namespace
 
+
 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
   Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
   adaptor->mImpl = impl;
 
-  impl->Initialize(configuration);
+  Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder();
+  auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
+
+  impl->Initialize( graphicsFactory, configuration );
+  delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created
 
   return adaptor;
 }
@@ -92,13 +101,34 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLo
 {
   Any winId = window.GetNativeHandle();
 
-  Window& windowImpl = Dali::GetImplementation(window);
+  Window& windowImpl = Dali::GetImplementation( window );
   Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
-  windowImpl.SetAdaptor(*adaptor);
+  windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 }
 
-void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+{
+  Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
+  Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); // Impl adaptor
+  adaptor->mImpl = impl;
+
+  impl->Initialize( graphicsFactory, configuration );
+
+  return adaptor;
+} // Called second
+
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+{
+  Any winId = window.GetNativeHandle();
+
+  Window& windowImpl = Dali::GetImplementation( window );
+  Dali::Adaptor* adaptor = New( graphicsFactory, winId, windowImpl.GetSurface(), configuration, environmentOptions );
+  windowImpl.SetAdaptor( *adaptor );
+  return adaptor;
+} // Called first
+
+void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration )
 {
   // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
   Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
@@ -116,8 +146,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
   {
     dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
   }
-  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
-  // files automatically.
+
+  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from files automatically.
 
   if( mEnvironmentOptions->PerformanceServerRequired() )
   {
@@ -129,35 +159,28 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
 
   mCallbackManager = CallbackManager::New();
 
-  PositionSize size = mSurface->GetPositionSize();
+  WindowPane defaultWindow = mWindowFrame.front();
+  PositionSize size = defaultWindow.surface->GetPositionSize();
 
   mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
 
-  if( mEnvironmentOptions->GetGlesCallTime() > 0 )
-  {
-    mGLES = new GlProxyImplementation( *mEnvironmentOptions );
-  }
-  else
-  {
-    mGLES = new GlImplementation();
-  }
-
-  const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
-  const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
+  mGraphics = &( graphicsFactory.Create() );
+  mGraphics->Initialize( mEnvironmentOptions );
 
-  mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
+  auto eglGraphics = static_cast<EglGraphics *>( mGraphics ); // This interface is temporary until Core has been updated to match
 
-  EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
+  GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+  EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation();
 
   mCore = Integration::Core::New( *this,
                                   *mPlatformAbstraction,
-                                  *mGLES,
-                                  *eglSyncImpl,
+                                  mGLES,
+                                  eglSyncImpl,
                                   *mGestureManager,
                                   dataRetentionPolicy ,
                                   ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
-                                  depthBufferAvailable,
-                                  stencilBufferAvailable );
+                                  mGraphics->GetDepthBufferRequired(),
+                                  mGraphics->GetStencilBufferRequired() );
 
   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
   if( 0u < timeInterval )
@@ -169,6 +192,15 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
 
   mVSyncMonitor = new VSyncMonitor;
 
+  if( defaultWindow.surface )
+  {
+    mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow.surface->GetSurfaceType() );
+  }
+  else
+  {
+    mDisplayConnection = Dali::DisplayConnection::New( *mGraphics );
+  }
+
   mThreadController = new ThreadController( *this, *mEnvironmentOptions );
 
   // Should be called after Core creation
@@ -265,13 +297,15 @@ Adaptor::~Adaptor()
   delete mObjectProfiler;
 
   delete mCore;
-  delete mEglFactory;
-  delete mGLES;
+
   delete mGestureManager;
+  delete mDisplayConnection;
   delete mPlatformAbstraction;
   delete mCallbackManager;
   delete mPerformanceInterface;
 
+  mGraphics->Destroy();
+
   // uninstall it on this thread (main actor thread)
   Dali::Integration::Log::UninstallLogFunction();
 
@@ -284,8 +318,7 @@ Adaptor::~Adaptor()
 
 void Adaptor::Start()
 {
-  // it doesn't support restart after stop at this moment
-  // to support restarting, need more testing
+  // It doesn't support restart after stop at this moment to support restarting, need more testing
   if( READY != mState )
   {
     return;
@@ -294,8 +327,10 @@ void Adaptor::Start()
   // Start the callback manager
   mCallbackManager->Start();
 
-  // create event handler
-  mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
+  WindowPane defaultWindow = mWindowFrame.front();
+
+  // Create event handler
+  mEventHandler = new EventHandler( defaultWindow.surface, *this, *mGestureManager, *this, mDragAndDropDetector );
 
   if( mDeferredRotationObserver != NULL )
   {
@@ -305,7 +340,8 @@ void Adaptor::Start()
 
   unsigned int dpiHor, dpiVer;
   dpiHor = dpiVer = 0;
-  mSurface->GetDpi( dpiHor, dpiVer );
+
+  defaultWindow.surface->GetDpi( dpiHor, dpiVer );
 
   // tell core about the DPI value
   mCore->SetDpi(dpiHor, dpiVer);
@@ -315,7 +351,8 @@ void Adaptor::Start()
   fontClient.SetDpi( dpiHor, dpiVer );
 
   // Tell the core the size of the surface just before we start the render-thread
-  PositionSize size = mSurface->GetPositionSize();
+  PositionSize size = defaultWindow.surface->GetPositionSize();
+
   mCore->SurfaceResized( size.width, size.height );
 
   // Initialize the thread controller
@@ -378,7 +415,7 @@ void Adaptor::Resume()
       (*iter)->OnResume();
     }
 
-    // trigger processing of events queued up while paused
+    // Trigger processing of events queued up while paused
     mCore->ProcessEvents();
 
     // Do at end to ensure our first update/render after resumption includes the processed messages as well
@@ -399,6 +436,9 @@ void Adaptor::Stop()
 
     mThreadController->Stop();
 
+    // Clear out all the handles to Windows
+    mWindowFrame.clear();
+
     // Delete the TTS player
     for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
     {
@@ -451,34 +491,45 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
   mEventHandler->FeedKeyEvent( keyEvent );
 }
 
-void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
+void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& newSurface )
 {
-  PositionSize positionSize = surface.GetPositionSize();
+  PositionSize positionSize = newSurface.GetPositionSize();
 
-  // let the core know the surface size has changed
+  // Let the core know the surface size has changed
   mCore->SurfaceResized( positionSize.width, positionSize.height );
 
   mResizedSignal.Emit( mAdaptor );
 
-  mNativeWindow = nativeWindow;
-  mSurface = &surface;
+  WindowPane newDefaultWindow;
+  newDefaultWindow.nativeWindow = nativeWindow;
+  newDefaultWindow.surface = &newSurface;
+
+  // Must delete the old Window first before replacing it with the new one
+  WindowPane oldDefaultWindow = mWindowFrame.front();
+  oldDefaultWindow.surface->DestroySurface();
 
-  // flush the event queue to give the update-render thread chance
+  // Update WindowFrame
+  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
+  iter = mWindowFrame.insert( iter, newDefaultWindow );
+
+  // Flush the event queue to give the update-render thread chance
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
 
-  // this method blocks until the render thread has completed the replace.
-  mThreadController->ReplaceSurface(mSurface);
+  // This method blocks until the render thread has completed the replace.
+  mThreadController->ReplaceSurface( newDefaultWindow.surface );
 }
 
 RenderSurface& Adaptor::GetSurface() const
 {
-  return *mSurface;
+  WindowPane defaultWindow = mWindowFrame.front();
+  return *(defaultWindow.surface);
 }
 
 void Adaptor::ReleaseSurfaceLock()
 {
-  mSurface->ReleaseLock();
+  WindowPane defaultWindow = mWindowFrame.front();
+  defaultWindow.surface->ReleaseLock();
 }
 
 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
@@ -515,6 +566,52 @@ 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 )
+{
+  // This is any Window that is not the main (default) one
+  WindowPane additionalWindow;
+  additionalWindow.instance = childWindow;
+  additionalWindow.window_name = childWindowName;
+  additionalWindow.class_name = childWindowClassName;
+  additionalWindow.window_mode = childWindowMode;
+
+  // Add the new Window to the Frame - the order is not important
+  mWindowFrame.push_back( additionalWindow );
+
+  Window& windowImpl = Dali::GetImplementation( *childWindow );
+  windowImpl.SetAdaptor( Get() );
+
+  return true;
+}
+
+bool Adaptor::RemoveWindow( Dali::Window* childWindow )
+{
+  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  {
+    if( iter->instance == childWindow )
+    {
+      mWindowFrame.erase( iter );
+      return true;
+    }
+  }
+
+  return false;
+}
+
+bool Adaptor::RemoveWindow( std::string childWindowName )
+{
+  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  {
+    if( iter->window_name == childWindowName )
+    {
+      mWindowFrame.erase( iter );
+      return true;
+    }
+  }
+
+  return false;
+}
+
 Dali::Adaptor& Adaptor::Get()
 {
   DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
@@ -546,21 +643,16 @@ void Adaptor::SetUseHardwareVSync( bool useHardware )
   mVSyncMonitor->SetUseHardwareVSync( useHardware );
 }
 
-EglFactory& Adaptor::GetEGLFactory() const
+Dali::DisplayConnection& Adaptor::GetDisplayConnectionInterface()
 {
-  DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
-  return *mEglFactory;
+  DALI_ASSERT_DEBUG( mDisplayConnection && "Display connection not created" );
+  return *mDisplayConnection;
 }
 
-EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
+GraphicsInterface& Adaptor::GetGraphicsInterface()
 {
-  return *mEglFactory;
-}
-
-Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
-{
-  DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
-  return *mGLES;
+  DALI_ASSERT_DEBUG( mGraphics && "Graphics interface not created" );
+  return *mGraphics;
 }
 
 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
@@ -568,11 +660,6 @@ Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface
   return *mPlatformAbstraction;
 }
 
-Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
-{
-  return *mGLES;
-}
-
 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
 {
   return *mNotificationTrigger;
@@ -590,7 +677,15 @@ SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
 
 RenderSurface* Adaptor::GetRenderSurfaceInterface()
 {
-  return mSurface;
+  if( !mWindowFrame.empty())
+  {
+    WindowPane defaultWindow = mWindowFrame.front();
+    return defaultWindow.surface;
+  }
+  else
+  {
+    return nullptr;
+  }
 }
 
 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
@@ -660,22 +755,22 @@ void Adaptor::SetMinimumPinchDistance(float distance)
 
 Any Adaptor::GetNativeWindowHandle()
 {
-  return mNativeWindow;
+  WindowPane defaultWindow = mWindowFrame.front();
+  return defaultWindow.nativeWindow;
 }
 
 Any Adaptor::GetGraphicsDisplay()
 {
   Any display;
 
-  if( mEglFactory )
+  if (mGraphics)
   {
-    EglInterface* egl = mEglFactory->GetImplementation();
-    if( egl )
-    {
-      auto eglImpl = static_cast<EglImplementation*>(egl);
-      display = eglImpl->GetDisplay();
-    }
+    auto eglGraphics = static_cast<EglGraphics *>( mGraphics ); // This interface is temporary until Core has been updated to match
+
+    EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    display = eglImpl.GetDisplay();
   }
+
   return display;
 }
 
@@ -802,7 +897,7 @@ void Adaptor::OnDamaged( const DamageArea& area )
 
 void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
 {
-  // let the core know the surface size has changed
+  // Let the core know the surface size has changed
   mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
 
   mResizedSignal.Emit( mAdaptor );
@@ -810,7 +905,7 @@ void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
 
 void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
 {
-  // flush the event queue to give the update-render thread chance
+  // Flush the event queue to give the update-render thread chance
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
 
@@ -824,7 +919,7 @@ void Adaptor::NotifySceneCreated()
   // Start thread controller after the scene has been created
   mThreadController->Start();
 
-  // process after surface is created (registering to remote surface provider if required)
+  // Process after surface is created (registering to remote surface provider if required)
   SurfaceInitialized();
 
   mState = RUNNING;
@@ -855,7 +950,7 @@ void Adaptor::RequestUpdateOnce()
 
 void Adaptor::IndicatorSizeChanged(int height)
 {
-  // let the core know the indicator height is changed
+  // Let the core know the indicator height is changed
   mCore->SetTopMargin(height);
 }
 
@@ -874,37 +969,41 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac
   mLanguageChangedSignal(),
   mAdaptor( adaptor ),
   mState( READY ),
-  mCore( NULL ),
-  mThreadController( NULL ),
-  mVSyncMonitor( NULL ),
-  mGLES( NULL ),
-  mGlSync( NULL ),
-  mEglFactory( NULL ),
-  mNativeWindow( nativeWindow ),
-  mSurface( surface ),
-  mPlatformAbstraction( NULL ),
-  mEventHandler( NULL ),
-  mCallbackManager( NULL ),
+  mCore( nullptr ),
+  mThreadController( nullptr ),
+  mVSyncMonitor( nullptr ),
+  mDisplayConnection( nullptr ),
+  mPlatformAbstraction( nullptr ),
+  mEventHandler( nullptr ),
+  mCallbackManager( nullptr ),
   mNotificationOnIdleInstalled( false ),
-  mNotificationTrigger( NULL ),
-  mGestureManager( NULL ),
+  mNotificationTrigger( nullptr ),
+  mGestureManager( nullptr ),
   mDaliFeedbackPlugin(),
-  mFeedbackController( NULL ),
+  mFeedbackController( nullptr ),
   mTtsPlayers(),
   mObservers(),
   mDragAndDropDetector(),
-  mDeferredRotationObserver( NULL ),
+  mDeferredRotationObserver( nullptr ),
   mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
-  mPerformanceInterface( NULL ),
+  mPerformanceInterface( nullptr ),
   mKernelTracer(),
   mSystemTracer(),
   mTriggerEventFactory(),
-  mObjectProfiler( NULL ),
+  mObjectProfiler( nullptr ),
   mSocketFactory(),
   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
   mUseRemoteSurface( false )
 {
   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
+
+  WindowPane defaultWindow;
+  defaultWindow.nativeWindow = nativeWindow;
+  defaultWindow.surface = surface;
+
+  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
+  iter = mWindowFrame.insert( iter, defaultWindow );
+
   gThreadLocalAdaptor = this;
 }
 
@@ -912,7 +1011,9 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac
 
 void Adaptor::SetViewMode( ViewMode viewMode )
 {
-  mSurface->SetViewMode( viewMode );
+  WindowPane defaultWindow = mWindowFrame.front();
+  defaultWindow.surface->SetViewMode( viewMode );
+
   mCore->SetViewMode( viewMode );
 }
 
index 53e9c43..26c3bb7 100755 (executable)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_ADAPTOR_IMPL_H__
-#define __DALI_INTERNAL_ADAPTOR_IMPL_H__
+#ifndef DALI_INTERNAL_ADAPTOR_IMPL_H
+#define DALI_INTERNAL_ADAPTOR_IMPL_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -31,6 +31,8 @@
 #include <dali/public-api/adaptor-framework/tts-player.h>
 #include <dali/devel-api/adaptor-framework/clipboard.h>
 
+#include <dali/internal/graphics/common/graphics-interface.h>
+
 #include <dali/internal/legacy/common/tizen-platform-abstraction.h>
 #include <dali/internal/adaptor/common/adaptor-internal-services.h>
 #include <dali/internal/system/common/environment-options.h>
@@ -43,6 +45,7 @@
 #include <dali/integration-api/trigger-event-factory.h>
 #include <dali/internal/network/common/socket-factory.h>
 
+
 namespace Dali
 {
 
@@ -60,8 +63,9 @@ namespace Internal
 
 namespace Adaptor
 {
+class DisplayConnection;
+class GraphicsFactory;
 class EventHandler;
-class EglFactory;
 class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
@@ -111,12 +115,44 @@ 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, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions );
+  static Dali::Adaptor* New( Dali::Window window,
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
+
+  /**
+   * Creates a New Adaptor
+   * @param[in]  graphicsFactory     A factory that creates the graphics interface
+   * @param[in]  nativeWindow        Native window handle
+   * @param[in]  surface             A render surface can be one of the following
+   *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
+   *                                  - Window, adaptor will use existing Window to draw on to
+   * @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( GraphicsFactory& graphicsFactory,
+                             Any nativeWindow,
+                             RenderSurface* surface,
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
+
+  /**
+   * Creates a New Adaptor
+   * @param[in]  graphicsFactory     A factory that creates the graphics interface
+   * @param[in]  nativeWindow        native window handle
+   * @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( GraphicsFactory& graphicsFactory,
+                             Dali::Window window,
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
 
   /**
    * 2-step initialisation, this should be called after creating an adaptor instance.
+   * @param[in]  graphicsFactory     A factory that creates the graphics interface
+   * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
    */
-  void Initialize(Dali::Configuration::ContextLoss configuration);
+  void Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration );
 
   /**
    * Virtual destructor.
@@ -212,6 +248,31 @@ public: // AdaptorInternalServices implementation
   virtual bool AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd );
 
   /**
+   * Adds a new Window instance to the Adaptor
+   * @param[in]  childWindow The child window instance
+   * @param[in]  childWindowName The child window title/name
+   * @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,
+                          const std::string& childWindowName,
+                          const std::string& childWindowClassName,
+                          const bool& childWindowMode );
+
+  /**
+   * Removes an existing Window instance from the Adaptor
+   * @param[in]  window The Window instance
+   */
+  virtual bool RemoveWindow( Dali::Window* childWindow );
+
+  /**
+   * Removes an existing Window instance from the Adaptor
+   * @param[in]  windowName The Window name
+   * @note If two Windows have the same name, the first one that matches will be removed
+   */
+  virtual bool RemoveWindow( std::string childWindowName );
+
+  /**
    * @copydoc Dali::Adaptor::RemoveIdle()
    */
   virtual void RemoveIdle( CallbackBase* callback );
@@ -239,17 +300,6 @@ public:
   void SetUseHardwareVSync(bool useHardware);
 
   /**
-   * @return reference to EglFactory class
-   */
-  EglFactory& GetEGLFactory() const;
-
-  /**
-   * Return GlAbstraction.
-   * @return the GlAbstraction.
-   */
-  Integration::GlAbstraction& GetGlAbstraction() const;
-
-  /**
    * Return the PlatformAbstraction.
    * @return The PlatformAbstraction.
    */
@@ -269,7 +319,7 @@ public:
   void SetRotationObserver( RotationObserver* observer );
 
   /**
-   * Destroy the TtsPlayer of sepcific mode.
+   * Destroy the TtsPlayer of specific mode.
    * @param[in] mode The mode of TtsPlayer to destroy
    */
   void DestroyTtsPlayer(Dali::TtsPlayer::Mode mode);
@@ -297,7 +347,7 @@ public:
   Any GetGraphicsDisplay();
 
   /**
-   * Sets use remote surface for eglSurface output
+   * Sets use remote surface for Surface output
    * @param[in] useRemoteSurface True if the remote surface is used
    */
   void SetUseRemoteSurface(bool useRemoteSurface);
@@ -382,14 +432,14 @@ public:  //AdaptorInternalServices
   virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface();
 
   /**
-   * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGlesInterface()
+   * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetDisplayConnectionInterface()
    */
-  virtual Dali::Integration::GlAbstraction& GetGlesInterface();
+  virtual Dali::DisplayConnection& GetDisplayConnectionInterface();
 
   /**
-  * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetEGLFactoryInterface()
-  */
-  virtual EglFactoryInterface& GetEGLFactoryInterface() const;
+   * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGraphicsInterface()
+   */
+  virtual GraphicsInterface& GetGraphicsInterface();
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
@@ -517,8 +567,8 @@ private: // From Dali::Internal::Adaptor::DamageObserver
 private:
 
   // Undefined
-  Adaptor(const Adaptor&);
-  Adaptor& operator=(Adaptor&);
+  Adaptor(const Adaptor&) = delete;
+  Adaptor& operator=(Adaptor&) = delete;
 
 private:
 
@@ -589,6 +639,19 @@ private: // Types
     STOPPED,             ///< Adaptor has been stopped.
   };
 
+  // A structure to encapsulate each Window instance for the Adaptor to track them
+  typedef struct WindowPane
+  {
+    Dali::Window*  instance;     ///< Window object
+    std::string    window_name;  ///< Name (title)_of the window
+    std::string    class_name;   ///< Class name that the window belongs to
+    bool           window_mode;  ///< Display mode of the window
+    Any            nativeWindow; ///< window identifier
+    RenderSurface* surface;      ///< The surface the Window is bound to
+  } WindowPane;
+
+  typedef std::vector<WindowPane> WindowFrames;
+
   typedef std::vector<LifeCycleObserver*>  ObserverContainer;
 
 private: // Data
@@ -601,12 +664,11 @@ private: // Data
   Dali::Integration::Core*              mCore;                        ///< Dali Core
   ThreadController*                     mThreadController;            ///< Controls the threads
   VSyncMonitor*                         mVSyncMonitor;                ///< Monitors VSync events
-  GlImplementation*                     mGLES;                        ///< GL implementation
-  GlSyncImplementation*                 mGlSync;                      ///< GL Sync implementation
-  EglFactory*                           mEglFactory;                  ///< EGL Factory
 
-  Any                                   mNativeWindow;                ///< window identifier
-  RenderSurface*                        mSurface;                     ///< Current surface
+  GraphicsInterface*                    mGraphics;                    ///< Graphics interface
+  Dali::DisplayConnection*              mDisplayConnection;           ///< Display connection
+  WindowFrames                          mWindowFrame;                 ///< A container of all the Windows that are currently created
+
   TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
 
   EventHandler*                         mEventHandler;                ///< event handler
@@ -629,8 +691,9 @@ private: // Data
   SocketFactory                         mSocketFactory;               ///< Socket factory
   const bool                            mEnvironmentOptionsOwned:1;   ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
   bool                                  mUseRemoteSurface;            ///< whether the remoteSurface is used or not
+
 public:
-  inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
+  inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) { return *adaptor.mImpl; }
 };
 
 } // namespace Internal
@@ -639,4 +702,4 @@ public:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_ADAPTOR_IMPL_H__
+#endif // DALI_INTERNAL_ADAPTOR_IMPL_H
index 5d52f9a..0cc2d32 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H__
-#define __DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H__
+#ifndef DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H
+#define DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H
 
 /*
  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
@@ -25,6 +25,8 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/trigger-event-interface.h>
 #include <dali/integration-api/trigger-event-factory-interface.h>
+#include <dali/internal/window-system/common/display-connection.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 #include <dali/internal/graphics/gles20/egl-factory-interface.h>
 #include <dali/internal/network/common/socket-factory-interface.h>
 #include <dali/internal/system/common/performance-interface.h>
@@ -61,23 +63,26 @@ public:
   /**
    * @return platform abstraction
    */
-  virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface()  = 0;
+  virtual Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface() = 0;
 
   /**
-   * @return gles abstraction
+   * Used to access the Display Connection interface from the Render thread
+   * @return the Display Connection interface
    */
-  virtual Dali::Integration::GlAbstraction& GetGlesInterface()  = 0;
+  virtual Dali::DisplayConnection& GetDisplayConnectionInterface() = 0;
 
   /**
-   * @return egl factory
+   * Used to access the abstracted graphics interface
+   * This also contains the depth and stencil buffers
+   * @return the graphics interface
    */
-  virtual EglFactoryInterface& GetEGLFactoryInterface() const  = 0;
+  virtual GraphicsInterface& GetGraphicsInterface() = 0;
 
   /**
    * Used by update-thread to notify core (main-thread) it has messages to process
    * @return trigger event ProcessCoreEvents
    */
-  virtual TriggerEventInterface& GetProcessCoreEventsTrigger()  = 0;
+  virtual TriggerEventInterface& GetProcessCoreEventsTrigger() = 0;
 
   /**
    * @return trigger event factory interface
@@ -92,27 +97,27 @@ public:
   /**
    * @return render surface
    */
-  virtual RenderSurface* GetRenderSurfaceInterface()  = 0;
+  virtual RenderSurface* GetRenderSurfaceInterface() = 0;
 
   /**
    * @return vsync monitor interface
    */
-  virtual VSyncMonitorInterface* GetVSyncMonitorInterface()  = 0;
+  virtual VSyncMonitorInterface* GetVSyncMonitorInterface() = 0;
 
   /**
    * @return performance interface
    */
-  virtual PerformanceInterface* GetPerformanceInterface()  = 0;
+  virtual PerformanceInterface* GetPerformanceInterface() = 0;
 
   /**
    * @return interface for logging to the kernel ( e.g. using ftrace )
    */
-  virtual TraceInterface& GetKernelTraceInterface()  = 0;
+  virtual TraceInterface& GetKernelTraceInterface() = 0;
 
   /**
    * @return system trace interface, e.g. for using Tizen Trace (ttrace) or Android Trace (atrace)
    */
-  virtual TraceInterface& GetSystemTraceInterface()  = 0;
+  virtual TraceInterface& GetSystemTraceInterface() = 0;
 
 
 protected:
@@ -132,10 +137,10 @@ protected:
   };
 
   // Undefined copy constructor.
-  AdaptorInternalServices( const AdaptorInternalServices& );
+  AdaptorInternalServices( const AdaptorInternalServices& ) = delete;
 
   // Undefined assignment operator.
-  AdaptorInternalServices& operator=( const AdaptorInternalServices& );
+  AdaptorInternalServices& operator=( const AdaptorInternalServices& ) = delete;
 };
 
 } // namespace Internal
@@ -144,4 +149,4 @@ protected:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H__
+#endif // DALI_INTERNAL_ADAPTOR_INTERNAL_SERVICES_H
index d2ccfda..47c42d5 100644 (file)
@@ -24,7 +24,6 @@
 // INTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/style-monitor.h>
 #include <dali/internal/system/common/command-line-options.h>
-#include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/adaptor/common/framework.h>
 #include <dali/internal/system/common/singleton-service-impl.h>
 #include <dali/internal/adaptor/common/lifecycle-controller-impl.h>
@@ -88,15 +87,16 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee
   mRegionChangedSignal(),
   mBatteryLowSignal(),
   mMemoryLowSignal(),
-  mEventLoop( NULL ),
-  mFramework( NULL ),
+  mEventLoop( nullptr ),
+  mFramework( nullptr ),
   mContextLossConfiguration( Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS ),
-  mCommandLineOptions( NULL ),
+  mCommandLineOptions( nullptr ),
   mSingletonService( SingletonService::New() ),
-  mAdaptor( NULL ),
-  mWindow(),
-  mWindowMode( windowMode ),
-  mName(),
+  mAdaptorBuilder( nullptr ),
+  mAdaptor( nullptr ),
+  mMainWindow(),
+  mMainWindowMode( windowMode ),
+  mMainWindowName(),
   mStylesheet( stylesheet ),
   mEnvironmentOptions(),
   mWindowPositionSize( positionSize ),
@@ -104,11 +104,11 @@ Application::Application( int* argc, char** argv[], const std::string& styleshee
   mSlotDelegate( this )
 {
   // Get mName from environment options
-  mName = mEnvironmentOptions.GetWindowName();
-  if( mName.empty() && argc && ( *argc > 0 ) )
+  mMainWindowName = mEnvironmentOptions.GetWindowName();
+  if( mMainWindowName.empty() && argc && ( *argc > 0 ) )
   {
     // Set mName from command-line args if environment option not set
-    mName = (*argv)[0];
+    mMainWindowName = (*argv)[0];
   }
 
   mCommandLineOptions = new CommandLineOptions(argc, argv);
@@ -120,8 +120,9 @@ Application::~Application()
 {
   mSingletonService.UnregisterAll();
 
-  mWindow.Reset();
+  mMainWindow.Reset();
   delete mAdaptor;
+  delete mAdaptorBuilder;
   delete mCommandLineOptions;
   delete mFramework;
 }
@@ -145,29 +146,36 @@ void Application::CreateWindow()
   }
 
   const std::string& windowClassName = mEnvironmentOptions.GetWindowClassName();
-  mWindow = Dali::Window::New( mWindowPositionSize, mName, windowClassName, mWindowMode == Dali::Application::TRANSPARENT );
+  mMainWindow = Dali::Window::New( mWindowPositionSize, mMainWindowName, windowClassName, mMainWindowMode == Dali::Application::TRANSPARENT );
 
   int indicatorVisibleMode = mEnvironmentOptions.GetIndicatorVisibleMode();
   if( indicatorVisibleMode >= Dali::Window::INVISIBLE && indicatorVisibleMode <= Dali::Window::AUTO )
   {
-    GetImplementation( mWindow ).SetIndicatorVisibleMode( static_cast< Dali::Window::IndicatorVisibleMode >( indicatorVisibleMode ) );
+    GetImplementation( mMainWindow ).SetIndicatorVisibleMode( static_cast< Dali::Window::IndicatorVisibleMode >( indicatorVisibleMode ) );
   }
 
   // Quit the application when the window is closed
-  GetImplementation( mWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit );
+  GetImplementation( mMainWindow ).DeleteRequestSignal().Connect( mSlotDelegate, &Application::Quit );
 }
 
 void Application::CreateAdaptor()
 {
-  DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" );
+  DALI_ASSERT_ALWAYS( mMainWindow && "Window required to create adaptor" );
 
-  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions );
+  auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
+
+  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( graphicsFactory, mMainWindow, mContextLossConfiguration, &mEnvironmentOptions );
 
   mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
 
   Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).SetUseRemoteSurface( mUseRemoteSurface );
 }
 
+void Application::CreateAdaptorBuilder()
+{
+  mAdaptorBuilder = new AdaptorBuilder();
+}
+
 void Application::MainLoop(Dali::Configuration::ContextLoss configuration)
 {
   mContextLossConfiguration = configuration;
@@ -179,7 +187,7 @@ void Application::MainLoop(Dali::Configuration::ContextLoss configuration)
 void Application::Lower()
 {
   // Lower the application without quitting it.
-  mWindow.Lower();
+  mMainWindow.Lower();
 }
 
 void Application::Quit()
@@ -199,6 +207,8 @@ void Application::QuitFromMainLoop()
 
 void Application::DoInit()
 {
+  CreateAdaptorBuilder();
+
   // If an application was pre-initialized, a window was made in advance
   if( mLaunchpadState == Launchpad::NONE )
   {
@@ -246,7 +256,7 @@ void Application::DoTerminate()
     mAdaptor->Stop();
   }
 
-  mWindow.Reset();
+  mMainWindow.Reset(); // This only resets (clears) the default Window
 }
 
 void Application::DoPause()
@@ -289,7 +299,7 @@ void Application::OnInit()
 
 void Application::OnTerminate()
 {
-  // we've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
+  // We've been told to quit by AppCore, ecore_x_destroy has been called, need to quit synchronously
   // delete the window as ecore_x has been destroyed by AppCore
 
   Dali::Application application(this);
@@ -394,7 +404,7 @@ Dali::Adaptor& Application::GetAdaptor()
 
 Dali::Window Application::GetWindow()
 {
-  return mWindow;
+  return mMainWindow;
 }
 
 // Stereoscopy
@@ -419,10 +429,9 @@ float Application::GetStereoBase() const
   return Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).GetStereoBase();
 }
 
-
 void Application::ReplaceWindow( const PositionSize& positionSize, const std::string& name )
 {
-  Dali::Window newWindow = Dali::Window::New( positionSize, name, mWindowMode == Dali::Application::TRANSPARENT );
+  Dali::Window newWindow = Dali::Window::New( positionSize, name, mMainWindowMode == Dali::Application::TRANSPARENT );
   Window& windowImpl = GetImplementation(newWindow);
   windowImpl.SetAdaptor(*mAdaptor);
 
@@ -436,7 +445,7 @@ void Application::ReplaceWindow( const PositionSize& positionSize, const std::st
 
   Any nativeWindow = newWindow.GetNativeHandle();
   Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface);
-  mWindow = newWindow;
+  mMainWindow = newWindow;
   mWindowPositionSize = positionSize;
 }
 
@@ -450,7 +459,6 @@ void Application::SetStyleSheet( const std::string& stylesheet )
   mStylesheet = stylesheet;
 }
 
-
 ApplicationPtr Application::GetPreInitializedApplication()
 {
   return gPreInitializedApplication;
index 2a16014..e906520 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_APPLICATION_H__
-#define __DALI_INTERNAL_APPLICATION_H__
+#ifndef DALI_INTERNAL_APPLICATION_H
+#define DALI_INTERNAL_APPLICATION_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -29,6 +29,7 @@
 #include <dali/internal/adaptor/common/framework.h>
 #include <dali/internal/window-system/common/window-impl.h>
 #include <dali/internal/system/common/environment-options.h>
+#include <dali/internal/adaptor/common/adaptor-builder-impl.h>
 
 namespace Dali
 {
@@ -376,6 +377,11 @@ protected:
   void CreateAdaptor();
 
   /**
+   * Creates the adaptor builder
+   */
+  void CreateAdaptorBuilder();
+
+  /**
    * Quits from the main loop
    */
   void QuitFromMainLoop();
@@ -402,16 +408,21 @@ private:
   Dali::Configuration::ContextLoss      mContextLossConfiguration;
   CommandLineOptions*                   mCommandLineOptions;
 
-  Dali::SingletonService                mSingletonService;
-  Dali::Adaptor*                        mAdaptor;
-  Dali::Window                          mWindow;
-  Dali::Application::WINDOW_MODE        mWindowMode;
-  std::string                           mName;
-  std::string                           mStylesheet;
-  EnvironmentOptions                    mEnvironmentOptions;
-  PositionSize                          mWindowPositionSize;
-  Launchpad::State                      mLaunchpadState;
-  bool                                  mUseRemoteSurface;
+  Dali::SingletonService                   mSingletonService;
+  Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder;   ///< The adaptor builder
+  Dali::Adaptor*                           mAdaptor;
+
+  // The Main Window is that window created by the Application during initial startup
+  // (previously this was the only window)
+  Dali::Window                             mMainWindow;       ///< Main Window instance
+  Dali::Application::WINDOW_MODE           mMainWindowMode;   ///< Window mode of the main window
+  std::string                              mMainWindowName;   ///< Name of the main window as obtained from environment options
+
+  std::string                              mStylesheet;
+  EnvironmentOptions                       mEnvironmentOptions;
+  PositionSize                             mWindowPositionSize;
+  Launchpad::State                         mLaunchpadState;
+  bool                                     mUseRemoteSurface;
 
   SlotDelegate< Application >           mSlotDelegate;
 
@@ -429,7 +440,7 @@ inline Application& GetImplementation(Dali::Application& application)
 
 inline const Application& GetImplementation(const Dali::Application& application)
 {
-  DALI_ASSERT_ALWAYS(application && "Timre handle is empty");
+  DALI_ASSERT_ALWAYS(application && "application handle is empty");
 
   const BaseObject& handle = application.GetBaseObject();
 
@@ -443,4 +454,4 @@ inline const Application& GetImplementation(const Dali::Application& application
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_APPLICATION_H__
+#endif // DALI_INTERNAL_APPLICATION_H
index 60ce74c..a73104a 100644 (file)
@@ -87,7 +87,6 @@ const unsigned int MAXIMUM_UPDATE_REQUESTS = 2;
 CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions )
 : mFpsTracker( environmentOptions ),
   mUpdateStatusLogger( environmentOptions ),
-  mRenderHelper( adaptorInterfaces ),
   mEventThreadSemaphore(),
   mUpdateRenderThreadWaitCondition(),
   mAdaptorInterfaces( adaptorInterfaces ),
@@ -154,7 +153,7 @@ void CombinedUpdateRenderController::Initialize()
   int error = pthread_create( mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this );
   DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() when creating UpdateRenderThread" );
 
-  // The Update/Render thread will now run and initialise EGL etc. and will then wait for Start to be called
+  // The Update/Render thread will now run and initialise the graphics interface etc. and will then wait for Start to be called
   // When this function returns, the application initialisation on the event thread should occur
 }
 
@@ -170,7 +169,11 @@ void CombinedUpdateRenderController::Start()
     sem_wait( &mEventThreadSemaphore );
   }
 
-  mRenderHelper.Start();
+  RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+  if( currentSurface )
+  {
+    currentSurface->StartRender();
+  }
 
   mRunning = TRUE;
 
@@ -212,7 +215,11 @@ void CombinedUpdateRenderController::Stop()
   LOG_EVENT_TRACE;
 
   // Stop Rendering and the Update/Render Thread
-  mRenderHelper.Stop();
+  RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+  if( currentSurface )
+  {
+    currentSurface->StopRender();
+  }
 
   StopUpdateRenderThread();
 
@@ -400,9 +407,13 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
   LOG_UPDATE_RENDER( "THREAD CREATED" );
 
-  mRenderHelper.InitializeEgl();
+  RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+  if( currentSurface )
+  {
+    currentSurface->InitializeGraphics( mAdaptorInterfaces.GetGraphicsInterface(), mAdaptorInterfaces.GetDisplayConnectionInterface() );
+  }
 
-  // tell core it has a context
+  // Tell core it has a context
   mCore.ContextCreated();
 
   NotifyThreadInitialised();
@@ -451,7 +462,14 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     if( DALI_UNLIKELY( newSurface ) )
     {
       LOG_UPDATE_RENDER_TRACE_FMT( "Replacing Surface" );
-      mRenderHelper.ReplaceSurface( newSurface );
+
+      // This is designed for replacing pixmap surfaces, but should work for window as well
+      // we need to delete the surface and renderable (pixmap / window)
+      // Then create a new pixmap/window and new surface
+      // If the new surface has a different display connection, then the context will be lost
+
+      mAdaptorInterfaces.GetDisplayConnectionInterface().Initialize();
+      newSurface->ReplaceGraphicsSurface();
       SurfaceReplaced();
     }
 
@@ -500,11 +518,9 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     bool surfaceResized = ShouldSurfaceBeResized();
     if( DALI_UNLIKELY( surfaceResized ) )
     {
-      // RenderHelper::ResizeSurface() should be called right after a viewport is changed.
       if( updateStatus.SurfaceRectChanged() )
       {
         LOG_UPDATE_RENDER_TRACE_FMT( "Resizing Surface" );
-        mRenderHelper.ResizeSurface();
         SurfaceResized();
       }
     }
@@ -516,7 +532,8 @@ void CombinedUpdateRenderController::UpdateRenderThread()
     // RENDER
     //////////////////////////////
 
-    mRenderHelper.ConsumeEvents();
+    mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents();
+
     if( mPreRenderCallback != NULL )
     {
       bool keepCallback = CallbackBase::ExecuteReturn<bool>(*mPreRenderCallback);
@@ -526,7 +543,12 @@ void CombinedUpdateRenderController::UpdateRenderThread()
         mPreRenderCallback = NULL;
       }
     }
-    mRenderHelper.PreRender();
+
+    RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+    if( currentSurface )
+    {
+      currentSurface->PreRender( mSurfaceResized );
+    }
 
     Integration::RenderStatus renderStatus;
 
@@ -538,12 +560,14 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
     if( renderStatus.NeedsPostRender() )
     {
-      mRenderHelper.PostRender( isRenderingToFbo );
+      if( currentSurface )
+      {
+        currentSurface->PostRender( isRenderingToFbo, ( mNewSurface != NULL ), mSurfaceResized );
+      }
     }
 
     // Trigger event thread to request Update/Render thread to sleep if update not required
-    if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) &&
-        ! renderStatus.NeedsUpdate() )
+    if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) && !renderStatus.NeedsUpdate() )
     {
       mSleepTrigger->Trigger();
       updateRequired = false;
@@ -600,7 +624,11 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
   // Inform core of context destruction & shutdown EGL
   mCore.ContextDestroyed();
-  mRenderHelper.ShutdownEgl();
+  if( currentSurface )
+  {
+    currentSurface->DestroySurface();
+    currentSurface = nullptr;
+  }
 
   LOG_UPDATE_RENDER( "THREAD DESTROYED" );
 
index 7760c7e..6eafcf1 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
-#define __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
+#ifndef DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H
+#define DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
 #include <dali/integration-api/thread-synchronization-interface.h>
 #include <dali/internal/system/common/performance-interface.h>
 #include <dali/internal/system/common/fps-tracker.h>
-#include <dali/internal/graphics/common/render-helper.h>
 #include <dali/internal/adaptor/common/thread-controller-interface.h>
 #include <dali/internal/system/common/update-status-logger.h>
+#include <dali/internal/window-system/common/display-connection.h>
+
 
 namespace Dali
 {
@@ -299,8 +300,6 @@ private:
   FpsTracker                        mFpsTracker;                       ///< Object that tracks the FPS
   UpdateStatusLogger                mUpdateStatusLogger;               ///< Object that logs the update-status as required.
 
-  RenderHelper                      mRenderHelper;                     ///< Helper class for EGL, pre & post rendering
-
   sem_t                             mEventThreadSemaphore;             ///< Used by the event thread to ensure all threads have been initialised, and when replacing the surface.
 
   ConditionalWait                   mUpdateRenderThreadWaitCondition;  ///< The wait condition for the update-render-thread.
@@ -339,7 +338,7 @@ private:
 
   volatile unsigned int             mPostRendering;                    ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
   volatile unsigned int             mSurfaceResized;                   ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
-  volatile unsigned int             mForceClear;                       ///< Will be set to clear forcely
+  volatile unsigned int             mForceClear;                       ///< Will be set to clear forcibly
 };
 
 } // namespace Adaptor
@@ -348,4 +347,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
+#endif // DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H
index 81cea18..f1a6591 100644 (file)
@@ -5,6 +5,7 @@ adaptor_adaptor_common_src_files=\
     ${adaptor_adaptor_dir}/common/lifecycle-controller-impl.cpp \
     ${adaptor_adaptor_dir}/common/adaptor-impl.cpp \
     ${adaptor_adaptor_dir}/common/adaptor.cpp \
+    ${adaptor_adaptor_dir}/common/adaptor-builder-impl.cpp \
     ${adaptor_adaptor_dir}/common/application-impl.cpp \
     ${adaptor_adaptor_dir}/common/combined-update-render-controller.cpp
 
index a6c2397..5f0f953 100644 (file)
@@ -112,11 +112,12 @@ void Adaptor::SurfaceInitialized()
   // Use strdup() in app_get_id(), so need to free memory
   if( appId )
   {
+    WindowPane defaultWindow = mWindowFrame.front();
 #ifdef ECORE_WAYLAND2
-    Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( mNativeWindow );
+    Ecore_Wl2_Window* ecoreWlWindow = AnyCast< Ecore_Wl2_Window* >( defaultWindow.nativeWindow );
     screen_connector_provider_remote_enable( appId, ecore_wl2_window_surface_get( ecoreWlWindow ) );
 #else
-    Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( mNativeWindow );
+    Ecore_Wl_Window* ecoreWlWindow = AnyCast< Ecore_Wl_Window* >( defaultWindow.nativeWindow );
     screen_connector_provider_remote_enable( appId, ecore_wl_window_surface_get( ecoreWlWindow ) );
 #endif
     free( appId );
diff --git a/dali/internal/graphics/common/graphics-factory-interface.h b/dali/internal/graphics/common/graphics-factory-interface.h
new file mode 100644 (file)
index 0000000..bcec0af
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef DALI_INTERNAL_BASE_GRAPHICS_FACTORY_INTERFACE_H
+#define DALI_INTERNAL_BASE_GRAPHICS_FACTORY_INTERFACE_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/internal/system/common/environment-options.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
+
+namespace Dali
+{
+class GraphicsInterface;
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Factory interface for creating Graphics Factory implementation
+ */
+class GraphicsFactoryInterface
+{
+public:
+  /**
+   * Create a Graphics interface implementation
+   * @return An implementation of the Graphics interface
+   */
+  virtual GraphicsInterface& Create() = 0;
+
+  /**
+   * Destroy the Graphics Factory implementation
+   */
+  virtual void Destroy() = 0;
+
+protected:
+  /**
+   * Virtual protected destructor - no deletion through this interface
+   */
+  virtual ~GraphicsFactoryInterface() {};
+};
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
+
+#endif // DALI_INTERNAL_BASE_GRAPHICS_FACTORY_INTERFACE_H
diff --git a/dali/internal/graphics/common/graphics-interface.h b/dali/internal/graphics/common/graphics-interface.h
new file mode 100644 (file)
index 0000000..5e80ef7
--- /dev/null
@@ -0,0 +1,98 @@
+#ifndef DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H
+#define DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_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/internal/system/common/environment-options.h>
+#include <dali/integration-api/core-enumerations.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * Factory interface for creating Graphics Factory implementation
+ */
+class GraphicsInterface
+{
+public:
+
+  /**
+   * Constructor
+   */
+  GraphicsInterface()
+: mDepthBufferRequired( Integration::DepthBufferAvailable::FALSE ),
+  mStencilBufferRequired( Integration::StencilBufferAvailable::FALSE )
+  {
+  };
+
+  /**
+   * Initialize the graphics interface
+   * @param[in]  environmentOptions  The environment options.
+   */
+  virtual void Initialize( EnvironmentOptions* environmentOptions ) = 0;
+
+  /**
+   * Destroy the Graphics Factory implementation
+   */
+  virtual void Destroy() = 0;
+
+  /**
+   * Get whether the depth buffer is required
+   * @return TRUE if the depth buffer is required
+   */
+  Integration::DepthBufferAvailable& GetDepthBufferRequired()
+  {
+    return mDepthBufferRequired;
+  };
+
+  /**
+   * Get whether the stencil buffer is required
+   * @return TRUE if the stencil buffer is required
+   */
+  Integration::StencilBufferAvailable GetStencilBufferRequired()
+  {
+    return mStencilBufferRequired;
+  };
+
+protected:
+  /**
+   * Virtual protected destructor - no deletion through this interface
+   */
+  virtual ~GraphicsInterface() {};
+
+
+protected:
+
+  Integration::DepthBufferAvailable mDepthBufferRequired;       ///< Whether the depth buffer is required
+  Integration::StencilBufferAvailable mStencilBufferRequired;   ///< Whether the stencil buffer is required
+};
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
+
+#endif // DALI_INTERNAL_BASE_GRAPHICS_INTERFACE_H
diff --git a/dali/internal/graphics/common/render-helper.cpp b/dali/internal/graphics/common/render-helper.cpp
deleted file mode 100644 (file)
index 95155c0..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2017 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/internal/graphics/common/render-helper.h>
-
-// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/adaptor/common/adaptor-internal-services.h>
-#include <dali/internal/window-system/common/display-connection.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace Adaptor
-{
-
-RenderHelper::RenderHelper( AdaptorInternalServices& adaptorInterfaces )
-: mGLES( adaptorInterfaces.GetGlesInterface() ),
-  mEglFactory( &adaptorInterfaces.GetEGLFactoryInterface()),
-  mEGL( NULL ),
-  mSurfaceReplaced( false ),
-  mSurfaceResized( false )
-{
-  // set the initial values before render thread starts
-  mSurface = adaptorInterfaces.GetRenderSurfaceInterface();
-
-  if( mSurface )
-  {
-    mDisplayConnection = Dali::DisplayConnection::New( mSurface->GetSurfaceType() );
-  }
-  else
-  {
-    mDisplayConnection = Dali::DisplayConnection::New();
-  }
-}
-
-RenderHelper::~RenderHelper()
-{
-  if (mDisplayConnection)
-  {
-    delete mDisplayConnection;
-    mDisplayConnection = NULL;
-  }
-
-  mEglFactory->Destroy();
-}
-
-void RenderHelper::Start()
-{
-  if( mSurface )
-  {
-    mSurface->StartRender();
-  }
-}
-
-void RenderHelper::Stop()
-{
-  if( mSurface )
-  {
-    // Tell surface we have stopped rendering
-    mSurface->StopRender();
-  }
-}
-
-void RenderHelper::ConsumeEvents()
-{
-  mDisplayConnection->ConsumeEvents();
-}
-
-void RenderHelper::InitializeEgl()
-{
-  mEGL = mEglFactory->Create();
-
-  DALI_ASSERT_ALWAYS( mSurface && "NULL surface" );
-
-  // Initialize EGL & OpenGL
-  mDisplayConnection->InitializeEgl( *mEGL );
-  mSurface->InitializeEgl( *mEGL );
-
-  // create the OpenGL context
-  mEGL->CreateContext();
-
-  // create the OpenGL surface
-  mSurface->CreateEglSurface(*mEGL);
-
-  // Make it current
-  mEGL->MakeContextCurrent();
-}
-
-void RenderHelper::ReplaceSurface( RenderSurface* newSurface )
-{
-  if( mSurface )
-  {
-    mSurface->DestroyEglSurface(*mEGL);
-  }
-
-  // This is designed for replacing pixmap surfaces, but should work for window as well
-  // we need to delete the egl surface and renderable (pixmap / window)
-  // Then create a new pixmap/window and new egl surface
-  // If the new surface has a different display connection, then the context will be lost
-  DALI_ASSERT_ALWAYS(newSurface && "NULL surface");
-
-  mDisplayConnection->InitializeEgl(*mEGL);
-
-  newSurface->ReplaceEGLSurface(*mEGL);
-
-  // use the new surface from now on
-  mSurface = newSurface;
-  mSurfaceReplaced = true;
-}
-
-void RenderHelper::ResizeSurface()
-{
-  mSurfaceResized = true;
-}
-
-void RenderHelper::ShutdownEgl()
-{
-  if( mSurface )
-  {
-    // give a chance to destroy the OpenGL surface that created externally
-    mSurface->DestroyEglSurface( *mEGL );
-
-    mSurface = NULL;
-  }
-
-  // delete the GL context / egl surface
-  mEGL->TerminateGles();
-}
-
-bool RenderHelper::PreRender()
-{
-  if( mSurface )
-  {
-    mSurface->PreRender( *mEGL, mGLES, mSurfaceResized );
-  }
-  mGLES.PreRender();
-  return true;
-}
-
-void RenderHelper::PostRender( bool renderToFbo )
-{
-  // Inform the gl implementation that rendering has finished before informing the surface
-  mGLES.PostRender();
-
-  if( renderToFbo )
-  {
-    mGLES.Flush();
-    mGLES.Finish();
-  }
-  else
-  {
-    if( mSurface )
-    {
-      // Inform the surface that rendering this frame has finished.
-      mSurface->PostRender( *mEGL, mGLES, mDisplayConnection, mSurfaceReplaced, mSurfaceResized );
-    }
-  }
-  mSurfaceReplaced = false;
-  mSurfaceResized = false;
-}
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
diff --git a/dali/internal/graphics/common/render-helper.h b/dali/internal/graphics/common/render-helper.h
deleted file mode 100644 (file)
index 641a0cb..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef DALI_INTERNAL_RENDER_HELPER_H
-#define DALI_INTERNAL_RENDER_HELPER_H
-
-/*
- * Copyright (c) 2017 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/integration-api/egl-interface.h>
-#include <dali/integration-api/render-surface.h>
-
-namespace Dali
-{
-
-class RenderSurface;
-class DisplayConnection;
-
-namespace Integration
-{
-class GlAbstraction;
-}
-
-namespace Internal
-{
-namespace Adaptor
-{
-
-class AdaptorInternalServices;
-class EglFactoryInterface;
-
-/**
- * Helper class for EGL, surface, pre & post rendering
- */
-class RenderHelper
-{
-public:
-
-  /**
-   * Create a RenderHelper.
-   * @param[in] adaptorInterfaces base adaptor interface
-   */
-  RenderHelper( AdaptorInternalServices& adaptorInterfaces );
-
-  /**
-   * Non-virtual Destructor
-   */
-  ~RenderHelper();
-
-  /////////////////////////////////////////////////////////////////////////////////////////////////
-  // Called on the Event Thread
-  /////////////////////////////////////////////////////////////////////////////////////////////////
-
-  /**
-   * Sets up all render related objects to start rendering.
-   */
-  void Start();
-
-  /**
-   * Sets up all render related objects to stop rendering.
-   */
-  void Stop();
-
-  /////////////////////////////////////////////////////////////////////////////////////////////////
-  // Called on the Rendering Thread
-  /////////////////////////////////////////////////////////////////////////////////////////////////
-
-  /**
-   * Consumes any pending events to avoid memory leaks
-   *
-   * @note Called from rendering thread
-   */
-  void ConsumeEvents();
-
-  /**
-   * Initializes EGL.
-   *
-   * @note Called from rendering thread
-   */
-  void InitializeEgl();
-
-  /**
-   * Replaces the rendering surface
-   *
-   * Used for replacing pixmaps due to resizing
-   * @param newSurface to use
-   *
-   * @note Called from render thread
-   */
-  void ReplaceSurface( RenderSurface* newSurface );
-
-  /**
-   * Resize the rendering surface.
-   *
-   * @note Called from render thread
-   */
-  void ResizeSurface();
-
-  /**
-   * Shuts down EGL.
-   *
-   * @note Called from render thread
-   */
-  void ShutdownEgl();
-
-  /**
-   * Called before core renders the scene
-   *
-   * @return true if successful and Core::Render should be called.
-   *
-   * @note Called from render thread
-   */
-  bool PreRender();
-
-  /**
-   * Called after core has rendered the scene
-   *
-   * @note Called from render thread
-   *
-   * @param[in] renderToFbo Whether to render to a Frame Buffer Object.
-   */
-  void PostRender( bool renderToFbo );
-
-private:
-
-  // Undefined
-  RenderHelper( const RenderHelper& RenderHelper );
-
-  // Undefined
-  RenderHelper& operator=( const RenderHelper& RenderHelper );
-
-private: // Data
-
-  Integration::GlAbstraction&   mGLES;                   ///< GL abstraction reference
-  EglFactoryInterface*          mEglFactory;             ///< Factory class to create EGL implementation
-  EglInterface*                 mEGL;                    ///< Interface to EGL implementation
-  RenderSurface*                mSurface;                ///< Current surface
-  Dali::DisplayConnection*      mDisplayConnection;      ///< Display connection
-  bool                          mSurfaceReplaced;        ///< True when new surface has been initialized.
-  bool                          mSurfaceResized;         ///< True when the surface is resized.
-};
-
-} // namespace Adaptor
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // DALI_INTERNAL_RENDER_HELPER_H
index 31217fb..0f7d9d6 100644 (file)
@@ -1,17 +1,14 @@
 
 
-# module: graphics, backend: common
-adaptor_graphics_common_src_files=\
-    ${adaptor_graphics_dir}/common/render-helper.cpp
-
 # module: graphics, backend: gles20
 adaptor_graphics_gles20_src_files=\
     ${adaptor_graphics_dir}/gles20/egl-debug.cpp \
-    ${adaptor_graphics_dir}/gles20/egl-factory.cpp \
     ${adaptor_graphics_dir}/gles20/egl-implementation.cpp \
     ${adaptor_graphics_dir}/gles20/egl-sync-implementation.cpp \
     ${adaptor_graphics_dir}/gles20/gl-extensions.cpp \
-    ${adaptor_graphics_dir}/gles20/gl-proxy-implementation.cpp
+    ${adaptor_graphics_dir}/gles20/gl-proxy-implementation.cpp \
+    ${adaptor_graphics_dir}/gles20/egl-graphics-factory.cpp \
+    ${adaptor_graphics_dir}/gles20/egl-graphics.cpp
 
 # module: graphics, backend: tizen
 adaptor_graphics_tizen_src_files=\
index 42a6029..3a8f9f6 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H__
-#define __DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H__
+#ifndef DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H
+#define DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H
 
 /*
  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
@@ -56,4 +56,4 @@ protected:
 } // Internal
 } // Dali
 
-#endif // __DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H__
+#endif // DALI_INTERNAL_BASE_EGL_FACTORY_INTERFACE_H
diff --git a/dali/internal/graphics/gles20/egl-factory.cpp b/dali/internal/graphics/gles20/egl-factory.cpp
deleted file mode 100644 (file)
index c5250fb..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2017 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/internal/graphics/gles20/egl-factory.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/graphics/gles20/egl-implementation.h>
-#include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-sync-implementation.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-
-EglFactory::EglFactory( int multiSamplingLevel,
-                        Integration::DepthBufferAvailable depthBufferRequired,
-                        Integration::StencilBufferAvailable stencilBufferRequired )
-: mEglImplementation(NULL),
-  mEglImageExtensions(NULL),
-  mEglSync(new EglSyncImplementation), // Created early, as needed by Core constructor
-  mMultiSamplingLevel( multiSamplingLevel ),
-  mDepthBufferRequired( depthBufferRequired ),
-  mStencilBufferRequired( stencilBufferRequired )
-{
-}
-
-EglFactory::~EglFactory()
-{
-  // Ensure the EGL implementation is destroyed
-  delete mEglImageExtensions;
-  delete mEglImplementation;
-  delete mEglSync;
-}
-
-EglInterface* EglFactory::Create()
-{
-  // Created by RenderThread (After Core construction)
-  mEglImplementation = new EglImplementation( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired );
-  mEglImageExtensions = new EglImageExtensions( mEglImplementation );
-
-  mEglSync->Initialize(mEglImplementation); // The sync impl needs the EglDisplay
-  return mEglImplementation;
-}
-
-void EglFactory::Destroy()
-{
-  delete mEglImageExtensions;
-  mEglImageExtensions = NULL;
-  delete mEglImplementation;
-  mEglImplementation = NULL;
-}
-
-EglInterface* EglFactory::GetImplementation()
-{
-  return mEglImplementation;
-}
-
-EglImageExtensions* EglFactory::GetImageExtensions()
-{
-  return mEglImageExtensions;
-}
-
-EglSyncImplementation* EglFactory::GetSyncImplementation()
-{
-  return mEglSync;
-}
-
-} // Adaptor
-} // Internal
-} // Dali
diff --git a/dali/internal/graphics/gles20/egl-factory.h b/dali/internal/graphics/gles20/egl-factory.h
deleted file mode 100644 (file)
index 7f7bf1c..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
-#define DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
-
-/*
- * Copyright (c) 2017 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/integration-api/core-enumerations.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/graphics/gles20/egl-factory-interface.h>
-
-namespace Dali
-{
-namespace Internal
-{
-namespace Adaptor
-{
-class EglImplementation;
-class EglImageExtensions;
-class EglSyncImplementation;
-
-class EglFactory : public EglFactoryInterface
-{
-public:
-
-  /**
-   * Constructor
-   * @param[in] multiSamplingLevel The Multi-sampling level required
-   * @param[in] depthBufferRequired Whether the depth buffer is required
-   * @param[in] stencilBufferRequired Whether the stencil buffer is required
-   */
-  EglFactory( int multiSamplingLevel,
-              Integration::DepthBufferAvailable depthBufferRequired,
-              Integration::StencilBufferAvailable stencilBufferRequired );
-
-  /**
-   * Destructor
-   */
-  virtual ~EglFactory();
-
-  /**
-   * Create an EGL Implementation
-   * @return[in] An implementation
-   */
-  EglInterface* Create();
-
-  /**
-   * Destroy the EGL Implementation
-   */
-  void Destroy();
-
-  /**
-   * Get an implementation if one has been created.
-   * @return An implementation, or NULL if one has not yet been created.
-   */
-  EglInterface* GetImplementation();
-
-  /**
-   * Get the image extension
-   */
-  EglImageExtensions* GetImageExtensions();
-
-  /**
-   * Get the fence sync implementation
-   * @return An implementation of fence sync
-   */
-  EglSyncImplementation* GetSyncImplementation();
-
-private:
-  /** Undefined */
-  EglFactory(const EglFactory& rhs);
-  EglFactory& operator=(const EglFactory& rhs);
-
-private:
-  EglImplementation* mEglImplementation;
-  EglImageExtensions* mEglImageExtensions;
-  EglSyncImplementation* mEglSync;
-
-  int mMultiSamplingLevel;
-  Integration::DepthBufferAvailable mDepthBufferRequired;
-  Integration::StencilBufferAvailable mStencilBufferRequired;
-};
-
-} // namespace Adaptor
-} // namespace Internal
-} // namespace Dali
-
-#endif // DALI_INTERNAL_ADAPTOR_EGL_FACTORY_IMPL_H
diff --git a/dali/internal/graphics/gles20/egl-graphics-factory.cpp b/dali/internal/graphics/gles20/egl-graphics-factory.cpp
new file mode 100644 (file)
index 0000000..80e6693
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ *
+ */
+
+
+// CLASS HEADER
+#include <dali/internal/graphics/gles20/egl-graphics-factory.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
+
+// INTERNAL INCLUDES
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+GraphicsFactory::GraphicsFactory()
+{
+}
+
+GraphicsFactory::~GraphicsFactory()
+{
+  /* Deleted by Adaptor destructor */
+}
+
+GraphicsInterface& GraphicsFactory::Create()
+{
+  GraphicsInterface* eglGraphicsInterface = new EglGraphics;
+  return *eglGraphicsInterface;
+}
+
+void GraphicsFactory::Destroy()
+{
+  /* Deleted by EglGraphics */
+}
+
+} // Adaptor
+} // Internal
+} // Dali
diff --git a/dali/internal/graphics/gles20/egl-graphics-factory.h b/dali/internal/graphics/gles20/egl-graphics-factory.h
new file mode 100644 (file)
index 0000000..6ba1d91
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef DALI_INTERNAL_GRAPHICS_FACTORY_H
+#define DALI_INTERNAL_GRAPHICS_FACTORY_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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/graphics/common/graphics-factory-interface.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class GraphicsFactory : public GraphicsFactoryInterface
+{
+public:
+
+  /**
+   * Constructor
+   */
+  GraphicsFactory();
+
+  /**
+   * Destructor
+   */
+  virtual ~GraphicsFactory();
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsFactoryInterface::Create()
+   */
+  GraphicsInterface& Create() override;
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsFactoryInterface::Destroy()
+   */
+  void Destroy();
+};
+
+} // Adaptor
+
+} // Internal
+
+} // Dali
+
+#endif // DALI_INTERNAL_GRAPHICS_FACTORY_H
diff --git a/dali/internal/graphics/gles20/egl-graphics.cpp b/dali/internal/graphics/gles20/egl-graphics.cpp
new file mode 100644 (file)
index 0000000..3df7198
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ *
+ */
+
+
+// CLASS HEADER
+#include <dali/internal/graphics/gles20/egl-graphics.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/display-utils.h> // For Utils::MakeUnique
+
+namespace Dali
+{
+namespace Internal
+{
+namespace Adaptor
+{
+
+EglGraphics::EglGraphics( )
+: mMultiSamplingLevel( 0 )
+{
+}
+
+EglGraphics::~EglGraphics()
+{
+}
+
+
+void EglGraphics::Initialize( EnvironmentOptions* environmentOptions )
+{
+  if( environmentOptions->GetGlesCallTime() > 0 )
+  {
+    mGLES = Utils::MakeUnique< GlProxyImplementation >( *environmentOptions );
+  }
+  else
+  {
+    mGLES.reset ( new GlImplementation() );
+  }
+
+  mDepthBufferRequired = static_cast< Integration::DepthBufferAvailable >( environmentOptions->DepthBufferRequired() );
+  mStencilBufferRequired = static_cast< Integration::StencilBufferAvailable >( environmentOptions->StencilBufferRequired() );
+
+  mMultiSamplingLevel = environmentOptions->GetMultiSamplingLevel();
+
+  mEglSync = Utils::MakeUnique< EglSyncImplementation >();
+}
+
+EglInterface* EglGraphics::Create()
+{
+  mEglImplementation = Utils::MakeUnique< EglImplementation >( mMultiSamplingLevel, mDepthBufferRequired, mStencilBufferRequired );
+  mEglImageExtensions = Utils::MakeUnique< EglImageExtensions >( mEglImplementation.get() );
+
+  mEglSync->Initialize( mEglImplementation.get() ); // The sync impl needs the EglDisplay
+
+  return mEglImplementation.get();
+}
+
+void EglGraphics::Destroy()
+{
+}
+
+//Dali::Integration::GlAbstraction& EglGraphics::GetGlesInterface()
+GlImplementation& EglGraphics::GetGlesInterface()
+{
+  return *mGLES;
+}
+
+Integration::GlAbstraction& EglGraphics::GetGlAbstraction() const
+{
+  DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
+  return *mGLES;
+}
+
+EglImplementation& EglGraphics::GetEglImplementation() const
+{
+  DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
+  return *mEglImplementation;
+}
+
+EglInterface& EglGraphics::GetEglInterface() const
+{
+  DALI_ASSERT_DEBUG( mEglImplementation && "EGLImplementation not created" );
+  EglInterface* eglInterface = mEglImplementation.get();
+  return *eglInterface;
+}
+
+EglSyncImplementation& EglGraphics::GetSyncImplementation()
+{
+  DALI_ASSERT_DEBUG( mEglSync && "EglSyncImplementation not created" );
+  return *mEglSync;
+}
+
+EglImageExtensions* EglGraphics::GetImageExtensions()
+{
+  DALI_ASSERT_DEBUG( mEglImageExtensions && "EglImageExtensions not created" );
+  return mEglImageExtensions.get();
+}
+
+} // Adaptor
+} // Internal
+} // Dali
diff --git a/dali/internal/graphics/gles20/egl-graphics.h b/dali/internal/graphics/gles20/egl-graphics.h
new file mode 100644 (file)
index 0000000..603b584
--- /dev/null
@@ -0,0 +1,139 @@
+#ifndef DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H
+#define DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <dali/internal/graphics/common/graphics-interface.h>
+#include <dali/internal/graphics/gles20/gl-proxy-implementation.h>
+#include <dali/internal/graphics/gles20/gl-implementation.h>
+#include <dali/integration-api/egl-interface.h>
+
+#include <dali/internal/graphics/gles20/egl-implementation.h>
+#include <dali/internal/graphics/common/egl-image-extensions.h>
+#include <dali/internal/graphics/gles20/egl-sync-implementation.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class EglGraphics : public GraphicsInterface
+{
+public:
+
+  /**
+   * Constructor
+   */
+  EglGraphics();
+
+  /**
+   * Destructor
+   */
+  virtual ~EglGraphics();
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Initialize()
+   */
+  void Initialize( EnvironmentOptions* environmentOptions ) override;
+
+  /**
+   * Creates the graphics interface for EGL
+   * @return The graphics interface for EGL
+   */
+  EglInterface* Create();
+
+  /**
+   * Gets the GL abstraction
+   * @return The GL abstraction
+   */
+  Integration::GlAbstraction& GetGlAbstraction() const;
+
+  /**
+   * Gets the implementation of EGL
+   * @return The implementation of EGL
+   */
+  EglImplementation& GetEglImplementation() const;
+
+  /**
+   * Gets the graphics interface for EGL
+   * @return The graphics interface for EGL
+   */
+  EglInterface& GetEglInterface() const;
+
+  /**
+   * @copydoc Dali::Integration::GlAbstraction& GetGlesInterface()
+   */
+  GlImplementation& GetGlesInterface();
+
+  /**
+   * Gets the implementation of GlSyncAbstraction for EGL.
+   * @return The implementation of GlSyncAbstraction for EGL.
+   */
+  EglSyncImplementation& GetSyncImplementation();
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetDepthBufferRequired()
+   */
+  Integration::DepthBufferAvailable& GetDepthBufferRequired();
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::GetStencilBufferRequired()
+   */
+  Integration::StencilBufferAvailable GetStencilBufferRequired();
+
+  /**
+   * Gets the EGL image extension
+   * @return The EGL image extension
+   */
+  EglImageExtensions* GetImageExtensions();
+
+  /**
+   * @copydoc Dali::Internal::Adaptor::GraphicsInterface::Destroy()
+   */
+  void Destroy() override;
+
+private:
+  // Eliminate copy and assigned operations
+  EglGraphics(const EglGraphics& rhs) = delete;
+  EglGraphics& operator=(const EglGraphics& rhs) = delete;
+
+
+private:
+  std::unique_ptr< GlImplementation > mGLES;                    ///< GL implementation
+  std::unique_ptr< EglImplementation > mEglImplementation;      ///< EGL implementation
+  std::unique_ptr< EglImageExtensions > mEglImageExtensions;    ///< EGL image extension
+  std::unique_ptr< EglSyncImplementation > mEglSync;            ///< GlSyncAbstraction implementation for EGL
+
+  int mMultiSamplingLevel;                                      ///< The multiple sampling level
+};
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_BASE_GRAPHICS_IMPLEMENTATION_H__
index d81bbd8..7bd4570 100644 (file)
@@ -24,6 +24,7 @@
 
 // INTERNAL HEADERS
 #include <dali/internal/graphics/gles20/gl-implementation.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 
 namespace Dali
 {
@@ -35,14 +36,18 @@ namespace Adaptor
 {
 
 NativeBitmapBuffer::NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pFormat )
-: mWidth(width),
+: mGlAbstraction( nullptr),
+  mWidth(width),
   mHeight(height),
   mPixelFormat(pFormat),
   mLastReadBuffer(NULL)
 {
   DALI_ASSERT_ALWAYS( adaptor );
   mBuffer = new Integration::LocklessBuffer( width * height * Pixel::GetBytesPerPixel(pFormat) );
-  mGlAbstraction = &(adaptor->GetGlAbstraction());
+
+  GraphicsInterface* graphics = &(adaptor->GetGraphicsInterface());
+  auto eglGraphics = static_cast<EglGraphics *>(graphics);
+  mGlAbstraction = &(eglGraphics->GetGlAbstraction());
 }
 
 NativeBitmapBuffer::~NativeBitmapBuffer()
index 865bd0e..fc8d55d 100644 (file)
@@ -27,6 +27,7 @@
 
 // INTERNAL HEADERS
 #include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 
 namespace Dali
 {
index 3cd791f..97210da 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/integration-api/render-surface.h>
 
 // Allow this to be encoded and saved:
 #include <dali/devel-api/adaptor-framework/bitmap-saver.h>
 
+
 namespace Dali
 {
 
@@ -91,8 +92,12 @@ NativeImageSourceTizen::NativeImageSourceTizen( unsigned int width, unsigned int
   mSetSource( false )
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
-  EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
-  mEglImageExtensions = eglFactory.GetImageExtensions();
+
+  GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
+  auto eglGraphics = static_cast<EglGraphics *>(graphics);
+
+  mEglImageExtensions = eglGraphics->GetImageExtensions();
+
   DALI_ASSERT_DEBUG( mEglImageExtensions );
 
   mTbmSurface = GetSurfaceFromAny( nativeImageSource );
index 157d3b8..c7b547f 100644 (file)
@@ -25,7 +25,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 
 namespace Dali
@@ -84,8 +84,12 @@ NativeImageSourceQueueTizen::NativeImageSourceQueueTizen( unsigned int width, un
   mBlendingRequired( false )
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
-  EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
-  mEglImageExtensions = eglFactory.GetImageExtensions();
+
+  GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
+  auto eglGraphics = static_cast<EglGraphics *>(graphics);
+
+  mEglImageExtensions = eglGraphics->GetImageExtensions();
+
   DALI_ASSERT_DEBUG( mEglImageExtensions );
 
   mTbmQueue = GetSurfaceFromAny( nativeImageSourceQueue );
index 9fed477..be32323 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/devel-api/adaptor-framework/bitmap-saver.h>
 #include <dali/integration-api/render-surface.h>
 
+
 namespace Dali
 {
 
@@ -97,8 +98,12 @@ NativeImageSourceX::NativeImageSourceX( unsigned int width, unsigned int height,
   mEglImageExtensions( NULL )
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
-  EglFactory& eglFactory = Adaptor::GetImplementation( Adaptor::Get() ).GetEGLFactory();
-  mEglImageExtensions = eglFactory.GetImageExtensions();
+
+  GraphicsInterface* graphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
+  auto eglGraphics = static_cast<EglGraphics *>(graphics);
+
+  mEglImageExtensions = eglGraphics->GetImageExtensions();
+
   DALI_ASSERT_DEBUG( mEglImageExtensions );
 
   // assign the pixmap
@@ -159,7 +164,7 @@ bool NativeImageSourceX::GetPixels(std::vector<unsigned char>& pixbuf, unsigned&
   XImageJanitor xImageJanitor( XGetImage( displayConnection,
                                           mPixmap,
                                           0, 0, // x,y of subregion to extract.
-                                          width, height, // of suregion to extract.
+                                          width, height, // of subregion to extract.
                                           0xFFFFFFFF,
                                           ZPixmap ) );
   XImage* const  pXImage = xImageJanitor.mXImage;
index 75f9312..9b74b2a 100755 (executable)
@@ -22,6 +22,8 @@
 #include <Ecore_X.h>
 
 // INTERNAL INCLUDES
+#include <dali/internal/graphics/common/graphics-interface.h>
+
 #include <dali/public-api/adaptor-framework/native-image-source.h>
 
 #include <dali/internal/imaging/common/native-image-source-impl.h>
index 9429525..e4c3541 100644 (file)
@@ -19,6 +19,9 @@
  */
 #include <dali/public-api/signals/callback.h>
 
+// INTERNAL INCLUDES
+#include <dali/internal/window-system/common/display-connection.h>
+
 namespace Dali
 {
 
@@ -122,10 +125,10 @@ public:
 private:
 
   // Undefined copy constructor.
-  ThreadController( const ThreadController& );
+  ThreadController( const ThreadController& ) = delete;
 
   // Undefined assignment operator.
-  ThreadController& operator=( const ThreadController& );
+  ThreadController& operator=( const ThreadController& ) = delete;
 
 private:
 
index 7e73ef1..8322e6e 100644 (file)
@@ -23,7 +23,6 @@
 #include <dali/public-api/object/base-object.h>
 #include <dali/internal/graphics/gles20/egl-implementation.h>
 
-#include <memory>
 
 namespace Dali
 {
@@ -67,12 +66,22 @@ public:
   virtual void ConsumeEvents() = 0;
 
   /**
-   * @copydoc Dali::DisplayConnection::InitializeEgl
+   * @copydoc Dali::DisplayConnection::InitializeGraphics
    */
-  virtual bool InitializeEgl(EglInterface& egl) = 0;
+  virtual bool InitializeGraphics() = 0;
 
+  /**
+   * Sets the render surface type
+   * @param[in] type The render surface type
+   */
   virtual void SetSurfaceType( RenderSurface::Type type ) = 0;
 
+  /**
+   * Sets the graphics interface
+   * @param[in] graphics The graphics interface
+   */
+  virtual void SetGraphicsInterface( GraphicsInterface& graphics ) = 0;
+
 public:
 
   /**
index dd5c506..1535056 100644 (file)
 // CLASS HEADER
 #include <dali/internal/window-system/common/display-connection.h>
 #include <dali/internal/window-system/common/display-connection-factory.h>
-// EXTERNAL INCLUDES
 
 // INTERNAL INCLUDES
 #include <dali/internal/window-system/common/display-connection-impl.h>
 #include <dali/internal/window-system/common/display-connection-factory.h>
-#include <dali/integration-api/egl-interface.h>
+
 
 namespace Dali
 {
 
-DisplayConnection* DisplayConnection::New()
+DisplayConnection* DisplayConnection::New( Dali::Internal::Adaptor::GraphicsInterface& graphics )
 {
   auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
   auto displayConnection = factory->CreateDisplayConnection();
 
   Internal::Adaptor::DisplayConnection* internal( displayConnection.release() );
+  internal->SetGraphicsInterface( graphics );
 
   return new DisplayConnection(internal);
 }
 
-DisplayConnection* DisplayConnection::New( RenderSurface::Type type )
+DisplayConnection* DisplayConnection::New( Dali::Internal::Adaptor::GraphicsInterface& graphics, RenderSurface::Type type )
 {
   auto factory = Dali::Internal::Adaptor::GetDisplayConnectionFactory();
   auto displayConnection = factory->CreateDisplayConnection();
 
   Internal::Adaptor::DisplayConnection* internal( displayConnection.release() );
 
+  internal->SetGraphicsInterface( graphics );
   internal->SetSurfaceType( type );
 
   return new DisplayConnection(internal);
@@ -69,9 +70,9 @@ void DisplayConnection::ConsumeEvents()
   mImpl->ConsumeEvents();
 }
 
-bool DisplayConnection::InitializeEgl(EglInterface& egl)
+bool DisplayConnection::Initialize()
 {
-  return mImpl->InitializeEgl(egl);
+  return mImpl->InitializeGraphics();
 }
 
 }
index c1e742c..1fc12ca 100644 (file)
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/render-surface.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 
-#include <memory>
 
 namespace Dali
 {
-
-class EglInterface;
-
 namespace Internal
 {
 namespace Adaptor
@@ -46,18 +43,20 @@ public:
   /**
    * @brief Create an initialized DisplayConnection.
    *
+   * @param[in] graphics The abstracted graphics interface
    * @return A handle to a newly allocated DisplayConnection resource.
    */
-  static DisplayConnection* New();
+  static DisplayConnection* New( Dali::Internal::Adaptor::GraphicsInterface& graphics );
 
   /**
    * @brief Create an initialized DisplayConnection.
    * Native surface will need this instead of DisplayConnection::New()
    *
+   * @param[in] graphics The abstracted graphics interface
    * @param[in] type Render surface type
    * @return A handle to a newly allocated DisplayConnection resource.
    */
-  static DisplayConnection* New( RenderSurface::Type type );
+  static DisplayConnection* New( Dali::Internal::Adaptor::GraphicsInterface& graphics, RenderSurface::Type type );
 
   /**
    * @brief Create a DisplayConnection handle; this can be initialised with DisplayConnection::New().
@@ -86,11 +85,9 @@ public:
   void ConsumeEvents();
 
   /**
-   * @brief Initialize EGL display
-   *
-   * @param egl implementation to use for the creation
+   * @brief Initialize the display
    */
-  bool InitializeEgl(EglInterface& egl);
+  bool Initialize();
 
 public:
 
index e8d8367..04bc79b 100644 (file)
@@ -30,6 +30,8 @@
 #include <dali/internal/window-system/common/window-base.h>
 #include <dali/internal/window-system/common/window-factory.h>
 #include <dali/internal/window-system/common/window-system.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
+
 
 namespace Dali
 {
@@ -79,15 +81,15 @@ WindowRenderSurface::~WindowRenderSurface()
 
 void WindowRenderSurface::Initialize( Any surface )
 {
-  // if width or height are zero, go full screen.
- if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
- {
-   // Default window size == screen size
-   mPositionSize.x = 0;
-   mPositionSize.y = 0;
+  // If width or height are zero, go full screen.
 if ( (mPositionSize.width == 0) || (mPositionSize.height == 0) )
 {
+    // Default window size == screen size
+    mPositionSize.x = 0;
+    mPositionSize.y = 0;
 
-   WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
- }
+    WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height );
 }
 
   // Create a window base
   auto windowFactory = Dali::Internal::Adaptor::GetWindowFactory();
@@ -174,16 +176,31 @@ void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpi
   mWindowBase->GetDpi( dpiHorizontal, dpiVertical );
 }
 
-void WindowRenderSurface::InitializeEgl( EglInterface& eglIf )
+void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection )
 {
-  DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
+  mGraphics = &graphics;
+
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  EglInterface* mEGL = eglGraphics->Create();
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
+  // Initialize EGL & OpenGL
+  displayConnection.Initialize();
 
+  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
   eglImpl.ChooseConfig(true, mColorDepth);
+
+  // Create the OpenGL context
+  mEGL->CreateContext();
+
+  // Create the OpenGL surface
+  CreateSurface();
+
+  // Make it current
+  mEGL->MakeContextCurrent();
 }
 
-void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
+void WindowRenderSurface::CreateSurface()
 {
   DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
 
@@ -199,29 +216,33 @@ void WindowRenderSurface::CreateEglSurface( EglInterface& eglIf )
     height = mPositionSize.width;
   }
 
-  // create the EGL window
+  // Create the EGL window
   EGLNativeWindowType window = mWindowBase->CreateEglWindow( width, height );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   eglImpl.CreateSurfaceWindow( window, mColorDepth );
 
   // Check rotation capability
   mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
 
-  DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateEglSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
+  DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle );
 }
 
-void WindowRenderSurface::DestroyEglSurface( EglInterface& eglIf )
+void WindowRenderSurface::DestroySurface()
 {
   DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   eglImpl.DestroySurface();
 
   mWindowBase->DestroyEglWindow();
 }
 
-bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl )
+bool WindowRenderSurface::ReplaceGraphicsSurface()
 {
   DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter );
 
@@ -240,13 +261,15 @@ bool WindowRenderSurface::ReplaceEGLSurface( EglInterface& egl )
     height = mPositionSize.width;
   }
 
-  // create the EGL window
+  // Create the EGL window
   EGLNativeWindowType window = mWindowBase->CreateEglWindow( width, height );
 
   // Set screen rotation
   mScreenRotationFinished = false;
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   return eglImpl.ReplaceSurfaceWindow( window );
 }
 
@@ -255,14 +278,14 @@ void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
   bool needToMove = false;
   bool needToResize = false;
 
-  // check moving
+  // Check moving
   if( (fabs(positionSize.x - mPositionSize.x) > MINIMUM_DIMENSION_CHANGE) ||
       (fabs(positionSize.y - mPositionSize.y) > MINIMUM_DIMENSION_CHANGE) )
   {
     needToMove = true;
   }
 
-  // check resizing
+  // Check resizing
   if( (fabs(positionSize.width - mPositionSize.width) > MINIMUM_DIMENSION_CHANGE) ||
       (fabs(positionSize.height - mPositionSize.height) > MINIMUM_DIMENSION_CHANGE) )
   {
@@ -305,7 +328,7 @@ void WindowRenderSurface::StartRender()
 {
 }
 
-bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface )
+bool WindowRenderSurface::PreRender( bool resizingSurface )
 {
   if( resizingSurface )
   {
@@ -341,28 +364,45 @@ bool WindowRenderSurface::PreRender( EglInterface& egl, Integration::GlAbstracti
     }
   }
 
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  auto mGLES = eglGraphics->GetGlesInterface();
+  mGLES.PreRender();
+
   return true;
 }
 
-void WindowRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface )
+void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
 {
-  if( resizingSurface )
+  // Inform the gl implementation that rendering has finished before informing the surface
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  auto mGLES = eglGraphics->GetGlesInterface();
+  mGLES.PostRender();
+
+  if( renderToFbo )
   {
-    if( !mRotationFinished )
+    mGLES.Flush();
+    mGLES.Finish();
+  }
+  else
+  {
+    if( resizingSurface )
     {
-      DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
+      if( !mRotationFinished )
+      {
+        DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" );
 
-      mRotationTrigger->Trigger();
+        mRotationTrigger->Trigger();
 
-      if( mThreadSynchronization )
-      {
-        // Wait until the event-thread complete the rotation event processing
-        mThreadSynchronization->PostRenderWaitForCompletion();
+        if( mThreadSynchronization )
+        {
+          // Wait until the event-thread complete the rotation event processing
+          mThreadSynchronization->PostRenderWaitForCompletion();
+        }
       }
     }
   }
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   eglImpl.SwapBuffers();
 
   if( mRenderNotification )
index 9357b41..6f93259 100644 (file)
 // INTERNAL INCLUDES
 #include <dali/integration-api/render-surface.h>
 #include <dali/integration-api/egl-interface.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/signals/connection-tracker.h>
 #include <dali/public-api/signals/dali-signal.h>
-#include <memory>
+
 
 namespace Dali
 {
@@ -119,29 +120,28 @@ public: // from Dali::RenderSurface
   virtual PositionSize GetPositionSize() const override;
 
   /**
-   * @copydoc Dali::RenderSurface::GetDpi()
    */
   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::InitializeEgl()
+   * @copydoc Dali::RenderSurface::InitializeGraphics()
    */
-  virtual void InitializeEgl( EglInterface& egl ) override;
+  virtual void InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::CreateEglSurface()
+   * @copydoc Dali::RenderSurface::CreateSurface()
    */
-  virtual void CreateEglSurface( EglInterface& egl ) override;
+  virtual void CreateSurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::DestroyEglSurface()
+   * @copydoc Dali::RenderSurface::DestroySurface()
    */
-  virtual void DestroyEglSurface( EglInterface& egl ) override;
+  virtual void DestroySurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
+   * @copydoc Dali::RenderSurface::ReplaceGraphicsSurface()
    */
-  virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
+  virtual bool ReplaceGraphicsSurface() override;
 
   /**
    * @copydoc Dali::RenderSurface::MoveResize()
@@ -161,12 +161,12 @@ public: // from Dali::RenderSurface
   /**
    * @copydoc Dali::RenderSurface::PreRender()
    */
-  virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
+  virtual bool PreRender( bool resizingSurface ) override;
 
   /**
    * @copydoc Dali::RenderSurface::PostRender()
    */
-  virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) override;
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
 
   /**
    * @copydoc Dali::RenderSurface::StopRender()
@@ -220,6 +220,7 @@ private: // Data
   ThreadSynchronizationInterface* mThreadSynchronization;
   TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
   TriggerEventInterface*          mRotationTrigger;
+  GraphicsInterface*              mGraphics;           ///< Graphics interface
   ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
   OutputSignalType                mOutputTransformedSignal;
   int                             mRotationAngle;
index ca46418..0dae2e9 100755 (executable)
@@ -17,6 +17,7 @@
 
 // CLASS HEADER
 #include <dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 
 // EXTERNAL_HEADERS
 #include <dali/integration-api/debug.h>
@@ -45,7 +46,8 @@ DisplayConnection* DisplayConnectionEcoreWl::New()
 
 DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
 : mDisplay( NULL ),
-  mSurfaceType( RenderSurface::WINDOW_RENDER_SURFACE )
+  mSurfaceType( RenderSurface::WINDOW_RENDER_SURFACE ),
+  mGraphics( nullptr )
 {
 }
 
@@ -66,9 +68,10 @@ void DisplayConnectionEcoreWl::ConsumeEvents()
 {
 }
 
-bool DisplayConnectionEcoreWl::InitializeEgl(EglInterface& egl)
+bool DisplayConnectionEcoreWl::InitializeGraphics()
 {
-  EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   if( !eglImpl.InitializeGles( mDisplay ) )
   {
@@ -98,6 +101,11 @@ void DisplayConnectionEcoreWl::SetSurfaceType( RenderSurface::Type type )
   }
 }
 
+void DisplayConnectionEcoreWl::SetGraphicsInterface( GraphicsInterface& graphics )
+{
+  mGraphics = &graphics;
+}
+
 EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
 {
   return EGLNativeDisplayType();
index 7c63d23..cc31ef0 100644 (file)
@@ -64,15 +64,22 @@ public:
   void ConsumeEvents();
 
   /**
-   * @copydoc Dali::DisplayConnection::InitializeEgl
+   * @copydoc Dali::DisplayConnection::InitializeGraphics
    */
-  bool InitializeEgl(EglInterface& egl);
+  bool InitializeGraphics();
 
   /**
-   * @brief Sets surface type
+   * @brief Sets the surface type
+   * @param[in] type The surface type
    */
   void SetSurfaceType( RenderSurface::Type type );
 
+  /**
+   * @brief Sets the graphics interface
+   * @param[in] graphics The graphics interface
+   */
+  void SetGraphicsInterface( GraphicsInterface& graphics );
+
 public:
 
   /**
@@ -100,7 +107,8 @@ protected:
 
 private:
   EGLNativeDisplayType mDisplay;        ///< Wayland-display for rendering
-  RenderSurface::Type mSurfaceType;
+  RenderSurface::Type mSurfaceType;     ///< The surface type
+  GraphicsInterface* mGraphics;         ///< The graphics interface
 };
 
 } // namespace Adaptor
index 8722ceb..66364cc 100644 (file)
@@ -34,6 +34,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/system/common/trigger-event.h>
 #include <dali/internal/graphics/gles20/egl-implementation.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 #include <dali/internal/window-system/common/display-connection.h>
 #include <dali/internal/window-system/common/window-system.h>
 #include <dali/integration-api/thread-synchronization-interface.h>
@@ -130,34 +131,54 @@ void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned i
   dpiVertical   = int( yres + 0.5f );
 }
 
-void NativeRenderSurfaceEcoreWl::InitializeEgl( EglInterface& egl )
+void NativeRenderSurfaceEcoreWl::InitializeGraphics( Internal::Adaptor::GraphicsInterface& graphics, DisplayConnection& displayConnection )
 {
   DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
   unsetenv( "EGL_PLATFORM" );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  mGraphics = &graphics;
 
-  eglImpl.ChooseConfig( true, mColorDepth );
+  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+
+  EglInterface* mEGL = eglGraphics->Create();
+
+  // Initialize EGL & OpenGL
+  displayConnection.Initialize();
+
+  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
+  eglImpl.ChooseConfig(true, mColorDepth);
+
+  // Create the OpenGL context
+  mEGL->CreateContext();
+
+  // Create the OpenGL surface
+  CreateSurface();
+
+  // Make it current
+  mEGL->MakeContextCurrent();
 }
 
-void NativeRenderSurfaceEcoreWl::CreateEglSurface( EglInterface& egl )
+void NativeRenderSurfaceEcoreWl::CreateSurface()
 {
   DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   eglImpl.CreateSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ), mColorDepth );
 }
 
-void NativeRenderSurfaceEcoreWl::DestroyEglSurface( EglInterface& egl )
+void NativeRenderSurfaceEcoreWl::DestroySurface()
 {
   DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+
   eglImpl.DestroySurface();
 }
 
-bool NativeRenderSurfaceEcoreWl::ReplaceEGLSurface( EglInterface& egl )
+bool NativeRenderSurfaceEcoreWl::ReplaceGraphicsSurface()
 {
   DALI_LOG_TRACE_METHOD( gNativeSurfaceLogFilter );
 
@@ -166,7 +187,8 @@ bool NativeRenderSurfaceEcoreWl::ReplaceEGLSurface( EglInterface& egl )
     return false;
   }
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   return eglImpl.ReplaceSurfaceWindow( reinterpret_cast< EGLNativeWindowType >( mTbmQueue ) );
 }
@@ -183,15 +205,17 @@ void NativeRenderSurfaceEcoreWl::StartRender()
 {
 }
 
-bool NativeRenderSurfaceEcoreWl::PreRender( EglInterface&, Integration::GlAbstraction&, bool )
+bool NativeRenderSurfaceEcoreWl::PreRender( bool )
 {
   // nothing to do for pixmaps
   return true;
 }
 
-void NativeRenderSurfaceEcoreWl::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface )
+void NativeRenderSurfaceEcoreWl::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
 {
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<Internal::Adaptor::EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+
   eglImpl.SwapBuffers();
 
   if( mThreadSynchronization )
@@ -203,7 +227,7 @@ void NativeRenderSurfaceEcoreWl::PostRender( EglInterface& egl, Integration::GlA
   {
     if( tbm_surface_queue_acquire( mTbmQueue, &mConsumeSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE )
     {
-      DALI_LOG_ERROR( "Failed to aquire a tbm_surface\n" );
+      DALI_LOG_ERROR( "Failed to acquire a tbm_surface\n" );
       return;
     }
   }
index cfc3d5a..6978b0f 100644 (file)
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
 #include <dali/integration-api/native-render-surface.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 
 namespace Dali
 {
 
+class DisplayConnection;
+
 /**
  * Ecore Wayland Native implementation of render surface.
  */
@@ -79,24 +82,24 @@ public: // from Dali::RenderSurface
   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::InitializeEgl()
+   * @copydoc Dali::RenderSurface::InitializeGraphics()
    */
-  virtual void InitializeEgl( EglInterface& egl ) override;
+  virtual void InitializeGraphics( Internal::Adaptor::GraphicsInterface& graphics, DisplayConnection& displayConnection ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::CreateEglSurface()
+   * @copydoc Dali::RenderSurface::CreateSurface()
    */
-  virtual void CreateEglSurface( EglInterface& egl ) override;
+  virtual void CreateSurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::DestroyEglSurface()
+   * @copydoc Dali::RenderSurface::DestroySurface()
    */
-  virtual void DestroyEglSurface( EglInterface& egl ) override;
+  virtual void DestroySurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
+   * @copydoc Dali::RenderSurface::ReplaceGraphicsSurface()
    */
-  virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
+  virtual bool ReplaceGraphicsSurface() override;
 
   /**
    * @copydoc Dali::RenderSurface::MoveResize()
@@ -116,12 +119,12 @@ public: // from Dali::RenderSurface
   /**
    * @copydoc Dali::RenderSurface::PreRender()
    */
-  virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
+  virtual bool PreRender( bool resizingSurface ) override;
 
   /**
    * @copydoc Dali::RenderSurface::PostRender()
    */
-  virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) override;
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface );
 
   /**
    * @copydoc Dali::RenderSurface::StopRender()
@@ -157,17 +160,18 @@ private:
 
 private: // Data
 
-  PositionSize                    mPosition;
-  TriggerEventInterface*          mRenderNotification;
-  ColorDepth                      mColorDepth;
-  tbm_format                      mTbmFormat;
-  bool                            mOwnSurface;
-  bool                            mDrawableCompleted;
-
-  tbm_surface_queue_h             mTbmQueue;
-  tbm_surface_h                   mConsumeSurface;
-  ThreadSynchronizationInterface* mThreadSynchronization;     ///< A pointer to the thread-synchronization
-  ConditionalWait                 mTbmSurfaceCondition;
+  PositionSize                           mPosition;
+  TriggerEventInterface*                 mRenderNotification;
+  Internal::Adaptor::GraphicsInterface*  mGraphics;                  ///< The graphics interface
+  ColorDepth                             mColorDepth;
+  tbm_format                             mTbmFormat;
+  bool                                   mOwnSurface;
+  bool                                   mDrawableCompleted;
+
+  tbm_surface_queue_h                    mTbmQueue;
+  tbm_surface_h                          mConsumeSurface;
+  ThreadSynchronizationInterface*        mThreadSynchronization;     ///< A pointer to the thread-synchronization
+  ConditionalWait                        mTbmSurfaceCondition;
 
 };
 
index b003cd1..9cf7d61 100644 (file)
@@ -24,6 +24,7 @@
 
 // INTERNAL HEADERS
 #include <dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
 
 namespace Dali
 {
@@ -43,7 +44,8 @@ DisplayConnection* DisplayConnectionX11::New()
 }
 
 DisplayConnectionX11::DisplayConnectionX11()
-: mDisplay(NULL)
+: mGraphics( nullptr ),
+  mDisplay( nullptr )
 {
 }
 
@@ -81,9 +83,10 @@ void DisplayConnectionX11::ConsumeEvents()
   while (events > 0);
 }
 
-bool DisplayConnectionX11::InitializeEgl(EglInterface& egl)
+bool DisplayConnectionX11::InitializeGraphics()
 {
-  EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   if (!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
   {
@@ -103,6 +106,11 @@ void DisplayConnectionX11::SetSurfaceType( RenderSurface::Type type )
   }
 }
 
+void DisplayConnectionX11::SetGraphicsInterface( GraphicsInterface& graphics )
+{
+  mGraphics = &graphics;
+}
+
 } // namespace Adaptor
 
 } // namespace Internal
index 5b5ba1e..ef2ac82 100644 (file)
@@ -74,12 +74,20 @@ public:
   void ConsumeEvents();
 
   /**
-   * @copydoc Dali::DisplayConnection::InitializeEgl
+   * @copydoc Dali::DisplayConnection::InitializeGraphics
    */
-  bool InitializeEgl(EglInterface& egl);
+  bool InitializeGraphics();
 
+  /**
+   * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetSurfaceType
+   */
   void SetSurfaceType( RenderSurface::Type type );
 
+  /**
+   * @copydoc Dali::Internal::Adaptor::DisplayConnection::SetGraphicsInterface
+   */
+  void SetGraphicsInterface( GraphicsInterface& graphics );
+
 public:
 
   /**
@@ -97,6 +105,8 @@ protected:
 
 private:
 
+  GraphicsInterface* mGraphics; ///< The graphics interface
+
 public:
 
   XDisplay*  mDisplay;        ///< X-display for rendering
index d9eabf3..910098a 100644 (file)
@@ -34,6 +34,8 @@
 #include <dali/integration-api/thread-synchronization-interface.h>
 #include <dali/internal/system/common/trigger-event.h>
 #include <dali/internal/window-system/common/display-connection.h>
+#include <dali/internal/graphics/gles20/egl-graphics.h>
+
 
 namespace Dali
 {
@@ -139,20 +141,22 @@ void PixmapRenderSurfaceEcoreX::GetDpi( unsigned int& dpiHorizontal, unsigned in
   dpiVertical   = int( yres + 0.5f );
 }
 
-void PixmapRenderSurfaceEcoreX::InitializeEgl( EglInterface& egl )
+void PixmapRenderSurfaceEcoreX::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection )
 {
-  DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
-
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  mGraphics = &graphics;
+  mDisplayConnection = &displayConnection;
 
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
   eglImpl.ChooseConfig(false, mColorDepth);
 }
 
-void PixmapRenderSurfaceEcoreX::CreateEglSurface( EglInterface& egl )
+void PixmapRenderSurfaceEcoreX::CreateSurface()
 {
   DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   for (int i = 0; i < BUFFER_COUNT; ++i)
   {
@@ -163,11 +167,13 @@ void PixmapRenderSurfaceEcoreX::CreateEglSurface( EglInterface& egl )
   }
 }
 
-void PixmapRenderSurfaceEcoreX::DestroyEglSurface( EglInterface& egl )
+void PixmapRenderSurfaceEcoreX::DestroySurface()
 {
   DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   for (int i = 0; i < BUFFER_COUNT; ++i)
   {
@@ -178,13 +184,15 @@ void PixmapRenderSurfaceEcoreX::DestroyEglSurface( EglInterface& egl )
   }
 }
 
-bool PixmapRenderSurfaceEcoreX::ReplaceEGLSurface( EglInterface& egl )
+bool PixmapRenderSurfaceEcoreX::ReplaceGraphicsSurface()
 {
   DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter );
 
   bool contextLost = false;
 
-  Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
+  Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
   for (int i = 0; i < BUFFER_COUNT; ++i)
   {
@@ -205,15 +213,18 @@ void PixmapRenderSurfaceEcoreX::StartRender()
 {
 }
 
-bool PixmapRenderSurfaceEcoreX::PreRender( EglInterface& egl, Integration::GlAbstraction&, bool )
+bool PixmapRenderSurfaceEcoreX::PreRender( bool )
 {
   // Nothing to do for pixmaps
   return true;
 }
 
-void PixmapRenderSurfaceEcoreX::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface )
+void PixmapRenderSurfaceEcoreX::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface )
 {
+  auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
+
   // flush gl instruction queue
+  Integration::GlAbstraction& glAbstraction = eglGraphics->GetGlAbstraction();
   glAbstraction.Flush();
 
   if( mThreadSynchronization )
@@ -225,7 +236,7 @@ void PixmapRenderSurfaceEcoreX::PostRender( EglInterface& egl, Integration::GlAb
     ConditionalWait::ScopedLock lock( mPixmapCondition );
     mConsumeBufferIndex = __sync_fetch_and_xor( &mProduceBufferIndex, 1 ); // Swap buffer indexes.
 
-    Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
+    Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
 
     // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit
     XPixmap pixmap = static_cast<XPixmap>( mX11Pixmaps[mProduceBufferIndex] );
@@ -254,7 +265,7 @@ void PixmapRenderSurfaceEcoreX::PostRender( EglInterface& egl, Integration::GlAb
       rect.width = mPosition.width;
       rect.height = mPosition.height;
 
-      XDisplay* display = AnyCast<XDisplay*>(displayConnection->GetDisplay());
+      XDisplay* display = AnyCast<XDisplay*>(mDisplayConnection->GetDisplay());
 
       // make a fixes region as updated area
       region = XFixesCreateRegion( display, &rect, 1 );
index 2cb3927..471092f 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__
-#define __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+#ifndef DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
+#define DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
 #include <dali/internal/window-system/common/pixmap-render-surface.h>
 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
 #include <dali/public-api/dali-adaptor-common.h>
+#include <dali/internal/graphics/common/graphics-interface.h>
 
 // EXTERNAL INCLUDES
 #include <dali/devel-api/threading/conditional-wait.h>
 #include <Ecore_X.h>
 
+
 namespace Dali
 {
 namespace Internal
@@ -81,24 +83,24 @@ public: // from Dali::RenderSurface
   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::InitializeEgl()
+   * @copydoc Dali::RenderSurface::InitializeGraphics()
    */
-  virtual void InitializeEgl( EglInterface& egl ) override;
+  virtual void InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) override;
 
   /**
-   * @copydoc Dali::RenderSurface::CreateEglSurface()
+   * @copydoc Dali::RenderSurface::CreateSurface()
    */
-  virtual void CreateEglSurface( EglInterface& egl ) override;
+  virtual void CreateSurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::DestroyEglSurface()
+   * @copydoc Dali::RenderSurface::DestroySurface()
    */
-  virtual void DestroyEglSurface( EglInterface& egl ) override;
+  virtual void DestroySurface() override;
 
   /**
-   * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
+   * @copydoc Dali::RenderSurface::ReplaceGraphicsSurface()
    */
-  virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
+  virtual bool ReplaceGraphicsSurface() override;
 
   /**
    * @copydoc Dali::RenderSurface::MoveResize()
@@ -118,12 +120,12 @@ public: // from Dali::RenderSurface
   /**
    * @copydoc Dali::RenderSurface::PreRender()
    */
-  virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
+  virtual bool PreRender( bool resizingSurface ) override;
 
   /**
    * @copydoc Dali::RenderSurface::PostRender()
    */
-  virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface );
+  virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) override;
 
   /**
    * @copydoc Dali::RenderSurface::StopRender()
@@ -174,7 +176,8 @@ private:
 private: // Data
 
   static const int BUFFER_COUNT = 2;
-
+  GraphicsInterface*              mGraphics;               ///< Graphics interface
+  Dali::DisplayConnection*        mDisplayConnection;      ///< Display connection
   PositionSize                    mPosition;               ///< Position
   TriggerEventInterface*          mRenderNotification;     ///< Render notification trigger
   ColorDepth                      mColorDepth;             ///< Color depth of surface (32 bit or 24 bit)
@@ -194,4 +197,4 @@ private: // Data
 
 } // namespace Dali
 
-#endif // __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__
+#endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
index b24742b..e6d8ccd 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_APPLICATION_H__
-#define __DALI_APPLICATION_H__
+#ifndef DALI_APPLICATION_H
+#define DALI_APPLICATION_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -19,7 +19,6 @@
  */
 
 // EXTERNAL INCLUDES
-#include <string>
 #include <dali/public-api/common/view-mode.h>
 #include <dali/public-api/object/base-handle.h>
 #include <dali/public-api/signals/callback.h>
@@ -471,4 +470,4 @@ public: // Not intended for application developers
  */
 } // namespace Dali
 
-#endif // __DALI_APPLICATION_H__
+#endif // DALI_APPLICATION_H