GlWindow::GlWindow()
: mWindowBase(),
- mGraphics( nullptr ),
+ mGraphics(),
+ mDisplayConnection( nullptr ),
mEventHandler( nullptr ),
mPositionSize(),
mColorDepth( COLOR_DEPTH_24 ),
mFocusChangeSignal(),
mResizeSignal(),
mVisibilityChangedSignal(),
- mGLInitCallback( 0 ),
- mGLRenderFrameCallback( 0 ),
- mGLTerminateCallback( 0 ),
+ mGLInitCallback(),
+ mGLRenderFrameCallback(),
+ mGLTerminateCallback(),
mGLRenderCallback( nullptr ),
mEGLSurface( nullptr ),
mEGLContext( nullptr ),
mEventHandler->RemoveObserver( *this );
}
- if( Dali::Adaptor::IsAvailable() && mGLRenderCallback )
- {
- Dali::Adaptor::Get().RemoveIdle( mGLRenderCallback );
- }
-
if( mGLTerminateCallback )
{
- mGLTerminateCallback();
+ CallbackBase::Execute(*mGLTerminateCallback);
}
if( mIsEGLInitialize )
{
- EglGraphics *eglGraphics = static_cast<EglGraphics*>( mGraphics );
+ GraphicsInterface* graphics = mGraphics.get();
+ EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
if( mEGLSurface )
eglImpl.DestroyContext( mEGLContext );
mEGLContext = nullptr;
}
+
+ eglImpl.TerminateGles();
+
+ mGraphics->Destroy();
}
}
mWindowBase->SetAvailableAnlges( angles );
}
-bool GlWindow::IsOrientationAvailable( Dali::GlWindow::GlWindowOrientation orientation ) const
+bool GlWindow::IsOrientationAvailable( WindowOrientation orientation ) const
{
- if( orientation <= Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE
- || orientation > Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE )
+ if( orientation <= WindowOrientation::NO_ORIENTATION_PREFERENCE
+ || orientation > WindowOrientation::LANDSCAPE_INVERSE )
{
DALI_LOG_INFO( gWindowLogFilter, Debug::Verbose, "Window::IsOrientationAvailable: Invalid input orientation [%d]\n", orientation );
return false;
return true;
}
-int GlWindow::ConvertToAngle( Dali::GlWindow::GlWindowOrientation orientation )
+int GlWindow::ConvertToAngle( WindowOrientation orientation )
{
int convertAngle = 0;
if ( mOrientationMode == 0 )
{
- convertAngle = ( static_cast< int >( orientation ) ) * 90;
+ convertAngle = static_cast< int >( orientation );
}
else if( mOrientationMode == 1)
{
switch( orientation )
{
- case Dali::GlWindow::GlWindowOrientation::LANDSCAPE:
+ case WindowOrientation::LANDSCAPE:
{
convertAngle = 0;
break;
}
- case Dali::GlWindow::GlWindowOrientation::PORTRAIT:
+ case WindowOrientation::PORTRAIT:
{
convertAngle = 90;
break;
}
- case Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE:
+ case WindowOrientation::LANDSCAPE_INVERSE:
{
convertAngle = 180;
break;
}
- case Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE:
+ case WindowOrientation::PORTRAIT_INVERSE:
{
convertAngle = 270;
break;
}
- case Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE:
+ case WindowOrientation::NO_ORIENTATION_PREFERENCE:
{
convertAngle = -1;
break;
return convertAngle;
}
-Dali::GlWindow::GlWindowOrientation GlWindow::ConvertToOrientation( int angle ) const
+WindowOrientation GlWindow::ConvertToOrientation( int angle ) const
{
- Dali::GlWindow::GlWindowOrientation orientation = Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE;
+ WindowOrientation orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
if ( mOrientationMode == 0 ) // Portrate mode
{
- orientation = static_cast< Dali::GlWindow::GlWindowOrientation >( angle / 90 );
+ orientation = static_cast< WindowOrientation >( angle );
}
else if( mOrientationMode == 1 ) // Landscape mode
{
{
case 0:
{
- orientation = Dali::GlWindow::GlWindowOrientation::LANDSCAPE;
+ orientation = WindowOrientation::LANDSCAPE;
break;
}
case 90:
{
- orientation = Dali::GlWindow::GlWindowOrientation::PORTRAIT;
+ orientation = WindowOrientation::PORTRAIT;
break;
}
case 180:
{
- orientation = Dali::GlWindow::GlWindowOrientation::LANDSCAPE_INVERSE;
+ orientation = WindowOrientation::LANDSCAPE_INVERSE;
break;
}
case 270:
{
- orientation = Dali::GlWindow::GlWindowOrientation::PORTRAIT_INVERSE;
+ orientation = WindowOrientation::PORTRAIT_INVERSE;
break;
}
case -1:
{
- orientation = Dali::GlWindow::GlWindowOrientation::NO_ORIENTATION_PREFERENCE;
+ orientation = WindowOrientation::NO_ORIENTATION_PREFERENCE;
break;
}
}
return orientation;
}
-Dali::GlWindow::GlWindowOrientation GlWindow::GetCurrentOrientation() const
+WindowOrientation GlWindow::GetCurrentOrientation() const
{
DALI_LOG_RELEASE_INFO( "Window (%p), WinId (%d), GetCurrentOrientation(): %d\n", this, mNativeWindowId, mTotalRotationAngle );
return ConvertToOrientation( mTotalRotationAngle );
}
-void GlWindow::SetAvailableOrientations( const Dali::Vector< Dali::GlWindow::GlWindowOrientation >& orientations )
+void GlWindow::SetAvailableOrientations( const Dali::Vector< WindowOrientation >& orientations )
{
Dali::Vector<float>::SizeType count = orientations.Count();
for( Dali::Vector<float>::SizeType index = 0; index < count; ++index )
SetAvailableAnlges( mAvailableAngles );
}
-void GlWindow::SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation )
+void GlWindow::SetPreferredOrientation( WindowOrientation orientation )
{
if( IsOrientationAvailable( orientation ) == false )
{
}
}
-void GlWindow::RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate )
+void GlWindow::RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback )
{
if( mIsEGLInitialize == false )
{
InitializeGraphics();
}
- mGLInitCallback = glInit;
- mGLRenderFrameCallback = glRenderFrame;
- mGLTerminateCallback = glTerminate;
+ mGLInitCallback = std::unique_ptr< CallbackBase >(initCallback);
+ mGLRenderFrameCallback = std::unique_ptr< CallbackBase >( renderFrameCallback );
+ mGLTerminateCallback = std::unique_ptr< CallbackBase >( terminateCallback );
mInitCallback = false;
bool GlWindow::RunCallback()
{
- EglGraphics *eglGraphics = static_cast<EglGraphics*>( mGraphics );
+ GraphicsInterface* graphics = mGraphics.get();
+ EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
eglImpl.MakeContextCurrent( mEGLSurface, mEGLContext );
+ int renderFrameResult = 0;
+
if( mIsRotated )
{
mWindowBase->SetEglWindowBufferTransform( mTotalRotationAngle );
{
if( mGLInitCallback )
{
- mGLInitCallback();
+ CallbackBase::Execute(*mGLInitCallback);
}
mInitCallback = true;
}
if( mGLRenderFrameCallback )
{
- mGLRenderFrameCallback();
+ renderFrameResult = CallbackBase::ExecuteReturn<int>(*mGLRenderFrameCallback);
}
if( mIsWindowRotated )
mIsWindowRotated = false;
}
- eglImpl.SwapBuffers( mEGLSurface );
+ if(renderFrameResult)
+ {
+ eglImpl.SwapBuffers( mEGLSurface );
+ }
return true;
}
{
if( !mIsEGLInitialize )
{
- mGraphics = &( Adaptor::GetImplementation( Adaptor::Get() ).GetGraphicsInterface() );
- EglGraphics *eglGraphics = static_cast<EglGraphics *>(mGraphics);
- Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+ // Init Graphics
+ std::unique_ptr< GraphicsFactory > graphicsFactoryPtr = Utils::MakeUnique< GraphicsFactory >();
+ auto graphicsFactory = *graphicsFactoryPtr.get();
+ mGraphics = std::unique_ptr< GraphicsInterface >( &graphicsFactory.Create() );
+ GraphicsInterface* graphics = mGraphics.get();
+ EglGraphics *eglGraphics = static_cast<EglGraphics*>( graphics );
+ eglGraphics->Initialize( mDepth, mStencil, mMSAA );
+ eglGraphics->Create();
+
+ mDisplayConnection = std::unique_ptr< Dali::DisplayConnection >( Dali::DisplayConnection::New( *graphics, Dali::RenderSurfaceInterface::Type::WINDOW_RENDER_SURFACE ) );
+ mDisplayConnection->Initialize();
+
+ Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
if( mGLESVersion == Dali::GlWindow::GlesVersion::VERSION_2_0 )
{
eglImpl.SetGlesVersion( 20 );