[Tizen] Use OpenGL es 2.0 if eglCreateContext is fail, Prevent glFinish without makeC...
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / egl-implementation.cpp
index 2172e37..ae7c6bc 100755 (executable)
@@ -147,6 +147,17 @@ bool EglImplementation::CreateContext()
   DALI_ASSERT_ALWAYS( (mEglContext == 0) && "EGL context recreated" );
 
   mEglContext = eglCreateContext(mEglDisplay, mEglConfig, NULL, &(mContextAttribs[0]));
+  if ( eglGetError() != EGL_SUCCESS )
+  {
+    if( mGlesVersion >= 30 )
+    {
+      eglDestroySurface( mEglDisplay, mEglContext );
+      mEglContext = NULL;
+      mEglConfig = NULL;
+      DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
+      return false;
+    }
+  }
   TEST_EGL_ERROR("eglCreateContext render thread");
 
   DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
@@ -211,7 +222,10 @@ void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eg
 
   if(mIsOwnSurface)
   {
-    glFinish();
+    if( mCurrentEglContext != EGL_NO_CONTEXT )
+    {
+      glFinish();
+    }
 
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
 
@@ -240,7 +254,10 @@ void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglS
 
   if(mIsOwnSurface)
   {
-    glFinish();
+    if( mCurrentEglContext != EGL_NO_CONTEXT )
+    {
+      glFinish();
+    }
 
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
 
@@ -326,8 +343,6 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
     return true;
   }
 
-  bool isTransparent = ( depth == COLOR_DEPTH_32 );
-
   mColorDepth = depth;
   mIsWindow = isWindowType;
 
@@ -350,11 +365,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 
   if( mGlesVersion >= 30 )
   {
-#ifdef _ARCH_ARM_
     configAttribs.PushBack( EGL_OPENGL_ES3_BIT_KHR );
-#else
-    configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
-#endif // _ARCH_ARM_
   }
   else
   {
@@ -372,18 +383,10 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
   configAttribs.PushBack( EGL_BLUE_SIZE );
   configAttribs.PushBack( 8 );
 
-  if ( isTransparent )
-  {
-    configAttribs.PushBack( EGL_ALPHA_SIZE );
-#ifdef _ARCH_ARM_
-    // For underlay video playback, we also need to set the alpha value of the 24/32bit window.
-    configAttribs.PushBack( 8 );
-#else
-    // There is a bug in the desktop emulator
-    // setting EGL_ALPHA_SIZE to 8 results in eglChooseConfig failing
-    configAttribs.PushBack( 8 );
-#endif // _ARCH_ARM_
-  }
+  // In the previous code, there was a branch for ARM.
+  // If there is an issue in only ARM, we need to check here again.
+  configAttribs.PushBack( EGL_ALPHA_SIZE );
+  configAttribs.PushBack( 8 );
 
   configAttribs.PushBack( EGL_DEPTH_SIZE );
   configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 );
@@ -409,7 +412,7 @@ bool EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
     if( mGlesVersion >= 30 )
     {
       mEglConfig = NULL;
-      DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retring to use OpenGL es 2.0.");
+      DALI_LOG_ERROR("Fail to use OpenGL es 3.0. Retrying to use OpenGL es 2.0.");
       return false;
     }