X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Fcommon%2Frender-manager.cpp;h=910cb054815d6f03c67d0aef2806df3e29ec2e68;hb=0a68c62785eaa442cfa213157431d6f2c9b37033;hp=a3e6db9bb3e9dda092604169bc96a9ef30e6ff3b;hpb=350439f0252940867ad25fd623a14a3a3cf73f41;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 index a3e6db9..910cb05 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -80,7 +80,6 @@ struct RenderManager::Impl renderQueue(), instructions(), renderAlgorithms(), - backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), frameCount( 0u ), renderBufferIndex( SceneGraphBuffers::INITIAL_UPDATE_BUFFER_INDEX ), defaultSurfaceRect(), @@ -91,7 +90,8 @@ struct RenderManager::Impl lastFrameWasRendered( false ), programController( glAbstraction ), depthBufferAvailable( depthBufferAvailableParam ), - stencilBufferAvailable( stencilBufferAvailableParam ) + stencilBufferAvailable( stencilBufferAvailableParam ), + defaultSurfaceOrientation( 0 ) { // 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() ); @@ -148,8 +148,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 @@ -174,6 +172,8 @@ struct RenderManager::Impl 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, @@ -249,14 +249,14 @@ RenderInstructionContainer& RenderManager::GetRenderInstructionContainer() return mImpl->instructions; } -void RenderManager::SetBackgroundColor( const Vector4& color ) +void RenderManager::SetDefaultSurfaceRect(const Rect& rect) { - mImpl->backgroundColor = color; + mImpl->defaultSurfaceRect = rect; } -void RenderManager::SetDefaultSurfaceRect(const Rect& rect) +void RenderManager::SetDefaultSurfaceOrientation( int orientation ) { - mImpl->defaultSurfaceRect = rect; + mImpl->defaultSurfaceOrientation = orientation; } void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer ) @@ -605,7 +605,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } Rect surfaceRect = mImpl->defaultSurfaceRect; - Vector4 backgroundColor = mImpl->backgroundColor; + int surfaceOrientation = mImpl->defaultSurfaceOrientation; Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable; Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable; @@ -637,7 +637,6 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } surfaceRect = Rect( 0, 0, static_cast( surfaceFrameBuffer->GetWidth() ), static_cast( surfaceFrameBuffer->GetHeight() ) ); - backgroundColor = surfaceFrameBuffer->GetBackgroundColor(); } else { @@ -665,7 +664,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 @@ -679,20 +681,12 @@ void RenderManager::DoRender( RenderInstruction& instruction ) surfaceRect.y, surfaceRect.width, surfaceRect.height ); - - mImpl->currentContext->ClearColor( backgroundColor.r, - backgroundColor.g, - backgroundColor.b, - backgroundColor.a ); } // 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. - - mImpl->currentContext->SetScissorTest( false ); - GLbitfield clearMask = GL_COLOR_BUFFER_BIT; mImpl->currentContext->ColorMask( true ); @@ -710,8 +704,6 @@ void RenderManager::DoRender( RenderInstruction& instruction ) clearMask |= GL_STENCIL_BUFFER_BIT; } - mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR ); - if( !instruction.mIgnoreRenderToFbo && ( instruction.mFrameBuffer != 0 ) ) { if ( instruction.mFrameBuffer->IsSurfaceBacked() ) // Surface rendering @@ -721,7 +713,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 { @@ -740,6 +732,7 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { viewportRect.Set( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() ); } + surfaceOrientation = 0; } } else // No Offscreen frame buffer rendering @@ -751,7 +744,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 { @@ -764,21 +757,45 @@ void RenderManager::DoRender( RenderInstruction& instruction ) } } + bool clearFullFrameRect = true; + if( instruction.mFrameBuffer != 0 ) + { + Viewport frameRect( 0, 0, instruction.mFrameBuffer->GetWidth(), instruction.mFrameBuffer->GetHeight() ); + clearFullFrameRect = ( frameRect == viewportRect ); + } + else + { + clearFullFrameRect = ( surfaceRect == viewportRect ); + } + + if ( surfaceOrientation == 90 || surfaceOrientation == 270 ) + { + int temp = viewportRect.width; + viewportRect.width = viewportRect.height; + viewportRect.height = temp; + } + 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 ); - mImpl->currentContext->Scissor( viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height ); - mImpl->currentContext->ColorMask( true ); - mImpl->currentContext->Clear( GL_COLOR_BUFFER_BIT , Context::CHECK_CACHED_VALUES ); - mImpl->currentContext->SetScissorTest( false ); + if( !clearFullFrameRect ) + { + 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->SetScissorTest( false ); + mImpl->currentContext->Clear( clearMask, Context::FORCE_CLEAR ); + } } // Clear the list of bound textures @@ -790,7 +807,8 @@ void RenderManager::DoRender( RenderInstruction& instruction ) mImpl->renderBufferIndex, depthBufferAvailable, stencilBufferAvailable, - mImpl->boundTextures ); + mImpl->boundTextures, + surfaceOrientation ); // Synchronise the FBO/Texture access when there are multiple contexts if ( mImpl->currentContext->IsSurfacelessContextSupported() )