X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fwindow-render-surface.cpp;h=e1a344f6c2bb36b301a51f7da64bc34005c2ce10;hb=aecc2d4c642e0cdf360e56accd3e5b96622a707f;hp=c29c8614d6b673a0624502f16ad0328f39eed6f3;hpb=a38310eae5990fae285513f81a552c6e3e6cb7b5;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 c29c861..e1a344f 100644 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,15 +23,16 @@ #include // INTERNAL INCLUDES -#include -#include -#include +#include +#include #include +#include +#include +#include #include #include #include -#include - +#include namespace Dali { @@ -52,11 +53,16 @@ Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose } // unnamed namespace WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent ) -: mPositionSize( positionSize ), +: mEGL( nullptr ), + mDisplayConnection( nullptr ), + mPositionSize( positionSize ), mWindowBase(), mThreadSynchronization( NULL ), mRenderNotification( NULL ), mRotationTrigger( NULL ), + mGraphics( nullptr ), + mEGLSurface( nullptr ), + mEGLContext( nullptr ), mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), mOutputTransformedSignal(), mRotationAngle( 0 ), @@ -65,7 +71,9 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s mRotationSupported( false ), mRotationFinished( true ), mScreenRotationFinished( true ), - mResizeFinished( true ) + mResizeFinished( true ), + mDpiHorizontal( 0 ), + mDpiVertical( 0 ) { DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" ); Initialize( surface ); @@ -77,6 +85,11 @@ WindowRenderSurface::~WindowRenderSurface() { delete mRotationTrigger; } + + if ( mEGLSurface ) + { + DestroySurface(); + } } void WindowRenderSurface::Initialize( Any surface ) @@ -87,7 +100,6 @@ void WindowRenderSurface::Initialize( Any surface ) // Default window size == screen size mPositionSize.x = 0; mPositionSize.y = 0; - WindowSystem::GetScreenSize( mPositionSize.width, mPositionSize.height ); } @@ -141,8 +153,7 @@ void WindowRenderSurface::RequestRotation( int angle, int width, int height ) if( !mRotationTrigger ) { - TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface(); - mRotationTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &WindowRenderSurface::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); + mRotationTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &WindowRenderSurface::ProcessRotationRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); } mPositionSize.width = width; @@ -173,31 +184,43 @@ PositionSize WindowRenderSurface::GetPositionSize() const void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { - mWindowBase->GetDpi( dpiHorizontal, dpiVertical ); -} + if( mDpiHorizontal == 0 || mDpiVertical == 0 ) + { + const char* environmentDpiHorizontal = std::getenv( DALI_ENV_DPI_HORIZONTAL ); + mDpiHorizontal = environmentDpiHorizontal ? std::atoi( environmentDpiHorizontal ) : 0; -void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) -{ - mGraphics = &graphics; + const char* environmentDpiVertical = std::getenv( DALI_ENV_DPI_VERTICAL ); + mDpiVertical = environmentDpiVertical ? std::atoi( environmentDpiVertical ) : 0; - auto eglGraphics = static_cast(mGraphics); + if( mDpiHorizontal == 0 || mDpiVertical == 0 ) + { + mWindowBase->GetDpi( mDpiHorizontal, mDpiVertical ); + } + } - EglInterface* mEGL = eglGraphics->Create(); + dpiHorizontal = mDpiHorizontal; + dpiVertical = mDpiVertical; +} - // Initialize EGL & OpenGL - displayConnection.Initialize(); +void WindowRenderSurface::InitializeGraphics() +{ + mGraphics = &mAdaptor->GetGraphicsInterface(); - Internal::Adaptor::EglImplementation& eglImpl = static_cast(*mEGL); - eglImpl.ChooseConfig(true, mColorDepth); + DALI_ASSERT_ALWAYS( mGraphics && "Graphics interface is not created" ); - // 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,12 +245,13 @@ 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(); - DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::CreateSurface: w = %d h = %d angle = %d screen rotation = %d\n", mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle ); + DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: WinId (%d), w = %d h = %d angle = %d screen rotation = %d\n", + mWindowBase->GetNativeWindowId(), mPositionSize.width, mPositionSize.height, mRotationAngle, mScreenRotationAngle ); } void WindowRenderSurface::DestroySurface() @@ -235,11 +259,15 @@ void WindowRenderSurface::DestroySurface() DALI_LOG_TRACE_METHOD( gWindowRenderSurfaceLogFilter ); auto eglGraphics = static_cast(mGraphics); + if( eglGraphics ) + { + DALI_LOG_RELEASE_INFO("WindowRenderSurface::DestroySurface: WinId (%d)\n", mWindowBase->GetNativeWindowId() ); - Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.DestroySurface(); + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + eglImpl.DestroySurface( mEGLSurface ); - mWindowBase->DestroyEglWindow(); + mWindowBase->DestroyEglWindow(); + } } bool WindowRenderSurface::ReplaceGraphicsSurface() @@ -270,7 +298,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 ) @@ -325,9 +353,10 @@ void WindowRenderSurface::StartRender() bool WindowRenderSurface::PreRender( bool resizingSurface ) { + MakeContextCurrent(); + if( resizingSurface ) { -#ifdef OVER_TIZEN_VERSION_4 // Window rotate or screen rotate if( !mRotationFinished || !mScreenRotationFinished ) { @@ -347,7 +376,6 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) { mWindowBase->SetEglWindowTransform( mRotationAngle ); } -#endif // Resize case if( !mResizeFinished ) @@ -360,8 +388,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; } @@ -370,39 +401,48 @@ 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 ) + if ( eglGraphics ) { - mGLES.Flush(); - mGLES.Finish(); - } - else - { - if( resizingSurface ) + GlImplementation& mGLES = eglGraphics->GetGlesInterface(); + mGLES.PostRender(); + + if( renderToFbo ) + { + mGLES.Flush(); + mGLES.Finish(); + } + else { - if( !mRotationFinished ) + if( resizingSurface ) { - DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PostRender: Trigger rotation event\n" ); + if( !mRotationFinished ) + { + if( mThreadSynchronization ) + { + // Enable PostRender flag + mThreadSynchronization->PostRenderStarted(); + } - mRotationTrigger->Trigger(); + DALI_LOG_RELEASE_INFO("WindowRenderSurface::PostRender: Trigger rotation event\n" ); - if( mThreadSynchronization ) - { - // Wait until the event-thread complete the rotation event processing - mThreadSynchronization->PostRenderWaitForCompletion(); + mRotationTrigger->Trigger(); + + 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(); + } } } @@ -422,9 +462,27 @@ void WindowRenderSurface::ReleaseLock() // Nothing to do. } -RenderSurface::Type WindowRenderSurface::GetSurfaceType() +Dali::RenderSurfaceInterface::Type WindowRenderSurface::GetSurfaceType() +{ + return Dali::RenderSurfaceInterface::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 RenderSurface::WINDOW_RENDER_SURFACE; + return mGraphics ? mGraphics->GetStencilBufferRequired() : Integration::StencilBufferAvailable::FALSE; } void WindowRenderSurface::OutputTransformed()