Merge branch 'devel/master' into tizen
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 29 Jul 2019 06:22:02 +0000 (15:22 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 29 Jul 2019 06:22:07 +0000 (15:22 +0900)
Change-Id: I4fb55dfd91b5b635986d36cf69e8ad527e4cfae0

automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/scene.cpp
dali/integration-api/scene.h
dali/internal/event/common/scene-impl.cpp
dali/internal/event/common/scene-impl.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/renderers/render-surface-frame-buffer.cpp
dali/internal/render/renderers/render-surface-frame-buffer.h
dali/public-api/dali-core-version.cpp
packaging/dali.spec

index 7ffb5e5..f3029fa 100644 (file)
@@ -78,8 +78,7 @@ void TestApplication::CreateCore()
 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 ) ) );
 }
 
index a744014..6e44ca7 100644 (file)
@@ -141,7 +141,8 @@ struct TouchFunctor
 
     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;
@@ -361,7 +362,8 @@ int UtcDaliSceneDiscard(void)
   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
@@ -431,12 +433,17 @@ int UtcDaliSceneRootLayerAndSceneAlignment(void)
   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);
@@ -462,7 +469,8 @@ int UtcDaliSceneRootLayerAndSceneAlignment(void)
   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.
@@ -487,13 +495,12 @@ int UtcDaliSceneDeleteSurface(void)
 {
   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();
@@ -874,7 +881,8 @@ int UtcDaliSceneEnsureEmptySceneCleared(void)
   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
@@ -897,7 +905,8 @@ int UtcDaliSceneEnsureEmptySceneCleared(void)
 
   // 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();
@@ -943,9 +952,8 @@ int UtcDaliSceneSurfaceResizedAdditionalScene(void)
   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();
@@ -965,3 +973,31 @@ int UtcDaliSceneSurfaceResizedAdditionalScene(void)
 
   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;
+}
index 5860a3a..38e2477 100644 (file)
@@ -29,9 +29,9 @@ namespace Dali
 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() );
 }
 
index dcc95b3..c53c413 100755 (executable)
@@ -61,11 +61,11 @@ public:
   /**
    * @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.
index 19be8cc..6055dc6 100644 (file)
@@ -48,21 +48,20 @@ const Vector4 DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f); // Default backg
 
 } //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() )
@@ -95,11 +94,11 @@ Scene::~Scene()
     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();
 
@@ -125,7 +124,9 @@ void Scene::Initialize()
   // 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()));
 
@@ -134,6 +135,9 @@ void Scene::Initialize()
 
   // Create the default render-task
   mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
+
+  // Set the surface
+  SetSurface( surface );
 }
 
 void Scene::Add(Actor& actor)
@@ -198,9 +202,10 @@ Actor& Scene::GetDefaultRootActor()
 
 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 );
@@ -214,21 +219,19 @@ void Scene::SurfaceResized()
 {
   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 );
 
@@ -254,6 +257,7 @@ void Scene::SurfaceResized()
 
 void Scene::SurfaceDeleted()
 {
+  mSurface = nullptr;
   if ( mFrameBuffer )
   {
     // The frame buffer doesn't have a valid render surface any more.
index 6671fa3..2c93c84 100644 (file)
@@ -62,7 +62,7 @@ public:
   /**
    * @copydoc Dali::Integration::Scene::New
    */
-  static ScenePtr New( const Size& size );
+  static ScenePtr New( Integration::RenderSurface& surface );
 
   /**
    * virtual destructor
@@ -251,12 +251,12 @@ public:
 private:
 
   // Constructor
-  Scene( const Size& size );
+  Scene();
 
   /**
    * Second-phase constructor.
    */
-  void Initialize();
+  void Initialize( Integration::RenderSurface& surface );
 
   // Undefined
   Scene(const Scene&) = delete;
@@ -267,9 +267,7 @@ private:
 private:
   Integration::RenderSurface* mSurface;
 
-  // The scene-size may be different with the surface-size
   Size mSize;
-  Size mSurfaceSize;
 
   Vector2 mDpi;
 
index b5a5011..7c56dfb 100644 (file)
@@ -610,6 +610,12 @@ void RenderManager::DoRender( RenderInstruction& instruction )
     {
       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();
index 7f1866d..7154ff6 100644 (file)
@@ -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
index 704a360..edd667d 100644 (file)
@@ -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
    */
index 63c157f..4ea7239 100644 (file)
@@ -28,7 +28,7 @@ namespace Dali
 
 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
index 6951ddd..eb9d25e 100644 (file)
@@ -1,6 +1,6 @@
 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