Modify parameters of CreateNativeSurface() 69/236169/14
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Mon, 15 Jun 2020 08:47:47 +0000 (17:47 +0900)
committerDaekwang Ryu <dkdk.ryu@samsung.com>
Wed, 15 Jul 2020 08:09:30 +0000 (17:09 +0900)
The surface parameter has been added like other CreateSurface methods.
When users pass a native surface handle,
NativeRenderSurface doesn't make a native surface of a specific platform.

The position of NativeRenderSurface isn't needed.

Change-Id: I46bd39f784ad3b7ea5fc2631a89f49df785ae041

16 files changed:
dali/integration-api/adaptor-framework/native-render-surface-factory.h
dali/integration-api/adaptor-framework/render-surface-interface.h
dali/internal/window-system/android/render-surface-factory-android.cpp
dali/internal/window-system/android/render-surface-factory-android.h
dali/internal/window-system/common/native-render-surface-factory.cpp
dali/internal/window-system/common/render-surface-factory.h
dali/internal/window-system/tizen-wayland/ecore-wl/render-surface-factory-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/ecore-wl/render-surface-factory-ecore-wl.h
dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.cpp
dali/internal/window-system/tizen-wayland/ecore-wl2/render-surface-factory-ecore-wl2.h
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.cpp
dali/internal/window-system/tizen-wayland/native-render-surface-ecore-wl.h
dali/internal/window-system/ubuntu-x11/render-surface-factory-ecore-x.cpp
dali/internal/window-system/ubuntu-x11/render-surface-factory-ecore-x.h
dali/internal/window-system/windows/render-surface-factory-win.cpp
dali/internal/window-system/windows/render-surface-factory-win.h

index 17990e4..0345a5f 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTEGRATION_NATIVE_RENDER_SURFACE_FACTORY_H
 
 /*
- * 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.
@@ -33,10 +33,12 @@ class NativeRenderSurface;
  * Factory function for native surface
  * A native surface is created.
  *
- * @param [in] positionSize the position and size of the surface to create
+ * @param [in] surfaceSize the size of the surface to create
+ * @param [in] surface the native surface handle of your platform.
+ * If you don't pass this, a native surface will be created.
  * @param [in] isTransparent Whether the surface has an alpha channel
  */
-NativeRenderSurface* CreateNativeSurface( PositionSize positionSize,
+NativeRenderSurface* CreateNativeSurface( SurfaceSize surfaceSize, Any surface,
                                           bool isTransparent );
 
 } // namespace Dali
index 172fee0..2c7f6b7 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/object/weak-handle.h>
 #include <dali/integration-api/scene.h>
