X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git;a=blobdiff_plain;f=dali%2Finternal%2Fgraphics%2Fgles%2Fegl-implementation.cpp;h=dca3bd01ac484a91141bb6b4d8d265cb95c91cb1;hp=9557582e90a61c896380bae317cb869417190675;hb=263ec21432f3d7c9f9be5b463748fdce8f6942e4;hpb=43235b18c881038f256cc7ebdbaa13d0930122c6 diff --git a/dali/internal/graphics/gles/egl-implementation.cpp b/dali/internal/graphics/gles/egl-implementation.cpp index 9557582..dca3bd0 100755 --- a/dali/internal/graphics/gles/egl-implementation.cpp +++ b/dali/internal/graphics/gles/egl-implementation.cpp @@ -68,7 +68,6 @@ EglImplementation::EglImplementation( int multiSamplingLevel, mColorDepth( COLOR_DEPTH_24 ), mGlesInitialized( false ), mIsOwnSurface( true ), - mContextCurrent( false ), mIsWindow( true ), mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ), mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE ) @@ -160,32 +159,53 @@ bool EglImplementation::CreateContext() return true; } -void EglImplementation::DestroyContext() +bool EglImplementation::CreateWindowContext( EGLContext& eglContext ) +{ + // make sure a context isn't created twice + DALI_ASSERT_ALWAYS( (eglContext == 0) && "EGL context recreated" ); + + eglContext = eglCreateContext(mEglDisplay, mEglConfig, mEglContext, &(mContextAttribs[0])); + TEST_EGL_ERROR("eglCreateContext render thread"); + + DALI_ASSERT_ALWAYS( EGL_NO_CONTEXT != eglContext && "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)); + + mEglWindowContexts.push_back( eglContext ); + + return true; +} + +void EglImplementation::DestroyContext( EGLContext& eglContext ) { DALI_ASSERT_ALWAYS( mEglContext && "no EGL context" ); - eglDestroyContext( mEglDisplay, mEglContext ); - mEglContext = 0; + eglDestroyContext( mEglDisplay, eglContext ); + eglContext = 0; } -void EglImplementation::DestroySurface() +void EglImplementation::DestroySurface( EGLSurface& eglSurface ) { - if(mIsOwnSurface && mCurrentEglSurface) + if(mIsOwnSurface && eglSurface) { // Make context null to prevent crash in driver side MakeContextNull(); - eglDestroySurface( mEglDisplay, mCurrentEglSurface ); - mCurrentEglSurface = 0; + eglDestroySurface( mEglDisplay, eglSurface ); + eglSurface = 0; } } -void EglImplementation::MakeContextCurrent() +void EglImplementation::MakeContextCurrent( EGLSurface eglSurface, EGLContext eglContext ) { - mContextCurrent = true; + mCurrentEglSurface = eglSurface; if(mIsOwnSurface) { - eglMakeCurrent( mEglDisplay, mCurrentEglSurface, mCurrentEglSurface, mEglContext ); + eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, eglContext ); } EGLint error = eglGetError(); @@ -205,7 +225,7 @@ void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglS if(mIsOwnSurface) { - eglMakeCurrent( mEglDisplay, mCurrentEglSurface, mCurrentEglSurface, mEglContext ); + eglMakeCurrent( mEglDisplay, eglSurface, eglSurface, mEglContext ); } EGLint error = eglGetError(); @@ -220,7 +240,6 @@ void EglImplementation::MakeCurrent( EGLNativePixmapType pixmap, EGLSurface eglS void EglImplementation::MakeContextNull() { - mContextCurrent = false; // clear the current context eglMakeCurrent( mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); } @@ -232,11 +251,18 @@ void EglImplementation::TerminateGles() // Make context null to prevent crash in driver side MakeContextNull(); - if(mIsOwnSurface && mCurrentEglSurface) + for ( auto eglSurface : mEglWindowSurfaces ) { - eglDestroySurface(mEglDisplay, mCurrentEglSurface); + if(mIsOwnSurface && eglSurface) + { + eglDestroySurface(mEglDisplay, eglSurface); + } } eglDestroyContext(mEglDisplay, mEglContext); + for ( auto eglContext : mEglWindowContexts ) + { + eglDestroyContext(mEglDisplay, eglContext); + } eglTerminate(mEglDisplay); @@ -254,14 +280,17 @@ bool EglImplementation::IsGlesInitialized() const return mGlesInitialized; } -void EglImplementation::SwapBuffers() +void EglImplementation::SwapBuffers( EGLSurface& eglSurface ) { - eglSwapBuffers( mEglDisplay, mCurrentEglSurface ); + if ( eglSurface != EGL_NO_SURFACE ) // skip if using surfaceless context + { + eglSwapBuffers( mEglDisplay, eglSurface ); + } } -void EglImplementation::CopyBuffers() +void EglImplementation::CopyBuffers( EGLSurface& eglSurface ) { - eglCopyBuffers( mEglDisplay, mCurrentEglSurface, mCurrentEglNativePixmap ); + eglCopyBuffers( mEglDisplay, eglSurface, mCurrentEglNativePixmap ); } void EglImplementation::WaitGL() @@ -276,6 +305,8 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth ) return; } + bool isTransparent = ( depth == COLOR_DEPTH_32 ); + mIsWindow = isWindowType; EGLint numConfigs; @@ -326,15 +357,18 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth ) configAttribs.PushBack( EGL_BLUE_SIZE ); configAttribs.PushBack( 8 ); - configAttribs.PushBack( EGL_ALPHA_SIZE ); + 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 ); + // 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( 0 ); + // There is a bug in the desktop emulator + // setting EGL_ALPHA_SIZE to 8 results in eglChooseConfig failing + configAttribs.PushBack( 8 ); #endif // _ARCH_ARM_ + } configAttribs.PushBack( EGL_DEPTH_SIZE ); configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 ); @@ -393,10 +427,8 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth ) } } -void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth ) +EGLSurface EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDepth depth ) { - DALI_ASSERT_ALWAYS( ( mCurrentEglSurface == 0 ) && "EGL surface already exists" ); - mEglNativeWindow = window; mColorDepth = depth; mIsWindow = true; @@ -408,6 +440,8 @@ void EglImplementation::CreateSurfaceWindow( EGLNativeWindowType window, ColorDe TEST_EGL_ERROR("eglCreateWindowSurface"); DALI_ASSERT_ALWAYS( mCurrentEglSurface && "Create window surface failed" ); + + return mCurrentEglSurface; } EGLSurface EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, ColorDepth depth ) @@ -427,7 +461,7 @@ EGLSurface EglImplementation::CreateSurfacePixmap( EGLNativePixmapType pixmap, C return mCurrentEglSurface; } -bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window ) +bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window, EGLSurface& eglSurface, EGLContext& eglContext ) { bool contextLost = false; @@ -436,13 +470,13 @@ bool EglImplementation::ReplaceSurfaceWindow( EGLNativeWindowType window ) MakeContextNull(); // destroy the surface - DestroySurface(); + DestroySurface( eglSurface ); // create the EGL surface CreateSurfaceWindow( window, mColorDepth ); // set the context to be current with the new surface - MakeContextCurrent(); + MakeContextCurrent( eglSurface, eglContext ); return contextLost; } @@ -466,7 +500,7 @@ EGLDisplay EglImplementation::GetDisplay() const return mEglDisplay; } -EGLDisplay EglImplementation::GetContext() const +EGLContext EglImplementation::GetContext() const { return mEglContext; }