X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fwindow-render-surface.cpp;h=2ff7944ebb1ab1bfede7e3fe81207ba24cf4dc4a;hb=e8e185f7d90010214890c2cb78bdd52c732f63ba;hp=04bc79b130952c06d6b04be4951fc3d201d27881;hpb=d5976a23365194349fc4a63043f9c1273d979d05;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/window-system/common/window-render-surface.cpp b/dali/internal/window-system/common/window-render-surface.cpp index 04bc79b..2ff7944 100644 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -25,12 +25,13 @@ // INTERNAL INCLUDES #include #include -#include +#include #include +#include #include #include #include -#include +#include namespace Dali @@ -57,6 +58,9 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s mThreadSynchronization( NULL ), mRenderNotification( NULL ), mRotationTrigger( NULL ), + mGraphics( nullptr ), + mEGLSurface( nullptr ), + mEGLContext( nullptr ), mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), mOutputTransformedSignal(), mRotationAngle( 0 ), @@ -176,28 +180,24 @@ void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpi mWindowBase->GetDpi( dpiHorizontal, dpiVertical ); } -void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) +void WindowRenderSurface::InitializeGraphics() { - mGraphics = &graphics; - auto eglGraphics = static_cast(mGraphics); - - EglInterface* mEGL = eglGraphics->Create(); - - // Initialize EGL & OpenGL - displayConnection.Initialize(); + mGraphics = &mAdaptor->GetGraphicsInterface(); - Internal::Adaptor::EglImplementation& eglImpl = static_cast(*mEGL); - eglImpl.ChooseConfig(true, mColorDepth); - - // Create the OpenGL context - mEGL->CreateContext(); + auto eglGraphics = static_cast(mGraphics); + mEGL = &eglGraphics->GetEglInterface(); - // Create the OpenGL surface - CreateSurface(); + if ( mEGLContext == NULL ) + { + // Create the OpenGL context for this window + Internal::Adaptor::EglImplementation& eglImpl = static_cast(*mEGL); + eglImpl.ChooseConfig(true, mColorDepth); + eglImpl.CreateWindowContext( mEGLContext ); - // Make it current - mEGL->MakeContextCurrent(); + // Create the OpenGL surface + CreateSurface(); + } } void WindowRenderSurface::CreateSurface() @@ -222,7 +222,7 @@ void WindowRenderSurface::CreateSurface() auto eglGraphics = static_cast(mGraphics); Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.CreateSurfaceWindow( window, mColorDepth ); + mEGLSurface = eglImpl.CreateSurfaceWindow( window, mColorDepth ); // Check rotation capability mRotationSupported = mWindowBase->IsEglWindowRotationSupported(); @@ -237,7 +237,7 @@ void WindowRenderSurface::DestroySurface() auto eglGraphics = static_cast(mGraphics); Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.DestroySurface(); + eglImpl.DestroySurface( mEGLSurface ); mWindowBase->DestroyEglWindow(); } @@ -270,7 +270,7 @@ bool WindowRenderSurface::ReplaceGraphicsSurface() auto eglGraphics = static_cast(mGraphics); Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - return eglImpl.ReplaceSurfaceWindow( window ); + return eglImpl.ReplaceSurfaceWindow( window, mEGLSurface, mEGLContext ); } void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) @@ -319,17 +319,14 @@ void WindowRenderSurface::MoveResize( Dali::PositionSize positionSize ) DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::MoveResize: %d, %d, %d, %d\n", mPositionSize.x, mPositionSize.y, mPositionSize.width, mPositionSize.height ); } -void WindowRenderSurface::SetViewMode( ViewMode viewMode ) -{ - mWindowBase->SetViewMode( viewMode ); -} - void WindowRenderSurface::StartRender() { } bool WindowRenderSurface::PreRender( bool resizingSurface ) { + MakeContextCurrent(); + if( resizingSurface ) { #ifdef OVER_TIZEN_VERSION_4 @@ -365,8 +362,11 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) } auto eglGraphics = static_cast(mGraphics); - auto mGLES = eglGraphics->GetGlesInterface(); - mGLES.PreRender(); + if ( eglGraphics ) + { + GlImplementation& mGLES = eglGraphics->GetGlesInterface(); + mGLES.PreRender(); + } return true; } @@ -375,39 +375,42 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b { // Inform the gl implementation that rendering has finished before informing the surface auto eglGraphics = static_cast(mGraphics); - auto mGLES = eglGraphics->GetGlesInterface(); - mGLES.PostRender(); - - if( renderToFbo ) - { - mGLES.Flush(); - mGLES.Finish(); - } - else + if ( eglGraphics ) { - if( resizingSurface ) + GlImplementation& mGLES = eglGraphics->GetGlesInterface(); + mGLES.PostRender(); + + if( renderToFbo ) { - if( !mRotationFinished ) + mGLES.Flush(); + mGLES.Finish(); + } + else + { + if( resizingSurface ) { - DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" ); + if( !mRotationFinished ) + { + DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" ); - mRotationTrigger->Trigger(); + mRotationTrigger->Trigger(); - if( mThreadSynchronization ) - { - // Wait until the event-thread complete the rotation event processing - mThreadSynchronization->PostRenderWaitForCompletion(); + if( mThreadSynchronization ) + { + // Wait until the event-thread complete the rotation event processing + mThreadSynchronization->PostRenderWaitForCompletion(); + } } } } - } - Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.SwapBuffers(); + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + eglImpl.SwapBuffers( mEGLSurface ); - if( mRenderNotification ) - { - mRenderNotification->Trigger(); + if( mRenderNotification ) + { + mRenderNotification->Trigger(); + } } } @@ -427,11 +430,29 @@ void WindowRenderSurface::ReleaseLock() // Nothing to do. } -RenderSurface::Type WindowRenderSurface::GetSurfaceType() +Integration::RenderSurface::Type WindowRenderSurface::GetSurfaceType() { return RenderSurface::WINDOW_RENDER_SURFACE; } +void WindowRenderSurface::MakeContextCurrent() +{ + if ( mEGL != nullptr ) + { + mEGL->MakeContextCurrent( mEGLSurface, mEGLContext ); + } +} + +Integration::DepthBufferAvailable WindowRenderSurface::GetDepthBufferRequired() +{ + return mGraphics ? mGraphics->GetDepthBufferRequired() : Integration::DepthBufferAvailable::FALSE; +} + +Integration::StencilBufferAvailable WindowRenderSurface::GetStencilBufferRequired() +{ + return mGraphics ? mGraphics->GetStencilBufferRequired() : Integration::StencilBufferAvailable::FALSE; +} + void WindowRenderSurface::OutputTransformed() { int screenRotationAngle = mWindowBase->GetScreenRotationAngle();