Delayed SceneHolder RenderTarget initialization
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / adaptor-framework / scene-holder-impl.cpp
index 2fb9af9..13b93d7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -160,6 +160,9 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface)
   mSurface->SetAdaptor(*mAdaptor);
   mSurface->SetScene(mScene);
 
+  // Recreate the render target
+  CreateRenderTarget();
+
   OnSurfaceSet(surface);
 }
 
@@ -169,6 +172,9 @@ void SceneHolder::SurfaceResized()
   mScene.SurfaceResized(static_cast<float>(surfacePositionSize.width), static_cast<float>(surfacePositionSize.height));
 
   mSurface->SetFullSwapNextFrame();
+
+  // Recreate the render target
+  CreateRenderTarget();
 }
 
 Dali::RenderSurfaceInterface* SceneHolder::GetSurface() const
@@ -205,7 +211,7 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
 
   // Create the scene
   PositionSize surfacePositionSize = mSurface->GetPositionSize();
-  int orientation = mSurface->GetOrientation();
+  int          orientation         = mSurface->GetOrientation();
   mScene                           = Dali::Integration::Scene::New(Size(static_cast<float>(surfacePositionSize.width), static_cast<float>(surfacePositionSize.height)), orientation);
 
   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
@@ -219,9 +225,23 @@ void SceneHolder::SetAdaptor(Dali::Adaptor& adaptor)
   mSurface->SetAdaptor(*mAdaptor);
   mSurface->SetScene(mScene);
 
+  // Create the render target
+  CreateRenderTarget();
+
   OnAdaptorSet(adaptor);
 }
 
+void SceneHolder::CreateRenderTarget()
+{
+  Graphics::RenderTargetCreateInfo rtInfo{};
+  rtInfo
+    .SetSurface(mSurface.get())
+    .SetExtent({static_cast<uint32_t>(mSurface->GetPositionSize().width), static_cast<uint32_t>(mSurface->GetPositionSize().height)})
+    .SetPreTransform(0 | Graphics::RenderTargetTransformFlagBits::TRANSFORM_IDENTITY_BIT);
+
+  mScene.SetSurfaceRenderTarget(rtInfo);
+}
+
 void SceneHolder::Pause()
 {
   Reset();
@@ -241,6 +261,11 @@ void SceneHolder::SurfaceRotated(float width, float height, int orientation)
   mScene.SurfaceRotated(width, height, orientation);
 }
 
+void SceneHolder::SetRotationCompletedAcknowledgement()
+{
+  mScene.SetRotationCompletedAcknowledgement();
+}
+
 void SceneHolder::FeedTouchPoint(Dali::Integration::Point& point, int timeStamp)
 {
   if(timeStamp < 1)