Force the completion of all GL executions before switching the context 71/202871/5
authorRichard Huang <r.huang@samsung.com>
Fri, 5 Apr 2019 09:38:21 +0000 (10:38 +0100)
committerRichard Huang <r.huang@samsung.com>
Wed, 10 Apr 2019 16:17:15 +0000 (17:17 +0100)
Change-Id: If09bfc187205bcd0f6f862f4774bcaf1f7a576c8

dali/internal/graphics/gles/egl-implementation.cpp
dali/internal/graphics/gles/egl-implementation.h

index dca3bd0..be463f7 100755 (executable)
@@ -64,6 +64,7 @@ EglImplementation::EglImplementation( int multiSamplingLevel,
   mEglConfig( 0 ),
   mEglContext( 0 ),
   mCurrentEglSurface( 0 ),
   mEglConfig( 0 ),
   mEglContext( 0 ),
   mCurrentEglSurface( 0 ),
+  mCurrentEglContext( EGL_NO_CONTEXT ),
   mMultiSamplingLevel( multiSamplingLevel ),
   mColorDepth( COLOR_DEPTH_24 ),
   mGlesInitialized( false ),
   mMultiSamplingLevel( multiSamplingLevel ),
   mColorDepth( COLOR_DEPTH_24 ),
   mGlesInitialized( false ),
@@ -201,11 +202,20 @@ void EglImplementation::DestroySurface( EGLSurface& eglSurface )
 
 void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext )
 {
 
 void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext )
 {
+  if (mCurrentEglContext == eglContext)
+  {
+    return;
+  }
+
   mCurrentEglSurface = eglSurface;
 
   if(mIsOwnSurface)
   {
   mCurrentEglSurface = eglSurface;
 
   if(mIsOwnSurface)
   {
+    glFinish();
+
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext );
+
+    mCurrentEglContext = eglContext;
   }
 
   EGLint error = eglGetError();
   }
 
   EGLint error = eglGetError();
@@ -220,12 +230,21 @@ void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eg
 
 void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface )
 {
 
 void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglSurface )
 {
+  if (mCurrentEglContext == mEglContext)
+  {
+    return;
+  }
+
   mCurrentEglNativePixmap = pixmap;
   mCurrentEglSurface = eglSurface;
 
   if(mIsOwnSurface)
   {
   mCurrentEglNativePixmap = pixmap;
   mCurrentEglSurface = eglSurface;
 
   if(mIsOwnSurface)
   {
+    glFinish();
+
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
     eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext );
+
+    mCurrentEglContext = mEglContext;
   }
 
   EGLint error = eglGetError();
   }
 
   EGLint error = eglGetError();
@@ -242,6 +261,7 @@ void EglImplementation::MakeContextNull()
 {
   // clear the current context
   eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
 {
   // clear the current context
   eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
+  mCurrentEglContext = EGL_NO_CONTEXT;
 }
 
 void EglImplementation::TerminateGles()
 }
 
 void EglImplementation::TerminateGles()
@@ -270,6 +290,7 @@ void EglImplementation::TerminateGles()
     mEglConfig  = NULL;
     mEglContext = NULL;
     mCurrentEglSurface = NULL;
     mEglConfig  = NULL;
     mEglContext = NULL;
     mCurrentEglSurface = NULL;
+    mCurrentEglContext = EGL_NO_CONTEXT;
 
     mGlesInitialized = false;
   }
 
     mGlesInitialized = false;
   }
index e299da7..3c75e3b 100644 (file)
@@ -205,6 +205,7 @@ private:
   EglWindowContextContainer mEglWindowContexts;                ///< The EGL context for the window
 
   EGLSurface           mCurrentEglSurface;
   EglWindowContextContainer mEglWindowContexts;                ///< The EGL context for the window
 
   EGLSurface           mCurrentEglSurface;
+  EGLContext           mCurrentEglContext;
 
   typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
   EglWindowSurfaceContainer mEglWindowSurfaces;                ///< The EGL surface for the window
 
   typedef std::vector<EGLSurface> EglWindowSurfaceContainer;
   EglWindowSurfaceContainer mEglWindowSurfaces;                ///< The EGL surface for the window