From: Adeel Kazmi Date: Mon, 22 Jul 2019 11:01:34 +0000 (+0100) Subject: Remove Core::SurfaceResized() method as we can call the required Scene method directly X-Git-Tag: dali_1.4.30~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-core.git;a=commitdiff_plain;h=ab4a6990c72570528bae710141edcd8070bd75a3 Remove Core::SurfaceResized() method as we can call the required Scene method directly Change-Id: Ibb992eeea3d09c4d1945e5354e9bb8ce8cff9200 --- diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp index 6e41c42..7ffb5e5 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-application.cpp @@ -81,8 +81,6 @@ void TestApplication::CreateScene() mScene = Dali::Integration::Scene::New( Vector2( static_cast( mSurfaceWidth ), static_cast( mSurfaceHeight ) ) ); mScene.SetSurface( *mRenderSurface ); mScene.SetDpi( Vector2( static_cast( mDpi.x ), static_cast( mDpi.y ) ) ); - - mCore->SurfaceResized( mRenderSurface ); } void TestApplication::InitializeCore() diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index ebf66d4..a744014 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -909,3 +909,59 @@ int UtcDaliSceneEnsureEmptySceneCleared(void) END_TEST; } + +int UtcDaliSceneSurfaceResizedDefaultScene(void) +{ + tet_infoline( "Ensure resizing of the surface is handled properly" ); + + TestApplication application; + + auto defaultScene = application.GetScene(); + Integration::RenderSurface* defaultSurface = defaultScene.GetSurface(); + DALI_TEST_CHECK( defaultSurface ); + + // Ensure stage size matches the surface size + auto stage = Stage::GetCurrent(); + DALI_TEST_EQUALS( stage.GetSize(), Vector2( defaultSurface->GetPositionSize().width, defaultSurface->GetPositionSize().height ), TEST_LOCATION ); + + // Resize the surface and inform the scene accordingly + Vector2 newSize( 1000.0f, 2000.0f ); + DALI_TEST_CHECK( stage.GetSize() != newSize ); + defaultSurface->MoveResize( PositionSize( 0, 0, newSize.width, newSize.height ) ); + defaultScene.SurfaceResized(); + + DALI_TEST_EQUALS( stage.GetSize(), newSize, TEST_LOCATION ); + DALI_TEST_EQUALS( defaultScene.GetSize(), newSize, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliSceneSurfaceResizedAdditionalScene(void) +{ + tet_infoline( "Ensure resizing of the surface is handled properly on additional scenes" ); + + 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 ); + + // Ensure stage size does NOT match the surface size + auto stage = Stage::GetCurrent(); + const auto stageSize = stage.GetSize(); + DALI_TEST_CHECK( stageSize != originalSurfaceSize ); + DALI_TEST_EQUALS( originalSurfaceSize, scene.GetSize(), TEST_LOCATION ); + + // Resize the surface and inform the scene accordingly + Vector2 newSize( 1000.0f, 2000.0f ); + DALI_TEST_CHECK( stage.GetSize() != newSize ); + surface.MoveResize( PositionSize( 0, 0, newSize.width, newSize.height ) ); + scene.SurfaceResized(); + + // Ensure the stage hasn't been resized + DALI_TEST_EQUALS( stage.GetSize(), stageSize, TEST_LOCATION ); + DALI_TEST_EQUALS( scene.GetSize(), newSize, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali/integration-api/core.cpp b/dali/integration-api/core.cpp index c2c0fcf..1f664e4 100644 --- a/dali/integration-api/core.cpp +++ b/dali/integration-api/core.cpp @@ -89,11 +89,6 @@ void Core::RecoverFromContextLoss() mImpl->RecoverFromContextLoss(); } -void Core::SurfaceResized( Integration::RenderSurface* surface ) -{ - mImpl->SurfaceResized(surface); -} - void Core::SurfaceDeleted( Integration::RenderSurface* surface ) { mImpl->SurfaceDeleted(surface); diff --git a/dali/integration-api/core.h b/dali/integration-api/core.h index 8da5583..2e57a76 100644 --- a/dali/integration-api/core.h +++ b/dali/integration-api/core.h @@ -289,15 +289,6 @@ public: void RecoverFromContextLoss(); /** - * Notify the Core that the GL surface has been resized. - * This should be done at least once i.e. after the first call to ContextCreated(). - * The Core will use the surface size for camera calculations, and to set the GL viewport. - * Multi-threading note: this method should be called from the main thread - * @param[in] surface The resized surface - */ - void SurfaceResized( Integration::RenderSurface* surface ); - - /** * Notify the Core that the GL surface has been deleted. * Multi-threading note: this method should be called from the main thread * @param[in] surface The deleted surface diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index b2a4922..5860a3a 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -124,6 +124,11 @@ void Scene::SetSurface( Integration::RenderSurface& surface ) GetImplementation(*this).SetSurface( surface ); } +void Scene::SurfaceResized() +{ + GetImplementation( *this ).SurfaceResized(); +} + Integration::RenderSurface* Scene::GetSurface() const { return GetImplementation(*this).GetSurface(); diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index 2128b47..dcc95b3 100755 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -202,6 +202,11 @@ public: void SetSurface( Integration::RenderSurface& surface ); /** + * @brief Informs the scene that the set surface has been resized. + */ + void SurfaceResized(); + + /** * @brief Gets the rendering surface bound to the scene * * @return The render surface diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index fb5eb11..75e373b 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -194,17 +194,6 @@ void Core::ContextDestroyed() mRenderManager->ContextDestroyed(); } -void Core::SurfaceResized( Integration::RenderSurface* surface ) -{ - for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter ) - { - if( (*iter)->GetSurface() == surface ) - { - (*iter)->SurfaceResized(); - } - } -} - void Core::SurfaceDeleted( Integration::RenderSurface* surface ) { for( auto scene : mScenes ) diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index e419745..b37e454 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -121,11 +121,6 @@ public: void RecoverFromContextLoss(); /** - * @copydoc Dali::Integration::Core::SurfaceResized(Integration::RenderSurface*) - */ - void SurfaceResized( Integration::RenderSurface* surface ); - - /** * @copydoc Dali::Integration::Core::SurfaceDeleted(Integration::RenderSurface*) */ void SurfaceDeleted( Integration::RenderSurface* surface );