Add support for new accessibility actions
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / egl-implementation-x.cpp
index 5077d17..07b01d5 100644 (file)
@@ -26,6 +26,7 @@
 
 // INTERNAL INCLUDES
 #include <ecore-x-render-surface.h>
+#include <gl/gl-implementation.h>
 
 namespace Dali
 {
@@ -56,7 +57,6 @@ EglImplementation::EglImplementation()
     mEglSurface(0),
     mGlesInitialized(false),
     mIsOwnSurface(true),
-    mSyncMode(FULL_SYNC),
     mContextCurrent(false),
     mIsWindow(true),
     mColorDepth(COLOR_DEPTH_24)
@@ -76,6 +76,12 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
 
     //@todo see if we can just EGL_DEFAULT_DISPLAY instead
     mEglDisplay = eglGetDisplay(mEglNativeDisplay);
+    EGLint error = eglGetError();
+
+    if( mEglDisplay == NULL && error != EGL_SUCCESS )
+    {
+      throw Dali::DaliException( "", "OpenGL ES is not supported");
+    }
 
     EGLint majorVersion = 0;
     EGLint minorVersion = 0;
@@ -122,6 +128,12 @@ bool EglImplementation::CreateContext()
 
   DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != mEglContext && "EGL context not created" );
 
+  DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VENDOR : %s ***\n", glGetString(GL_VENDOR));
+  DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_RENDERER : %s ***\n", glGetString(GL_RENDERER));
+  DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_VERSION : %s ***\n", glGetString(GL_VERSION));
+  DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** GL_SHADING_LANGUAGE_VERSION : %s***\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
+  DALI_LOG_INFO(Debug::Filter::gShader, Debug::General, "*** Supported Extensions ***\n%s\n\n", glGetString(GL_EXTENSIONS));
+
   return true;
 }
 
@@ -231,11 +243,6 @@ void EglImplementation::MakeContextCurrent()
       eglQueryString(mEglDisplay, EGL_VERSION),
       eglQueryString(mEglDisplay, EGL_CLIENT_APIS),
       eglQueryString(mEglDisplay, EGL_EXTENSIONS));
-
-  if ( mIsWindow )
-  {
-    SetRefreshSync( mSyncMode );
-  }
 }
 
 void EglImplementation::MakeContextNull()
@@ -276,32 +283,6 @@ bool EglImplementation::IsGlesInitialized() const
   return mGlesInitialized;
 }
 
-bool EglImplementation::SetRefreshSync( SyncMode mode )
-{
-  if ( mIsWindow == false )
-  {
-    return false;
-  }
-  mSyncMode = mode;
-
-  // eglSwapInterval specifies the minimum number of video frame periods
-  // per buffer swap for the window associated with the current context.
-
-  if ( !mContextCurrent )
-  {
-    return true;
-  }
-
-  EGLBoolean ok = eglSwapInterval( mEglDisplay, mode );
-  if ( !ok )
-  {
-    TEST_EGL_ERROR("eglSwapInterval");
-    return false;
-  }
-
-  return true;
-}
-
 void EglImplementation::SwapBuffers()
 {
   eglSwapBuffers( mEglDisplay, mEglSurface );
@@ -356,6 +337,7 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 
 #else // DALI_GLES_VERSION >= 30
 
+  DALI_LOG_WARNING( "Using OpenGL ES 2 \n" );
   configAttribs.PushBack( EGL_OPENGL_ES2_BIT );
 
 #endif //DALI_GLES_VERSION >= 30
@@ -386,10 +368,12 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
   configAttribs.PushBack( 24 );
   configAttribs.PushBack( EGL_STENCIL_SIZE );
   configAttribs.PushBack( 8 );
+#ifndef DALI_PROFILE_UBUNTU
   configAttribs.PushBack( EGL_SAMPLES );
   configAttribs.PushBack( 4 );
   configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
   configAttribs.PushBack( 1 );
+#endif // DALI_PROFILE_UBUNTU
   configAttribs.PushBack( EGL_NONE );
 
   if ( eglChooseConfig( mEglDisplay, &(configAttribs[0]), &mEglConfig, 1, &numConfigs ) != EGL_TRUE )
@@ -399,27 +383,27 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
     {
       case EGL_BAD_DISPLAY:
       {
-        DALI_LOG_ERROR("Display is not an EGL display connection");
+        DALI_LOG_ERROR("Display is not an EGL display connection\n");
         break;
       }
       case EGL_BAD_ATTRIBUTE:
       {
-        DALI_LOG_ERROR("The parameter confirAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range");
+        DALI_LOG_ERROR("The parameter configAttribs contains an invalid frame buffer configuration attribute or an attribute value that is unrecognized or out of range\n");
         break;
       }
       case EGL_NOT_INITIALIZED:
       {
-        DALI_LOG_ERROR("Display has not been initialized");
+        DALI_LOG_ERROR("Display has not been initialized\n");
         break;
       }
       case EGL_BAD_PARAMETER:
       {
-        DALI_LOG_ERROR("The parameter numConfig is NULL");
+        DALI_LOG_ERROR("The parameter numConfig is NULL\n");
         break;
       }
       default:
       {
-        DALI_LOG_ERROR("Unknown error");
+        DALI_LOG_ERROR("Unknown error.\n");
       }
     }
     DALI_ASSERT_ALWAYS(false && "eglChooseConfig failed!");
@@ -427,13 +411,12 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 
   if ( numConfigs != 1 )
   {
-    DALI_LOG_ERROR("No configurations found.");
+    DALI_LOG_ERROR("No configurations found.\n");
 
     TEST_EGL_ERROR("eglChooseConfig");
   }
 }
 
