From 9fc046f0695cf9d0488ec0cc4a5fb55f21d69c72 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 4 May 2016 10:21:38 +0900 Subject: [PATCH] Support post render callback Change-Id: Ic04432c7cb5372cc9605812f076450466d2886fb --- pepper-dali/internal/compositor-impl.cpp | 8 ++-- pepper-dali/internal/compositor-impl.h | 5 ++ pepper-dali/internal/object-impl.cpp | 8 +--- pepper-dali/internal/object-view-impl.cpp | 37 ++++++++++++--- pepper-dali/internal/object-view-impl.h | 17 +++++-- pepper-dali/internal/output-impl.cpp | 58 +++++++++++++++++++----- pepper-dali/internal/output-impl.h | 30 +++++++++++- pepper-dali/public-api/compositor/compositor.cpp | 5 ++ pepper-dali/public-api/compositor/compositor.h | 8 ++++ 9 files changed, 143 insertions(+), 33 deletions(-) diff --git a/pepper-dali/internal/compositor-impl.cpp b/pepper-dali/internal/compositor-impl.cpp index 172f162..a458cbe 100644 --- a/pepper-dali/internal/compositor-impl.cpp +++ b/pepper-dali/internal/compositor-impl.cpp @@ -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() diff --git a/pepper-dali/internal/compositor-impl.h b/pepper-dali/internal/compositor-impl.h index 6a56870..27b33bb 100644 --- a/pepper-dali/internal/compositor-impl.h +++ b/pepper-dali/internal/compositor-impl.h @@ -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 diff --git a/pepper-dali/internal/object-impl.cpp b/pepper-dali/internal/object-impl.cpp index 423daba..572c5a3 100644 --- a/pepper-dali/internal/object-impl.cpp +++ b/pepper-dali/internal/object-impl.cpp @@ -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 ) { diff --git a/pepper-dali/internal/object-view-impl.cpp b/pepper-dali/internal/object-view-impl.cpp index 0dc2a17..b03122b 100644 --- a/pepper-dali/internal/object-view-impl.cpp +++ b/pepper-dali/internal/object-view-impl.cpp @@ -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 diff --git a/pepper-dali/internal/object-view-impl.h b/pepper-dali/internal/object-view-impl.h index a0c3cc6..eabe70e 100644 --- a/pepper-dali/internal/object-view-impl.h +++ b/pepper-dali/internal/object-view-impl.h @@ -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; diff --git a/pepper-dali/internal/output-impl.cpp b/pepper-dali/internal/output-impl.cpp index b5b3d4f..2acb8ce 100644 --- a/pepper-dali/internal/output-impl.cpp +++ b/pepper-dali/internal/output-impl.cpp @@ -22,6 +22,8 @@ #include // EXTERNAL INCLUDES +#include +#include #include 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() { diff --git a/pepper-dali/internal/output-impl.h b/pepper-dali/internal/output-impl.h index e1564cf..4dc66bb 100644 --- a/pepper-dali/internal/output-impl.h +++ b/pepper-dali/internal/output-impl.h @@ -27,6 +27,7 @@ #include #include #include +#include #include // TODO: temp @@ -44,7 +45,7 @@ namespace Internal class Output; typedef IntrusivePtr 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; }; diff --git a/pepper-dali/public-api/compositor/compositor.cpp b/pepper-dali/public-api/compositor/compositor.cpp index 026199a..15ceadb 100644 --- a/pepper-dali/public-api/compositor/compositor.cpp +++ b/pepper-dali/public-api/compositor/compositor.cpp @@ -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() ) ); diff --git a/pepper-dali/public-api/compositor/compositor.h b/pepper-dali/public-api/compositor/compositor.h index 9123637..56ed671 100644 --- a/pepper-dali/public-api/compositor/compositor.h +++ b/pepper-dali/public-api/compositor/compositor.h @@ -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. -- 2.7.4