From: Richard Huang Date: Fri, 19 Jul 2019 14:54:10 +0000 (+0100) Subject: Skip rendering frame buffer if the render surface becomes invalid X-Git-Tag: dali_1.4.30~2^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=06daab23501b8cc1c6990e4d91136ab5be4711f7 Skip rendering frame buffer if the render surface becomes invalid Change-Id: I4eeb9f9b9c3be342343e21ef3565351f940e5f04 --- diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index ebf66d4..acfec96 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -434,9 +434,17 @@ int UtcDaliSceneRootLayerAndSceneAlignment(void) Dali::Integration::Scene scene = Dali::Integration::Scene::New( Vector2( 480.0f, 800.0f ) ); DALI_TEST_CHECK( scene ); + // Create the render surface for the scene + TestRenderSurface* renderSurface = new TestRenderSurface( Dali::PositionSize( 0, 0, 480.0f, 800.0f ) ); + scene.SetSurface( *renderSurface ); + // One reference of scene kept here and the other one kept in the Core DALI_TEST_CHECK( scene.GetBaseObject().ReferenceCount() == 2 ); + // Add a renderable actor to the scene + auto actor = CreateRenderableActor(); + scene.Add( actor ); + // Render and notify. application.SendNotification(); application.Render(0); diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index b5a5011..7c56dfb 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -610,6 +610,12 @@ void RenderManager::DoRender( RenderInstruction& instruction ) { surfaceFrameBuffer = static_cast( instruction.mFrameBuffer ); + if ( !surfaceFrameBuffer->IsSurfaceValid() ) + { + // Skip rendering the frame buffer if the render surface becomes invalid + return; + } + if ( mImpl->currentContext->IsSurfacelessContextSupported() ) { Context* surfaceContext = surfaceFrameBuffer->GetContext(); diff --git a/dali/internal/render/renderers/render-surface-frame-buffer.cpp b/dali/internal/render/renderers/render-surface-frame-buffer.cpp index 7f1866d..7154ff6 100644 --- a/dali/internal/render/renderers/render-surface-frame-buffer.cpp +++ b/dali/internal/render/renderers/render-surface-frame-buffer.cpp @@ -44,7 +44,7 @@ SurfaceFrameBuffer::~SurfaceFrameBuffer() void SurfaceFrameBuffer::Destroy( Context& context ) { - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->DestroySurface(); mSurface = nullptr; @@ -58,7 +58,7 @@ void SurfaceFrameBuffer::GlContextDestroyed() mContext->GlContextDestroyed(); } - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->DestroySurface(); mSurface = nullptr; @@ -70,7 +70,7 @@ void SurfaceFrameBuffer::Initialize(Context& context) mContext = &context; mContext->GlContextCreated(); - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->InitializeGraphics(); } @@ -78,7 +78,7 @@ void SurfaceFrameBuffer::Initialize(Context& context) void SurfaceFrameBuffer::Bind( Context& context ) { - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->PreRender( mSizeChanged ); @@ -98,7 +98,7 @@ uint32_t SurfaceFrameBuffer::GetHeight() const void SurfaceFrameBuffer::PostRender() { - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->PostRender( false, false, mSizeChanged ); } @@ -113,22 +113,12 @@ Context* SurfaceFrameBuffer::GetContext() void SurfaceFrameBuffer::MakeContextCurrent() { - if ( mSurface && !mIsSurfaceInvalid ) + if ( IsSurfaceValid() ) { mSurface->MakeContextCurrent(); } } -Integration::DepthBufferAvailable SurfaceFrameBuffer::GetDepthBufferRequired() -{ - return mSurface && !mIsSurfaceInvalid ? Integration::DepthBufferAvailable::FALSE : mSurface->GetDepthBufferRequired(); -} - -Integration::StencilBufferAvailable SurfaceFrameBuffer::GetStencilBufferRequired() -{ - return mSurface && !mIsSurfaceInvalid ? Integration::StencilBufferAvailable::TRUE : mSurface->GetStencilBufferRequired(); -} - Vector4 SurfaceFrameBuffer::GetBackgroundColor() { return mBackgroundColor; @@ -146,6 +136,11 @@ void SurfaceFrameBuffer::SetBackgroundColor( const Vector4& color ) mBackgroundColor = color; } +bool SurfaceFrameBuffer::IsSurfaceValid() const +{ + return mSurface && !mIsSurfaceInvalid; +} + } //Render } //Internal diff --git a/dali/internal/render/renderers/render-surface-frame-buffer.h b/dali/internal/render/renderers/render-surface-frame-buffer.h index 704a360..edd667d 100644 --- a/dali/internal/render/renderers/render-surface-frame-buffer.h +++ b/dali/internal/render/renderers/render-surface-frame-buffer.h @@ -104,6 +104,13 @@ public: */ void MarkSurfaceAsInvalid() { mIsSurfaceInvalid = true; }; + /** + * @brief Gets whether the render surface in this frame buffer is valid or not + * @note The render surface becomes invalid when it is deleted in the event thread + * @return Whether the render surface is valid or not + */ + bool IsSurfaceValid() const; + public: /** @@ -123,18 +130,6 @@ public: void MakeContextCurrent(); /** - * @brief Gets whether the depth buffer is required - * @return TRUE if the depth buffer is required - */ - Integration::DepthBufferAvailable GetDepthBufferRequired(); - - /** - * @brief Gets whether the stencil buffer is required - * @return TRUE if the stencil buffer is required - */ - Integration::StencilBufferAvailable GetStencilBufferRequired(); - - /** * @brief Gets the background color of the surface. * @return The background color */