[Tizen] Use OpenGL es 2.0 if eglCreateContext is fail, Prevent glFinish without makeC...
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / combined-update-render-controller.cpp
index 93e1d9e..2185ed8 100644 (file)
@@ -214,9 +214,13 @@ void CombinedUpdateRenderController::Resume()
 
     mRunning = TRUE;
     mForceClear = TRUE;
-  }
 
-  DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" );
+    DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" );
+  }
+  else
+  {
+    DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume: Already resumed [%d, %d, %d]\n", mRunning, mUpdateRenderRunCount, mUpdateRenderThreadCanSleep );
+  }
 }
 
 void CombinedUpdateRenderController::Stop()
@@ -431,18 +435,41 @@ void CombinedUpdateRenderController::UpdateRenderThread()
   EglInterface* eglInterface = &eglGraphics->GetEglInterface();
 
   Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( *eglInterface );
+
   // Try to use OpenGL es 3.0
   // ChooseConfig returns false here when the device only support gles 2.0.
   // Because eglChooseConfig with gles 3.0 setting fails when the device only support gles 2.0 and Our default setting is gles 3.0.
-  if( eglImpl.ChooseConfig( true, COLOR_DEPTH_32 ) )
+  if( !eglImpl.ChooseConfig( true, COLOR_DEPTH_32 ) )
+  {
+    // Retry to use OpenGL es 2.0
+    eglGraphics->SetGlesVersion( 20 );
+    eglImpl.ChooseConfig( true, COLOR_DEPTH_32 );
+  }
+  else
+  {
+    if( !eglImpl.CreateContext() )
+    {
+      // Retry to use OpenGL es 2.0
+      eglGraphics->SetGlesVersion( 20 );
+      eglImpl.ChooseConfig( true, COLOR_DEPTH_32 );
+    }
+  }
+
+  // Check whether surfaceless context is supported
+  bool isSurfacelessContextSupported = eglImpl.IsSurfacelessContextSupported();
+  eglGraphics->SetIsSurfacelessContextSupported( isSurfacelessContextSupported );
+
+  if ( isSurfacelessContextSupported )
   {
     // Create a surfaceless OpenGL context for shared resources
-    eglImpl.CreateContext();
+    if( eglImpl.GetContext() == 0 )
+    {
+      eglImpl.CreateContext();
+    }
     eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );
   }
-  else // Retry to use OpenGL es 2.0
+  else
   {
-    eglGraphics->SetGlesVersion( 20 );
     currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
     if( currentSurface )
     {
@@ -583,7 +610,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
       }
     }
 
-    if( eglImpl.GetGlesVersion() >= 30 )
+    if( eglImpl.IsSurfacelessContextSupported() )
     {
       // Make the shared surfaceless context as current before rendering
       eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );