void TestApplication::CreateScene()
{
mRenderSurface = new TestRenderSurface( Dali::PositionSize( 0, 0, mSurfaceWidth, mSurfaceHeight ) );
- mScene = Dali::Integration::Scene::New( Vector2( static_cast<float>( mSurfaceWidth ), static_cast<float>( mSurfaceHeight ) ) );
- mScene.SetSurface( *mRenderSurface );
+ mScene = Dali::Integration::Scene::New( *mRenderSurface );
mScene.SetDpi( Vector2( static_cast<float>( mDpi.x ), static_cast<float>( mDpi.y ) ) );
}
if ( signalData.createNewScene )
{
- Dali::Integration::Scene scene = Dali::Integration::Scene::New( Vector2( 480.0f, 800.0f ) );
+ TestRenderSurface* surface = new TestRenderSurface( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) ); // This is a leak, but we need to keep the surface alive till the end
+ Dali::Integration::Scene scene = Dali::Integration::Scene::New( *surface );
DALI_TEST_CHECK( scene );
signalData.newSceneCreated = true;
tet_infoline("Testing Dali::Scene::Discard");
// Create a new Scene
- Dali::Integration::Scene scene = Dali::Integration::Scene::New( Vector2( 480.0f, 800.0f ) );
+ TestRenderSurface surface( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) );
+ Dali::Integration::Scene scene = Dali::Integration::Scene::New( surface );
DALI_TEST_CHECK( scene );
// One reference of scene kept here and the other one kept in the Core
TestApplication application;
// Create a Scene
- Dali::Integration::Scene scene = Dali::Integration::Scene::New( Vector2( 480.0f, 800.0f ) );
+ TestRenderSurface surface( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) );
+ Dali::Integration::Scene scene = Dali::Integration::Scene::New( surface );
DALI_TEST_CHECK( scene );
// 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);
DALI_TEST_CHECK( rootLayer.GetBaseObject().ReferenceCount() == 1 );
// Create a new Scene while the root layer of the deleted scene is still alive
- Dali::Integration::Scene newScene = Dali::Integration::Scene::New( Vector2( 480.0f, 800.0f ) );
+ TestRenderSurface surface2( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) );
+ Dali::Integration::Scene newScene = Dali::Integration::Scene::New( surface2 );
DALI_TEST_CHECK( newScene );
// Render and notify.
{
TestApplication application;
- // Create a Scene
- 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 );
+
+ // Create a Scene
+ Dali::Integration::Scene scene = Dali::Integration::Scene::New( *renderSurface );
+ DALI_TEST_CHECK( scene );
// Render and notify.
application.SendNotification();
auto defaultScene = application.GetScene();
defaultScene.SetBackgroundColor( Color::WHITE );
- auto newScene = Integration::Scene::New( Vector2( 480.0f, 800.0f ) );
+ TestRenderSurface surface( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) );
+ auto newScene = Integration::Scene::New( surface );
newScene.SetBackgroundColor( Color::RED );
// Need to create a renderable as we don't start rendering until we have at least one
// Add another scene and set its background color, ensure we clear it to the appropriate color
- auto thirdScene = Integration::Scene::New( Vector2( 200.0f, 200.0f ) );
+ TestRenderSurface surface2( PositionSize( 0.0f, 0.0f, 480.0f, 800.0f ) );
+ auto thirdScene = Integration::Scene::New( surface2 );
thirdScene.SetBackgroundColor( Color::BLUE );
clearCountBefore = glAbstraction.GetClearCountCalled();
TestApplication application;
Vector2 originalSurfaceSize( 500.0f, 1000.0f );
- auto scene = Integration::Scene::New( Vector2::ZERO );
TestRenderSurface surface( PositionSize( 0.0f, 0.0f, originalSurfaceSize.width, originalSurfaceSize.height ) );
- scene.SetSurface( surface );
+ auto scene = Integration::Scene::New( surface );
// Ensure stage size does NOT match the surface size
auto stage = Stage::GetCurrent();
END_TEST;
}
+
+int UtcDaliSceneSetSurface(void)
+{
+ tet_infoline( "Scene::SetSurface test" );
+
+ TestApplication application;
+
+ // Create a scene with a surface and ensure the size and surface is set correctly on the scene
+ Vector2 surfaceSize( 480.0f, 800.0f );
+ TestRenderSurface surface( PositionSize( 0.0f, 0.0f, surfaceSize.width, surfaceSize.height ) );
+ auto scene = Integration::Scene::New( surface );
+ DALI_TEST_EQUALS( scene.GetSize(), surfaceSize, TEST_LOCATION );
+ DALI_TEST_CHECK( scene.GetSurface() == &surface );
+
+ // Create a new surface and set that on the scene
+ Vector2 newSurfaceSize( 1000.0f, 1000.0f );
+ TestRenderSurface newSurface( PositionSize( 0.0f, 0.0f, newSurfaceSize.width, newSurfaceSize.height ) );
+ scene.SetSurface( newSurface );
+ DALI_TEST_EQUALS( scene.GetSize(), newSurfaceSize, TEST_LOCATION );
+ DALI_TEST_CHECK( scene.GetSurface() == &newSurface );
+
+ // Ensure setting the same surface again doesn't have any side effects
+ scene.SetSurface( newSurface );
+ DALI_TEST_EQUALS( scene.GetSize(), newSurfaceSize, TEST_LOCATION );
+ DALI_TEST_CHECK( scene.GetSurface() == &newSurface );
+
+ END_TEST;
+}
namespace Integration
{
-Scene Scene::New( const Size& size )
+Scene Scene::New( Integration::RenderSurface& surface )
{
- Internal::ScenePtr internal = Internal::Scene::New( size );
+ Internal::ScenePtr internal = Internal::Scene::New( surface );
return Scene( internal.Get() );
}
/**
* @brief Create an initialized Scene handle.
*
- * @param[in] size The size of the scene in pixels as a Vector
+ * @param[in] surface Binds this rendering surface to this scene
*
* @return a handle to a newly allocated Dali resource.
*/
- static Scene New( const Size& size );
+ static Scene New( Integration::RenderSurface& surface );
/**
* @brief Downcast an Object handle to Scene handle.
} //Unnamed namespace
-ScenePtr Scene::New( const Size& size )
+ScenePtr Scene::New( Integration::RenderSurface& surface )
{
- ScenePtr scene = new Scene( size );
+ ScenePtr scene = new Scene;
// Second-phase construction
- scene->Initialize();
+ scene->Initialize( surface );
return scene;
}
-Scene::Scene( const Size& size )
+Scene::Scene()
: mSurface( nullptr ),
- mSize( size ),
- mSurfaceSize( Vector2::ZERO ),
- mDpi( Vector2::ZERO ),
+ mSize(), // Don't set the proper value here, this will be set when the surface is set later
+ mDpi(),
mBackgroundColor( DEFAULT_BACKGROUND_COLOR ),
mDepthTreeDirty( false ),
mEventProcessor( *this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor() )
mFrameBuffer.Reset();
}
- // Discard this Scene from the Core
- Discard();
+ // No need to discard this Scene from Core, as Core stores an intrusive_ptr to this scene
+ // When this destructor is called, the scene has either already been removed from Core or Core has already been destroyed
}
-void Scene::Initialize()
+void Scene::Initialize( Integration::RenderSurface& surface )
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
// Create the default camera actor first; this is needed by the RenderTaskList
// The default camera attributes and position is such that children of the default layer,
// can be positioned at (0,0) and be at the top-left of the viewport.
- mDefaultCamera = CameraActor::New( mSize );
+ const PositionSize positionSize = surface.GetPositionSize();
+ const Vector2 surfaceSize( static_cast< float >( positionSize.width ), static_cast< float >( positionSize.height ) );
+ mDefaultCamera = CameraActor::New( surfaceSize );
mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
Add(*(mDefaultCamera.Get()));
// Create the default render-task
mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
+
+ // Set the surface
+ SetSurface( surface );
}
void Scene::Add(Actor& actor)
void Scene::SetSurface( Integration::RenderSurface& surface )
{
- mSurface = &surface;
- if ( mSurface )
+ if( mSurface != &surface )
{
+ mSurface = &surface;
+
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
mFrameBuffer = Dali::Internal::FrameBuffer::New( surface, Dali::FrameBuffer::Attachment::NONE );
{
if( mSurface )
{
- const float fWidth = static_cast<float>( mSurface->GetPositionSize().width );
- const float fHeight = static_cast<float>( mSurface->GetPositionSize().height );
+ const PositionSize surfacePositionSize = mSurface->GetPositionSize();
+ const float fWidth = static_cast< float >( surfacePositionSize.width );
+ const float fHeight = static_cast< float >( surfacePositionSize.height );
- if( ( fabsf( mSurfaceSize.width - fWidth ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSurfaceSize.height - fHeight ) > Math::MACHINE_EPSILON_1 ) )
+ if( ( fabsf( mSize.width - fWidth ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSize.height - fHeight ) > Math::MACHINE_EPSILON_1 ) )
{
- Rect<int32_t> newSize( 0, 0, static_cast<int32_t>( mSurface->GetPositionSize().width ), static_cast<int32_t>( mSurface->GetPositionSize().height ) );
-
- mSurfaceSize.width = fWidth;
- mSurfaceSize.height = fHeight;
+ Rect< int32_t > newSize( 0, 0, static_cast< int32_t >( surfacePositionSize.width ), static_cast< int32_t >( surfacePositionSize.height ) );
- mSize.width = mSurfaceSize.width;
- mSize.height = mSurfaceSize.height;
+ mSize.width = fWidth;
+ mSize.height = fHeight;
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
- mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
+ mDefaultCamera->SetPerspectiveProjection( mSize );
mRootLayer->SetSize( mSize.width, mSize.height );
void Scene::SurfaceDeleted()
{
+ mSurface = nullptr;
if ( mFrameBuffer )
{
// The frame buffer doesn't have a valid render surface any more.
/**
* @copydoc Dali::Integration::Scene::New
*/
- static ScenePtr New( const Size& size );
+ static ScenePtr New( Integration::RenderSurface& surface );
/**
* virtual destructor
private:
// Constructor
- Scene( const Size& size );
+ Scene();
/**
* Second-phase constructor.
*/
- void Initialize();
+ void Initialize( Integration::RenderSurface& surface );
// Undefined
Scene(const Scene&) = delete;
private:
Integration::RenderSurface* mSurface;
- // The scene-size may be different with the surface-size
Size mSize;
- Size mSurfaceSize;
Vector2 mDpi;
{
surfaceFrameBuffer = static_cast<Render::SurfaceFrameBuffer*>( 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();
void SurfaceFrameBuffer::Destroy( Context& context )
{
- if ( mSurface && !mIsSurfaceInvalid )
+ if ( IsSurfaceValid() )
{
mSurface->DestroySurface();
mSurface = nullptr;
mContext->GlContextDestroyed();
}
- if ( mSurface && !mIsSurfaceInvalid )
+ if ( IsSurfaceValid() )
{
mSurface->DestroySurface();
mSurface = nullptr;
mContext = &context;
mContext->GlContextCreated();
- if ( mSurface && !mIsSurfaceInvalid )
+ if ( IsSurfaceValid() )
{
mSurface->InitializeGraphics();
}
void SurfaceFrameBuffer::Bind( Context& context )
{
- if ( mSurface && !mIsSurfaceInvalid )
+ if ( IsSurfaceValid() )
{
mSurface->PreRender( mSizeChanged );
void SurfaceFrameBuffer::PostRender()
{
- if ( mSurface && !mIsSurfaceInvalid )
+ if ( IsSurfaceValid() )
{
mSurface->PostRender( false, false, mSizeChanged );
}
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;
mBackgroundColor = color;
}
+bool SurfaceFrameBuffer::IsSurfaceValid() const
+{
+ return mSurface && !mIsSurfaceInvalid;
+}
+
} //Render
} //Internal
*/
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:
/**
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
*/
const uint32_t CORE_MAJOR_VERSION = 1;
const uint32_t CORE_MINOR_VERSION = 4;
-const uint32_t CORE_MICRO_VERSION = 29;
+const uint32_t CORE_MICRO_VERSION = 30;
const char * const CORE_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali
Summary: DALi 3D Engine
-Version: 1.4.29
+Version: 1.4.30
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT