Support post render callback 67/68367/1 accepted/tizen/common/20160504.130850 accepted/tizen/ivi/20160504.115238 accepted/tizen/mobile/20160504.115018 accepted/tizen/tv/20160504.114857 accepted/tizen/wearable/20160504.115128 submit/tizen/20160504.065825
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 4 May 2016 01:21:38 +0000 (10:21 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 4 May 2016 01:21:38 +0000 (10:21 +0900)
Change-Id: Ic04432c7cb5372cc9605812f076450466d2886fb

pepper-dali/internal/compositor-impl.cpp
pepper-dali/internal/compositor-impl.h
pepper-dali/internal/object-impl.cpp
pepper-dali/internal/object-view-impl.cpp
pepper-dali/internal/object-view-impl.h
pepper-dali/internal/output-impl.cpp
pepper-dali/internal/output-impl.h
pepper-dali/public-api/compositor/compositor.cpp
pepper-dali/public-api/compositor/compositor.h

index 172f162..a458cbe 100644 (file)
@@ -96,6 +96,11 @@ Compositor::~Compositor()
   }
 }
 
+const std::string& Compositor::GetName() const
+{
+  return mSocketName;
+}
+
 void* Compositor::GetCompositorHandle()
 {
   return static_cast< void* >( mCompositor );
@@ -181,9 +186,6 @@ void Compositor::Initialize( Application application, const std::string& name )
   mOutput.ObjectViewDeletedSignal().Connect( this, &Compositor::OnObjectViewDeleted );
 
   DALI_LOG_INFO( gPepperCompositorLogging, Debug::Verbose, "Compositor::Initialize: success. socket name = %s\n", mSocketName.c_str() );
-
-  // TODO: temp
-  setenv("WAYLAND_DISPLAY", mSocketName.c_str(), 1);
 }
 
 int Compositor::GetSocketFdFromServer()
index 6a56870..27b33bb 100644 (file)
@@ -52,6 +52,11 @@ public:
    */
   static CompositorPtr New( Application application, const std::string& name );
 
+  /**
+   * @copydoc Dali::Pepper::Compositor::GetName()
+   */
+  const std::string& GetName() const;
+
   void* GetCompositorHandle();
 
 public: //Signals
index 423daba..572c5a3 100644 (file)
@@ -125,8 +125,6 @@ bool Object::AttchBuffer( int* width, int* height )
   mBuffer = buffer;
   mBufferDestroyListener = pepper_object_add_event_listener( (pepper_object_t*)buffer, PEPPER_EVENT_OBJECT_DESTROY, 0, Object::OnDestroyBuffer, this );
 
-  bufferResource = pepper_buffer_get_resource( buffer );
-
   if( !mObjectView )
   {
     mObjectView = Pepper::ObjectView::New();
@@ -135,14 +133,12 @@ bool Object::AttchBuffer( int* width, int* height )
     Pepper::GetImplementation( mObjectView ).SetSurface( mSurface );
     Pepper::GetImplementation( mObjectView ).SetInput( mPointer, mKeyboard, mTouch );
 
-    // TODO: support multi touch, focus in/out, mouse in/out
-
-    // TODO: resize callback
-
     Pepper::Object handle( this );
     mObjectViewAddedSignal.Emit( handle, mObjectView );
   }
 
+  bufferResource = pepper_buffer_get_resource( buffer );
+
   shmBuffer = wl_shm_buffer_get( bufferResource );
   if( shmBuffer )
   {
index 0dc2a17..b03122b 100644 (file)
@@ -170,6 +170,18 @@ void ObjectView::SetInput( pepper_pointer_t* pointer, pepper_keyboard_t* keyboar
   mTouch = touch;
 }
 
+void ObjectView::OnInitialize()
+{
+  mImageView = Toolkit::ImageView::New();
+  mImageView.SetParentOrigin( ParentOrigin::CENTER );
+  mImageView.SetAnchorPoint( AnchorPoint::CENTER );
+
+  Self().Add( mImageView );
+  Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+
+  // TODO: support multi touch, focus in/out, mouse in/out
+}
+
 bool ObjectView::OnTouchEvent( const TouchEvent& touchEvent )
 {
   if( 1 == touchEvent.GetPointCount() )
@@ -226,14 +238,27 @@ bool ObjectView::OnTouchEvent( const TouchEvent& touchEvent )
   return false;
 }
 
-void ObjectView::OnInitialize()
+void ObjectView::OnSizeSet( const Vector3& targetSize )
 {
-  mImageView = Toolkit::ImageView::New();
-  mImageView.SetParentOrigin( ParentOrigin::CENTER );
-  mImageView.SetAnchorPoint( AnchorPoint::CENTER );
+  if( mSurface )
+  {
+    Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
+    if( shellClient )
+    {
+      shellClient->Configure( static_cast< int >( targetSize.width ), static_cast< int >( targetSize.height ), ObjectView::OnConfigureCallback, this );
+    }
+  }
 
-  Self().Add( mImageView );
-  Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+  DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnSizeSet:width = %.2f height = %.2f\n", targetSize.width, targetSize.height );
+}
+
+void ObjectView::OnConfigureCallback( void* data, int width, int height )
+{
+  ObjectView* objectView = static_cast< ObjectView* >( data );
+
+  objectView->mImageView.SetSize( static_cast< float >( width ), static_cast< float >( height ) );
+
+  DALI_LOG_INFO( gPepperObjectViewLogging, Debug::Verbose, "ObjectView::OnConfigureCallback:width = %d height = %d\n", width, height );
 }
 
 } // namespace Internal
