- scene pan gesture is created in core construction and never dies so no need to send an add/remove message or have a container to iterate; just ownerpointer is enough
Change-Id: Idd7b8be54cade3206778382410287d8e3a290b7f
{
TestApplication application;
- PanGestureDetector detector = PanGestureDetector::New();;
+ PanGestureDetector detector = PanGestureDetector::New();
PanGestureDetector copy( detector );
DALI_TEST_CHECK( detector );
{
TestApplication application;
- PanGestureDetector detector = PanGestureDetector::New();;
+ PanGestureDetector detector = PanGestureDetector::New();
PanGestureDetector assign;
assign = detector;
mStage->Initialize();
- mGestureEventProcessor = new GestureEventProcessor(*mStage, gestureManager, mRenderController);
- mEventProcessor = new EventProcessor(*mStage, *mNotificationManager, *mGestureEventProcessor);
+ mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController );
+ mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor );
mShaderFactory = new ShaderFactory();
mUpdateManager->SetShaderSaver( *mShaderFactory );
namespace Internal
{
-GestureEventProcessor::GestureEventProcessor(Stage& stage, Integration::GestureManager& gestureManager, Integration::RenderController& renderController)
-: mStage(stage),
- mGestureManager(gestureManager),
- mLongPressGestureProcessor(stage, gestureManager),
- mPanGestureProcessor(stage, gestureManager),
- mPinchGestureProcessor(stage, gestureManager),
- mTapGestureProcessor(stage, gestureManager),
- mRenderController(renderController),
+GestureEventProcessor::GestureEventProcessor( Stage& stage, SceneGraph::UpdateManager& updateManager, Integration::GestureManager& gestureManager, Integration::RenderController& renderController )
+: mStage( stage ),
+ mGestureManager( gestureManager ),
+ mLongPressGestureProcessor( stage, gestureManager ),
+ mPanGestureProcessor( stage, gestureManager, updateManager ),
+ mPinchGestureProcessor( stage, gestureManager ),
+ mTapGestureProcessor( stage, gestureManager ),
+ mRenderController( renderController ),
mUpdateRequired( false )
{
}
#define __DALI_INTERNAL_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
class RenderController;
}
+namespace SceneGraph
+{
+class UpdateManager;
+}
+
namespace Internal
{
/**
* Create a gesture event processor.
* @param[in] stage The stage.
+ * @param[in] updateManager The update manager
* @param[in] gestureManager The gesture manager
* @param[in] renderController The render controller
*/
- GestureEventProcessor(Stage& stage, Integration::GestureManager& gestureManager, Integration::RenderController& renderController);
+ GestureEventProcessor( Stage& stage, SceneGraph::UpdateManager& updateManager, Integration::GestureManager& gestureManager, Integration::RenderController& renderController );
/**
* Non-virtual destructor; GestureProcessor is not a base class
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
} // unnamed namespace
-PanGestureProcessor::PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager )
+PanGestureProcessor::PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager, SceneGraph::UpdateManager& updateManager )
: GestureProcessor( Gesture::Pan ),
mStage( stage ),
mGestureManager( gestureManager ),
mCurrentPanEvent( NULL ),
mSceneObject( SceneGraph::PanGesture::New() ) // Create scene object to store pan information.
{
- // Pass ownership to scene-graph
- AddGestureMessage( mStage.GetUpdateManager(), mSceneObject );
+ // Pass ownership to scene-graph; scene object lives for the lifecycle of UpdateManager
+ updateManager.SetPanGestureProcessor( mSceneObject );
}
PanGestureProcessor::~PanGestureProcessor()
{
- if( Stage::IsInstalled() && ( mSceneObject != NULL ) )
- {
- RemoveGestureMessage( mStage.GetUpdateManager(), mSceneObject );
- mSceneObject = NULL; // mSceneObject is about to be destroyed
- }
+ mSceneObject = NULL; // mSceneObject is owned and destroyed by update manager (there is only one of these for now)
}
void PanGestureProcessor::Process( const Integration::PanGestureEvent& panEvent )
#define __DALI_INTERNAL_PAN_GESTURE_EVENT_PROCESSOR_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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 SceneGraph
{
class PanGesture;
+class UpdateManager;
}
/**
* Create a pan gesture processor.
* @param[in] stage The stage.
* @param[in] gestureManager The gesture manager
+ * @param[in] updateManager The Update Manager
*/
- PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager );
+ PanGestureProcessor( Stage& stage, Integration::GestureManager& gestureManager, SceneGraph::UpdateManager& updateManager );
/**
- * Non-virtual destructor; PanGestureProcessor is not a base class
+ * Destructor
*/
- ~PanGestureProcessor();
+ virtual ~PanGestureProcessor();
public: // To be called by GestureEventProcessor
* @param[in] nextRenderTime The estimated time of the next render (in milliseconds).
* @return true, if properties were updated.
*/
- virtual bool UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
+ bool UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
/**
* Retrieves a reference to the panning flag property.
*/
void EnableProfiling();
+ /**
+ * Reset default properties, custom ones not supported due to this being the only object in scene side
+ * @param updateBufferIndex index to use
+ */
+ void ResetDefaultProperties( BufferIndex updateBufferIndex );
+
private:
/**
// Undefined
PanGesture& operator=(const PanGesture&);
- // PropertyOwner
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
// Defines information to be gathered by the gesture reading code.
struct FrameGestureInfo
{
typedef OwnerContainer<Renderer*> RendererOwner;
typedef RendererOwner::Iterator RendererIter;
-typedef OwnerContainer<PanGesture*> GestureOwner;
-typedef GestureOwner::Iterator GestureIter;
-
typedef OwnerContainer< Camera* > CameraOwner;
typedef OwnerContainer< PropertyOwner* > CustomObjectOwner;
renderers(),
textureSets(),
shaders(),
- gestures(),
+ panGestureProcessor( NULL ),
messageQueue( renderController, sceneGraphBuffers ),
keepRenderingSeconds( 0.0f ),
nodeDirtyFlags( TransformFlag ), // set to TransformFlag to ensure full update the first time through Update()
RendererOwner renderers; ///< A container of owned renderers
TextureSetOwner textureSets; ///< A container of owned texture sets
ShaderOwner shaders; ///< A container of owned shaders
- GestureOwner gestures; ///< A container of owned gesture detectors
+ OwnerPointer<PanGesture> panGestureProcessor; ///< Owned pan gesture processor; it lives for the lifecycle of UpdateManager
MessageQueue messageQueue; ///< The messages queued from the event-thread
ShaderDataBinaryQueue renderCompiledShaders; ///< Shaders compiled on Render thread are inserted here for update thread to pass on to event thread.
EraseUsingDiscardQueue( mImpl->renderers, renderer, mImpl->discardQueue, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
-void UpdateManager::AddGesture( PanGesture* gesture )
+void UpdateManager::SetPanGestureProcessor( PanGesture* panGestureProcessor )
{
- DALI_ASSERT_DEBUG( NULL != gesture );
+ DALI_ASSERT_DEBUG( NULL != panGestureProcessor );
- mImpl->gestures.PushBack( gesture );
-}
-
-void UpdateManager::RemoveGesture( PanGesture* gesture )
-{
- DALI_ASSERT_DEBUG( gesture != NULL );
-
- // Find the gesture and destroy it
- GestureOwner& gestures = mImpl->gestures;
- for ( GestureIter iter = gestures.Begin(), endIter = gestures.End(); iter != endIter; ++iter )
- {
- if ( *iter == gesture )
- {
- gestures.Erase( iter );
- return;
- }
- }
+ mImpl->panGestureProcessor = panGestureProcessor;
}
void UpdateManager::AddTextureSet( TextureSet* textureSet )
{
bool gestureUpdated( false );
- // constrain gestures... (in construction order)
- GestureOwner& gestures = mImpl->gestures;
-
- for ( GestureIter iter = gestures.Begin(), endIter = gestures.End(); iter != endIter; ++iter )
+ if( mImpl->panGestureProcessor )
{
- PanGesture& gesture = **iter;
- gesture.ResetToBaseValues( bufferIndex ); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
- gestureUpdated |= gesture.UpdateProperties( lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
+ // gesture processor only supports default properties
+ mImpl->panGestureProcessor->ResetDefaultProperties( bufferIndex ); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
+ gestureUpdated |= mImpl->panGestureProcessor->UpdateProperties( lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
}
return gestureUpdated;
// Gestures
/**
- * Add a newly created gesture.
- * @param[in] gesture The gesture to add.
- * @post The gesture is owned by the UpdateManager.
+ * Set the pan gesture processor.
+ * Pan Gesture processor lives for the lifetime of UpdateManager
+ * @param[in] gesture The gesture processor.
+ * @post The gestureProcessor is owned by the UpdateManager.
*/
- void AddGesture( PanGesture* gesture );
-
- /**
- * Remove a gesture.
- * @pre The gesture has been added to the UpdateManager.
- * @param[in] gesture The gesture to remove.
- * @post The gesture is destroyed.
- */
- void RemoveGesture( PanGesture* gesture );
+ void SetPanGestureProcessor( PanGesture* gestureProcessor );
// Textures
new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel );
}
-inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture )
-{
- // Message has ownership of PanGesture while in transit from event -> update
- typedef MessageValue1< UpdateManager, OwnerPointer< PanGesture > > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::AddGesture, gesture );
-}
-
-inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture )
-{
- typedef MessageValue1< UpdateManager, PanGesture* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture );
-}
-
inline void AddRendererMessage( UpdateManager& manager, Renderer& object )
{
typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > LocalType;