X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fcommon%2Frender-manager.cpp;h=a1b527bf85ae96be5e0cb2e3282421e91dd1456b;hb=353b9c30a0e93abc10ff49ed7921030e4ebaf304;hp=fbad2b303ad769acdbfb0f8ee70ddc899c1100ad;hpb=0057d3c32d20146e66241436fdb3b08f56a5ab5d;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp old mode 100755 new mode 100644 index fbad2b3..a1b527b --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -62,37 +62,6 @@ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_REN } // unnamed namespace #endif -namespace -{ -const float partialUpdateRatio = 0.8f; // If the partial update area exceeds 80%, change to full update. - -/** - * @brief Find the intersection of two AABB rectangles. - * This is a logical AND operation. IE. The intersection is the area overlapped by both rectangles. - * @param[in] aabbA Rectangle A - * @param[in] aabbB Rectangle B - * @return The intersection of rectangle A & B (result is a rectangle) - */ -inline ClippingBox IntersectAABB( const ClippingBox& aabbA, const ClippingBox& aabbB ) -{ - ClippingBox intersectionBox; - - // First calculate the largest starting positions in X and Y. - intersectionBox.x = std::max( aabbA.x, aabbB.x ); - intersectionBox.y = std::max( aabbA.y, aabbB.y ); - - // Now calculate the smallest ending positions, and take the largest starting - // positions from the result, to get the width and height respectively. - // If the two boxes do not intersect at all, then we need a 0 width and height clipping area. - // We use max here to clamp both width and height to >= 0 for this use-case. - intersectionBox.width = std::max( std::min( aabbA.x + aabbA.width, aabbB.x + aabbB.width ) - intersectionBox.x, 0 ); - intersectionBox.height = std::max( std::min( aabbA.y + aabbA.height, aabbB.y + aabbB.height ) - intersectionBox.y, 0 ); - - return intersectionBox; -} - -} - /** * Structure to contain internal data */ @@ -102,8 +71,7 @@ struct RenderManager::Impl Integration::GlSyncAbstraction& glSyncAbstraction, Integration::GlContextHelperAbstraction& glContextHelperAbstraction, Integration::DepthBufferAvailable depthBufferAvailableParam, - Integration::StencilBufferAvailable stencilBufferAvailableParam, - Integration::PartialUpdateAvailable partialUpdateAvailableParam ) + Integration::StencilBufferAvailable stencilBufferAvailableParam ) : context( glAbstraction, &surfaceContextContainer ), currentContext( &context ), glAbstraction( glAbstraction ), @@ -112,7 +80,6 @@ struct RenderManager::Impl renderQueue(), instructions(), renderAlgorithms(), - backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), frameCount( 0u ), renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ), defaultSurfaceRect(), @@ -123,9 +90,7 @@ struct RenderManager::Impl lastFrameWasRendered( false ), programController( glAbstraction ), depthBufferAvailable( depthBufferAvailableParam ), - stencilBufferAvailable( stencilBufferAvailableParam ), - partialUpdateAvailable( partialUpdateAvailableParam ), - defaultSurfaceOrientation( 0 ) + stencilBufferAvailable( stencilBufferAvailableParam ) { // Create thread pool with just one thread ( there may be a need to create more threads in the future ). threadPool = std::unique_ptr( new Dali::ThreadPool() ); @@ -182,8 +147,6 @@ struct RenderManager::Impl RenderInstructionContainer instructions; Render::RenderAlgorithms renderAlgorithms; ///< The RenderAlgorithms object is used to action the renders required by a RenderInstruction - Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame. - uint32_t frameCount; ///< The current frame count BufferIndex renderBufferIndex; ///< The index of the buffer to read from; this is opposite of the "update" buffer @@ -204,29 +167,24 @@ struct RenderManager::Impl Integration::DepthBufferAvailable depthBufferAvailable; ///< Whether the depth buffer is available Integration::StencilBufferAvailable stencilBufferAvailable; ///< Whether the stencil buffer is available - Integration::PartialUpdateAvailable partialUpdateAvailable; ///< Whether the partial update is available std::unique_ptr threadPool; ///< The thread pool Vector boundTextures; ///< The textures bound for rendering Vector textureDependencyList; ///< The dependency list of binded textures - int defaultSurfaceOrientation; ///< defaultSurfaceOrientation for the default surface we are rendering to - }; RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction, Integration::GlSyncAbstraction& glSyncAbstraction, Integration::GlContextHelperAbstraction& glContextHelperAbstraction, Integration::DepthBufferAvailable depthBufferAvailable, - Integration::StencilBufferAvailable stencilBufferAvailable, - Integration::PartialUpdateAvailable partialUpdateAvailable ) + Integration::StencilBufferAvailable stencilBufferAvailable ) { RenderManager* manager = new RenderManager; manager->mImpl = new Impl( glAbstraction, glSyncAbstraction, glContextHelperAbstraction, depthBufferAvailable, - stencilBufferAvailable, - partialUpdateAvailable ); + stencilBufferAvailable ); return manager; } @@ -288,21 +246,11 @@ RenderInstructionContainer& RenderManager::GetRenderInstructionContainer() return mImpl->instructions; } -void RenderManager::SetBackgroundColor( const Vector4& color ) -{ - mImpl->backgroundColor = color; -} - void RenderManager::SetDefaultSurfaceRect(const Rect& rect) { mImpl->defaultSurfaceRect = rect; } -void RenderManager::SetDefaultSurfaceOrientation( int orientation ) -{ - mImpl->defaultSurfaceOrientation = orientation; -} - void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer ) { // Initialize the renderer as we are now in render thread @@ -634,87 +582,10 @@ void RenderManager::Render( Integration::RenderStatus& status, bool forceClear, DALI_PRINT_RENDER_END(); } -bool GetDamagedRect( Rect &viewportRect, RenderInstruction& instruction, Rect &damagedRect ) -{ - // merge bounding - int dx1 = viewportRect.width, dx2 = 0, dy1 = viewportRect.height, dy2 = 0; - int checkWidth = static_cast( static_cast( viewportRect.width ) * partialUpdateRatio ); - int checkHeight = static_cast( static_cast( viewportRect.height ) * partialUpdateRatio ); - Rect screenRect; - - bool isPartialUpdate = false; - - const RenderListContainer::SizeType renderListCount = instruction.RenderListCount(); - // Iterate through each render list. - - for( RenderListContainer::SizeType index = 0; index < renderListCount; ++index ) - { - const RenderList* renderList = instruction.GetRenderList( index ); - - if( renderList && !renderList->IsEmpty() && renderList->IsPartialUpdateEnabled() ) - { - const std::size_t itemCount = renderList->Count(); - for( uint32_t itemIndex = 0u; itemIndex < itemCount; ++itemIndex ) - { - const RenderItem& item = renderList->GetItem( itemIndex ); - - if( item.mPartialUpdateEnabled ) - { - isPartialUpdate = true; - - screenRect = item.CalculateViewportSpaceAABB( viewportRect.width, viewportRect.height, true ); - - dx1 = std::min( screenRect.x, dx1 ); - dx2 = std::max( screenRect.x + screenRect.width, dx2); - dy1 = std::min( screenRect.y, dy1 ); - dy2 = std::max( screenRect.y + screenRect.height, dy2 ); - - if( ( dx2 - dx1 ) > checkWidth && ( dy2 - dy1 ) > checkHeight ) - { - return false; - } - } - } - } - } - - if( isPartialUpdate ) - { - if( dx1 < 0.0f ) - { - dx1 = 0.0f; - } - if( dy1 < 0.0f ) - { - dy1 = 0.0f; - } - if( dx2 > viewportRect.width ) - { - dx2 = viewportRect.width; - } - if( dy2 > viewportRect.height ) - { - dy2 = viewportRect.height; - } - - damagedRect.x = dx1; - damagedRect.y = dy1; - damagedRect.width = dx2 - dx1; - damagedRect.height = dy2 - dy1; - } - - return isPartialUpdate; -} - void RenderManager::DoRender( RenderInstruction& instruction ) { Rect viewportRect; Vector4 clearColor; - bool isPartialUpdate = false; - Dali::DamagedRect damagedRect; - Dali::DamagedRect mergedRect; - Dali::ClippingBox scissorBox; - Dali::ClippingBox intersectRect; if ( instruction.mIsClearColorSet ) { @@ -726,11 +597,8 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } Rect surfaceRect = mImpl->defaultSurfaceRect; - int surfaceOrientation = mImpl->defaultSurfaceOrientation; - Vector4 backgroundColor = mImpl->backgroundColor; Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable; Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable; - Integration::PartialUpdateAvailable partialUpdateAvailable = mImpl->partialUpdateAvailable; Render::SurfaceFrameBuffer* surfaceFrameBuffer = nullptr; if ( instruction.mFrameBuffer != 0 ) @@ -760,7 +628,6 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } surfaceRect = Rect( 0, 0, static_cast( surfaceFrameBuffer->GetWidth() ), static_cast( surfaceFrameBuffer->GetHeight() ) ); - backgroundColor = surfaceFrameBuffer->GetBackgroundColor(); } else { @@ -788,7 +655,10 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { // For each offscreen buffer, update the dependency list with the new texture id used by this frame buffer. Render::TextureFrameBuffer* textureFrameBuffer = static_cast( instruction.mFrameBuffer ); - mImpl->textureDependencyList.PushBack( textureFrameBuffer->GetTextureId() ); + for (unsigned int i0 = 0, i1 = textureFrameBuffer->GetColorAttachmentCount(); i0 < i1; ++i0) + { + mImpl->textureDependencyList.PushBack( textureFrameBuffer->GetTextureId(i0) ); + } } } else @@ -796,65 +666,18 @@ void RenderManager::DoRender( RenderInstruction& instruction ) mImpl->currentContext->BindFramebuffer( GL_FRAMEBUFFER, 0u ); } - - if( surfaceFrameBuffer && - partialUpdateAvailable == Integration::PartialUpdateAvailable::TRUE ) - { - const RenderListContainer::SizeType renderListCount = instruction.RenderListCount(); - // Iterate through each render list. - if( surfaceFrameBuffer->IsPartialUpdateEnabled() ) - { - isPartialUpdate = GetDamagedRect( surfaceRect, instruction, damagedRect ) ; - } - - if( !isPartialUpdate ) - { - damagedRect = surfaceRect; - } - - surfaceFrameBuffer->SetDamagedRect( damagedRect, mergedRect ); - - if( mergedRect.IsEmpty() ) - { - isPartialUpdate = false; - } - else - { - scissorBox.x = mergedRect.x; - scissorBox.y = mergedRect.y; - scissorBox.width = mergedRect.width; - scissorBox.height = mergedRect.height; - } - } - if ( surfaceFrameBuffer ) { - mImpl->currentContext->Viewport( surfaceRect.x, - surfaceRect.y, - surfaceRect.width, - surfaceRect.height ); - - - mImpl->currentContext->ClearColor( backgroundColor.r, - backgroundColor.g, - backgroundColor.b, - backgroundColor.a ); + mImpl->currentContext->Viewport( surfaceRect.x, + surfaceRect.y, + surfaceRect.width, + surfaceRect.height ); } // Clear the entire color, depth and stencil buffers for the default framebuffer, if required. // It is important to clear all 3 buffers when they are being used, for performance on deferred renderers // e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit", // and then stall. That problem is only noticeable when rendering a large number of vertices per frame. - if( isPartialUpdate ) - { - mImpl->currentContext->SetScissorTest( true ); - mImpl->currentContext->Scissor( scissorBox.x, scissorBox.y, scissorBox.width, scissorBox.height ); - } - else - { - mImpl->currentContext->SetScissorTest( false ); - } - GLbitfield clearMask = GL_COLOR_BUFFER_BIT; mImpl->currentContext->ColorMask( true ); @@ -872,14 +695,6 @@ void RenderManager::DoRender( RenderInstruction& instruction ) clearMask |= GL_STENCIL_BUFFER_BIT; } - mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR ); - - if( isPartialUpdate ) - { - mImpl->currentContext->SetScissorTest( false ); - } - - if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) ) { if ( instruction.mFrameBuffer->IsSurfaceBacked() ) // Surface rendering @@ -889,7 +704,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) // For glViewport the lower-left corner is (0,0) // For glViewport the lower-left corner is (0,0) const int32_t y = ( surfaceRect.height - instruction.mViewport.height ) - instruction.mViewport.y; - viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); + viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); } else { @@ -908,7 +723,6 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() ); } - surfaceOrientation = 0; } } else // No Offscreen frame buffer rendering @@ -920,7 +734,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { // For glViewport the lower-left corner is (0,0) const int32_t y = ( instruction.mFrameBuffer->GetHeight() - instruction.mViewport.height ) - instruction.mViewport.y; - viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); + viewportRect.Set( instruction.mViewport.x, y, instruction.mViewport.width, instruction.mViewport.height ); } else { @@ -933,36 +747,38 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } } - if ( surfaceOrientation == 90 || surfaceOrientation == 270 ) + bool clearFullFrameRect = true; + if( instruction.mFrameBuffer != 0 ) { - int temp = viewportRect.width; - viewportRect.width = viewportRect.height; - viewportRect.height = temp; + Viewport frameRect( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() ); + clearFullFrameRect = ( frameRect == viewportRect ); + } + else + { + clearFullFrameRect = ( surfaceRect == viewportRect ); } mImpl->currentContext->Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height); - if ( instruction.mIsClearColorSet ) + if( instruction.mIsClearColorSet ) { mImpl->currentContext->ClearColor( clearColor.r, clearColor.g, clearColor.b, clearColor.a ); - // Clear the viewport area only - mImpl->currentContext->SetScissorTest( true ); - if( isPartialUpdate ) + if( !clearFullFrameRect ) { - intersectRect = IntersectAABB( scissorBox, viewportRect ); - mImpl->currentContext->Scissor( intersectRect.x, intersectRect.y, intersectRect.width, intersectRect.height ); + mImpl->currentContext->SetScissorTest( true ); + mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height ); + mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR ); + mImpl->currentContext->SetScissorTest( false ); } else { - mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height ); + mImpl->currentContext->SetScissorTest( false ); + mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR ); } - mImpl->currentContext->ColorMask( true ); - mImpl->currentContext->Clear( GL_COLOR_BUFFER_BIT , Context::CHECK_CACHED_VALUES ); - mImpl->currentContext->SetScissorTest( false ); } // Clear the list of bound textures @@ -974,9 +790,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) mImpl->renderBufferIndex, depthBufferAvailable, stencilBufferAvailable, - mImpl->boundTextures, - surfaceOrientation, - scissorBox ); + mImpl->boundTextures ); // Synchronise the FBO/Texture access when there are multiple contexts if ( mImpl->currentContext->IsSurfacelessContextSupported() )