-
 void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth )
 {
   DALI_ASSERT_ALWAYS( ( mEglSurface == 0 ) && "EGL surface already exists" );
@@ -468,54 +451,27 @@ void EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDe
   DALI_ASSERT_ALWAYS( mEglSurface && "Create pixmap surface failed" );
 }
 
-bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLNativeDisplayType display )
+bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window )
 {
   bool contextLost = false;
 
+  // display connection has not changed, then we can just create a new surface
   //  the surface is bound to the context, so set the context to null
   MakeContextNull();
 
   // destroy the surface
   DestroySurface();
 
-  // If the display has not changed, then we can just create a new surface
-  if ( display == mEglNativeDisplay )
-  {
-    // create the EGL surface
-    CreateSurfaceWindow( window, mColorDepth );
-
-    // set the context to be current with the new surface
-    MakeContextCurrent();
-  }
-  else  // the display has changed, we need to start egl with a new x-connection
-  {
-    // Note! this code path is untested
-
-    // this will release all EGL specific resources
-    eglTerminate( mEglDisplay );
-
-    mGlesInitialized = false;
-
-    // let the adaptor know that all resources have been lost
-    contextLost = true;
-
-    // re-initialise GLES with the new connection
-    InitializeGles( display );
+  // create the EGL surface
+  CreateSurfaceWindow( window, mColorDepth );
 
-    // create the EGL surface
-    CreateSurfaceWindow( window, mColorDepth );
-
-    // create the OpenGL context
-    CreateContext();
-
-    // Make it current
-    MakeContextCurrent();
-  }
+  // set the context to be current with the new surface
+  MakeContextCurrent();
 
   return contextLost;
 }
 
-bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNativeDisplayType display )
+bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap )
 {
   bool contextLost = false;
 
@@ -525,39 +481,13 @@ bool EglImplementation::ReplaceSurfacePixmap( EGLNativePixmapType pixmap, EGLNat
   // destroy the surface
   DestroySurface();
 
-  // If the display has not changed, then we can just create a new surface
-  if ( display == mEglNativeDisplay )
-  {
-    // create the EGL surface
-    CreateSurfacePixmap( pixmap, mColorDepth );
-
-    // set the context to be current with the new surface
-    MakeContextCurrent();
-  }
-  else  // the display has changed, we need to start egl with a new x-connection
-  {
-    // Note! this code path is untested
-
-    // this will release all EGL specific resources
-    eglTerminate( mEglDisplay );
-
-    mGlesInitialized = false;
-
-    // let the adaptor know that all resources have been lost
-    contextLost = true;
-
-    // re-initialise GLES with the new connection
-    InitializeGles( display );
+  // display connection has not changed, then we can just create a new surface
+  // create the EGL surface
+  CreateSurfacePixmap( pixmap, mColorDepth );
 
-    // create the EGL surface
-    CreateSurfacePixmap( pixmap, mColorDepth );
+  // set the context to be current with the new surface
+  MakeContextCurrent();
 
-    // create the OpenGL context
-    CreateContext();
-
-    // Make it current
-    MakeContextCurrent();
-  }
   return contextLost;
 }
 
@@ -576,4 +506,3 @@ EGLDisplay EglImplementation::GetContext() const
 } // namespace Internal
 
 } // namespace Dali
-