SceneHolder creates RenderTarget 92/256192/5
authorAdam Bialogonski <adam.b@samsung.com>
Tue, 30 Mar 2021 17:22:10 +0000 (18:22 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Tue, 13 Apr 2021 11:01:38 +0000 (12:01 +0100)
(cherry-picked from Richard's patch)

Change-Id: Ic04f47b698c5aa8b0ec486a3dc81bb60af6bfe7d

dali/integration-api/adaptor-framework/scene-holder-impl.cpp
dali/integration-api/adaptor-framework/scene-holder-impl.h

index ec4be19..f252f98 100644 (file)
@@ -160,6 +160,9 @@ void SceneHolder::SetSurface(Dali::RenderSurfaceInterface* surface)
   mSurface->SetAdaptor(*mAdaptor);
   mSurface->SetScene(mScene);
 
+  // Recreate the render target
+  CreateRenderTarget();
+
   OnSurfaceSet(surface);
 }
 
@@ -219,9 +222,24 @@ 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);
+  mRenderTarget = mAdaptor->GetGraphicsInterface().GetController().CreateRenderTarget(rtInfo, std::move(mRenderTarget));
+
+  mScene.SetSurfaceRenderTarget(mRenderTarget.get());
+}
+
 void SceneHolder::Pause()
 {
   Reset();
index 7eb7e56..6c53831 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTEGRATION_INTERNAL_SCENEHOLDER_H
 
 /*
- * 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.
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/graphics-api/graphics-controller.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/point.h>
 #include <dali/integration-api/events/touch-event-combiner.h>
@@ -216,6 +217,11 @@ public:
   void AddFramePresentedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId);
 
   /**
+   * @brief Creates the render target for the surface when the surface is created/resized/replaced.
+   */
+  void CreateRenderTarget();
+
+  /**
    * @copydoc Dali::Integration::SceneHolder::Get()
    */
   static Dali::Integration::SceneHolder Get(Dali::Actor actor);
@@ -265,6 +271,9 @@ public: // The following methods must be overridden
    */
   virtual Dali::Any GetNativeHandle() const = 0;
 
+private:
+  Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget{nullptr};
+
 protected:
   // Constructor
   SceneHolder();