[4.0] Depth & Stencil buffers now disabled by default, can be enabled using env var
[platform/core/uifw/dali-adaptor.git] / adaptors / common / gl / egl-implementation.cpp
index c73525f..c6b179d 100644 (file)
@@ -52,19 +52,25 @@ namespace Adaptor
   } \
 }
 
-EglImplementation::EglImplementation()
-  : mEglNativeDisplay(0),
-    mEglNativeWindow(0),
-    mCurrentEglNativePixmap(0),
-    mEglDisplay(0),
-    mEglConfig(0),
-    mEglContext(0),
-    mCurrentEglSurface(0),
-    mGlesInitialized(false),
-    mIsOwnSurface(true),
-    mContextCurrent(false),
-    mIsWindow(true),
-    mColorDepth(COLOR_DEPTH_24)
+EglImplementation::EglImplementation( int multiSamplingLevel,
+                                      Integration::DepthBufferAvailable depthBufferRequired,
+                                      Integration::StencilBufferAvailable stencilBufferRequired )
+: mContextAttribs(),
+  mEglNativeDisplay( 0 ),
+  mEglNativeWindow( 0 ),
+  mCurrentEglNativePixmap( 0 ),
+  mEglDisplay( 0 ),
+  mEglConfig( 0 ),
+  mEglContext( 0 ),
+  mCurrentEglSurface( 0 ),
+  mMultiSamplingLevel( multiSamplingLevel ),
+  mColorDepth( COLOR_DEPTH_24 ),
+  mGlesInitialized( false ),
+  mIsOwnSurface( true ),
+  mContextCurrent( false ),
+  mIsWindow( true ),
+  mDepthBufferRequired( depthBufferRequired == Integration::DepthBufferAvailable::TRUE ),
+  mStencilBufferRequired( stencilBufferRequired == Integration::StencilBufferAvailable::TRUE )
 {
 }
 
@@ -154,6 +160,8 @@ void EglImplementation::DestroySurface()
 {
   if(mIsOwnSurface && mCurrentEglSurface)
   {
+    // Make context null to prevent crash in driver side
+    MakeContextNull();
     eglDestroySurface( mEglDisplay, mCurrentEglSurface );
     mCurrentEglSurface = 0;
   }
@@ -220,9 +228,7 @@ void EglImplementation::TerminateGles()
 {
   if ( mGlesInitialized )
   {
-    // in latest Mali DDK (r2p3 ~ r3p0 in April, 2012),
-    // MakeContextNull should be called before eglDestroy surface
-    // to prevent crash in _mali_surface_destroy_callback
+    // Make context null to prevent crash in driver side
     MakeContextNull();
 
     if(mIsOwnSurface && mCurrentEglSurface)
@@ -329,14 +335,18 @@ void EglImplementation::ChooseConfig( bool isWindowType, ColorDepth depth )
 #endif // _ARCH_ARM_
 
   configAttribs.PushBack( EGL_DEPTH_SIZE );
-  configAttribs.PushBack( 24 );
+  configAttribs.PushBack( mDepthBufferRequired ? 24 : 0 );
   configAttribs.PushBack( EGL_STENCIL_SIZE );
-  configAttribs.PushBack( 8 );
+  configAttribs.PushBack( mStencilBufferRequired ? 8 : 0 );
+
 #ifndef DALI_PROFILE_UBUNTU
-  configAttribs.PushBack( EGL_SAMPLES );
-  configAttribs.PushBack( 4 );
-  configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
-  configAttribs.PushBack( 1 );
+  if( mMultiSamplingLevel != EGL_DONT_CARE )
+  {
+    configAttribs.PushBack( EGL_SAMPLES );
+    configAttribs.PushBack( mMultiSamplingLevel );
+    configAttribs.PushBack( EGL_SAMPLE_BUFFERS );
+    configAttribs.PushBack( 1 );
+  }
 #endif // DALI_PROFILE_UBUNTU
   configAttribs.PushBack( EGL_NONE );