index a0c3cc6..eabe70e 100644 (file)
@@ -92,19 +92,24 @@ protected:
    */
   virtual ~ObjectView();
 
-protected: // From CustomActorImpl
+private: // From Control
+
+  /**
+   * @copydoc Dali::Toolkit::Control::OnInitialize()
+   */
+  virtual void OnInitialize();
+
+private: // From CustomActorImpl
 
   /**
    * @copydoc Dali::CustomActorImpl::OnTouchEvent( const TouchEvent& event )
    */
   virtual bool OnTouchEvent( const TouchEvent& event );
 
-private: // From Control
-
   /**
-   * @copydoc Dali::Toolkit::Control::OnInitialize()
+   * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
    */
-  virtual void OnInitialize();
+  virtual void OnSizeSet( const Vector3& targetSize );
 
 private:
 
@@ -114,6 +119,8 @@ private:
   // Undefined
   ObjectView& operator= ( const ObjectView& );
 
+  static void OnConfigureCallback( void* data, int width, int height );
+
 private:
 
   Toolkit::ImageView mImageView;
index b5b3d4f..2acb8ce 100644 (file)
@@ -22,6 +22,8 @@
 #include <pepper-dali/internal/compositor-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/adaptors/adaptor.h>
+#include <dali/devel-api/adaptor-framework/render-surface.h>
 #include <dali/integration-api/debug.h>
 
 namespace Dali
