X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fwindow-system%2Fcommon%2Fwindow-render-surface.cpp;h=0ac8bf356bb74c21b672fae55714f7123a1a0454;hb=3c63fbf108561366679ff4379d3b155b0bc0fc99;hp=f1e4cb71a18e36f3d3c3f2c79ae539fa334d8326;hpb=bfcbf40ba0b5fca5980b89074fb8cf12c53cb4c0;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 old mode 100644 new mode 100755 index f1e4cb7..0ac8bf3 --- a/dali/internal/window-system/common/window-render-surface.cpp +++ b/dali/internal/window-system/common/window-render-surface.cpp @@ -46,6 +46,7 @@ namespace { const int MINIMUM_DIMENSION_CHANGE( 1 ); ///< Minimum change for window to be considered to have moved +const int TILE_SIZE = 16u; ///< Unit of tile size at GPU driver #if defined(DEBUG_ENABLED) Debug::Filter* gWindowRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_WINDOW_RENDER_SURFACE"); @@ -68,13 +69,16 @@ WindowRenderSurface::WindowRenderSurface( Dali::PositionSize positionSize, Any s mOutputTransformedSignal(), mRotationAngle( 0 ), mScreenRotationAngle( 0 ), + mBufferAge( 0 ), + mPreBufferAge( 0 ), mOwnSurface( false ), mRotationSupported( false ), mRotationFinished( true ), mScreenRotationFinished( true ), mResizeFinished( true ), mDpiHorizontal( 0 ), - mDpiVertical( 0 ) + mDpiVertical( 0 ), + mPreDamagedRect() { DALI_LOG_INFO( gWindowRenderSurfaceLogFilter, Debug::Verbose, "Creating Window\n" ); Initialize( surface ); @@ -117,6 +121,7 @@ void WindowRenderSurface::Initialize( Any surface ) if( mScreenRotationAngle != 0 ) { mScreenRotationFinished = false; + mResizeFinished = false; } } @@ -147,12 +152,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(); @@ -205,6 +204,11 @@ void WindowRenderSurface::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpi dpiVertical = mDpiVertical; } +int WindowRenderSurface::GetOrientation() const +{ + return mWindowBase->GetOrientation(); +} + void WindowRenderSurface::InitializeGraphics() { @@ -355,11 +359,11 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) if( resizingSurface ) { + int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; + // Window rotate or screen rotate if( !mRotationFinished || !mScreenRotationFinished ) { - int totalAngle = (mRotationAngle + mScreenRotationAngle) % 360; - mWindowBase->SetEglWindowRotation( totalAngle ); mWindowBase->SetEglWindowBufferTransform( totalAngle ); @@ -376,9 +380,23 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) } // 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" ); @@ -395,6 +413,92 @@ bool WindowRenderSurface::PreRender( bool resizingSurface ) return true; } +std::vector WindowRenderSurface::MergeRect( const Rect& damagedRect, int bufferAge ) +{ + std::vector mergedRectArray; + // merge bounding + int dx1 = mPositionSize.width, dx2 = 0, dy1 = mPositionSize.height, dy2 = 0; + int checkWidth = mPositionSize.width - TILE_SIZE; + int checkHeight = mPositionSize.height - TILE_SIZE; + + dx1 = std::min( damagedRect.x, dx1 ); + dx2 = std::max( damagedRect.x + damagedRect.width, dx2); + dy1 = std::min( damagedRect.y, dy1 ); + dy2 = std::max( damagedRect.y + damagedRect.height, dy2 ); + + for( int j = 0; j <= bufferAge; j++ ) + { + if( !mPreDamagedRect[j].IsEmpty() ) + { + dx1 = std::min( mPreDamagedRect[j].x, dx1 ); + dx2 = std::max( mPreDamagedRect[j].x + mPreDamagedRect[j].width, dx2); + dy1 = std::min( mPreDamagedRect[j].y, dy1 ); + dy2 = std::max( mPreDamagedRect[j].y + mPreDamagedRect[j].height, dy2 ); + + if( dx1 < TILE_SIZE && dx2 > checkWidth && dy1 < TILE_SIZE && dy2 > checkHeight ) + { + dx1 = 0, dx2 = mPositionSize.width, dy1 = 0, dy2 = mPositionSize.height; + break; + } + } + } + + dx1 = TILE_SIZE * (dx1 / TILE_SIZE); + dy1 = TILE_SIZE * (dy1 / TILE_SIZE); + dx2 = TILE_SIZE * ((dx2 + TILE_SIZE - 1) / TILE_SIZE); + dy2 = TILE_SIZE * ((dy2 + TILE_SIZE - 1) / TILE_SIZE); + + mergedRectArray.push_back( dx1 ); + mergedRectArray.push_back( dy1 ); + mergedRectArray.push_back( dx2 - dx1 ); + mergedRectArray.push_back( dy2 - dy1 ); + + return mergedRectArray; +} + + +void WindowRenderSurface::SetDamagedRect( const Dali::DamagedRect& damagedRect, Dali::DamagedRect& mergedRect ) +{ + auto eglGraphics = static_cast( mGraphics ); + std::vector rectArray; + if( eglGraphics ) + { + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + + rectArray = MergeRect( damagedRect, mBufferAge ); + + mPreDamagedRect[4] = std::move( mPreDamagedRect[3] ); + mPreDamagedRect[3] = std::move( mPreDamagedRect[2] ); + mPreDamagedRect[2] = std::move( mPreDamagedRect[1] ); + mPreDamagedRect[1] = std::move( mPreDamagedRect[0] ); + mPreDamagedRect[0] = std::move( damagedRect ); + + eglImpl.SetDamagedRect( rectArray, mEGLSurface ); + } + + if( !rectArray.empty() ) + { + mergedRect.x = rectArray[0]; + mergedRect.y = rectArray[1]; + mergedRect.width = rectArray[2]; + mergedRect.height = rectArray[3]; + } +} + +int32_t WindowRenderSurface::GetBufferAge() +{ + int result = mBufferAge = 0; + auto eglGraphics = static_cast( mGraphics ); + if( eglGraphics ) + { + Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + mBufferAge = eglImpl.GetBufferAge( mEGLSurface );; + result = ( mBufferAge != mPreBufferAge ) ? 0 : mBufferAge; + mPreBufferAge = mBufferAge; + } + return result; +} + void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) { // Inform the gl implementation that rendering has finished before informing the surface @@ -429,6 +533,7 @@ void WindowRenderSurface::PostRender( bool renderToFbo, bool replacingSurface, b } Internal::Adaptor::EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + eglImpl.SwapBuffers( mEGLSurface ); if( mRenderNotification ) @@ -485,6 +590,7 @@ void WindowRenderSurface::OutputTransformed() { mScreenRotationAngle = screenRotationAngle; mScreenRotationFinished = false; + mResizeFinished = false; mOutputTransformedSignal.Emit();