Remove Core::SurfaceResized() method as we can call the required Scene method directly 80/210580/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 22 Jul 2019 11:01:34 +0000 (12:01 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 22 Jul 2019 15:38:59 +0000 (16:38 +0100)
Change-Id: Ibb992eeea3d09c4d1945e5354e9bb8ce8cff9200

automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/core.cpp
dali/integration-api/core.h
dali/integration-api/scene.cpp
dali/integration-api/scene.h
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h

index 6e41c42..7ffb5e5 100644 (file)
@@ -81,8 +81,6 @@ void TestApplication::CreateScene()
   mScene = Dali::Integration::Scene::New( Vector2( static_cast<float>( mSurfaceWidth ), static_cast<float>( mSurfaceHeight ) ) );
   mScene.SetSurface( *mRenderSurface );
   mScene.SetDpi( Vector2( static_cast<float>( mDpi.x ), static_cast<float>( mDpi.y ) ) );
-
-  mCore->SurfaceResized( mRenderSurface );
 }
 
 void TestApplication::InitializeCore()
index ebf66d4..a744014 100644 (file)
@@ -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;
+}
index c2c0fcf..1f664e4 100644 (file)
@@ -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);
index 8da5583..2e57a76 100644 (file)
@@ -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
index b2a4922..5860a3a 100644 (file)
@@ -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();
index 2128b47..dcc95b3 100755 (executable)
@@ -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
index fb5eb11..75e373b 100644 (file)
@@ -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 )
index e419745..b37e454 100644 (file)
@@ -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 );