@@ -74,7 +76,8 @@ OutputPtr Output::New( Pepper::Compositor compositor, Application application, P
 Output::Output()
 : mSize(),
   mOutput( NULL ),
-  mPrimaryPlane( NULL )
+  mPrimaryPlane( NULL ),
+  mRepaintRequest( false )
 {
 }
 
@@ -87,9 +90,11 @@ void Output::Initialize( Pepper::Compositor& compositor, Application application
   mCompositor = compositor;
   mInput = input;
 
-  // TODO: use application info
-  mSize.width = 720.0f;
-  mSize.height = 1280.0f;
+  RenderSurface& surface = Adaptor::Get().GetSurface();
+  PositionSize positionSize = surface.GetPositionSize();
+
+  mSize.width = positionSize.width;
+  mSize.height = positionSize.height;
 
   mOutput = pepper_compositor_add_output( static_cast< pepper_compositor_t* >( Pepper::GetImplementation( compositor ).GetCompositorHandle() ), &outputInterface, "dali", this, WL_OUTPUT_TRANSFORM_NORMAL, 1 );
   if( !mOutput )
@@ -108,9 +113,10 @@ void Output::Initialize( Pepper::Compositor& compositor, Application application
 
   application.ResizeSignal().Connect( this, &Output::OnResize );
 
-  // TODO: render post?
+  // Set the thread-synchronization interface on the render-surface
+  surface.SetThreadSynchronization( *this );
 
-  DALI_LOG_INFO( gPepperOutputLogging, Debug::Verbose, "Output::Initialize: success\n" );
+  DALI_LOG_INFO( gPepperOutputLogging, Debug::Verbose, "Output::Initialize: success [width = %.2f height = %.2f]\n", mSize.width, mSize.height );
 }
 
 void Output::OnDestroy( void* data )
@@ -197,10 +203,12 @@ void Output::OnRepaint( void* data, const pepper_list_t* planeList )
 
   DALI_LOG_INFO( gPepperOutputLogging, Debug::Verbose, "Output::OnRepaint\n" );
 
-  // TODO: repaint
+  output->mRepaintRequest = true;
+
+  // TODO: temp
   if( !output->mRenderFinishTimer )
   {
-    output->mRenderFinishTimer= Timer::New(10);
+    output->mRenderFinishTimer= Timer::New(1);
     output->mRenderFinishTimer.TickSignal().Connect( output, &Output::OnRenderFinishTimerTick );
   }
 
@@ -263,10 +271,11 @@ Pepper::Output::OutputSignalType& Output::ObjectViewDeletedSignal()
 
 void Output::OnResize( Application& application )
 {
-  // TODO
-  // Can't get a new size! Use a new size later
-  mSize.width = 720.0f;
-  mSize.height = 1280.0f;
+  RenderSurface& surface = Adaptor::Get().GetSurface();
+  PositionSize positionSize = surface.GetPositionSize();
+
+  mSize.width = positionSize.width;
+  mSize.height = positionSize.height;
 
   pepper_output_update_mode( mOutput );
 }
@@ -292,6 +301,31 @@ void Output::OnObjectViewDeleted( Pepper::Object object, Pepper::ObjectView obje
   }
 }
 
+void Output::PostRenderComplete()
+{
+  if( mRepaintRequest )
+  {
+    struct timespec ts;
+
+    DALI_LOG_INFO( gPepperOutputLogging, Debug::Verbose, "Output::PostRenderComplete" );
+
+    pepper_compositor_get_time( static_cast< pepper_compositor_t* >( Pepper::GetImplementation( mCompositor ).GetCompositorHandle() ), &ts );
+    pepper_output_finish_frame( mOutput, &ts );
+
+    mRepaintRequest = false;
+  }
+}
+
+void Output::PostRenderStarted()
+{
+  // Do nothing
+}
+
+void Output::PostRenderWaitForCompletion()
+{
+  // Do nothing
+}
+
 // TODO: temp
 bool Output::OnRenderFinishTimerTick()
 {
index e1564cf..4dc66bb 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/signals/connection-tracker.h>
+#include <dali/integration-api/adaptors/thread-synchronization-interface.h>
 #include <pepper-output-backend.h>
 
 // TODO: temp
@@ -44,7 +45,7 @@ namespace Internal
 class Output;
 typedef IntrusivePtr<Output> OutputPtr;
 
-class Output : public BaseObject, public ConnectionTracker
+class Output : public BaseObject, public ConnectionTracker, public ThreadSynchronizationInterface
 {
 public:
 
@@ -90,6 +91,31 @@ private:
   void OnObjectViewAdded( Pepper::Object object, Pepper::ObjectView objectView );
   void OnObjectViewDeleted( Pepper::Object object, Pepper::ObjectView objectView );
 
+private: // From ThreadSynchronizationInterface
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+  // Called by the Event Thread if post-rendering is required
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+
+  /**
+   * @copydoc ThreadSynchronizationInterface::PostRenderComplete()
+   */
+  virtual void PostRenderComplete();
+
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+  //// Called by the Render Thread if post-rendering is required
+  /////////////////////////////////////////////////////////////////////////////////////////////////
+
+  /**
+   * @copydoc ThreadSynchronizationInterface::PostRenderStarted()
+   */
+  virtual void PostRenderStarted();
+
+  /**
+   * @copydoc ThreadSynchronizationInterface::PostRenderStarted()
+   */
+  virtual void PostRenderWaitForCompletion();
+
   // TODO: temp
   bool OnRenderFinishTimerTick();
 
@@ -117,6 +143,8 @@ private: // Data
   Pepper::Output::OutputSignalType mObjectViewAddedSignal;
   Pepper::Output::OutputSignalType mObjectViewDeletedSignal;
 
+  bool mRepaintRequest;
+
   // TODO: temp
   Timer mRenderFinishTimer;
 };
index 026199a..15ceadb 100644 (file)
@@ -34,6 +34,11 @@ Compositor Compositor::New( Application application, const std::string& name )
   return Compositor( internal.Get() );
 }
 
+const std::string& Compositor::GetName() const
+{
+  return GetImplementation( *this ).GetName();
+}
+
 Compositor Compositor::DownCast( BaseHandle handle )
 {
   return Compositor( dynamic_cast< Internal::Compositor* >( handle.GetObjectPtr() ) );
index 9123637..56ed671 100644 (file)
@@ -65,6 +65,14 @@ public:
   static Compositor New( Application application, const std::string& name );
 
   /**
+   * @brief Gets the name of the compositor.
+   *
+   * @since_tizen 3.0
+   * @return compositor name.
+   */
+  const std::string& GetName() const;
+
+  /**
    * @brief Downcast a handle to Compositor handle.
    *
    * If the BaseHandle points is a Compositor the downcast returns a valid handle.