X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fwindow-render-surface.cpp;h=5258aaeb08d1389f83b34bbf6252109d0f54f9b7;hb=85495083ed69849f52ee7563e91e9ff96312975a;hp=cac09c5fc15d6c5dd25dca813a55152532aded53;hpb=1f0b06f56e2145a70206d85a32c16e409d25907a;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 cac09c5..5258aae 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) 2019 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. @@ -27,10 +27,12 @@ #include #include #include +#include #include #include #include #include +#include namespace Dali @@ -52,12 +54,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 ), @@ -78,6 +84,11 @@ WindowRenderSurface::~WindowRenderSurface() { delete mRotationTrigger; } + + if ( mEGLSurface ) + { + DestroySurface(); + } } void WindowRenderSurface::Initialize( Any surface ) @@ -104,6 +115,7 @@ void WindowRenderSurface::Initialize( Any surface ) if( mScreenRotationAngle != 0 ) { mScreenRotationFinished = false; + mResizeFinished = false; } } @@ -134,12 +146,6 @@ void WindowRenderSurface::SetTransparency( bool transparent ) void WindowRenderSurface::RequestRotation( int angle, int width, int height ) { - if( !mRotationSupported ) - { - DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::Rotate: Rotation is not supported!\n" ); - return; - } - if( !mRotationTrigger ) { TriggerEventFactoryInterface& triggerFactory = Internal::Adaptor::Adaptor::GetImplementation( Adaptor::Get() ).GetTriggerEventFactoryInterface(); @@ -174,31 +180,41 @@ PositionSize WindowRenderSurface::GetPositionSize() const void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) { - mWindowBase->GetDpi( dpiHorizontal, dpiVertical ); -} + const char* environmentDpiHorizontal = std::getenv( DALI_ENV_DPI_HORIZONTAL ); + dpiHorizontal = environmentDpiHorizontal ? std::atoi( environmentDpiHorizontal ) : 0; -void WindowRenderSurface::InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) -{ - mGraphics = &graphics; + const char* environmentDpiVertical = std::getenv( DALI_ENV_DPI_VERTICAL ); + dpiVertical = environmentDpiVertical ? std::atoi( environmentDpiVertical ) : 0; - auto eglGraphics = static_cast(mGraphics); + if( dpiHorizontal == 0 || dpiVertical == 0 ) + { + mWindowBase->GetDpi( dpiHorizontal, dpiVertical ); + } +} - EglInterface* mEGL = eglGraphics->Create(); +int WindowRenderSurface::GetOrientation() const +{ + return mWindowBase->GetOrientation(); +} - // Initialize EGL & OpenGL - displayConnection.Initialize(); +void WindowRenderSurface::InitializeGraphics() +{ - Internal::Adaptor::EglImplementation& eglImpl = static_cast(*mEGL); - eglImpl.ChooseConfig(true, mColorDepth); + mGraphics = &mAdaptor->GetGraphicsInterface(); - // 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() @@ -223,12 +239,15 @@ 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 ); + int screenWidth, screenHeight; + WindowSystem::GetScreenSize( screenWidth, screenHeight ); + DALI_LOG_RELEASE_INFO("WindowRenderSurface::CreateSurface: w = %d h = %d screenWidth = %d screenHeight = %d angle = %d screen rotation = %d\n", + mPositionSize.width, mPositionSize.height, screenWidth, screenHeight, mRotationAngle, mScreenRotationAngle ); } void WindowRenderSurface::DestroySurface() @@ -238,7 +257,7 @@ void WindowRenderSurface::DestroySurface() auto eglGraphics = static_cast(mGraphics); Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.DestroySurface(); + eglImpl.DestroySurface( mEGLSurface ); mWindowBase->DestroyEglWindow(); } @@ -271,7 +290,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 ) @@ -326,14 +345,15 @@ void WindowRenderSurface::StartRender() bool WindowRenderSurface::PreRender( bool resizingSurface ) { + MakeContextCurrent(); + if( resizingSurface ) { -#ifdef OVER_TIZEN_VERSION_4 + int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; + // Window rotate or screen rotate if( !mRotationFinished || !mScreenRotationFinished ) { - int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; - mWindowBase->SetEglWindowRotation( totalAngle ); mWindowBase->SetEglWindowBufferTransform( totalAngle ); @@ -348,12 +368,25 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) { mWindowBase->SetEglWindowTransform( mRotationAngle ); } -#endif // Resize case - if( !mResizeFinished ) + if ( !mResizeFinished ) { - mWindowBase->ResizeEglWindow( mPositionSize ); + Dali::PositionSize positionSize; + positionSize.x = mPositionSize.x; + positionSize.y = mPositionSize.y; + if( totalAngle == 0 || totalAngle == 180 ) + { + positionSize.width = mPositionSize.width; + positionSize.height = mPositionSize.height; + } + else + { + positionSize.width = mPositionSize.height; + positionSize.height = mPositionSize.width; + } + + mWindowBase->ResizeEglWindow( positionSize ); mResizeFinished = true; DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "WindowRenderSurface::PreRender: Set resize\n" ); @@ -404,7 +437,7 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b } Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); - eglImpl.SwapBuffers(); + eglImpl.SwapBuffers( mEGLSurface ); if( mRenderNotification ) { @@ -429,11 +462,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(); @@ -442,6 +493,7 @@ void WindowRenderSurface::OutputTransformed() { mScreenRotationAngle = screenRotationAngle; mScreenRotationFinished = false; + mResizeFinished = false; mOutputTransformedSignal.Emit();