[dali_1.9.20] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / scene-holder-impl.cpp
index 1a213a2..e296ea1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 #include <dali/internal/adaptor/common/lifecycle-observer.h>
+#include <dali/internal/graphics/gles/egl-graphics.h>
 #include <dali/internal/input/common/key-impl.h>
 #include <dali/internal/input/common/physical-keyboard-impl.h>
 
@@ -47,7 +48,7 @@ namespace
 {
 
 #if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gTouchEventLogFilter  = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_ADAPTOR_EVENTS_TOUCH");
+Debug::Filter* gSceneHolderLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_SCENE_HOLDER" );
 #endif
 
 // Copied from x server
@@ -120,6 +121,7 @@ SceneHolder::SceneHolder()
   mId( mSceneHolderCounter++ ),
   mSurface( nullptr ),
   mAdaptor( nullptr ),
+  mIsBeingDeleted( false ),
   mAdaptorStarted( false ),
   mVisible( true )
 {
@@ -188,7 +190,9 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface)
 {
   mSurface.reset( surface );
 
-  mScene.SetSurface( *mSurface.get() );
+  mScene.SurfaceReplaced();
+
+  SurfaceResized();
 
   unsigned int dpiHorizontal, dpiVertical;
   dpiHorizontal = dpiVertical = 0;
@@ -197,13 +201,22 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface)
   mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
 
   mSurface->SetAdaptor( *mAdaptor );
+  mSurface->SetScene( mScene );
 
   OnSurfaceSet( surface );
 }
 
 void SceneHolder::SurfaceResized()
 {
-  mScene.SurfaceResized();
+  PositionSize surfacePositionSize = mSurface->GetPositionSize();
+  mScene.SurfaceResized( static_cast<float>( surfacePositionSize.width ), static_cast<float>( surfacePositionSize.height ) );
+
+  GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+  EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+  if (eglGraphics)
+  {
+    eglGraphics->SetFullSwapNextFrame();
+  }
 }
 
 Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const
@@ -216,6 +229,13 @@ void SceneHolder::SetBackgroundColor( const Vector4& color )
   if( mScene )
   {
     mScene.SetBackgroundColor( color );
+
+    GraphicsInterface& graphics = mAdaptor->GetGraphicsInterface();
+    EglGraphics* eglGraphics = static_cast<EglGraphics*>(&graphics);
+    if (eglGraphics)
+    {
+      eglGraphics->SetFullSwapNextFrame();
+    }
   }
 }
 
@@ -235,7 +255,8 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
   mAdaptorStarted = true;
 
   // Create the scene
-  mScene = Dali::Integration::Scene::New( *mSurface );
+  PositionSize surfacePositionSize = mSurface->GetPositionSize();
+  mScene = Dali::Integration::Scene::New( Size(static_cast<float>( surfacePositionSize.width ), static_cast<float>( surfacePositionSize.height )) );
 
   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation( adaptor );
   mAdaptor = &adaptorImpl;
@@ -252,6 +273,7 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
     mScene.SetDpi( Vector2( static_cast<float>( dpiHorizontal ), static_cast<float>( dpiVertical ) ) );
 
     mSurface->SetAdaptor( *mAdaptor );
+    mSurface->SetScene( mScene );
   }
 
   OnAdaptorSet( adaptor );
@@ -285,7 +307,7 @@ void SceneHolder::FeedTouchPoint( Dali::Integration::Point& point, int timeStamp
   Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
   if( type != Integration::TouchEventCombiner::DispatchNone )
   {
-    DALI_LOG_INFO( gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y );
+    DALI_LOG_INFO( gSceneHolderLogFilter, Debug::Verbose, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y );
 
     // Signals can be emitted while processing core events, and the scene holder could be deleted in the signal callback.
     // Keep the handle alive until the core events are processed.
@@ -337,6 +359,20 @@ void SceneHolder::FeedKeyEvent( Dali::Integration::KeyEvent& keyEvent )
   mAdaptor->ProcessCoreEvents();
 }
 
+void SceneHolder::AddFrameRenderedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId )
+{
+  mScene.AddFrameRenderedCallback( std::move( callback ), frameId );
+
+  DALI_LOG_INFO( gSceneHolderLogFilter, Debug::General, "SceneHolder::AddFrameRenderedCallback:: Added [%d]\n", frameId );
+}
+
+void SceneHolder::AddFramePresentedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId )
+{
+  mScene.AddFramePresentedCallback( std::move( callback ), frameId );
+
+  DALI_LOG_INFO( gSceneHolderLogFilter, Debug::General, "SceneHolder::AddFramePresentedCallback:: Added [%d]\n", frameId );
+}
+
 Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor )
 {
   SceneHolder* sceneHolderImpl = nullptr;