[Tizen] Revert "Support multiple window rendering"
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-render-surface.cpp
index 2ff7944..cac09c5 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/integration-api/thread-synchronization-interface.h>
 #include <dali/internal/graphics/gles/egl-implementation.h>
 #include <dali/internal/adaptor/common/adaptor-impl.h>
-#include <dali/internal/adaptor/common/adaptor-internal-services.h>
 #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>
@@ -59,8 +58,6 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s
   mRenderNotification( NULL ),
   mRotationTrigger( NULL ),
   mGraphics( nullptr ),
-  mEGLSurface( nullptr ),
-  mEGLContext( nullptr ),
   mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ),
   mOutputTransformedSignal(),
   mRotationAngle( 0 ),
@@ -180,24 +177,28 @@ void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpi
   mWindowBase->GetDpi( dpiHorizontal, dpiVertical );
 }
 
-void WindowRenderSurface::InitializeGraphics()
+void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection )
 {
-
-  mGraphics = &mAdaptor->GetGraphicsInterface();
+  mGraphics = &graphics;
 
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
-  mEGL = &eglGraphics->GetEglInterface();
 
-  if ( mEGLContext == NULL )
-  {
-    // Create the OpenGL context for this window
-    Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>(*mEGL);
-    eglImpl.ChooseConfig(true, mColorDepth);
-    eglImpl.CreateWindowContext( mEGLContext );
+  EglInterface* mEGL = eglGraphics->Create();
 
-    // Create the OpenGL surface
-    CreateSurface();
-  }
+  // 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::CreateSurface()
@@ -222,7 +223,7 @@ void WindowRenderSurface::CreateSurface()
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
 
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-  mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth );
+  eglImpl.CreateSurfaceWindow( window, mColorDepth );
 
   // Check rotation capability
   mRotationSupported = mWindowBase->IsEglWindowRotationSupported();
@@ -237,7 +238,7 @@ void WindowRenderSurface::DestroySurface()
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
 
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-  eglImpl.DestroySurface( mEGLSurface );
+  eglImpl.DestroySurface();
 
   mWindowBase->DestroyEglWindow();
 }
@@ -270,7 +271,7 @@ bool WindowRenderSurface::ReplaceGraphicsSurface()
   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
 
   Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-  return eglImpl.ReplaceSurfaceWindow( window, mEGLSurface, mEGLContext );
+  return eglImpl.ReplaceSurfaceWindow( window );
 }
 
 void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize )
@@ -325,8 +326,6 @@ void WindowRenderSurface::StartRender()
 
 bool WindowRenderSurface::PreRender( bool resizingSurface )
 {
-  MakeContextCurrent();
-
   if( resizingSurface )
   {
 #ifdef OVER_TIZEN_VERSION_4
@@ -405,7 +404,7 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b
     }
 
     Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
-    eglImpl.SwapBuffers( mEGLSurface );
+    eglImpl.SwapBuffers();
 
     if( mRenderNotification )
     {
@@ -430,29 +429,11 @@ void WindowRenderSurface::ReleaseLock()
   // Nothing to do.
 }
 
-Integration::RenderSurface::Type WindowRenderSurface::GetSurfaceType()
+RenderSurface::Type WindowRenderSurface::GetSurfaceType()
 {
   return RenderSurface::WINDOW_RENDER_SURFACE;
 }
 
-void WindowRenderSurface::MakeContextCurrent()
-{
-  if ( mEGL != nullptr )
-  {
-    mEGL->MakeContextCurrent( mEGLSurface, mEGLContext );
-  }
-}
-
-Integration::DepthBufferAvailable WindowRenderSurface::GetDepthBufferRequired()
-{
-  return mGraphics ? mGraphics->GetDepthBufferRequired() : Integration::DepthBufferAvailable::FALSE;
-}
-
-Integration::StencilBufferAvailable WindowRenderSurface::GetStencilBufferRequired()
-{
-  return mGraphics ? mGraphics->GetStencilBufferRequired() : Integration::StencilBufferAvailable::FALSE;
-}
-
 void WindowRenderSurface::OutputTransformed()
 {
   int screenRotationAngle = mWindowBase->GetScreenRotationAngle();