+#include <dali/public-api/math/uint-16-pair.h>
 
 namespace Dali
 {
@@ -45,7 +46,8 @@ class GraphicsInterface;
 /**
  * @brief The position and size of the render surface.
  */
-typedef Dali::Rect<int> PositionSize;
+using PositionSize =  Dali::Rect<int>;
+using SurfaceSize = Uint16Pair;
 
 /**
  * @brief Interface for a render surface onto which Dali draws.
index 27b3725..6dc3f79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -44,7 +44,7 @@ std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryAndroid::CreatePixmap
   return std::unique_ptr< PixmapRenderSurface >( nullptr );
 }
 
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryAndroid::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryAndroid::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
   return std::unique_ptr< NativeRenderSurface >( nullptr );
 }
index fb820de..4ade01e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_RENDER_SURFACE_FACTORY_ANDROID_H
 
 /*
- * Copyright (c) 2018 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.
@@ -34,7 +34,7 @@ public:
 
   std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
 
-  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
 };
 
 } // namespace Adaptor
index 3b07c24..9263c40 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.
 namespace Dali
 {
 
-DALI_ADAPTOR_API NativeRenderSurface* CreateNativeSurface( PositionSize positionSize, bool isTransparent )
+DALI_ADAPTOR_API NativeRenderSurface* CreateNativeSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
   auto renderSurfaceFactory = Dali::Internal::Adaptor::GetRenderSurfaceFactory();
-  auto nativeRenderSurface =  renderSurfaceFactory->CreateNativeRenderSurface( positionSize, isTransparent );
+  auto nativeRenderSurface =  renderSurfaceFactory->CreateNativeRenderSurface( surfaceSize, surface, isTransparent );
   return nativeRenderSurface.release();
 }
 
index 408ae14..a5d8d72 100644 (file)
@@ -49,7 +49,7 @@ public:
 
   virtual std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) = 0;
 
-  virtual std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) = 0;
+  virtual std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) = 0;
 };
 
 extern std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory();
index ef2f93b..bd23041 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -44,9 +44,9 @@ std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreWl::CreatePixmap
   return std::unique_ptr< PixmapRenderSurface >( nullptr );
 }
 
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
-  return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( positionSize, isTransparent );
+  return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( surfaceSize, surface, isTransparent );
 }
 
 // this should be created from somewhere
index 8db3813..a20bc74 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL_H
 
 /*
- * Copyright (c) 2018 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.
@@ -34,7 +34,7 @@ public:
 
   std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
 
-  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
 };
 
 } // namespace Adaptor
index e0069a7..1b1f816 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
@@ -44,9 +44,9 @@ std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreWl2::CreatePixma
   return std::unique_ptr< PixmapRenderSurface >( nullptr );
 }
 
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreWl2::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
-  return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( positionSize, isTransparent );
+  return Utils::MakeUnique< NativeRenderSurfaceEcoreWl >( surfaceSize, surface, isTransparent );
 }
 
 // this should be created from somewhere
index fbb4eff..eca7f5d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_RENDER_SURFACE_FACTORY_ECORE_WL2_H
 
 /*
- * Copyright (c) 2018 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.
@@ -34,7 +34,7 @@ public:
 
   std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
 
-  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
 };
 
 } // namespace Adaptor
index 48069c7..d5b5869 100644 (file)
@@ -53,8 +53,8 @@ Debug::Filter* gNativeSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, fals
 
 } // unnamed namespace
 
-NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent )
-: mPosition( positionSize ),
+NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent )
+: mSurfaceSize( surfaceSize ),
   mRenderNotification( NULL ),
   mGraphics( NULL ),
   mEGL( nullptr ),
@@ -70,7 +70,17 @@ NativeRenderSurfaceEcoreWl::NativeRenderSurfaceEcoreWl( Dali::PositionSize posit
 {
   Dali::Internal::Adaptor::WindowSystem::Initialize();
 
-  CreateNativeRenderable();
+  if( surface.Empty() )
+  {
+    CreateNativeRenderable();
+  }
+  else
+  {
+    // check we have a valid type
+    DALI_ASSERT_ALWAYS( ( surface.GetType() == typeid (tbm_surface_queue_h) ) && "Surface type is invalid" );
+    mTbmQueue = AnyCast< tbm_surface_queue_h >( surface );
+  }
+
   setenv( "EGL_PLATFORM", "tbm", 1 );
 }
 
@@ -120,7 +130,7 @@ void NativeRenderSurfaceEcoreWl::WaitUntilSurfaceReplaced()
 
 PositionSize NativeRenderSurfaceEcoreWl::GetPositionSize() const
 {
-  return mPosition;
+  return PositionSize( 0, 0, static_cast<int>( mSurfaceSize.GetWidth() ), static_cast<int>( mSurfaceSize.GetHeight() ) );
 }
 
 void NativeRenderSurfaceEcoreWl::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical )
@@ -209,7 +219,8 @@ void NativeRenderSurfaceEcoreWl::MoveResize( Dali::PositionSize positionSize )
     DALI_LOG_ERROR( "Failed to resize tbm_surface_queue" );
   }
 
-  mPosition = positionSize;
+  mSurfaceSize.SetWidth( static_cast<uint16_t>( positionSize.width ) );
+  mSurfaceSize.SetHeight( static_cast<uint16_t>( positionSize.height ) );
 }
 
 void NativeRenderSurfaceEcoreWl::StartRender()
@@ -326,10 +337,13 @@ void NativeRenderSurfaceEcoreWl::ReleaseLock()
 
 void NativeRenderSurfaceEcoreWl::CreateNativeRenderable()
 {
+  int width = static_cast<int>( mSurfaceSize.GetWidth() );
+  int height = static_cast<int>( mSurfaceSize.GetHeight() );
+
   // check we're creating one with a valid size
-  DALI_ASSERT_ALWAYS( mPosition.width > 0 && mPosition.height > 0 && "tbm_surface size is invalid" );
+  DALI_ASSERT_ALWAYS( width > 0 && height > 0 && "tbm_surface size is invalid" );
 
-  mTbmQueue = tbm_surface_queue_create( 3, mPosition.width, mPosition.height, mTbmFormat, TBM_BO_DEFAULT );
+  mTbmQueue = tbm_surface_queue_create( 3, width, height, mTbmFormat, TBM_BO_DEFAULT );
 
   if( mTbmQueue )
   {
index bfca63c..ea9c6d7 100644 (file)
@@ -44,10 +44,11 @@ public:
 
   /**
     * Uses an Wayland surface to render to.
-    * @param [in] positionSize the position and size of the surface
+    * @param [in] surfaceSize the size of the surface
+    * @param [in] surface the native surface handle
     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
     */
-  NativeRenderSurfaceEcoreWl( Dali::PositionSize positionSize, bool isTransparent = false );
+  NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent = false );
 
   /**
    * @brief Destructor
@@ -172,7 +173,7 @@ private:
 
 private: // Data
 
-  PositionSize                           mPosition;
+  SurfaceSize                            mSurfaceSize;
   TriggerEventInterface*                 mRenderNotification;
   Internal::Adaptor::GraphicsInterface*  mGraphics;                  ///< The graphics interface
   EglInterface*                          mEGL;
index b8b1f7e..c5ba610 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.
@@ -44,7 +44,7 @@ std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryEcoreX::CreatePixmapR
   return Utils::MakeUnique< PixmapRenderSurfaceEcoreX >( positionSize, surface, isTransparent );
 }
 
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreX::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryEcoreX::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
   return std::unique_ptr< NativeRenderSurface >( nullptr );
 }
index 47086a6..6fd5981 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_RENDER_SURFACE_FACTORY_ECORE_X_H
 
 /*
- * Copyright (c) 2018 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.
@@ -34,7 +34,7 @@ public:
 
   std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
 
-  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent = false ) override;
 };
 
 } // namespace Adaptor
index efb6714..1864367 100755 (executable)
@@ -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.
@@ -45,7 +45,7 @@ std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryWin::CreatePixmapRend
   return nullptr;
 }
 
-std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryWin::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent )
+std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryWin::CreateNativeRenderSurface( SurfaceSize surfaceSize, Any surface, bool isTransparent )
 {
   return std::unique_ptr< NativeRenderSurface >( nullptr );
 }
index fd05c74..436ad70 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H
 
 /*
- * Copyright (c) 2018 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.
@@ -34,7 +34,7 @@ public:
 
   std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override;
 
-  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override;
+  std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( SurfaceSize surfaceSize, bool isTransparent = false ) override;
 };
 
 } // namespace Adaptor